-
Notifications
You must be signed in to change notification settings - Fork 0
Zig15 windows ci #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: zig15
Are you sure you want to change the base?
Changes from all commits
b968ca2
bb07694
b16f4f4
4a84725
a368815
1da68ab
99fb7c9
e0b438e
821277d
f4c02b2
da85f9e
2cf7a14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| name: Build Windows | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| env: | ||
| ZIG_VERSION: 0.15.2 | ||
|
|
||
| jobs: | ||
| build-native-windows: | ||
| name: Windows - Native Build and Test | ||
| runs-on: windows-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Setup Zig | ||
| uses: goto-bus-stop/setup-zig@v2 | ||
| with: | ||
| version: ${{ env.ZIG_VERSION }} | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| # Workaround for Zig 0.15.2 bug on Windows (https://github.com/ziglang/zig/issues/25805) | ||
| # When cwd and cache path are on different drives, build fails | ||
| # Setting cache dir explicitly to be on the same drive as the source | ||
| - name: Build native with Zig (Windows only) | ||
| working-directory: packages/core/src/zig | ||
| run: zig build -Doptimize=ReleaseFast --cache-dir .zig-cache --global-cache-dir .zig-cache | ||
|
|
||
| - name: Copy native binaries to node_modules | ||
| working-directory: packages/core | ||
| run: bun scripts/build.ts --native --skip-zig-build | ||
|
|
||
| - name: Verify Windows binary exists | ||
| shell: pwsh | ||
| run: | | ||
| if (!(Test-Path "packages/core/node_modules/@opentui/core-win32-x64/opentui.dll")) { | ||
| Write-Error "Windows x64 binary missing!" | ||
| exit 1 | ||
| } | ||
| Write-Host "Windows x64 binary exists" | ||
| Get-ChildItem "packages/core/node_modules/@opentui/core-win32-x64/" | ||
|
|
||
| - name: Run native tests | ||
| working-directory: packages/core/src/zig | ||
| run: zig build test --summary all --cache-dir .zig-cache --global-cache-dir .zig-cache | ||
|
|
||
| - name: Build lib | ||
| working-directory: packages/core | ||
| run: bun run build:lib | ||
|
|
||
| - name: Run JS tests | ||
| working-directory: packages/core | ||
| run: bun run test:js | ||
|
|
||
| build-on-macos: | ||
| name: macOS - Cross-compile for Windows | ||
| runs-on: macos-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Setup Zig | ||
| uses: goto-bus-stop/setup-zig@v2 | ||
| with: | ||
| version: ${{ env.ZIG_VERSION }} | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| - name: Build for Windows (cross-compile) | ||
| working-directory: packages/core/src/zig | ||
| run: zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseFast | ||
|
|
||
| - name: Package Windows binaries | ||
| run: | | ||
| mkdir -p artifacts | ||
| cp packages/core/src/zig/lib/x86_64-windows/opentui.dll artifacts/ | ||
| ls -la artifacts/ | ||
|
|
||
| - name: Upload cross-compiled Windows binaries | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-binaries-cross-compiled | ||
| path: artifacts/opentui.dll | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| test-cross-compiled-on-windows: | ||
| name: Windows - Test macOS Cross-Compiled Binaries | ||
| runs-on: windows-latest | ||
| needs: build-on-macos | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Download cross-compiled Windows binaries | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: windows-binaries-cross-compiled | ||
| path: artifacts/ | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install | ||
|
|
||
| - name: Setup cross-compiled binaries | ||
| shell: bash | ||
| run: | | ||
| # Create the target directory | ||
| targetDir="packages/core/node_modules/@opentui/core-win32-x64" | ||
| mkdir -p "$targetDir" | ||
|
|
||
| # Copy the cross-compiled DLL | ||
| cp artifacts/opentui.dll "$targetDir/" | ||
|
|
||
| # Create index.ts that exports the path to the DLL | ||
| echo 'const module = await import("./opentui.dll", { with: { type: "file" } })' > "$targetDir/index.ts" | ||
| echo 'const path = module.default' >> "$targetDir/index.ts" | ||
| echo 'export default path;' >> "$targetDir/index.ts" | ||
|
|
||
| # Create package.json | ||
| echo '{"name":"@opentui/core-win32-x64","version":"0.0.0","main":"index.ts","types":"index.ts"}' > "$targetDir/package.json" | ||
|
|
||
| echo "Cross-compiled binary placed at:" | ||
| ls -la "$targetDir" | ||
|
|
||
| - name: Build lib (uses cross-compiled binary) | ||
| working-directory: packages/core | ||
| run: bun run build:lib | ||
|
|
||
| - name: Run JS tests with cross-compiled binary | ||
| working-directory: packages/core | ||
| run: bun run test:js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,7 +223,9 @@ pub fn enableDetectedFeatures(self: *Terminal, tty: anytype, use_kitty_keyboard: | |
| } | ||
|
|
||
| fn checkEnvironmentOverrides(self: *Terminal) void { | ||
| var env_map = std.process.getEnvMap(std.heap.page_allocator) catch return; | ||
| var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | ||
| defer _ = gpa.deinit(); | ||
| var env_map = std.process.getEnvMap(gpa.allocator()) catch return; | ||
|
Comment on lines
+226
to
+228
|
||
| defer env_map.deinit(); | ||
|
|
||
| // Always just try to enable bracketed paste, even if it was reported as not supported | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local GeneralPurposeAllocator is created and deinitialized within this function scope. However, the arena allocator initialized from this GPA outlives the GPA itself. The arena.deinit() on line 67 will attempt to free memory after the GPA has been deinitialized on line 65, which could lead to use-after-free or undefined behavior. The GPA must remain valid for the lifetime of the arena allocator.