Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
run: |
ctest --output-on-failure

- name: the cxx frontend
run: |
npm ci --ignore-scripts
node scripts/bootstrap.js --cxx=build/src/frontend/cxx --syntax-only

build-linux-mlir:
runs-on: ubuntu-26.04

Expand All @@ -39,10 +44,11 @@ jobs:

- name: Install LLVM and MLIR deps
run: |
sudo apt-get install -y libmlir-22-dev mlir-22-tools
sudo apt-get install -y libmlir-22-dev mlir-22-tools liblld-22-dev

- name: Install unit tests requirements
run: |
npm ci --ignore-scripts
pipx install uv
uv sync

Expand All @@ -61,6 +67,10 @@ jobs:
run: |
ctest --output-on-failure

- name: Bootstrap the cxx frontend
run: |
node scripts/bootstrap.js --cxx=build/src/frontend/cxx

build-windows:
runs-on: windows-latest

Expand Down
21 changes: 8 additions & 13 deletions packages/cxx-gen-ast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

Source-driven compiler code generation and read-only JavaScript reflection.

`npm run cxx-gen-ast` refreshes `semantic-model.json` from the built JavaScript
frontend and then generates AST support and semantic wrappers from it, so a
change to a declaration in `src/parser/cxx/` reaches the generated code in one
step. The snapshot is generated, not checked in: when the frontend has not been
built the generator reuses the snapshot it finds and says so, and fails with
what to build when there is none. `--no-refresh` keeps it on purpose.
`npm run cxx-gen-model` uses the same snapshot for persistence. Neither command
extracts declarations from `ast.h`.
`npm run cxx-gen-ast` refreshes the semantic model, the AST supporting code, and the TypeScript API.

`npm run cxx-dump-model` prints the model, `--write` refreshes the snapshot
alone, and `--check` verifies it is current.
`npm run cxx-dump-model` prints the model, `--write` refreshes the snapshot, and `--check` verifies it is current.

See [the semantic API design](../../docs/design/semantic-api.md) for build
steps, ownership, and coverage. Run generator tests with
`npm test -w @robertoraggi/cxx-gen-ast`.
The cxx-gen-ast requires cxx-frontend, it is a bit of a circular dependency, build it with:

```bash
npm ci
npm run build:cxx-frontend
```
9 changes: 6 additions & 3 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const cxx = argv.cxx ? path.resolve(String(argv.cxx)) : await which("cxx");

const compileFlags = [
`-std=${std}`,
"-c",
opt,
...includePaths.flatMap((dir) => ["-I", dir]),
"-D_WASI_EMULATED_MMAN",
Expand Down Expand Up @@ -151,9 +150,13 @@ async function compile(sources) {
}

await runPool(sources, async (source) => {
const output = syntaxOnly ? "/dev/null" : objectFileFor(source);
try {
await $`${cxx} ${compileFlags} ${source} -o ${output}`;
if (syntaxOnly) {
await $`${cxx} -fsyntax-only ${compileFlags} ${source}`;
} else {
const output = objectFileFor(source);
await $`${cxx} -c ${compileFlags} ${source} -o ${output}`;
}
echo(chalk.green(`[${++done}/${sources.length}] compiled ${source}`));
} catch (error) {
++done;
Expand Down