first commit
This commit is contained in:
61
scripts/build.sh
Executable file
61
scripts/build.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# build.sh — wrapper for Mestre Buildroot builds.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/build.sh # full build
|
||||
# ./scripts/build.sh menuconfig # Buildroot menuconfig
|
||||
# ./scripts/build.sh linux-menuconfig # Linux kernel menuconfig
|
||||
# ./scripts/build.sh uboot-menuconfig # U-Boot menuconfig
|
||||
# ./scripts/build.sh <pkg>-rebuild # Force-rebuild a single package
|
||||
# ./scripts/build.sh clean # Clean build output
|
||||
# ./scripts/build.sh -- -j4 # Pass arbitrary args through to make
|
||||
#
|
||||
# On first invocation, the build directory is created and configured from
|
||||
# the mestre_x6200_defconfig. Subsequent invocations reuse the existing
|
||||
# build directory.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
BUILD_DIR="$REPO_ROOT/build"
|
||||
BR2_EXTERNAL="$REPO_ROOT/br2_external"
|
||||
DEFCONFIG="mestre_x6200_defconfig"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Sanity check: submodule must be present
|
||||
# ---------------------------------------------------------------------------
|
||||
if [ ! -f "$REPO_ROOT/buildroot/Makefile" ]; then
|
||||
echo "!!! Buildroot submodule not initialized."
|
||||
echo " Run: ./scripts/setup.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# First-time configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
if [ ! -f "$BUILD_DIR/.config" ]; then
|
||||
if [ ! -f "$BR2_EXTERNAL/configs/$DEFCONFIG" ]; then
|
||||
echo "!!! Defconfig not found: $BR2_EXTERNAL/configs/$DEFCONFIG"
|
||||
echo " The defconfig hasn't been added yet. See the project's"
|
||||
echo " milestone status in README.md."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ">>> First-time configuration: $DEFCONFIG"
|
||||
mkdir -p "$BUILD_DIR"
|
||||
make -C "$REPO_ROOT/buildroot" \
|
||||
BR2_EXTERNAL="$BR2_EXTERNAL" \
|
||||
O="$BUILD_DIR" \
|
||||
"$DEFCONFIG"
|
||||
echo
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Run make in the build directory
|
||||
# ---------------------------------------------------------------------------
|
||||
# Default to plain `make` if no extra args were passed.
|
||||
if [ $# -eq 0 ]; then
|
||||
make -C "$BUILD_DIR"
|
||||
else
|
||||
make -C "$BUILD_DIR" "$@"
|
||||
fi
|
||||
59
scripts/setup.sh
Executable file
59
scripts/setup.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# setup.sh — bootstrap the Mestre development environment.
|
||||
#
|
||||
# Idempotent. Safe to run multiple times.
|
||||
#
|
||||
# Performs:
|
||||
# 1. Initializes the Buildroot submodule.
|
||||
# 2. Checks that the host has the tools Buildroot needs.
|
||||
#
|
||||
# On success, you can build with:
|
||||
# ./scripts/build.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. Buildroot submodule
|
||||
# ---------------------------------------------------------------------------
|
||||
if [ ! -f "$REPO_ROOT/buildroot/Makefile" ]; then
|
||||
echo ">>> Initializing Buildroot submodule (this may take a minute)..."
|
||||
git submodule update --init buildroot
|
||||
else
|
||||
echo ">>> Buildroot submodule already initialized."
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Host prerequisites
|
||||
# ---------------------------------------------------------------------------
|
||||
# Buildroot's full list lives at:
|
||||
# https://buildroot.org/downloads/manual/manual.html#requirement
|
||||
# We check the most commonly missing ones; Buildroot itself will surface
|
||||
# anything else we've forgotten.
|
||||
echo ">>> Checking host prerequisites..."
|
||||
missing=()
|
||||
for tool in make gcc g++ patch perl python3 cpio rsync bc unzip wget file which sed; do
|
||||
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||
missing+=("$tool")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#missing[@]} -gt 0 ]; then
|
||||
echo
|
||||
echo "!!! Missing host tools: ${missing[*]}"
|
||||
echo
|
||||
echo "On Debian/Ubuntu, install with:"
|
||||
echo " sudo apt-get install build-essential patch perl python3 \\"
|
||||
echo " cpio rsync bc unzip wget file"
|
||||
echo
|
||||
echo "See https://buildroot.org/downloads/manual/manual.html#requirement"
|
||||
echo "for the complete list."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ">>> All required host tools present."
|
||||
echo
|
||||
echo "Setup complete. Next:"
|
||||
echo " ./scripts/build.sh"
|
||||
Reference in New Issue
Block a user