Skip to content

Commit 0437216

Browse files
committed
Support build by clang.
Based on https://github.com/gengjiawen/android-jsc/tree/feature/abi_support and some enhancements: - Build by clang - NDK r17c - Keep app_platform (minSdkVersion) at API 16 for 32bits, follows original JSC & RN's spec. 64bits will be API 21. - Repack AAR with POM by gradle and publish into npm. Works referenced from https://github.com/react-community/jsc-android-buildscripts. This supports to use local maven repository directly from node_modules. - Docker build based on pure openjdk:8-jdk image. The docker builder referenced from https://github.com/gengjiawen/android-ndk. - All build steps are reproducible by Travis CI. Some tech notes: - patches/log2.patch fallback for log2() only defined in NDK after API 19. - Travis build process getting a little tricky. Travis limits one job cost at maximum 50 minutes and we cannot finish all build before 50 minutes. The workaround is to split whole process into differnt build stage, i.e. multiple build jobs. And I store the last build status into docker hub at https://hub.docker.com/r/kudojscbuilder/android-jsc. 1. Prepare build environment docker image. 2. Based on previous image, build only armv7/x86 binary and upload new image to docker hub. Note that I also store buck-out/* object files into docker image. So that we don't need to rebuild 32bits assets for next stage. 3. Based on previous image, do full build and deploy into npm. Migration Guide: 1. yarn add @kudo-ci/android-jsc 2. Use @kudo-ci/android-jsc local maven repository before jcenter() diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index a419728d77..cec9b33a7b 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -324,7 +314,7 @@ dependencies { api "com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}" api "com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}" api 'com.squareup.okio:okio:1.14.0' - compile project(':android-jsc') + compile 'org.webkit:android-jsc:r174650' diff --git a/build.gradle b/build.gradle index 08845e85fc..5339ff8981 100644 --- a/build.gradle +++ b/build.gradle @@ -20,10 +20,13 @@ buildscript { allprojects { repositories { + maven { + url "$rootDir/node_modules/@kudo-ci/android-jsc/dist" + } + google() jcenter() mavenLocal() - def androidSdk = System.getenv("ANDROID_SDK") maven { url "$androidSdk/extras/m2repository/"
1 parent 9560d9a commit 0437216

21 files changed

+540
-180
lines changed

.buckconfig

+21-123
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,21 @@
1-
[buildfile]
2-
includes = //BUILD_DEFS
31
[ndk]
42
cpu_abis = armv7, arm64, x86, x86_64
5-
gcc_version = 4.9
6-
app_platform = android-21
7-
cppflags = \
8-
-std=gnu11 \
9-
-Wall \
10-
-Werror \
11-
-g3 \
12-
-DNEBUG \
13-
-fstack-protector
14-
cflags = \
15-
-std=gnu11 \
16-
-Wall \
17-
-Werror \
18-
-g3 \
19-
-Wa,--noexecstack \
20-
-fstack-protector \
21-
-ffunction-sections \
22-
-funwind-tables \
23-
-fomit-frame-pointer \
24-
-fno-strict-aliasing
25-
cxxppflags = \
26-
-std=gnu++11 \
27-
-Wall \
28-
-Werror \
29-
-Wno-literal-suffix \
30-
-g3 \
31-
-DNEBUG \
32-
-fstack-protector \
33-
-fno-exceptions \
34-
-fno-rtti
35-
cxxflags = \
36-
-std=gnu++11 \
3+
app_platform_per_cpu_abi = armv7 => android-16, arm64 => android-21, x86 => android-16, x86_64 => android-21
4+
compiler = clang
5+
cxx_runtime = libcxx
6+
ndk_version = 17.2.4988734
7+
extra_cxxflags = \
8+
-std=c++11 \
379
-Wall \
3810
-Werror \
3911
-g3 \
12+
-pthread \
13+
-D_LIBCPP_HAS_THREAD_API_PTHREAD \
14+
-Wno-tautological-constant-compare \
15+
-Wno-null-dereference \
16+
-Wno-undefined-var-template \
17+
-Wno-inconsistent-missing-override \
18+
-Wno-unused-lambda-capture \
4019
-Wa,--noexecstack \
4120
-fstack-protector \
4221
-ffunction-sections \
@@ -45,94 +24,13 @@
4524
-fno-strict-aliasing \
4625
-fno-exceptions \
4726
-fno-rtti
48-
ldflags = \
49-
-Wl,--build-id \
50-
-Wl,-z,noexecstack \
51-
-Wl,--gc-sections \
52-
-Wl,-z,defs \
53-
-Wl,-z,nocopyreloc \
54-
-Wl,--as-needed
55-
arm_cppflags = \
56-
-mthumb \
57-
-Os
58-
arm_cflags = \
59-
-mtune=xscale \
60-
-msoft-float \
61-
-mthumb \
62-
-Os
63-
arm_cxxppflags = \
64-
-mthumb \
65-
-Os
66-
arm_cxxflags = \
67-
-mtune=xscale \
68-
-msoft-float \
69-
-mthumb \
70-
-Os
71-
arm_ldflags = \
72-
-Wl,--fix-cortex-a8
73-
armv7_cppflags = \
74-
-mfloat-abi=softfp \
75-
-mthumb \
76-
-Os
77-
armv7_cflags = \
78-
-finline-limit=64 \
79-
-mfpu=vfpv3-d16 \
80-
-mfloat-abi=softfp \
81-
-mthumb \
82-
-Os
83-
armv7_cxxppflags = \
84-
-mfloat-abi=softfp \
85-
-mthumb \
86-
-Os
87-
armv7_cxxflags = \
88-
-finline-limit=64 \
89-
-mfpu=vfpv3-d16 \
90-
-mfloat-abi=softfp \
91-
-mthumb \
92-
-Os
93-
x86_64_cppflags = \
94-
-O2
95-
x86_64_cflags = \
96-
-funswitch-loops \
97-
-finline-limit=300 \
98-
-O2
99-
x86_64_cxxppflags = \
100-
-O2
101-
x86_64_cxxflags = \
102-
-funswitch-loops \
103-
-finline-limit=300 \
104-
-O2
105-
x86_cppflags = \
106-
-O2
107-
x86_cflags = \
108-
-funswitch-loops \
109-
-finline-limit=300 \
110-
-O2
111-
x86_cxxppflags = \
112-
-O2
113-
x86_cxxflags = \
114-
-funswitch-loops \
115-
-finline-limit=300 \
116-
-O2
27+
extra_ldflags = \
28+
-lm
29+
11730
[cxx]
11831
preprocess_mode = piped
119-
cppflags = \
120-
-std=gnu11 \
121-
-pthread \
122-
-O0 \
123-
-g3
124-
cflags = \
125-
-std=gnu11 \
126-
-pthread \
127-
-O0 \
128-
-g3
129-
cxxppflags = \
130-
-std=gnu++11 \
131-
-pthread \
132-
-O0 \
133-
-g3
134-
cxxflags = \
135-
-std=gnu++11 \
136-
-pthread \
137-
-O0 \
138-
-g3
32+
cpp = /usr/bin/clang
33+
cc = /usr/bin/clang
34+
cxxpp = /usr/bin/clang++
35+
cxx = /usr/bin/clang++
36+
ld = /usr/bin/clang++

.buckversion

-1
This file was deleted.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.idea
2+
.gradle
23
*.iml
34
gen
45
buck-out/
6+
build/
57
.buckd/
68
icu
79
!icu/BUCK
@@ -10,3 +12,4 @@ jsc
1012
!jsc/extra_headers
1113
*.gz
1214
*.bz2
15+
dist/

.travis.yml

+33-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,39 @@ dist: trusty
22
sudo: required
33
env:
44
global:
5-
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
6-
5+
- _JAVA_OPTIONS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
6+
- DOCKER_IMAGE="$DOCKER_USERNAME/android-jsc:$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER"
7+
- DOCKER_IMAGE_PARTIAL="$DOCKER_IMAGE-partial"
78
language: c
8-
99
services:
1010
- docker
11-
12-
script:
13-
- travis_wait 60 docker run --rm --name hei -v $PWD:/pwd -w /pwd gengjiawen/android-jsc:feature_abi_support /bin/sh -c "./fetch_sources.sh && buck build :android-jsc"
14-
11+
jobs:
12+
include:
13+
- stage: Prepare docker builder
14+
script:
15+
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
16+
- travis_wait 15 docker build -t $DOCKER_IMAGE_PARTIAL-builder .
17+
- docker push $DOCKER_IMAGE_PARTIAL-builder
18+
- exit 0
19+
- stage: Build android-jsc armv7 x86
20+
script:
21+
- travis_wait 50 docker run -v $PWD:/pwd -w /pwd $DOCKER_IMAGE_PARTIAL-builder /bin/sh -c "cp -Rf /pwd /android-jsc && cd /android-jsc && ./fetch_sources.sh && ./build.sh 32"
22+
- travis_wait 20 docker commit `docker ps -l -q` $DOCKER_IMAGE_PARTIAL-32bits
23+
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
24+
- docker push $DOCKER_IMAGE_PARTIAL-32bits
25+
- stage: Build android-jsc arm64 x86_64
26+
script:
27+
- travis_wait 50 docker run -v $PWD:/pwd -w /android-jsc $DOCKER_IMAGE_PARTIAL-32bits /bin/sh -c "./build.sh all && mkdir -p /pwd/build && cp -f buck-out/gen/android-jsc.aar /pwd/build/ && /pwd/repack.sh"
28+
# - travis_wait 20 docker commit `docker ps -l -q` $DOCKER_IMAGE
29+
# - mkdir -p outputs && echo 123 > outputs/123.txt
30+
# - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
31+
# - docker push $DOCKER_IMAGE
32+
deploy:
33+
provider: npm
34+
skip_cleanup: true
35+
email: ckchien+npmci@gmail.com
36+
api_key:
37+
secure: tBSHAobh0mWzRQ6J63OTbgK0ySN1fQG2o4PpvQVBhZjI2mQRGp5z8NU3Q1j5pQR0n23JzIV32m5wbuCoif5STXG80yv2T0jIhk02ZqH08z/J6ibC5x04Nvueg6JXUh8pnyvawqTNf7xVyfeiM/pLtM00j5Dmjry0D2IFbaUZgn4cbvwIEq5ZvJLTYsiOkhwv9hY1Q4jQ64z5xhtiNVL1lrFQE+3akZZZPUeY8cRdXguBzFQiIiwavve1rCTiMCoebwxyFijayIiWXx9gBzHwVwU+P5k3NcWGYGQjZMGWzaxTclSWqhM07fVuRll/6+aaX2n1y7d4iV+CpGNXe2sVuahw4S+bd+LC8mM5YQu6xyT6CsdxugKmgDK914lvdtsYvxVhdSwBNeOZAMhqvCBKGZKbBtRrqxPRtKy1BxgNMVjWQXRLcz/+oe4WaCxAvcwhSjAl7ZgzJXYIn7YzKk6+KRz0chowk+bunDmTZItXIN0/gXNmVm+65hRjnHUBC5LPsSiHO/Kc0P0z6MX6iKlDXl11sk3L0Ap4TGU+r50fR91QD7H8126fI/z2WTXhT1O0BcHUN0UIGsAFf307TDbaqzskG/lBvBMPkdQfcxOaz8xtGoy6lKE3SK7WFvUlwxbpLhMXZtd7yF9fmru95Qn2rWQSE5I+171eq2p1CsYXsTY=
38+
on:
39+
repo: Kudo/android-jsc
40+
branch: clang

BUILD_DEFS

-30
This file was deleted.

Dockerfile

+59-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,68 @@
1-
FROM gengjiawen/android-ndk
1+
FROM openjdk:8-jdk
2+
3+
ARG sdk_version=sdk-tools-linux-4333796.zip
4+
ARG android_home=/opt/android/sdk
5+
6+
RUN apt-get update && \
7+
apt-get install --yes \
8+
xvfb clang unzip lib32z1 lib32stdc++6 build-essential > /dev/null
9+
10+
# Download and install Android SDK
11+
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/${sdk_version} https://dl.google.com/android/repository/${sdk_version} && \
12+
mkdir -p ${android_home} && \
13+
unzip -q /tmp/${sdk_version} -d ${android_home} && \
14+
rm /tmp/${sdk_version}
15+
16+
# Set environmental variables
17+
ENV ANDROID_HOME ${android_home}
18+
ENV ANDROID_SDK_HOME ${android_home}
19+
ENV PATH=${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH}
20+
ENV ADB_INSTALL_TIMEOUT 120
21+
22+
# Fix install warning
23+
RUN mkdir ~/.android && echo '### User Sources for Android SDK Manager' > ~/.android/repositories.cfg
24+
25+
RUN yes | sdkmanager --licenses > /dev/null && sdkmanager --update > /dev/null
26+
27+
# Update SDK manager and install system image, platform and build tools
28+
RUN sdkmanager \
29+
"tools" \
30+
"platform-tools" \
31+
"emulator" \
32+
"extras;android;m2repository" \
33+
"extras;google;m2repository" \
34+
"extras;google;google_play_services" > /dev/null 2>&1
35+
36+
RUN sdkmanager \
37+
"build-tools;25.0.3" \
38+
"build-tools;26.0.2" \
39+
"build-tools;27.0.3" > /dev/null 2>&1
40+
41+
RUN sdkmanager "platforms;android-27" > /dev/null 2>&1
42+
43+
#install ndk
44+
RUN sdkmanager \
45+
"lldb;3.0" \
46+
"cmake;3.6.4111459" > /dev/null 2>&1
247

3-
# use old ndk
448
ENV ANDROID_NDK_HOME /opt/android-ndk
549
ENV ANDROID_NDK /opt/android-ndk
650
ENV NDK_HOME /opt/android-ndk
7-
ENV ANDROID_NDK_VERSION r10e
8-
RUN rm -rf ${ANDROID_HOME}/ndk-bundle
51+
ENV ANDROID_NDK_VERSION r17c
52+
ENV PATH ${ANDROID_NDK_HOME}:$PATH
953

1054
RUN mkdir /opt/android-ndk-tmp && \
11-
cd /opt/android-ndk-tmp && \
12-
wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
13-
unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
14-
mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME} && \
15-
cd ${ANDROID_NDK_HOME} && \
16-
rm -rf /opt/android-ndk-tmp
55+
cd /opt/android-ndk-tmp && \
56+
wget -q https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
57+
unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
58+
mv ./android-ndk-${ANDROID_NDK_VERSION} ${ANDROID_NDK_HOME} && \
59+
cd ${ANDROID_NDK_HOME} && \
60+
rm -rf /opt/android-ndk-tmp
1761

18-
ENV PATH ${ANDROID_NDK_HOME}:$PATH
19-
20-
RUN apt-get install git ant python-dev ruby zip subversion -y
62+
RUN apt-get install git ant python-dev ruby zip subversion -y > /dev/null
2163

2264
#install buck and checkout jsc
23-
RUN wget "https://github.com/facebook/buck/releases/download/v2018.03.26.01/buck_2018.03.26_all.deb" && \
24-
dpkg -i buck_2018.03.26_all.deb && \
25-
buck --version && \
26-
svn export https://svn.webkit.org/repository/webkit/trunk/@174650
27-
28-
65+
RUN wget "https://github.com/facebook/buck/releases/download/v2018.10.17.01/buck.2018.10.17.01_all.deb" > /dev/null 2>&1 && \
66+
dpkg -i buck.2018.10.17.01_all.deb > /dev/null 2>&1 && \
67+
buck --version && \
68+
svn export https://svn.webkit.org/repository/webkit/trunk/@174650 > /dev/null

0 commit comments

Comments
 (0)