Skip to content

Commit

Permalink
Make local builds easier
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Aug 18, 2022
1 parent c362dca commit d1e35ce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/out
/dist
/tmp
/ondk-*
/*.zip
36 changes: 20 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,40 @@

set -e

if [ -z $1 ]; then
echo "Usage: $0 <arch>"
echo "<arch> is either x86_64 or aarch64"
echo
exit 1
fi

. common.sh

OS=$(uname | tr '[:upper:]' '[:lower:]')
ARCH="$1"
NATIVE_ARCH=$(uname -m)
if [ $NATIVE_ARCH = "arm64" ]; then
# Apple calls aarch64 arm64
NATIVE_ARCH='aarch64'
fi

if [ -z $1 ]; then
# Build the native architecture by default
ARCH=$NATIVE_ARCH
else
ARCH=$1
fi

if [ $OS = "darwin" ]; then
NDK_DIRNAME='darwin-x86_64'
TRIPLE="${ARCH}-apple-darwin"
NATIVE_TRIPLE="${NATIVE_ARCH}-apple-darwin"
DYN_EXT='dylib'

if [ $ARCH = "aarch64" ]; then
# Configure jemalloc to use 16k pages for Apple Silicon
# Apple Silicon uses 16k pages
export JEMALLOC_SYS_WITH_LG_PAGE=14
else
export JEMALLOC_SYS_WITH_LG_PAGE=12
fi

command -v ninja >/dev/null || brew install ninja
else
NDK_DIRNAME='linux-x86_64'
TRIPLE="${ARCH}-unknown-linux-gnu"
NATIVE_TRIPLE="${NATIVE_ARCH}-unknown-linux-gnu"
DYN_EXT='so'

command -v ninja >/dev/null || sudo apt-get install ninja-build
Expand All @@ -41,11 +49,7 @@ build() {
python3 ./x.py --config "../config-${OS}.toml" --host $TRIPLE install
cd ../

if [ $OS = "darwin" -a $ARCH = "aarch64" ]; then
RUST_CLANG=$(rust/build/x86_64-apple-darwin/llvm/bin/llvm-config --version)
else
RUST_CLANG=$(rust/build/$TRIPLE/llvm/bin/llvm-config --version)
fi
RUST_CLANG=$(rust/build/$NATIVE_TRIPLE/llvm/bin/llvm-config --version)

cd out
cp -af ../rust/build/$TRIPLE/llvm/bin llvm-bin
Expand Down Expand Up @@ -113,7 +117,7 @@ universal() {

clone

if [ $OS = "darwin" -a $ARCH = "aarch64" ]; then
if [ -n "$GITHUB_ACTION" -a $OS = "darwin" -a $ARCH = "aarch64" ]; then
if [ ! -f tmp/stage-1.tar.gz ]; then
echo '! Missing stage 1 artifacts'
exit 1
Expand All @@ -129,7 +133,7 @@ fi

build

if [ $OS = "darwin" ]; then
if [ -n "$GITHUB_ACTION" -a $OS = "darwin" ]; then
if [ $ARCH = "x86_64" ]; then
# Pack up first stage artifacts
mkdir tmp
Expand Down
8 changes: 8 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0

set -e

rm -rf rust out out.arm out.x86 android-ndk-*.zip ndk ondk-* dist
4 changes: 2 additions & 2 deletions common.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0

RUST_VERSION='3830ecaa8db798d2727cbdfa4ddf314ff938f268'
RUST_VERSION='9c20b2a8cc7588decb6de25ac6a7912dcef24d65'
NDK_VERSION='r25'
OUTPUT_VERSION='r25.1'
OUTPUT_VERSION='r25.2'

NDK_CLANG='14.0.6'

Expand Down

0 comments on commit d1e35ce

Please sign in to comment.