diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 0678d7a..5b97585 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -5,34 +5,30 @@ jobs: strategy: fail-fast: false matrix: - os: - - { name: linux, on: ubuntu-latest } - - { name: darwin, on: macos-14 } - - { name: windows, on: windows-latest } - arch: - - x86_64 - - aarch64 - exclude: - # aarch64 windows support is not available in downstream dependencies - - os: { name: windows, on: windows-latest } - arch: aarch64 + platform: + - { os: linux, arch: x86_64, on: ubuntu-latest, deps: linux } + - { os: linux, arch: aarch64, on: ubuntu-latest, deps: linux } + - { os: darwin, arch: x86_64, on: macos-14, deps: darwin } + - { os: darwin, arch: aarch64, on: macos-14, deps: darwin } + - { os: freebsd, arch: x86_64, on: ubuntu-latest, deps: linux } + - { os: windows, arch: x86_64, on: windows-latest, deps: windows } env: - TARGET_OS: "${{ matrix.os.name }}" - TARGET_ARCH: "${{ matrix.arch }}" - runs-on: "${{ matrix.os.on }}" - name: build ${{ matrix.os.name }}-${{ matrix.arch }} + TARGET_OS: "${{ matrix.platform.os }}" + TARGET_ARCH: "${{ matrix.platform.arch }}" + runs-on: "${{ matrix.platform.on }}" + name: build ${{ matrix.platform.os }}-${{ matrix.platform.arch }} defaults: run: shell: bash steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - if: ${{ matrix.os.name != 'darwin' }} + if: ${{ matrix.platform.os != 'darwin' }} - uses: dtolnay/rust-toolchain@stable with: - targets: "${{ matrix.arch }}-apple-darwin" - if: ${{ matrix.os.name == 'darwin' }} + targets: "${{ matrix.platform.arch }}-apple-darwin" + if: ${{ matrix.platform.os == 'darwin' }} - uses: homebrew/actions/setup-homebrew@master - if: ${{ matrix.os.name == 'darwin' }} - - run: ./hack/ci/install-${{ matrix.os.name }}-deps.sh + if: ${{ matrix.platform.os == 'darwin' }} + - run: ./hack/ci/install-${{ matrix.platform.deps }}-deps.sh - run: ./hack/build/cargo.sh build --bin kratactl diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 21efa78..a1286dc 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -55,38 +55,34 @@ jobs: client: strategy: matrix: - os: - - { name: linux, on: ubuntu-latest } - - { name: darwin, on: macos-14 } - - { name: windows, on: windows-latest } - arch: - - x86_64 - - aarch64 - exclude: - # aarch64 windows support is not available in downstream dependencies - - os: { name: windows, on: windows-latest } - arch: aarch64 + platform: + - { os: linux, arch: x86_64, on: ubuntu-latest, deps: linux } + - { os: linux, arch: aarch64, on: ubuntu-latest, deps: linux } + - { os: darwin, arch: x86_64, on: macos-14, deps: darwin } + - { os: darwin, arch: aarch64, on: macos-14, deps: darwin } + - { os: freebsd, arch: x86_64, on: ubuntu-latest, deps: linux } + - { os: windows, arch: x86_64, on: windows-latest, deps: windows } env: - TARGET_OS: "${{ matrix.os.name }}" - TARGET_ARCH: "${{ matrix.arch }}" - runs-on: "${{ matrix.os.on }}" - name: client ${{ matrix.os.name }}-${{ matrix.arch }} + TARGET_OS: "${{ matrix.platform.os }}" + TARGET_ARCH: "${{ matrix.platform.arch }}" + runs-on: "${{ matrix.platform.on }}" + name: client ${{ matrix.platform.os }}-${{ matrix.platform.arch }} defaults: run: shell: bash steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - if: ${{ matrix.os.name != 'darwin' }} + if: ${{ matrix.platform.os != 'darwin' }} - uses: dtolnay/rust-toolchain@stable with: - targets: "${{ matrix.arch }}-apple-darwin" - if: ${{ matrix.os.name == 'darwin' }} + targets: "${{ matrix.platform.arch }}-apple-darwin" + if: ${{ matrix.platform.os == 'darwin' }} - uses: homebrew/actions/setup-homebrew@master - if: ${{ matrix.os.name == 'darwin' }} - - run: ./hack/ci/install-${{ matrix.os.name }}-deps.sh + if: ${{ matrix.platform.os == 'darwin' }} + - run: ./hack/ci/install-${{ matrix.platform.os }}-deps.sh - run: ./hack/build/cargo.sh build --release --bin kratactl - uses: actions/upload-artifact@v4 with: - name: kratactl-${{ matrix.os.name }}-${{ matrix.arch }} + name: kratactl-${{ matrix.platform.os }}-${{ matrix.platform.arch }} path: "target/*/release/kratactl*" diff --git a/Cross.toml b/Cross.toml index c3bf740..0c64139 100644 --- a/Cross.toml +++ b/Cross.toml @@ -17,3 +17,18 @@ pre-build = [ pre-build = [ "apt-get update && apt-get --assume-yes install protobuf-compiler" ] + +[target.riscv64gc-unknown-linux-gnu] +pre-build = [ + "apt-get update && apt-get --assume-yes install protobuf-compiler" +] + +[target.x86_64-unknown-freebsd] +pre-build = [ + "apt-get update && apt-get --assume-yes install protobuf-compiler" +] + +[target.x86_64-unknown-netbsd] +pre-build = [ + "apt-get update && apt-get --assume-yes install protobuf-compiler" +] diff --git a/hack/build/target.sh b/hack/build/target.sh index 252ed01..51b9af6 100755 --- a/hack/build/target.sh +++ b/hack/build/target.sh @@ -32,56 +32,41 @@ if [ "${TARGET_OS}" = "darwin" ] then if [ -z "${RUST_TARGET}" ] then - if [ "${TARGET_ARCH}" = "x86_64" ] - then - RUST_TARGET="x86_64-apple-darwin" - fi - - if [ "${TARGET_ARCH}" = "aarch64" ] - then - RUST_TARGET="aarch64-apple-darwin" - fi + [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-apple-darwin" + [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-apple-darwin" fi elif [ "${TARGET_OS}" = "windows" ] then if [ -z "${RUST_TARGET}" ] then - if [ "${TARGET_ARCH}" = "x86_64" ] - then - RUST_TARGET="x86_64-pc-windows-msvc" - fi - - if [ "${TARGET_ARCH}" = "aarch64" ] - then - RUST_TARGET="aarch64-pc-windows-msvc" - fi + [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-pc-windows-msvc" + [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-pc-windows-msvc" + fi +elif [ "${TARGET_OS}" = "freebsd" ] +then + if [ -z "${RUST_TARGET}" ] + then + [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-freebsd" + fi +elif [ "${TARGET_OS}" = "netbsd" ] +then + if [ -z "${RUST_TARGET}" ] + then + [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-netbsd" fi else if [ -z "${RUST_TARGET}" ] then - if [ "${TARGET_ARCH}" = "x86_64" ] - then - RUST_TARGET="x86_64-unknown-linux-${TARGET_LIBC}" - fi - - if [ "${TARGET_ARCH}" = "aarch64" ] - then - RUST_TARGET="aarch64-unknown-linux-${TARGET_LIBC}" - fi + [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-linux-${TARGET_LIBC}" + [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-unknown-linux-${TARGET_LIBC}" + [ "${TARGET_ARCH}" = "riscv64gc" ] && RUST_TARGET="riscv64gc-unknown-linux-${TARGET_LIBC}" fi fi if [ -z "${C_TARGET}" ] then - if [ "${TARGET_ARCH}" = "x86_64" ] - then - C_TARGET="x86_64-linux-${TARGET_LIBC}" - fi - - if [ "${TARGET_ARCH}" = "aarch64" ] - then - C_TARGET="aarch64-linux-${TARGET_LIBC}" - fi + [ "${TARGET_ARCH}" = "x86_64" ] && C_TARGET="x86_64-linux-${TARGET_LIBC}" + [ "${TARGET_ARCH}" = "aarch64" ] && C_TARGET="aarch64-linux-${TARGET_LIBC}" fi if [ "${KRATA_TARGET_C_MODE}" = "1" ] diff --git a/hack/debug/common.sh b/hack/debug/common.sh index e935ef5..74258bb 100644 --- a/hack/debug/common.sh +++ b/hack/debug/common.sh @@ -22,8 +22,9 @@ build_and_run() { sudo mkdir -p /var/lib/krata/guest if [ "${KRATA_BUILD_INITRD}" = "1" ] then + TARGET_ARCH="$(./hack/build/arch.sh)" ./hack/initrd/build.sh -q - sudo cp "target/initrd/initrd" "/var/lib/krata/guest/initrd" + sudo cp "target/initrd/initrd-${TARGET_ARCH}" "/var/lib/krata/guest/initrd" fi RUST_TARGET="$(./hack/build/target.sh)" ./hack/build/cargo.sh build ${CARGO_BUILD_FLAGS} --bin "${EXE_TARGET}"