enhance xce-build skill

This commit is contained in:
Rongsong Shen 2026-05-30 08:13:59 +08:00
parent 9bbff7b016
commit c8e0f65a39
7 changed files with 107 additions and 22 deletions

82
src/tools/xce-build.sh Executable file
View file

@ -0,0 +1,82 @@
#!/usr/bin/env bash
set -euo pipefail
COMPONENT="${1:-all}"
BUILD_DIR="${2:-xce.build}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SRC_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$SRC_DIR"
usage() {
echo "Usage: $0 [component] [build_dir]"
echo "Components: all (default), lib, controller, scheduler, worker, apiserver, xcecli"
exit 1
}
setup_build() {
echo "=== Clean build: $BUILD_DIR ==="
rm -rf "$BUILD_DIR"
meson setup "$BUILD_DIR" --buildtype=debug -Db_sanitize=address
}
case "$COMPONENT" in
lib)
setup_build
echo "=== Building lib + tests ==="
meson compile -C "$BUILD_DIR" xcelib_test
echo "=== Running lib tests ==="
meson test -C "$BUILD_DIR" "libxce test" --print-errorlogs
;;
controller)
setup_build
echo "=== Building lib + controller + tests ==="
meson compile -C "$BUILD_DIR" xce_controller controller_unit_test
echo "=== Running controller tests ==="
meson test -C "$BUILD_DIR" --suite controller --print-errorlogs
;;
scheduler)
setup_build
echo "=== Building lib + scheduler + tests ==="
meson compile -C "$BUILD_DIR" xce_scheduler sched_test
echo "=== Running scheduler tests ==="
"./$BUILD_DIR/scheduler/testsuite/sched_test"
;;
worker)
setup_build
echo "=== Building lib + worker ==="
meson compile -C "$BUILD_DIR" xcecd xcecd_worker xrun
echo "=== Worker built (no unit tests registered) ==="
;;
apiserver)
setup_build
echo "=== Building lib + apiserver + xcecli ==="
meson compile -C "$BUILD_DIR" apiserver xcecli
echo "=== Running frontend Go unit tests ==="
cd frontend && make test
;;
xcecli)
setup_build
echo "=== Building xcecli ==="
meson compile -C "$BUILD_DIR" xcecli
echo "=== Running xcecli Go unit tests ==="
cd frontend/xcecli && CGO_ENABLED=0 go test ./... -count=1
;;
all)
setup_build
echo "=== Building all components ==="
meson compile -C "$BUILD_DIR"
echo "=== Running all C tests ==="
meson test -C "$BUILD_DIR" --print-errorlogs
echo "=== Running scheduler test (manual) ==="
"./$BUILD_DIR/scheduler/testsuite/sched_test"
echo "=== Running frontend Go unit tests ==="
cd frontend && make test
;;
*)
usage
;;
esac
echo "=== Done: $COMPONENT ==="