kratactl: freebsd build

This commit is contained in:
Alex Zenla 2024-03-22 04:41:38 +00:00
parent aaf8e50c0e
commit f854dfe77a
No known key found for this signature in database
GPG Key ID: 067B238899B51269
5 changed files with 71 additions and 78 deletions

View File

@ -5,34 +5,30 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: platform:
- { name: linux, on: ubuntu-latest } - { os: linux, arch: x86_64, on: ubuntu-latest, deps: linux }
- { name: darwin, on: macos-14 } - { os: linux, arch: aarch64, on: ubuntu-latest, deps: linux }
- { name: windows, on: windows-latest } - { os: darwin, arch: x86_64, on: macos-14, deps: darwin }
arch: - { os: darwin, arch: aarch64, on: macos-14, deps: darwin }
- x86_64 - { os: freebsd, arch: x86_64, on: ubuntu-latest, deps: linux }
- aarch64 - { os: windows, arch: x86_64, on: windows-latest, deps: windows }
exclude:
# aarch64 windows support is not available in downstream dependencies
- os: { name: windows, on: windows-latest }
arch: aarch64
env: env:
TARGET_OS: "${{ matrix.os.name }}" TARGET_OS: "${{ matrix.platform.os }}"
TARGET_ARCH: "${{ matrix.arch }}" TARGET_ARCH: "${{ matrix.platform.arch }}"
runs-on: "${{ matrix.os.on }}" runs-on: "${{ matrix.platform.on }}"
name: build ${{ matrix.os.name }}-${{ matrix.arch }} name: build ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
defaults: defaults:
run: run:
shell: bash shell: bash
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
if: ${{ matrix.os.name != 'darwin' }} if: ${{ matrix.platform.os != 'darwin' }}
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
with: with:
targets: "${{ matrix.arch }}-apple-darwin" targets: "${{ matrix.platform.arch }}-apple-darwin"
if: ${{ matrix.os.name == 'darwin' }} if: ${{ matrix.platform.os == 'darwin' }}
- uses: homebrew/actions/setup-homebrew@master - uses: homebrew/actions/setup-homebrew@master
if: ${{ matrix.os.name == 'darwin' }} if: ${{ matrix.platform.os == 'darwin' }}
- run: ./hack/ci/install-${{ matrix.os.name }}-deps.sh - run: ./hack/ci/install-${{ matrix.platform.deps }}-deps.sh
- run: ./hack/build/cargo.sh build --bin kratactl - run: ./hack/build/cargo.sh build --bin kratactl

View File

@ -55,38 +55,34 @@ jobs:
client: client:
strategy: strategy:
matrix: matrix:
os: platform:
- { name: linux, on: ubuntu-latest } - { os: linux, arch: x86_64, on: ubuntu-latest, deps: linux }
- { name: darwin, on: macos-14 } - { os: linux, arch: aarch64, on: ubuntu-latest, deps: linux }
- { name: windows, on: windows-latest } - { os: darwin, arch: x86_64, on: macos-14, deps: darwin }
arch: - { os: darwin, arch: aarch64, on: macos-14, deps: darwin }
- x86_64 - { os: freebsd, arch: x86_64, on: ubuntu-latest, deps: linux }
- aarch64 - { os: windows, arch: x86_64, on: windows-latest, deps: windows }
exclude:
# aarch64 windows support is not available in downstream dependencies
- os: { name: windows, on: windows-latest }
arch: aarch64
env: env:
TARGET_OS: "${{ matrix.os.name }}" TARGET_OS: "${{ matrix.platform.os }}"
TARGET_ARCH: "${{ matrix.arch }}" TARGET_ARCH: "${{ matrix.platform.arch }}"
runs-on: "${{ matrix.os.on }}" runs-on: "${{ matrix.platform.on }}"
name: client ${{ matrix.os.name }}-${{ matrix.arch }} name: client ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
defaults: defaults:
run: run:
shell: bash shell: bash
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
if: ${{ matrix.os.name != 'darwin' }} if: ${{ matrix.platform.os != 'darwin' }}
- uses: dtolnay/rust-toolchain@stable - uses: dtolnay/rust-toolchain@stable
with: with:
targets: "${{ matrix.arch }}-apple-darwin" targets: "${{ matrix.platform.arch }}-apple-darwin"
if: ${{ matrix.os.name == 'darwin' }} if: ${{ matrix.platform.os == 'darwin' }}
- uses: homebrew/actions/setup-homebrew@master - uses: homebrew/actions/setup-homebrew@master
if: ${{ matrix.os.name == 'darwin' }} if: ${{ matrix.platform.os == 'darwin' }}
- run: ./hack/ci/install-${{ matrix.os.name }}-deps.sh - run: ./hack/ci/install-${{ matrix.platform.os }}-deps.sh
- run: ./hack/build/cargo.sh build --release --bin kratactl - run: ./hack/build/cargo.sh build --release --bin kratactl
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: kratactl-${{ matrix.os.name }}-${{ matrix.arch }} name: kratactl-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
path: "target/*/release/kratactl*" path: "target/*/release/kratactl*"

View File

@ -17,3 +17,18 @@ pre-build = [
pre-build = [ pre-build = [
"apt-get update && apt-get --assume-yes install protobuf-compiler" "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"
]

View File

@ -32,56 +32,41 @@ if [ "${TARGET_OS}" = "darwin" ]
then then
if [ -z "${RUST_TARGET}" ] if [ -z "${RUST_TARGET}" ]
then then
if [ "${TARGET_ARCH}" = "x86_64" ] [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-apple-darwin"
then [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-apple-darwin"
RUST_TARGET="x86_64-apple-darwin"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
then
RUST_TARGET="aarch64-apple-darwin"
fi
fi fi
elif [ "${TARGET_OS}" = "windows" ] elif [ "${TARGET_OS}" = "windows" ]
then then
if [ -z "${RUST_TARGET}" ] if [ -z "${RUST_TARGET}" ]
then then
if [ "${TARGET_ARCH}" = "x86_64" ] [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-pc-windows-msvc"
then [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-pc-windows-msvc"
RUST_TARGET="x86_64-pc-windows-msvc" fi
fi elif [ "${TARGET_OS}" = "freebsd" ]
then
if [ "${TARGET_ARCH}" = "aarch64" ] if [ -z "${RUST_TARGET}" ]
then then
RUST_TARGET="aarch64-pc-windows-msvc" [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-freebsd"
fi fi
elif [ "${TARGET_OS}" = "netbsd" ]
then
if [ -z "${RUST_TARGET}" ]
then
[ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-netbsd"
fi fi
else else
if [ -z "${RUST_TARGET}" ] if [ -z "${RUST_TARGET}" ]
then then
if [ "${TARGET_ARCH}" = "x86_64" ] [ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-unknown-linux-${TARGET_LIBC}"
then [ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-unknown-linux-${TARGET_LIBC}"
RUST_TARGET="x86_64-unknown-linux-${TARGET_LIBC}" [ "${TARGET_ARCH}" = "riscv64gc" ] && RUST_TARGET="riscv64gc-unknown-linux-${TARGET_LIBC}"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
then
RUST_TARGET="aarch64-unknown-linux-${TARGET_LIBC}"
fi
fi fi
fi fi
if [ -z "${C_TARGET}" ] if [ -z "${C_TARGET}" ]
then then
if [ "${TARGET_ARCH}" = "x86_64" ] [ "${TARGET_ARCH}" = "x86_64" ] && C_TARGET="x86_64-linux-${TARGET_LIBC}"
then [ "${TARGET_ARCH}" = "aarch64" ] && C_TARGET="aarch64-linux-${TARGET_LIBC}"
C_TARGET="x86_64-linux-${TARGET_LIBC}"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
then
C_TARGET="aarch64-linux-${TARGET_LIBC}"
fi
fi fi
if [ "${KRATA_TARGET_C_MODE}" = "1" ] if [ "${KRATA_TARGET_C_MODE}" = "1" ]

View File

@ -22,8 +22,9 @@ build_and_run() {
sudo mkdir -p /var/lib/krata/guest sudo mkdir -p /var/lib/krata/guest
if [ "${KRATA_BUILD_INITRD}" = "1" ] if [ "${KRATA_BUILD_INITRD}" = "1" ]
then then
TARGET_ARCH="$(./hack/build/arch.sh)"
./hack/initrd/build.sh -q ./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 fi
RUST_TARGET="$(./hack/build/target.sh)" RUST_TARGET="$(./hack/build/target.sh)"
./hack/build/cargo.sh build ${CARGO_BUILD_FLAGS} --bin "${EXE_TARGET}" ./hack/build/cargo.sh build ${CARGO_BUILD_FLAGS} --bin "${EXE_TARGET}"