add new and init to toolchain

This commit is contained in:
2026-07-04 17:38:45 +02:00
parent cdde49e68b
commit e7f69ffb5a
17 changed files with 711 additions and 63 deletions
+14 -10
View File
@@ -31,9 +31,12 @@ invocation in command-line order:
C preprocessing.
Instead of passing these on the command line, a project can describe its build
in Brolang itself. `brolang build [root]` (root defaults to the current
directory) reads a `config` constant from `root/build.bro` and compiles the
program package it names:
in Brolang itself. `brolang new <project>` creates a project with local `std`
and `ffi` copies; `brolang init` does the same for the current directory without
overwriting existing files. `brolang build [root]` reads a `config` constant
from `root/build.bro` and compiles the program package it names. Without
`root`, it searches the current directory and parents for the nearest
`build.bro`. Build outputs are written to `root/build/<name>`.
```bro
b :: import "@std/build"
@@ -49,12 +52,12 @@ config :: b.BuildConfig{
}
```
`source` is the program package, relative to `build.bro`. The list fields map to
the matching C options (`libraries``-l`, `lib_paths``-L`, `includes`
`-I`, `defines` → C defines, `links` linker inputs) and, like those flags,
their paths are relative to the invocation directory. Lists take the address of
an array literal; empty lists are written `&[]`. See `examples/build/` for
runnable projects.
`name` is a plain executable name, and `source` is the program package relative
to `build.bro`. The list fields map to the matching C options (`libraries`
`-l`, `lib_paths``-L`, `includes``-I`, `defines` → C defines, `links`
linker inputs) and, like those flags, their paths are relative to the invocation
directory. Lists take the address of an array literal; empty lists are written
`&[]`. See `examples/build/` for runnable projects.
Relative `.h` imports create synthetic package namespaces backed by libclang:
@@ -146,11 +149,12 @@ specialization is demanded.
Every immediate `.bro` file in the input directory belongs to the root
package. Imports are relative directory paths and are local to the file that
declares them:
declares them. Imports beginning with `@` resolve from the project root:
```bro
import "../math"
other_math :: import "../math"
heap :: import "@std/mem/heap"
value :: math.sum(other_math.value, 1)
```