Including Makex Files¶
Note
This is a new/experimental feature and subject to change.
The intent of this feature is to explore ideas in build systems.
This feature may be disabled or removed.
Makex provides an include()
function to include the contents of another Makex File.
This is useful to reduce duplication and share common patterns among a project or its components.
It’s signature follows:
- include(path, search=False, tasks=False, required=True)¶
Include the specified path.
- Parameters:
This will search for the file in the including Makex File’s folder and all folders up to its Workspace.
Files to be included should be suffixed with the .mx
extension.
Note
While you may create tasks in an included file, this is not recommended and disabled by default.
Use include(tasks=True)
to include any tasks defined in the included file.
Example¶
For example, given a Makex file to be included (//tools.mx
)
and a Makexfile which includes (//projects/Makexfile
); the including Makex File
can call a macro (make_task
) which registers a task in itself:
The //project/Makexfile
file:
include("tools.mx", search=True)
make_task()
The //tools.mx
file:
@macro
def make_task():
task(
name="example-task"
)
As demonstrated, when search=True
the include function will search the Makex File’s folder and all
parent folders up to the current workspace for the file to include.
Optional Includes¶
Optional includes may be used to define macros and tasks which are not necessarily required or private.