Skip to content

Commit 0d3e97e

Browse files
Merge pull request #9 from QAQ-cmd/main
Enhance build-rootfs.sh for toolchain detection and WSL
2 parents 7a7e8d4 + 1eda99d commit 0d3e97e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

scripts/build-rootfs.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ if [[ "$RECONFIGURE" == 1 || ! -f .config ]]; then
4848
make rk3506_aes_defconfig
4949
fi
5050

51+
# Detect toolchain root from PATH (avoid hardcoding /opt/... in the defconfig).
52+
# This lets the user change toolchain location without editing config files.
53+
TC_GCC=$(command -v "arm-none-linux-gnueabihf-gcc" 2>/dev/null || true)
54+
if [[ -z "$TC_GCC" ]]; then
55+
die "arm-none-linux-gnueabihf-gcc not found on PATH. Run: source scripts/env-setup.sh"
56+
fi
57+
BR2_TC_PATH=$(cd "$(dirname "$TC_GCC")/.." && pwd)
58+
log_info "detected toolchain: $BR2_TC_PATH"
59+
5160
# WSL: buildroot dependencies.mk rejects PATH entries with spaces (/mnt/c/...).
5261
# forge_clean_path strips them; run make under the cleaned PATH.
53-
log_info "make (PATH cleaned of /mnt + whitespace)"
54-
PATH="$(forge_clean_path)" make
62+
# BR2_TOOLCHAIN_EXTERNAL_PATH overrides the defconfig's hardcoded default.
63+
log_info "make (PATH cleaned of /mnt + whitespace, BR2_TOOLCHAIN_EXTERNAL_PATH from env)"
64+
PATH="$(forge_clean_path)" make BR2_TOOLCHAIN_EXTERNAL_PATH="$BR2_TC_PATH"
5565

5666
ROOTFS_TAR="$BUILDROOT/output/images/rootfs.tar"
5767
[[ -f "$ROOTFS_TAR" ]] || die "buildroot produced no rootfs.tar"

0 commit comments

Comments
 (0)