Skip to content

Commit 6401155

Browse files
authored
Use Buck from Jitpack (#178)
1 parent 0954129 commit 6401155

File tree

4 files changed

+26
-58
lines changed

4 files changed

+26
-58
lines changed

.circleci/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ jobs:
2525
nvm i node
2626
node publish_docker.js
2727
28+
build:
29+
<<: *defaults
30+
steps:
31+
- checkout
32+
- run: *build-docker
33+
- run:
34+
name: Check if Emulator (Headless) starts
35+
command: docker run --rm -v "$(pwd)/scripts/":/scripts react-native-community/react-native /bin/sh -c "/scripts/test-emulator-headless.sh"
36+
- run:
37+
name: Checkout React Native
38+
command: git clone https://github.com/facebook/react-native.git
39+
- run:
40+
name: Build React Native
41+
command: docker run --rm --ulimit nofile=10240 -v "$(pwd)/scripts/":/scripts -v "$(pwd)/react-native/":/react-native -w /react-native react-native-community/react-native /bin/sh -c "/scripts/test-react-native-setup.sh"
42+
2843
workflows:
2944
version: 2
3045
main:
@@ -33,3 +48,4 @@ workflows:
3348
filters:
3449
branches:
3550
only: master
51+
- build

.github/workflows/build.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

Dockerfile

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
# build buck from source
2-
FROM ubuntu:20.04 AS buck
3-
4-
ARG BUCK_VERSION=2021.01.12.01
5-
ENV ANT_OPTS="-Xmx4096m"
6-
RUN apt update && apt install -y --no-install-recommends \
7-
ant \
8-
git \
9-
openjdk-11-jdk-headless \
10-
python-setuptools \
11-
python3-setuptools
12-
# install buck by compiling it from source. We also remove the buck repo once it's built.
13-
RUN git clone --depth 1 --branch v${BUCK_VERSION} https://github.com/facebook/buck.git \
14-
&& cd buck \
15-
&& ant \
16-
&& ./bin/buck build buck --config java.target_level=11 --config java.source_level=11 --out /tmp/buck.pex
17-
18-
# build react native image and use buck built from source from above stage
191
FROM ubuntu:20.04
2+
203
LABEL Description="This image provides a base Android development environment for React Native, and may be used to run tests."
214

225
ENV DEBIAN_FRONTEND=noninteractive
@@ -26,6 +9,7 @@ ENV DEBIAN_FRONTEND=noninteractive
269
ARG SDK_VERSION=commandlinetools-linux-8512546_latest.zip
2710
ARG ANDROID_BUILD_VERSION=31
2811
ARG ANDROID_TOOLS_VERSION=31.0.0
12+
ARG BUCK_VERSION=2022.05.05.01
2913
ARG NDK_VERSION=21.4.7075529
3014
ARG NODE_VERSION=14.x
3115
ARG WATCHMAN_VERSION=4.9.0
@@ -41,8 +25,6 @@ ENV CMAKE_BIN_PATH=${ANDROID_HOME}/cmake/$CMAKE_VERSION/bin
4125

4226
ENV PATH=${ANDROID_NDK}:${CMAKE_BIN_PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:/opt/buck/bin/:${PATH}
4327

44-
COPY --from=buck /tmp/buck.pex /usr/local/bin/buck
45-
4628
# Install system dependencies
4729
RUN apt update -qq && apt install -qq -y --no-install-recommends \
4830
apt-transport-https \
@@ -101,6 +83,11 @@ RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \
10183
&& npm i -g yarn \
10284
&& rm -rf /var/lib/apt/lists/*
10385

86+
# download and install buck using the java11 pex from Jitpack
87+
RUN curl -L https://jitpack.io/com/github/facebook/buck/v${BUCK_VERSION}/buck-v${BUCK_VERSION}-java11.pex -o /tmp/buck.pex \
88+
&& mv /tmp/buck.pex /usr/local/bin/buck \
89+
&& chmod +x /usr/local/bin/buck
90+
10491
# Full reference at https://dl.google.com/android/repository/repository2-1.xml
10592
# download and unpack android
10693
# workaround buck clang version detection by symlinking

scripts/test-react-native-setup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buck build ReactAndroid/src/main/java/com/facebook/react/shell
1313

1414
echo "Build React Native via Gradle"
1515
yarn install
16-
./gradlew --no-daemon :ReactAndroid:packageReactNdkLibsForBuck
16+
./gradlew --no-daemon :ReactAndroid:packageReactNdkLibsForBuck -PreactNativeArchitectures=arm64-v8a
1717

18-
echo "Assemble RNTester app"
19-
./gradlew --no-daemon :packages:rn-tester:android:app:assembleRelease
18+
echo "Assemble RNTester Release arm64-v8a"
19+
./gradlew --no-daemon :packages:rn-tester:android:app:assembleRelease -PreactNativeArchitectures=arm64-v8a

0 commit comments

Comments
 (0)