You can build applications using either a build script or just by invoking FixBuild manually
using the build parameters. For more information run fixbuild -h
.
Build scripts use a partially declarative approach to set the build properties. You can also
add your own actions written in FixScript and using the provided simple functions for common
tasks. Or, instead, you can just write a normal console program for maximum control. FixBuild
works in two modes, either you can build applications manually using the parameters, this mode
is used when there is any parameter present with a single dash. Otherwise a file named
build.fix
is searched in the current and parent directories to execute.
An example of a build script:
use "build"; build { verbose: true, exclude: ["test", "another"], sources: ".", resources: "res", main: "test/main", binary: "example", binary_windows32: "example_win32", targets: ["windows32", "linux32"], gui: true }; prepare { // runs before any other action (including parsing of parameters) } prebuild { // runs before any task and after parsing of parameters } postbuild { // runs after a successful build (all tasks) with no errors } postbuild-fail { // runs after an unsuccessful build } cleanup { // runs after all actions are done (will not run if prepare fails) } task example "this will show in --help as a description" { // a custom task named 'example' } default task another-example (dep1, dep2) { // a custom task named 'another-example', which is set as a default instead of 'build' // it depends on tasks dep1 and dep2 } task -internal-task "" { // tasks with empty descriptions are removed from --help }
There are three predefined tasks, build
(builds executables for current platform and is the default
action), dist
(builds executables for all platforms) and clean
(cleans generated files).
If you define tasks with these names, they will be run after doing the implicit action.
The task names can contain characters, digits and dashes (in any order, including beginning).
You can use @nofail
annotation before calling a function to suppress any exceptions.
It is just a nicer syntax for var (r, e) = func(...)
.
Property | Type | Parameter | Description |
---|---|---|---|
verbose | boolean | -v | enables verbose mode |
processors | boolean | -np | passing false disables running of token processors (enabled by default) |
compress | boolean | -nc | passing false disables compression of the scripts (enabled by default) |
exclude | array of strings | -ex | excludes given file names and directories from processing |
sources | string | -src | specifies a directory with the sources (the current directory is used by default) |
resources | string | -res | embeds resources from given directory |
main | string or array of strings | -m | the name of the main script (must be specified) you can specify additional scripts in case the static detection is insufficient |
targets | array of strings | -t | a list of platform targets, either full list, or list of disallowed targets (by prepending them with '- ') |
binary | string | -o | the output executable file (defaults to the same name as the main script) |
binary_<target> | string | -o | alternative executable file for specific platform target |
gui | boolean | -g | enables building of a GUI application (experimental) |
icon | array of strings | -icon | provide different sizes of an icon as PNG files |
wasm_raw | boolean | -wasm_raw | passing true produces raw WASM file instead of HTML for GUI applications |
By default all library scripts are provided internally by FixBuild. There is a build:
namespace for build related scripts. Currently only the build:build
(the token processor)
and the build:common
(the common library) scripts are provided. As a shorthand, referencing
build
script from the initial build.fix
script aliases to build:build
.
You can also import scripts from files relative to the build script. Simply use a "path/:script
"
when importing. The important bit is the /:
for accessing the files. All the scripts are
imported into a global namespace (the script
portion of it). To import files in the current
directory just use this form: "./:script
". The imported scripts refer to their directory
implicitly. You can override the internal libraries as long as the scripts from the files are loaded first.
These functions are automatically made available by the build
token processor.
In case you need to import them manually use build:common
script name.
function get_builds(): Dynamic[String][String]
function get_executable(): String
main
function.
The string is returned by reference and you can change it.
function get_arguments(): String[]
function get_current_target(): String
function get_available_targets(): String[]
function register_task(name: String, func)
function register_task(name: String, func, desc: String)
function register_task(name: String, func, desc: String, deps: String[])
function get_task_list(): String[]
function get_task_description(name: String): String
function set_task_description(name: String, desc: String)
function get_task_dependencies(name: String): String[]
function get_default_task(): String
function set_default_task(name: String)
function run_task(name: String): Boolean
function run_task(name: String, force: Boolean): Boolean
function show_help()
function build(values: Dynamic[String])
function needs_update(dest: String or String[], src: String or String[]): Boolean
function makedir(name: String or String[])
function removedir(name: String or String[])
function remove(name: String or String[])
function touch(name: String or String[])
function basename(fname: String): String
function copy(src: String, dest: String)
function matches(pattern: String, value: String): Boolean
function matches_dir(pattern: String, value: String): Boolean
?
matches any character and *
matches any number of
characters (zero or more). The directory variant splits both the pattern and
the value by /
and tests each part separately (the number of parts
must be the same to match).
function find(pattern: String): String[]
function find(pattern: String, dir: String): String[]
function find(pattern: String, dir: String, excludes: String[]): String[]
matches
function. The excludes are using the directory variant of the pattern.
function run(command: String or String[])
function run(command: String or String[], dir: String)
function exit()
function exit(code: Integer)
function is_windows(): Boolean
function is_linux(): Boolean
function is_macos(): Boolean
function is_haiku(): Boolean
function is_wasm(): Boolean
function get_fixbuild_version(): String
function get_fixbuild_path(): String