Skip to content

Commit

Permalink
Add support for setting up GN on Linux & Mac.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde committed May 20, 2018
1 parent 01b83a3 commit 7b6ee14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions tools/setup_gn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
15 changes: 11 additions & 4 deletions tools/setup_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

0 comments on commit 7b6ee14

Please sign in to comment.