91 lines
2.7 KiB
Bash
Executable file
91 lines
2.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Linux validation pipeline run inside the Ubuntu container. Mirrors
|
|
# .github/workflows/build.yml so a local docker run produces the same
|
|
# pass/fail signal as a CI push.
|
|
#
|
|
# Usage (invoked automatically as the container ENTRYPOINT):
|
|
# docker run --rm -v "$PWD":/workspace:ro fold-linux-validate
|
|
|
|
set -euo pipefail
|
|
|
|
SRC=/workspace
|
|
BUILD=/build/release
|
|
|
|
if [ ! -d "$SRC" ]; then
|
|
echo "ERROR: /workspace not mounted. Run with -v \"\$PWD\":/workspace:ro" >&2
|
|
exit 2
|
|
fi
|
|
|
|
echo "==> Copying source into container (read-only mount → writable build dir)"
|
|
mkdir -p /build
|
|
# Copy without the host's build/, .git/, and any large cache dirs.
|
|
# Use rsync if available; fall back to cp.
|
|
if command -v rsync >/dev/null; then
|
|
rsync -a \
|
|
--exclude '/build' \
|
|
--exclude '/.git' \
|
|
--exclude '/.cache' \
|
|
--exclude '/bench/results' \
|
|
--exclude '*.o' \
|
|
--exclude '*.json.gz' \
|
|
"$SRC/" /build/src/
|
|
else
|
|
cp -r "$SRC" /build/src
|
|
fi
|
|
cd /build/src
|
|
|
|
echo "==> Conan profile detect (clang-${LLVM_VERSION:-19})"
|
|
conan profile detect --force
|
|
|
|
echo "==> Conan install"
|
|
conan install . --output-folder="$BUILD" --build=missing \
|
|
-s build_type=Release \
|
|
-o build_tests=True
|
|
|
|
echo "==> Meson setup"
|
|
# Symlink z3.pc into the conan-generated build dir so pkg-config finds
|
|
# it through PKG_CONFIG_PATH. The path is arch-dependent
|
|
# (x86_64-linux-gnu on amd64, aarch64-linux-gnu on arm64 Docker
|
|
# Desktop), so probe both.
|
|
Z3_PC=""
|
|
for d in /usr/lib/x86_64-linux-gnu /usr/lib/aarch64-linux-gnu /usr/lib; do
|
|
if [ -f "$d/pkgconfig/z3.pc" ]; then
|
|
Z3_PC="$d/pkgconfig/z3.pc"
|
|
break
|
|
fi
|
|
done
|
|
if [ -n "$Z3_PC" ]; then
|
|
ln -sf "$Z3_PC" "$BUILD/z3.pc"
|
|
echo " z3.pc -> $Z3_PC"
|
|
else
|
|
echo " WARNING: no z3.pc found under /usr/lib/*/pkgconfig" >&2
|
|
fi
|
|
# -Dcapstone=auto + --wrap-mode=default: build the Capstone gadget-discovery wrap
|
|
# when cmake/network allow, else degrade to the r2 /R search (no failure).
|
|
# --wrap-mode=default overrides the wrap_mode=nofallback in Conan's native file.
|
|
meson setup "$BUILD" \
|
|
--native-file "$BUILD/conan_meson_native.ini" \
|
|
--wrap-mode=default \
|
|
-Dcpp_std=c++23 \
|
|
-Dbuild-tests=true \
|
|
-Dghidra=auto \
|
|
-Dcapstone=auto \
|
|
-Dllvm-config-path="$LLVM_CONFIG"
|
|
|
|
echo "==> Compile"
|
|
meson compile -C "$BUILD"
|
|
|
|
echo "==> Test"
|
|
meson test -C "$BUILD" --print-errorlogs
|
|
|
|
echo "==> Smoke (clone detector on fixture)"
|
|
"$BUILD/src/cli/fold" --version
|
|
"$BUILD/src/cli/fold" scan \
|
|
tests/fixtures/clones \
|
|
--std c++20 \
|
|
--detectors clone \
|
|
--format markdown --output /tmp/fold-smoke.md \
|
|
--processes 1
|
|
head -30 /tmp/fold-smoke.md
|
|
|
|
echo "==> Linux validation OK"
|