diff --git a/README.md b/README.md index 66095f1..4f64acc 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,17 @@ GN Cross Compilation Buildroot A GN buildroot for setting up cross-compilation environments. +Prerequisites +------------- + +* A Mac or Linux host. + Usage for Raspberry Pi ---------------------- -* Download the prepared toolchain and sysroot to the `out` directory `./tools/setup_sdk.sh`. +* Download the prepared toolchain, sysroot and related tools to the `out` directory `./tools/setup_sdk.sh`. * This takes a while and downloads upto 1 GB of data from cloud storage. * Prepare the build output directory `out` with paths to your toolchain using `./tools/setup_gn.sh`. -* Tell `gn` to use this out directory `gn gen out`. * Build using `ninja -C out` on your host. * Hack and repeat. * Push your executable to the Raspberry Pi and run. diff --git a/tools/setup_gn.sh b/tools/setup_gn.sh index 72cd6a2..55e34c4 100755 --- a/tools/setup_gn.sh +++ b/tools/setup_gn.sh @@ -15,3 +15,5 @@ echo "sysroot_path = \"${SDK_DIR}/sysroot\"" >> "${ARGS_GN}" echo "target_triple = \"arm-linux-gnueabihf\"" >> "${ARGS_GN}" echo "extra_system_include_dirs = [\"/opt/vc/include\"]" >> "${ARGS_GN}" echo "extra_system_lib_dirs = [\"/opt/vc/lib\"]" >> "${ARGS_GN}" + +"${SDK_DIR}/gn" gen "${OUT_DIR}" diff --git a/tools/setup_sdk.sh b/tools/setup_sdk.sh index 51db43b..fb80567 100755 --- a/tools/setup_sdk.sh +++ b/tools/setup_sdk.sh @@ -7,11 +7,14 @@ ReportError() { } TOOCHAIN_NAME="" +GN_PLATFORM_NAME="" if [ "$(uname)" == "Darwin" ]; then - TOOLCHAIN_NAME="darwin-x64" + TOOLCHAIN_NAME="darwin-x64" + GN_PLATFORM_NAME="mac" elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - TOOLCHAIN_NAME="linux-x64" + TOOLCHAIN_NAME="linux-x64" + GN_PLATFORM_NAME="linux64" else ReportError "This platform is not supported. Supported platforms are Darwin or Linux." exit -1 @@ -24,12 +27,16 @@ rm -rf "${SDK_DIR}" mkdir -p "${SDK_DIR}" echo "Settng up Toolchain..." -wget -O "${SDK_DIR}/toolchain.tar.gz" https://storage.googleapis.com/xcompile_sdk/pi/toolchain/${TOOLCHAIN_NAME}.tar.gz +wget -O "${SDK_DIR}/toolchain.tar.gz" "https://storage.googleapis.com/xcompile_sdk/pi/toolchain/${TOOLCHAIN_NAME}.tar.gz" tar -xzvf "${SDK_DIR}/toolchain.tar.gz" -C "${SDK_DIR}" rm "${SDK_DIR}/toolchain.tar.gz" mv "${SDK_DIR}/${TOOLCHAIN_NAME}" "${SDK_DIR}/toolchain" echo "Setting up Sysroot..." -wget -O "${SDK_DIR}/sysroot.tar.gz" https://storage.googleapis.com/xcompile_sdk/pi/sysroot.tar.gz +wget -O "${SDK_DIR}/sysroot.tar.gz" "https://storage.googleapis.com/xcompile_sdk/pi/sysroot.tar.gz" tar -xzvf "${SDK_DIR}/sysroot.tar.gz" -C "${SDK_DIR}" rm "${SDK_DIR}/sysroot.tar.gz" + +echo "Setting up GN..." +wget -O "${SDK_DIR}/gn" "https://storage.googleapis.com/fuchsia-build/fuchsia/gn/${GN_PLATFORM_NAME}/216b1a3e072f9e531abcf79600fa52fd729b1262" +chmod +x "${SDK_DIR}/gn"