View Source Bundlex.Project behaviour (Bundlex v1.2.0)
Behaviour that should be implemented by each project using Bundlex in the
bundlex.exs
file.
Summary
Types
Type describing input project configuration.
Type describing configuration of a native.
Struct representing bundlex project.
Functions
Returns the project struct of given application.
Determines if module
is a bundlex project module.
Types
@type config_t() :: Bunch.KVList.t( :natives | :libs, Bunch.KVList.t(native_name_t(), native_config_t()) )
Type describing input project configuration.
It's a keyword list, where natives and libs can be specified. Libs are
native packages that are compiled as static libraries and linked to natives
that have them specified in deps
field of their configuration.
@type native_config_t() :: [ sources: [String.t()], includes: [String.t()], lib_dirs: [String.t()], libs: [String.t()], os_deps: [Bundlex.Native.os_dep()], pkg_configs: [String.t()], deps: [{Application.app(), native_name_t() | [native_name_t()]}], src_base: String.t(), compiler_flags: [String.t()], linker_flags: [String.t()], language: :c | :cpp, interface: [Bundlex.Native.interface_t()] | Bundlex.Native.interface_t() | nil, preprocessor: [Bundlex.Project.Preprocessor.t()] | Bundlex.Project.Preprocessor.t() ]
Type describing configuration of a native.
It's a keyword list containing the following keys:
sources
- C files to be compiled (at least one must be provided),includes
- Paths to look for header files (empty list by default).lib_dirs
- Paths to look for libraries (empty list by default).libs
- Names of libraries to link (empty list by default).pkg_configs
- (deprecated) Names of libraries for which the appropriate flags will be obtained using pkg-config (empty list by default).deps
- Dependencies in the form of{app, lib_name}
, whereapp
is the application name of the dependency, andlib_name
is the name of lib specified in bundlex project of this dependency. See Dependencies section in readme for details.src_base
- Native files should reside inproject_root/c_src/<src_base>
(application name by default).compiler_flags
- Custom flags for compiler.linker_flags
- Custom flags for linker.language
- Language of native. :c or :cpp may be chosen (:c by default)interface
- Interface of native. It can be single atom e.g. :nif or list of atoms.preprocessors
- Modules implementingBundlex.Project.Preprocessor
behaviour
@type native_name_t() :: atom()
@type t() :: %Bundlex.Project{ app: atom(), config: config_t(), module: module(), src_path: String.t() }
Struct representing bundlex project.
Contains the following fields:
:config
- project configuration:src_path
- path to the native sources:module
- bundlex project module:app
- application that exports project
Callbacks
@callback project() :: config_t()
Callback returning project configuration.
Functions
@spec get(application :: atom()) :: {:ok, t()} | {:error, :invalid_project_specification | {:no_bundlex_project_in_file, path :: binary()} | :unknown_application}
Returns the project struct of given application.
If the module has not been loaded yet, it is loaded from
project_dir/bundlex.exs
file.
@spec native_config_keys() :: [atom()]
Determines if module
is a bundlex project module.