增加单独编译mips架构的编译脚本
This commit is contained in:
85
build_arch.sh
Executable file
85
build_arch.sh
Executable file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
BUILD_SH="${ROOT_DIR}/build.sh"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Usage:
|
||||||
|
./build_arch.sh <arch> [--le|--be] [-- <extra build.sh args>]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
./build_arch.sh mips
|
||||||
|
./build_arch.sh mips.le
|
||||||
|
./build_arch.sh mips --be
|
||||||
|
./build_arch.sh riscv64
|
||||||
|
./build_arch.sh sparc.be -- --skip-fetch -d
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- If <arch> has no endian suffix, default is ".le"
|
||||||
|
- Use "--le" or "--be" to force endianness
|
||||||
|
- Everything after "--" is passed to build.sh
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
arch="$1"; shift || true
|
||||||
|
|
||||||
|
force_endian=""
|
||||||
|
extra_args=()
|
||||||
|
|
||||||
|
# Parse flags until optional "--"
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--le|--be)
|
||||||
|
force_endian="${1#--}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
extra_args+=("$@")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# unknown flag -> treat as extra args (or enforce strict if you want)
|
||||||
|
extra_args+=("$1")
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Normalize arch -> ensure it matches CORES entries like "mips.le", "mips.be", "mips64.le", etc.
|
||||||
|
if [[ "$arch" == *.* ]]; then
|
||||||
|
# Already has suffix (e.g. mips.le)
|
||||||
|
normalized="$arch"
|
||||||
|
else
|
||||||
|
# No suffix: apply forced endian or default to le
|
||||||
|
if [[ -n "$force_endian" ]]; then
|
||||||
|
normalized="${arch}.${force_endian}"
|
||||||
|
else
|
||||||
|
normalized="${arch}.le"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If user provided both "mips.le" and "--be", --be wins (optional behavior)
|
||||||
|
if [[ -n "$force_endian" ]]; then
|
||||||
|
base="${normalized%%.*}"
|
||||||
|
normalized="${base}.${force_endian}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$BUILD_SH" ]]; then
|
||||||
|
echo "Error: build.sh not found or not executable at: $BUILD_SH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$BUILD_SH" --external-lib-arch "$normalized" "${extra_args[@]}"
|
||||||
|
|
||||||
Reference in New Issue
Block a user