Build system¶
#load "build/build.bl"
Compiler integrated build pipeline. Build pipline can be used to manage whole project compilation process directly in BL. All you need is to create the build file called build.bl and specify the build_entry function inside. When -b flag is used without need of specifying any files, the compiler will lookup build.bl file in the current directory and execute it in compile time. All compilation steps, target input and output can be specified here. Example: Build System.
Example of minimal build.bl:
build :: fn () #build_entry {
// create new executable target
exe :: add_executable("MyProgram");
// add 'main.bl' file into the target 'exe'
add_unit(exe, "main.bl");
// Start compilation
compile(exe);
}
Start build pipeline using our build.bl file:
$ blc -build
Compiler will automatically use build.bl file as build script and execute build function in compile time. SDK file build/build.bl containing compiler API for build pipeline manipulation is loaded implicitly.
Warning
Build API is available only in compile-time.
Basics¶
Create new executable target¶
Target is a single build target defined as consisting of build Units representing source files needed for compilation. It’s basically a target compiled into an executable or binary file. Use add_executable function to specify your target. There are several options related to target, described later in this documentation.
exe :: add_executable("MyProgram");
Add file into target¶
Use add_unit function to add source files into the target. There is no need to add all files you want to use, general load and import will do so automatically. Only main or entry files must be included.
add_unit(exe, "main.bl");
Specify output directory¶
Output directory is a directory where all compiler-produced files will be written (i.e. native executables). Use set_output_dir function to specify this directory, current directory is used by default.
set_output_dir(exe, "bin");
Command line argumets¶
All argumets passed after –build|-b compiler flag are automatically forwarded into command_line_arguments global variable.