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:
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

View File

@ -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*"

View File

@ -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"
]

View File

@ -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"
[ "${TARGET_ARCH}" = "x86_64" ] && RUST_TARGET="x86_64-pc-windows-msvc"
[ "${TARGET_ARCH}" = "aarch64" ] && RUST_TARGET="aarch64-pc-windows-msvc"
fi
if [ "${TARGET_ARCH}" = "aarch64" ]
elif [ "${TARGET_OS}" = "freebsd" ]
then
if [ -z "${RUST_TARGET}" ]
then
RUST_TARGET="aarch64-pc-windows-msvc"
[ "${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" ]

View File

@ -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}"