Skip to content

Commit 1b388ce

Browse files
committed
Add CMake native build support
Add an optional CMake build path for developers who need incremental native builds. Previously the source-build docs and automation centered on build_lib.py, which left CMake users without a supported workflow. The new path configures Warp and warp-clang with CMake and Ninja, generates derived native headers through the active Python environment, and writes binaries to warp/bin. CI and warp-builder coverage exercise the path, and installation docs describe both uv and manual Python setup. Signed-off-by: Eric Shi <ershi@nvidia.com>
1 parent e3e5c70 commit 1b388ce

7 files changed

Lines changed: 1092 additions & 3 deletions

File tree

.github/workflows/build-warp-builder-images.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ jobs:
204204
echo "uv Version:"
205205
uv --version
206206
echo ""
207+
echo "CMake Version:"
208+
cmake --version
209+
echo ""
210+
echo "Ninja Version:"
211+
ninja --version
212+
echo ""
207213
echo "Architecture:"
208214
uname -m
209215
echo ""
@@ -216,6 +222,16 @@ jobs:
216222
echo "=== Build Complete ==="
217223
ls -lh warp/bin/
218224
echo ""
225+
echo "=== Building Warp with CMake ==="
226+
rm -rf warp/bin _build/cmake-image
227+
uv sync --no-install-project
228+
export WARP_CACHE_ROOT="/tmp/warp-cache-cmake-image-${{ github.run_id }}-${{ matrix.cuda_version }}-${{ matrix.arch }}"
229+
export WARP_CACHE_PATH="${WARP_CACHE_ROOT}"
230+
cmake -S . -B _build/cmake-image -G Ninja -DWARP_LLVM_PATH=/opt/llvm
231+
cmake --build _build/cmake-image --parallel
232+
uv run python -c "import warp; info = warp.print_diagnostics(); assert not info[\"warp_native\"].startswith(\"unknown\"); assert not info[\"warp_clang\"].startswith(\"unknown\")"
233+
ls -lh warp/bin/
234+
echo ""
219235
echo "=== Building Python Wheel ==="
220236
uv build --wheel
221237
echo ""

.github/workflows/ci.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,131 @@ jobs:
125125
retention-days: ${{ github.repository == 'NVIDIA/warp' && 7 || 1 }}
126126

127127

128+
build-warp-cmake:
129+
if: github.event_name != 'schedule' || github.repository == 'NVIDIA/warp'
130+
runs-on: ${{ matrix.os }}
131+
permissions:
132+
contents: read
133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
include:
137+
- os: windows-2025
138+
platform: windows
139+
cuda-version: "13.0.2"
140+
cuda-sub-packages: '["cudart", "crt", "nvcc", "nvrtc_dev", "nvjitlink", "nvvm", "nvptxcompiler"]'
141+
cuda-non-cuda-packages: ''
142+
warp-cache-root-suffix: '\warp-cache-cmake'
143+
- os: ubuntu-24.04
144+
platform: ubuntu-x86_64
145+
cuda-version: "13.0.2"
146+
cuda-sub-packages: '["cudart-dev", "nvcc", "nvrtc-dev"]'
147+
cuda-non-cuda-packages: '["libnvjitlink-dev"]'
148+
warp-cache-root-suffix: /warp-cache-cmake
149+
- os: ubuntu-24.04-arm
150+
platform: ubuntu-aarch64
151+
cuda-version: "13.0.2"
152+
cuda-sub-packages: '["cudart-dev", "nvcc", "nvrtc-dev"]'
153+
cuda-non-cuda-packages: '["libnvjitlink-dev"]'
154+
warp-cache-root-suffix: /warp-cache-cmake
155+
steps:
156+
- name: Checkout repository
157+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
158+
with:
159+
persist-credentials: false
160+
lfs: true
161+
162+
- name: Install uv
163+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
164+
with:
165+
version: "0.11.16"
166+
167+
- name: Set up Python
168+
run: uv python install
169+
170+
- name: Install CTK (with non-CUDA packages)
171+
if: matrix.cuda-sub-packages != '' && matrix.cuda-non-cuda-packages != ''
172+
uses: Jimver/cuda-toolkit@3d45d157f327c09c04b50ee6ccdea2d9d017ec76 # v0.2.35
173+
with:
174+
cuda: ${{ matrix.cuda-version }}
175+
sub-packages: ${{ matrix.cuda-sub-packages }}
176+
non-cuda-sub-packages: ${{ matrix.cuda-non-cuda-packages }}
177+
method: 'network'
178+
179+
- name: Install CTK (without non-CUDA packages)
180+
if: matrix.cuda-sub-packages != '' && matrix.cuda-non-cuda-packages == ''
181+
uses: Jimver/cuda-toolkit@3d45d157f327c09c04b50ee6ccdea2d9d017ec76 # v0.2.35
182+
with:
183+
cuda: ${{ matrix.cuda-version }}
184+
sub-packages: ${{ matrix.cuda-sub-packages }}
185+
method: 'network'
186+
187+
- name: Print build tool versions
188+
run: |
189+
cmake --version
190+
ninja --version
191+
192+
- name: Prepare Python environment for CMake codegen
193+
run: uv sync --no-install-project
194+
195+
- name: Set up MSVC developer environment
196+
if: matrix.platform == 'windows'
197+
run: |
198+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
199+
$vsPath = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
200+
$vsDevCmd = Join-Path $vsPath "Common7\Tools\VsDevCmd.bat"
201+
if (!(Test-Path $vsDevCmd)) {
202+
throw "VsDevCmd.bat was not found"
203+
}
204+
205+
$before = @{}
206+
Get-ChildItem Env: | ForEach-Object { $before[$_.Name] = $_.Value }
207+
cmd /c "`"$vsDevCmd`" -arch=x64 -host_arch=x64 > nul && set" |
208+
ForEach-Object {
209+
$name, $value = $_ -split '=', 2
210+
if ($name -and $before[$name] -ne $value) {
211+
"$name=$value" >> $env:GITHUB_ENV
212+
}
213+
}
214+
215+
- name: Build Warp with CMake
216+
if: matrix.platform != 'windows'
217+
env:
218+
WARP_CACHE_ROOT: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
219+
WARP_CACHE_PATH: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
220+
run: |
221+
cuda_path="${CUDA_HOME:-${CUDA_PATH:-}}"
222+
if [ -z "$cuda_path" ]; then
223+
echo "CUDA_HOME or CUDA_PATH must be set" >&2
224+
exit 1
225+
fi
226+
cmake -S . -B _build/cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DWARP_CUDA_PATH:PATH="$cuda_path"
227+
cmake --build _build/cmake --parallel
228+
229+
- name: Build Warp with CMake
230+
if: matrix.platform == 'windows'
231+
env:
232+
WARP_CACHE_ROOT: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
233+
WARP_CACHE_PATH: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
234+
run: |
235+
if (!$env:CUDA_PATH) {
236+
throw "CUDA_PATH must be set"
237+
}
238+
cmake -S . -B _build/cmake -G Ninja `
239+
-DCMAKE_BUILD_TYPE=Release `
240+
-DCMAKE_C_COMPILER=cl `
241+
-DCMAKE_CXX_COMPILER=cl `
242+
"-DWARP_CUDA_PATH:PATH=$env:CUDA_PATH"
243+
cmake --build _build/cmake --parallel
244+
245+
- name: Verify Warp diagnostics
246+
env:
247+
WARP_CACHE_ROOT: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
248+
WARP_CACHE_PATH: ${{ runner.temp }}${{ matrix.warp-cache-root-suffix }}
249+
run: |
250+
uv run python -c "import warp; info = warp.print_diagnostics(); assert not info['warp_native'].startswith('unknown'); assert not info['warp_clang'].startswith('unknown')"
251+
252+
128253
test-warp-cpu:
129254
if: github.event_name != 'schedule' || github.repository == 'NVIDIA/warp'
130255
runs-on: ${{ matrix.os }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
- Add `--use-dynamic-cuda` build option to link against shared CUDA libraries instead of embedding
3838
them statically; the corresponding shared libraries must be present at runtime
3939
([GH-1334](https://github.com/NVIDIA/warp/issues/1334)).
40+
- Add an optional CMake source-build path for `warp` and `warp-clang`
41+
with Packman-managed dependencies and support for parallel and incremental
42+
developer builds ([GH-1495](https://github.com/NVIDIA/warp/issues/1495)).
4043
- Add pluggable logging infrastructure: implement the `wp.Logger` protocol and pass it to `wp.set_logger()`,
4144
or scope it temporarily with `wp.ScopedLogger`. `wp.config.log_level` controls the global verbosity threshold
4245
and can be scoped temporarily with `wp.ScopedLogLevel`; all Python-side diagnostic output now routes through

0 commit comments

Comments
 (0)