-
Notifications
You must be signed in to change notification settings - Fork 0
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
chore(build): make build.sh generic (macOS + Linux) and configurable
Context
The current build.sh is macOS/Homebrew-specific:
mkdir -p build && cd build
cmake .. \
-DLLVM_DIR=$(brew --prefix llvm)/lib/cmake/llvm \
-DClang_DIR=$(brew --prefix llvm)/lib/cmake/clang \
-DCMAKE_BUILD_TYPE=Release \
&& make -j$(sysctl -n hw.logicalcpu)Issues:
brew --prefix llvmdoes not exist on Linux (or not necessarily).sysctl -n hw.logicalcpuis macOS-only.- No configurability (build type, Ninja generator, build directory, LLVM/Clang overrides, etc.).
Goal
Have a single script that:
- works on macOS and Linux
- auto-detects a sensible parallel build jobs count
- can be configured for:
BUILD_TYPE(Release/Debug/RelWithDebInfo)BUILD_DIRGENERATOR(Makefiles/Ninja)LLVM_DIRandClang_DIRvia environment variables or auto-detection
- keeps a simple UX (
./build.sh,./build.sh --clean, etc.)
Proposal (spec)
Inputs (CLI or env)
--build-dir <dir>(default:build)--type <Release|Debug|RelWithDebInfo>(default:Release)--generator <Ninja|Unix Makefiles>(optional)--clean(delete the build directory)--llvm-dir <path>/LLVM_DIR=...--clang-dir <path>/Clang_DIR=...--jobs <n>(override)
Expected detections
- OS via
uname -s jobs:- macOS:
sysctl -n hw.logicalcpu - Linux:
nproc(fallback:getconf _NPROCESSORS_ONLN)
- macOS:
- LLVM/Clang CMake dirs:
- macOS: if
brewis present, trybrew --prefix llvm - Linux:
- if
llvm-configis present: usellvm-config --cmakedir(often reliable) - otherwise fallback to common paths (
/usr/lib/llvm-*/lib/cmake/llvm, etc.) if found
- if
- Otherwise: fail with a clear message explaining how to provide
LLVM_DIR/Clang_DIR.
- macOS: if
Tasks
- Create
scripts/build.sh(or replacebuild.sh) withset -euo pipefail - Add minimal argument parsing (
case "$1" in ...) +--help - Implement cross-platform
JOBSdetection - Implement LLVM/Clang auto-detection (brew + llvm-config) + fallbacks + clean errors
- Support Ninja if installed (
command -v ninja) - Use
cmake --build . -j "$JOBS"instead of callingmakedirectly (more portable) - Document usage in
README.md(Build on macOS/Linux section) - Add a quick CI check that validates:
- the script can configure (at least
cmake -S -B) - on
ubuntu-latest+macos-latest(GitHub Actions)
- the script can configure (at least
Acceptance criteria
./build.shworks on macOS with LLVM installed via Homebrew../build.shworks on Linux with LLVM/Clang installed via packages/llvm-config or viaLLVM_DIR/Clang_DIR../build.sh --cleancleans and rebuilds.- The script does not rely on OS-specific commands without fallback.
- Error messages are actionable (e.g., “export LLVM_DIR=… and re-run”).
Notes / usage examples
- macOS (brew):
./build.sh --type Release
- Linux (packages):
./build.sh --type Debug
- Manual override:
LLVM_DIR=/opt/llvm/lib/cmake/llvm Clang_DIR=/opt/llvm/lib/cmake/clang ./build.sh --generator Ninja
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request