Skip to content

Commit 9d48950

Browse files
committed
Use pyproject.toml for dependency management of the unit test framework
1 parent ea4e23e commit 9d48950

File tree

5 files changed

+104
-62
lines changed

5 files changed

+104
-62
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515

1616
- name: Install unit tests requirements
1717
run: |
18-
python3 -m venv .env
19-
. .env/bin/activate
20-
pip install -r tests/unit_tests/requirements.txt
18+
pipx install uv
19+
uv sync
2120
2221
- name: Build
2322
run: |
@@ -83,9 +82,8 @@ jobs:
8382
8483
- name: Install unit tests requirements
8584
run: |
86-
python3 -m venv .env
87-
. .env/bin/activate
88-
pip install -r tests/unit_tests/requirements.txt
85+
pipx install uv
86+
uv sync
8987
9088
- name: Build
9189
run: |
@@ -112,7 +110,8 @@ jobs:
112110

113111
- name: Install unit tests requirements
114112
run: |
115-
pip install -r tests\unit_tests\requirements.txt
113+
pipx install uv
114+
uv sync
116115
117116
- name: Build
118117
run: |
@@ -181,9 +180,8 @@ jobs:
181180

182181
- name: Install unit tests requirements
183182
run: |
184-
python3 -m venv .env
185-
. .env/bin/activate
186-
pip install -r tests/unit_tests/requirements.txt
183+
pipx install uv
184+
uv sync
187185
188186
- name: Build
189187
run: |

README.md

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A compiler front end for the C++ language
22

3-
cxx-frontend is a work-in-progress compiler frontend for C++23
3+
cxx-frontend is a work-in-progress compiler frontend for C++26 and C23
44

55
The compiler frontend is designed to be a powerful tool for developers, enabling them to parse, analyze, and modify C++ source code. This project aims to provide a robust foundation for building a complete C++ frontend, staying
66
up-to-date with the latest language features and standards.
@@ -17,53 +17,60 @@ For updates, improvements, and recent features in cxx-frontend, please consult t
1717

1818
- **Multi-Language Support**: In addition to C++, the library provides APIs for TypeScript and JavaScript.
1919

20-
- **C++-23 Support**: Latest language enhancements, syntax, and features (WIP).
20+
- **C++-26 and C23 Support**: Latest language enhancements, syntax, and features (WIP).
2121

22-
## Syntax Checker and AST Browser Showcase
22+
## Playground
2323

24-
Storybook and CodeMirror are used to demonstrate how to create a syntax checker and navigate the Abstract Syntax Tree (AST)
24+
The playground uses the Monaco Editor to demonstrate how to create a syntax checker and navigate the Abstract Syntax Tree (AST).
2525

2626
https://robertoraggi.github.io/cplusplus/
2727

28-
## Installing from npm
28+
## Native Build and CLI tools
2929

30-
To integrate the latest stable version of the C++ Compiler Frontend bindings into your project, you can install them from npm:
30+
On Linux, macOS and Windows:
31+
32+
install the python packages required to run the unit tests (optional)
3133

3234
```sh
33-
npm install cxx-frontend
35+
uv sync && source .venv/bin/activate
3436
```
3537

36-
Once installed, you can use the bindings in your Node.js or web projects as needed.
38+
configure the source code
3739

38-
## Getting Started Using Example Projects
40+
```sh
41+
cmake --preset default
42+
```
3943

40-
These projects are pre-configured and serve as starting points for various [use cases](https://github.com/robertoraggi/cplusplus/tree/main/templates).
44+
build
4145

42-
For Node.js
46+
```sh
47+
cmake --build build
48+
```
49+
50+
run the unit tests
4351

4452
```sh
45-
npx degit robertoraggi/cplusplus/templates/cxx-parse cxx-parse
46-
cd cxx-parse
47-
npm install
48-
node .
53+
cd build
54+
ctest --progress
4955
```
5056

51-
For web-based applications, use these commands to clone, set up, and start a development server:
57+
Dump the AST to stdout
5258

5359
```sh
54-
npx degit robertoraggi/cplusplus/templates/cxx-browser-esm-vite cxx-browser-esm-vite
55-
cd cxx-browser-esm-vite
56-
npm install
57-
npm run dev
60+
./build/src/frontend/cxx tests/manual/source.cc -ast-dump
5861
```
5962

6063
## Build the npm package (requires docker)
6164

65+
prepare the package
66+
6267
```sh
63-
# prepare the package
6468
npm ci
69+
```
70+
71+
compile WASM and TypeScript code
6572

66-
# compile WASM and TypeScript code
73+
```sh
6774
npm run build:cxx-frontend
6875
```
6976

@@ -72,55 +79,48 @@ npm run build:cxx-frontend
7279
```sh
7380
npm ci
7481
npm run build:wasi
82+
```
7583

76-
# run the C++ front end CLI tool using wasmtime
84+
run the C++ front end CLI tool using wasmtime
85+
86+
```sh
7787
wasmtime \
7888
--mapdir=/::build.wasi/install \
7989
--mapdir tests::tests \
8090
build.wasi/install/usr/bin/cxx.wasm -- \
8191
tests/manual/source.cc -ast-dump
8292
```
8393

84-
## Native Build and CLI tools
94+
## Installing from npm
8595

86-
On Linux, macOS and Windows:
96+
To integrate the latest stable version of the C++ Compiler Frontend bindings into your project, you can install them from npm:
8797

8898
```sh
89-
# install the python packages required to run the unit tests (optional)
90-
pip install -r tests/unit_tests/requirements.txt
91-
92-
# configure the source code
93-
cmake . \
94-
-G Ninja \
95-
-B build \
96-
-DCMAKE_BUILD_TYPE=Release \
97-
-DCXX_INTERPROCEDURAL_OPTIMIZATION=1
99+
npm install cxx-frontend
100+
```
98101

99-
# build
100-
cmake --build build
102+
Once installed, you can use the bindings in your Node.js or web projects as needed.
101103

102-
# run the unit tests
103-
cd build
104-
ctest --progress
105-
```
104+
## Getting Started Using Example Projects
106105

107-
## Serialize the AST
106+
These projects are pre-configured and serve as starting points for various [use cases](https://github.com/robertoraggi/cplusplus/tree/main/templates).
108107

109-
Use `-emit-ast` to serialize the AST of a C++ program to a flatbuffer binary file
108+
For Node.js
110109

111110
```sh
112-
# serialize the AST
113-
$ ./build/src/frontend/cxx -emit-ast source.cc -o source.ast
111+
npx degit robertoraggi/cplusplus/templates/cxx-parse cxx-parse
112+
cd cxx-parse
113+
npm install
114+
node .
114115
```
115116

116-
You can use any flatbuffers supported decoder to read the AST, e.g.
117+
For web-based applications, use these commands to clone, set up, and start a development server:
117118

118119
```sh
119-
# Use flatc to dump the AST to JSON
120-
$ ./build/_deps/flatbuffers-build/flatc --raw-binary -t build/src/parser/cxx/ast.bfbs -- source.ast
121-
122-
$ ll source.*
123-
source.ast source.cc source.json
120+
npx degit robertoraggi/cplusplus/templates/cxx-browser-esm-vite cxx-browser-esm-vite
121+
cd cxx-browser-esm-vite
122+
npm install
123+
npm run dev
124124
```
125125

126126
## License

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[project]
2+
name = "cplusplus"
3+
version = "1.1.27"
4+
description = "A compiler frontend for C++23"
5+
readme = "README.md"
6+
requires-python = ">=3.11"
7+
dependencies = [
8+
"filecheck>=1.0.2",
9+
"lit>=18.1.8",
10+
]

tests/unit_tests/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

uv.lock

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)