Build Commands
Building a project is done by invoking the C3 compiler with the build
or run
command inside of the project structure. The compiler will search upwards in the file hierarchy until a project.json
file is found.
You can also customise the project build config.
Compile Individual Files
By default the compiler is compiling stand-alone files to output an executable binary.
Run
When starting out, with C3 it’s natural to use compile-run
to try things out. For larger projects, the built-in build system is recommended instead.
The compile-run
command works same as compilation, but also immediately runs the resulting executable.
Common additional parameters
Additional parameters:
--lib <path>
add a library to search.--output <path>
override the output directory.--path <path>
execute as if standing at<path>
Init a new project
Create a new project structure in the current directory.
Use the --template
to select a template. The following are built in:
exe
- the default template, produces an executable.static-lib
- template for producing a static library.dynamic-lib
- template for producing a dynamic library.
It is also possible to give the path to a custom template.
Additional parameters:
--template <path>
indicate an alternative template to use.
For example c3c init hello_world
creates the following structure:
Directorybuild/
- …
Directorydocs/
- …
Directorylib/
- …
Directoryresources/
- …
Directoryscripts/
- …
Directorysrc/
- main.c3
Directorytest/
- …
- LICENSE
- project.json
- README.md
Check the project configuration docs to learn more about configuring your project.
Test
Will run any tests in the project in the "sources"
directory defined in your project.json
for example:
Tests are defined with a @test
attribute, for example:
Build
Build the project in the current path. It doesn’t matter where in the project structure you are.
The built-in templates define two targets: debug
(which is the default) and release
.
Clean
Build and Run
Build the target (if needed) and run the executable.
Clean and Run
Clean, build and run the target.
Dist
Not properly added yet
Clean, build and package the target for distribution. Will also run the target if it is a executable.
Docs
Not added yet
Rebuilds the documentation.
Bench
Runs benchmarks on a target.