Skip to content

Commit

Permalink
Add build script, update a test
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Jul 6, 2023
1 parent 755578a commit 13529ad
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
79 changes: 79 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

set -euo pipefail

cd "$(dirname "$0")" || exit 1
project_root="$(pwd)"

help() {
>&2 echo "USAGE: $(basename "$0") [build, test, ...]"
}

clean() {
rm -rf ./zig-cache ./zig-out
}

compile() {
zig build
}

test() {
zig build test
}

release() {
zig build -Drelease-small=true
}

cross-clean() {
rm -rf ./target
}

cross-release() {
local triples=(
aarch64-linux-gnu
aarch64-linux-musleabi
arm-linux-musleabi
arm-linux-musleabihf
x86-linux-gnu
x86-linux-musl
mips64el-linux-gnuabi64
mips64el-linux-musl
mips64-linux-gnuabi64
mips64-linux-musl
mipsel-linux-gnu
mipsel-linux-musl
mips-linux-gnu
mips-linux-musl
powerpc64le-linux-gnu
powerpc64le-linux-musl
powerpc-linux-gnu
powerpc-linux-musl
riscv64-linux-gnu
riscv64-linux-musl
# wasm32-wasi-musl TODO
x86_64-linux-gnu
x86_64-linux-musl
)

for triple in "${triples[@]}"; do
>&2 echo "** Cross-compiling for $triple"
local out="$project_root"/target/"$triple"
mkdir -p "$out"

zig build -Doptimize=ReleaseSmall -Dtarget="$triple" -p "$out"
done
}

cross-tar() {
cd "$project_root"/target || exit 1
for triple in *; do
>&2 echo "** Making archive for $triple"
tar -czvf "$triple".tgz "$triple"
done
}

for cmd in "$@"; do
cd "$project_root" || exit 1
eval "$cmd"
done
2 changes: 1 addition & 1 deletion src/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test "findup --version" {
defer allocator.free(result.stdout);
defer allocator.free(result.stderr);

try testing.expectEqualStrings("findup 1.1-rc\n", result.stdout);
try testing.expectEqualStrings("findup 1.1.1\n", result.stdout);
}

test "findup build.zig" {
Expand Down

0 comments on commit 13529ad

Please sign in to comment.