Skip to content
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

feat: compile darwin via Zig #148

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/build-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build via Nix

inputs:
package:
description: package specification to build
required: true
flake:
description: flake specification
default: .
install-path:
description: path within resulting output, from which to install (e.g. `/bin/foo`)


runs:
using: composite
steps:
- run: nix build -L --show-trace --override-input 'nixify' '.' '${{ inputs.flake }}#${{ inputs.package }}'
shell: bash
- run: nix run -L --inputs-from . 'nixpkgs#coreutils' -- --coreutils-prog=ginstall -p "./result${{ inputs.install-path }}" '${{ inputs.package }}'
shell: bash
- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.package }}
path: ${{ inputs.package }}
211 changes: 211 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ jobs:
package: rust-hello
test-bin: ./result/bin/rust-hello

- os: ubuntu-22.04
package: rust-hello-aarch64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello
Expand All @@ -115,6 +120,11 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-x86_64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe
Expand All @@ -131,6 +141,11 @@ jobs:
package: rust-hello-debug
test-bin: ./result/bin/rust-hello

- os: ubuntu-22.04
package: rust-hello-debug-aarch64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-debug-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/rust-hello
Expand All @@ -146,6 +161,11 @@ jobs:
test-bin: nix run --inputs-from . 'nixpkgs#wasmtime' ./result/bin/rust-hello.wasm
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-debug-x86_64-apple-darwin
test-bin: file ./result/bin/rust-hello
test-oci: docker load < ./result

- os: ubuntu-22.04
package: rust-hello-debug-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/rust-hello.exe
Expand All @@ -167,6 +187,7 @@ jobs:
accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: cachix/cachix-action@v12
continue-on-error: true
with:
name: rvolosatovs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
Expand All @@ -177,3 +198,193 @@ jobs:
- run: nix build -L --show-trace --override-input 'nixify' '.' './examples/rust-hello#${{ matrix.config.package }}-oci'
if: ${{ matrix.config.package != 'default' && matrix.config.package != 'rust-hello' && matrix.config.package != 'rust-hello-debug' }}
- run: ${{ matrix.config.test-oci }}

rust-complex:
strategy:
matrix:
config:
# Darwin
- os: macos-12
package: default
test-bin: ./result/bin/foo

- os: macos-12
package: rust-complex
test-bin: ./result/bin/foo

- os: macos-12
package: rust-complex-aarch64-apple-darwin
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-aarch64-unknown-linux-musl
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-armv7-unknown-linux-musleabihf
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-x86_64-apple-darwin
test-bin: ./result/bin/foo

- os: macos-12
package: rust-complex-x86_64-pc-windows-gnu
test-bin: file ./result/bin/foo.exe
suffix: .exe

- os: macos-12
package: rust-complex-x86_64-unknown-linux-musl
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-debug
test-bin: ./result/bin/foo

- os: macos-12
package: rust-complex-debug-aarch64-apple-darwin
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-debug-aarch64-unknown-linux-musl
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-debug-armv7-unknown-linux-musleabihf
test-bin: file ./result/bin/foo

- os: macos-12
package: rust-complex-debug-x86_64-apple-darwin
test-bin: ./result/bin/foo

- os: macos-12
package: rust-complex-debug-x86_64-pc-windows-gnu
test-bin: file ./result/bin/foo.exe
suffix: .exe

- os: macos-12
package: rust-complex-debug-x86_64-unknown-linux-musl
test-bin: file ./result/bin/foo

# Linux
- os: ubuntu-22.04
package: default
test-bin: ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex
test-bin: ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-aarch64-apple-darwin
test-bin: file ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-x86_64-apple-darwin
test-bin: file ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe
suffix: .exe

- os: ubuntu-22.04
package: rust-complex-x86_64-unknown-linux-musl
test-bin: ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug
test-bin: ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug-aarch64-apple-darwin
test-bin: file ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug-aarch64-unknown-linux-musl
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-aarch64 ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug-armv7-unknown-linux-musleabihf
test-bin: nix shell --inputs-from . 'nixpkgs#qemu' -c qemu-arm ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug-x86_64-apple-darwin
test-bin: file ./result/bin/foo

- os: ubuntu-22.04
package: rust-complex-debug-x86_64-pc-windows-gnu
test-bin: nix shell --inputs-from . 'nixpkgs#wine64' -c wine64 ./result/bin/foo.exe
suffix: .exe

- os: ubuntu-22.04
package: rust-complex-debug-x86_64-unknown-linux-musl
test-bin: ./result/bin/foo

runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@v4
with:
extra-conf: |
accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: cachix/cachix-action@v12
continue-on-error: true
with:
name: rvolosatovs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- uses: ./.github/actions/build-nix
with:
package: ${{ matrix.config.package }}
flake: ./examples/rust-complex
install-path: /bin/foo${{ matrix.config.suffix }}
- run: ${{ matrix.config.test-bin }}

test-linux:
needs: rust-complex
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-unknown-linux-musl
- run: chmod +x ./rust-complex-x86_64-unknown-linux-musl
- run: ./rust-complex-x86_64-unknown-linux-musl

test-macos:
needs: rust-complex
runs-on: macos-12
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-aarch64-apple-darwin
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-apple-darwin
- run: chmod +x ./rust-complex-x86_64-apple-darwin
- run: ./rust-complex-x86_64-apple-darwin
- run: lipo -create ./rust-complex-aarch64-apple-darwin ./rust-complex-x86_64-apple-darwin -output ./rust-complex-universal-darwin
- run: chmod +x ./rust-complex-universal-darwin
- run: ./rust-complex-universal-darwin
- uses: actions/upload-artifact@v3
with:
name: rust-complex-universal-darwin
path: rust-complex-universal-darwin

test-windows:
needs: rust-complex
runs-on: windows-2022
steps:
- uses: actions/download-artifact@v3
with:
name: rust-complex-x86_64-pc-windows-gnu
- run: .\rust-complex-x86_64-pc-windows-gnu
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.fenix.url = github:nix-community/fenix;
inputs.flake-utils.url = github:numtide/flake-utils;
inputs.macos-sdk.url = github:hexops-graveyard/sdk-macos-12.0;
inputs.macos-sdk.flake = false;
inputs.nix-filter.url = github:numtide/nix-filter;
inputs.nix-log.url = github:rvolosatovs/nix-log;
inputs.nixlib.url = github:nix-community/nixpkgs.lib;
Expand All @@ -39,6 +41,7 @@
extendDerivations {
buildInputs = with pkgs; [
wasmtime
zig
];
}
devShells;
Expand Down
Loading
Loading