Skip to content

Commit df3606c

Browse files
authored
feat: add wit-codegen tool (#15)
Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
1 parent 72f9cda commit df3606c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6158
-759
lines changed

.github/copilot-instructions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
- **Implementation mirrors the official Python reference**: The C++ code structure, type names, and semantics directly correspond to the Python implementation in `ref/component-model/design/mvp/canonical-abi/definitions.py` and the specification in `ref/component-model/design/mvp/CanonicalABI.md`. When making changes, cross-reference these files to ensure alignment.
55
- Supports async runtime primitives (`Store`, `Thread`, `Task`), resource management (`own`, `borrow`), streams/futures, waitables, and error contexts.
66

7+
## Working style
8+
- **Do not create summary documents**: Avoid creating markdown files in `docs/` to summarize work sessions, changes, or fixes unless explicitly requested. The git commit history and code comments are sufficient documentation.
9+
- Focus on making changes directly to code, updating existing documentation only when functionality changes, and providing concise summaries in responses rather than generating files.
10+
711
## Core headers
812
- `include/cmcpp/traits.hpp` defines `ValTrait`, type aliases (e.g., `bool_t`, `string_t`), and concept shortcuts that every new type must implement.
913
- `include/cmcpp/context.hpp` encapsulates `LiftLowerContext`, `ComponentInstance`, `Task`, resource tables (`HandleTable`, `InstanceTable`), and canonical operations like `canon_waitable_*`, `canon_stream_*`, `canon_future_*`.
@@ -37,5 +41,4 @@
3741
## Tooling notes
3842
- Dependencies are managed through `vcpkg.json` with overlays in `vcpkg_overlays/` (notably for WAMR); stick with preset builds so CMake wires in the correct toolchain file automatically.
3943
- Cargo manifest (`Cargo.toml`) is only for fetching `wasm-tools` and `wit-bindgen-cli`; if you touch wasm generation logic, update both the manifest and any scripts referencing those versions.
40-
- Release management uses Release Please with conventional commits (`feat:`, `fix:`, etc.) to automate changelog and version bumps.
4144
- Keep documentation alongside code: update `README.md` when introducing new host types or workflows so downstream integrators stay aligned with the canonical ABI behavior.

.github/instructions/general.instructions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ This repository is a modern C++20 header-only library implementing WebAssembly C
4545
- **Function Templates**: Use function templates for type-generic operations
4646
- **SFINAE/Concepts**: Use concepts or SFINAE for template constraints
4747
- **Const Correctness**: Maintain const correctness throughout
48-
- **Naming**: Use snake_case for variables, PascalCase for types
49-
- **Commit Messages**: Use conventional commits (`feat:`, `fix:`, etc.) for Release Please automation
48+
- **Naming**: Use snake_case for variables, PascalCase for types

.github/workflows/release.yml

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: C++ Release CI
1+
name: Release
22

33
on:
44
push:
@@ -11,15 +11,59 @@ env:
1111
jobs:
1212
build:
1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
include:
16-
- os: "ubuntu-24.04"
17-
fail-fast: false
17+
- os: ubuntu-24.04
18+
preset: linux-ninja-Release
19+
build-preset: linux-ninja-Release
20+
cpack-generators: "TGZ;DEB;RPM"
21+
package-patterns: |
22+
build/cmcpp-*.tar.gz
23+
build/cmcpp_*.deb
24+
build/cmcpp-*.rpm
25+
extra-deps: |
26+
sudo apt-get update
27+
sudo apt-get install -y \
28+
autoconf \
29+
autoconf-archive \
30+
automake \
31+
build-essential \
32+
ninja-build \
33+
rpm
1834
19-
runs-on: ${{ matrix.os }}
35+
- os: windows-2022
36+
preset: vcpkg-VS-17
37+
build-preset: VS-17-Release
38+
cpack-generators: "ZIP;NSIS"
39+
cpack-config: "-C Release"
40+
package-patterns: |
41+
build/cmcpp-*.zip
42+
build/cmcpp-*.exe
43+
extra-deps: ""
2044

45+
- os: macos-14
46+
preset: linux-ninja-Release
47+
build-preset: linux-ninja-Release
48+
cpack-generators: "TGZ;ZIP"
49+
package-patterns: |
50+
build/cmcpp-*.tar.gz
51+
build/cmcpp-*.zip
52+
extra-deps: |
53+
brew install \
54+
pkg-config \
55+
autoconf \
56+
autoconf-archive \
57+
automake \
58+
coreutils \
59+
libtool \
60+
cmake \
61+
ninja
62+
63+
runs-on: ${{ matrix.os }}
2164
permissions:
2265
contents: write
66+
2367
steps:
2468
- uses: actions/checkout@v4
2569
with:
@@ -47,47 +91,45 @@ jobs:
4791
restore-keys: |
4892
${{ runner.os }}-vcpkg-
4993
50-
- name: install dependencies
51-
run: |
52-
sudo apt-get update
53-
sudo apt-get install -y \
54-
autoconf \
55-
autoconf-archive \
56-
automake \
57-
build-essential \
58-
ninja-build
59-
60-
- name: Install rust dependencies
94+
- name: Install dependencies
95+
if: matrix.extra-deps != ''
96+
run: ${{ matrix.extra-deps }}
97+
98+
- name: Install Rust dependencies
6199
run: |
62100
cargo install wasm-tools wit-bindgen-cli || true
63101
64-
- name: configure
102+
- name: Configure CMake
65103
run: |
66-
cmake --preset linux-ninja-Release
104+
cmake --preset ${{ matrix.preset }}
67105
68-
- name: build
106+
- name: Build
69107
run: |
70-
cmake --build --preset linux-ninja-Release
108+
cmake --build --preset ${{ matrix.build-preset }}
71109
72-
- name: test
110+
- name: Run Tests
73111
working-directory: build
74112
run: |
75-
ctest -VV
113+
ctest ${{ matrix.cpack-config || '' }} -VV
76114
77-
- name: Package
115+
- name: Create Packages
116+
working-directory: build
78117
run: |
79-
tar -czvf cmcpp-${GITHUB_REF_NAME}.tar.gz include LICENSE LICENSE-BOOST-PFR
118+
IFS=';' read -ra GENS <<< "${{ matrix.cpack-generators }}"
119+
for gen in "${GENS[@]}"; do
120+
cpack ${{ matrix.cpack-config || '' }} -G "$gen"
121+
done
122+
shell: bash
80123

81-
- name: Create Release
82-
uses: ncipollo/release-action@v1
124+
- name: Upload Packages
125+
uses: softprops/action-gh-release@v2
83126
with:
84-
generateReleaseNotes: true
85-
tag: ${{ github.ref_name }}
86-
artifacts: cmcpp-${{ github.ref_name }}.tar.gz
127+
files: ${{ matrix.package-patterns }}
128+
fail_on_unmatched_files: false
87129

88130
- name: Upload error logs
89131
if: ${{ failure() || cancelled() }}
90132
uses: actions/upload-artifact@v4
91133
with:
92-
name: ${{ matrix.os }}-logs
134+
name: ${{ runner.os }}-logs
93135
path: ./**/*.log

.github/workflows/windows.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ jobs:
5252
restore-keys: |
5353
${{ runner.os }}-vcpkg-
5454
55+
- name: Set up JDK 17
56+
uses: actions/setup-java@v5
57+
with:
58+
java-version: "17"
59+
distribution: "temurin"
60+
5561
- name: Install rust dependencies
5662
run: |
5763
cargo install wasm-tools wit-bindgen-cli || true

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
/build*
1+
/build
22
/.vscode/settings.json
33
/cpm_modules
44
/vcpkg_installed
55
/test/wasm/build*
66
.DS_Store
77

8+
# ANTLR jar files
9+
antlr-*.jar
10+
*.jar
811

912
# Added by cargo
1013

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
url = https://github.com/WebAssembly/component-model.git
77
[submodule "ref/wasm-micro-runtime"]
88
path = ref/wasm-micro-runtime
9-
url = git@github.com:bytecodealliance/wasm-micro-runtime.git
9+
url = https://github.com/bytecodealliance/wasm-micro-runtime.git
10+
[submodule "ref/wit-bindgen"]
11+
path = ref/wit-bindgen
12+
url = https://github.com/bytecodealliance/wit-bindgen.git

.vscode/launch.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,56 @@
7070
"environment": [],
7171
"externalConsole": false,
7272
"preLaunchTask": "CMake: build"
73+
},
74+
{
75+
"name": "(gdb) test-wit-grammar",
76+
"type": "cppdbg",
77+
"request": "launch",
78+
"program": "${workspaceFolder}/build/test/test-wit-grammar",
79+
"args": [],
80+
"stopAtEntry": false,
81+
"cwd": "${workspaceFolder}",
82+
"environment": [],
83+
"externalConsole": false,
84+
"preLaunchTask": "CMake: build"
85+
},
86+
{
87+
"name": "(gdb) test-wit-grammar (verbose)",
88+
"type": "cppdbg",
89+
"request": "launch",
90+
"program": "${workspaceFolder}/build/test/test-wit-grammar",
91+
"args": [
92+
"--verbose"
93+
],
94+
"stopAtEntry": false,
95+
"cwd": "${workspaceFolder}",
96+
"environment": [],
97+
"externalConsole": false,
98+
"preLaunchTask": "CMake: build"
99+
},
100+
{
101+
"name": "(win) test-wit-grammar",
102+
"type": "cppvsdbg",
103+
"request": "launch",
104+
"program": "${workspaceFolder}/build/test/Debug/test-wit-grammar.exe",
105+
"args": [],
106+
"stopAtEntry": false,
107+
"cwd": "${workspaceFolder}",
108+
"environment": [],
109+
"preLaunchTask": "CMake: build"
110+
},
111+
{
112+
"name": "(win) test-wit-grammar (verbose)",
113+
"type": "cppvsdbg",
114+
"request": "launch",
115+
"program": "${workspaceFolder}/build/test/Debug/test-wit-grammar.exe",
116+
"args": [
117+
"--verbose"
118+
],
119+
"stopAtEntry": false,
120+
"cwd": "${workspaceFolder}",
121+
"environment": [],
122+
"preLaunchTask": "CMake: build"
73123
}
74124
]
75125
}

0 commit comments

Comments
 (0)