AtlatestRepositorysigil-doc

sigil-doc / tree / testbuild-d3-bytecode-base.sh

1#!/usr/bin/env bash
2set -euo pipefail
3repo_dir="$(cd "$(dirname "$0")/.." && pwd)"
4compiler="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"
5compiler_repo="${SIGIL_COMPILER_REPO:-$(cd "$(dirname "$compiler")/../../.." && pwd)}"
6zig="${SIGIL_ZIG:-$HOME/.sigil/toolchain/zig/zig}"
7out_dir="${D3_BYTECODE_BASE_DIR:-$repo_dir/build/d3-bytecode-base}"
8zig_cache="${D3_ZIG_CACHE:-$repo_dir/build/d3-zig-cache}"
9mkdir -p "$out_dir" "$zig_cache"
11includes=(
12 "-I$compiler_repo/packages/sigil-lib/include"
13 "-I$compiler_repo/packages/sigil-lib/src"
14 "-I$compiler_repo/packages/sigil-lib/vendor/miniz"
15 "-I$compiler_repo/packages/sigil-lib/vendor/minicoro"
17ZIG_GLOBAL_CACHE_DIR="$zig_cache" "$zig" cc -std=c99 -O2 -DNDEBUG -D_GNU_SOURCE \
18 -D_POSIX_C_SOURCE=200809L "${includes[@]}" \
19 -c "$compiler_repo/packages/sigil-run/src/main.c" -o "$out_dir/main.o"
20runtime_objects=("$compiler_repo"/build/boot/obj/libsigil/*.o)
21ZIG_GLOBAL_CACHE_DIR="$zig_cache" "$zig" cc -o "$out_dir/sigil-run" \
22 "$compiler_repo/build/boot/obj/app_info.o" "$out_dir/main.o" \
23 "${runtime_objects[@]}" "$compiler_repo/build/boot/obj/miniz/miniz.o" \
24 "$compiler_repo/build/boot/obj/minicoro/minicoro.o" -lm -lpthread
25printf '%s\n' "$out_dir/sigil-run"