Projects

How projects work in Bramble.

How projects work in Bramble.

Projects

A project can be either a single Bramble source code file or a directory containing one or more Bramble files.

To compile a single file, pass the pass to the file itself to the compiler. To compile a multi-file project, pass the path to the projects root directory to the compiler.

Importing a Project

To import an external Bramble project into your project you will need to manifest and the binary of the import target project.

Referring to Imported Items

To use an imported item in your project, you will have to use the canonical path to the item. This path is specified with

project::<project name>[::<sub directory>]*::<file>[::<module>]*::<item>

Allowing use statements to create aliases and remove the need for full paths to imported items is a QOL feature that has not yet been added to Bramble.

Manifests

If you want to use a project as a library in another project, you need to generate a project manifest. This manifest is a file which includes information about exported functions and types.

To generate a manifest, pass the --manifest flag to the compiler.

Importing

The manifest is then passed to the compiler so that the compiler will add the items from the other project to your current project as external imports.

Linking

Bramble currently uses gcc to perform linking. This is the final step for handling imports. You will need to pass the binary for your project and the binary for the imported project to gcc and it will output the final executable file.

Note: that only one binary can include a main function.

Examples

There are two examples of multi-file projects in the Bramble integration test suite: ./tests/src/projects/basic and ./tests/src/projects/nested.

All integration tests import the std::io project and the ./tests/make.sh script shows how to build a project with imports.


Last modified February 7, 2022: Add RFCs to the documentation site (5ab3587)