feat: rustc-style --version with git commit and build date #1448
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cross-Compile | |
| on: | |
| push: | |
| branches: [main, dev] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # Build target SDK on Ubuntu, then cross-compile from macOS using it | |
| build-linux-sdk: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y llvm clang lld cmake make gcc g++ \ | |
| autoconf automake libtool linux-headers-generic git \ | |
| libzstd-dev zlib1g-dev libsqlite3-dev libcurl4-openssl-dev file | |
| - name: Install npm dependencies | |
| run: npm install | |
| - name: Cache vendor libraries | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| vendor/ | |
| c_bridges/*.o | |
| key: vendor-${{ runner.os }}-${{ hashFiles('scripts/build-vendor.sh', 'scripts/vendor-pins.sh', 'c_bridges/*.c') }} | |
| - name: Build vendor libraries | |
| run: bash scripts/build-vendor.sh | |
| - name: Build compiler | |
| run: npm run build | |
| - name: Build tree-sitter objects | |
| run: | | |
| mkdir -p build | |
| TS_SRC=node_modules/tree-sitter-typescript/tsx/src | |
| TS_INCLUDE=node_modules/tree-sitter-typescript | |
| clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/parser.c -o build/tree-sitter-typescript-parser.o | |
| clang -c -O2 -fPIC -I $TS_SRC -I $TS_INCLUDE $TS_SRC/scanner.c -o build/tree-sitter-typescript-scanner.o | |
| clang -c -O2 -fPIC -I vendor/tree-sitter/lib/include c_bridges/treesitter-bridge.c -o build/treesitter-bridge.o | |
| - name: Build target SDK tarball | |
| run: bash scripts/build-target-sdk.sh | |
| - name: Upload target SDK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: chadscript-target-linux-x64 | |
| path: chadscript-target-linux-x64.tar.gz | |
| # Cross-compile from macOS to Linux using the SDK, then verify on Linux | |
| cross-compile-macos-to-linux: | |
| needs: build-linux-sdk | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install system dependencies | |
| run: | | |
| brew install llvm lld cmake autoconf automake libtool | |
| echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH | |
| echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH | |
| echo "/opt/homebrew/opt/lld/bin" >> $GITHUB_PATH | |
| echo "/usr/local/opt/lld/bin" >> $GITHUB_PATH | |
| - name: Install npm dependencies | |
| run: npm install | |
| - name: Cache vendor libraries | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| vendor/ | |
| c_bridges/*.o | |
| key: vendor-${{ runner.os }}-${{ hashFiles('scripts/build-vendor.sh', 'scripts/vendor-pins.sh', 'c_bridges/*.c') }} | |
| - name: Build vendor libraries | |
| run: bash scripts/build-vendor.sh | |
| - name: Build compiler | |
| run: npm run build | |
| - name: Download Linux target SDK | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: chadscript-target-linux-x64 | |
| - name: Install target SDK | |
| run: | | |
| mkdir -p ~/.chadscript/targets/linux-x64 | |
| tar -xzf chadscript-target-linux-x64.tar.gz -C ~/.chadscript/targets/linux-x64 | |
| cat ~/.chadscript/targets/linux-x64/sdk.json | |
| - name: Cross-compile hello.ts for Linux x64 (Node.js compiler) | |
| run: | | |
| echo 'console.log("Hello from ChadScript!");' > hello.ts | |
| echo 'process.exit(0);' >> hello.ts | |
| node dist/chad-node.js build --target linux-x64 hello.ts -o .build/hello-linux -v | |
| - name: Verify binary format (Node.js compiler) | |
| run: | | |
| file .build/hello-linux | |
| file .build/hello-linux | grep -q "ELF 64-bit" | |
| - name: Build native chad binary | |
| run: node dist/chad-node.js build src/chad-native.ts -o .build/chad | |
| - name: Cross-compile hello.ts for Linux x64 (native compiler) | |
| run: .build/chad build --target linux-x64 hello.ts -o .build/hello-linux-native -v | |
| - name: Verify binary format (native compiler) | |
| run: | | |
| file .build/hello-linux-native | |
| file .build/hello-linux-native | grep -q "ELF 64-bit" | |
| - name: Upload cross-compiled binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hello-linux-cross | |
| path: | | |
| .build/hello-linux | |
| .build/hello-linux-native | |
| # Verify the cross-compiled binary actually runs on Linux | |
| verify-cross-compiled-binary: | |
| needs: cross-compile-macos-to-linux | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Download cross-compiled binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: hello-linux-cross | |
| path: . | |
| - name: Run cross-compiled binary (Node.js compiler) | |
| run: | | |
| chmod +x hello-linux | |
| ./hello-linux | |
| echo "Node.js compiler cross-compiled binary ran successfully" | |
| - name: Run cross-compiled binary (native compiler) | |
| run: | | |
| chmod +x hello-linux-native | |
| ./hello-linux-native | |
| echo "Native compiler cross-compiled binary ran successfully" |