Skip to content

Commit dbcedc8

Browse files
committed
Publish stripped libraries in default AAR.
Summary: 1. To reduce final APK size, publish stripped libjsc.so in dist/**/*.aar 2. The unstripped version is important for troubleshooting especially crash backtrace symbalication. Will publish unstripped version in dist.unstripped/**/*.aar
1 parent 3683604 commit dbcedc8

File tree

10 files changed

+94
-47
lines changed

10 files changed

+94
-47
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
- run: npm run start
6565
- run:
6666
name: compress dist
67-
command: tar -czf dist.tgz dist
67+
command: tar -czf dist.tgz dist dist.unstripped
6868
- store_artifacts:
6969
path: dist.tgz
7070
- run:

lib/android-jsc/build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
apply plugin: 'com.android.library'
22

3+
def distDir = project.findProperty("distDir") ?: ""
4+
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
5+
def revision = project.findProperty("revision") ?: "".replaceAll("\\s", "")
6+
def i18n = project.findProperty("i18n") ?: ""
7+
8+
if (!distDir) throw new RuntimeException("expecting --project-prop distDir=??? but was empty")
9+
if (!jniLibsDir) throw new RuntimeException("expecting --project-prop jniLibsDir=??? but was empty")
10+
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")
11+
if (!i18n) throw new RuntimeException("expecting --project-prop i18n=??? but was empty")
12+
313
android {
414
compileSdkVersion 28
515

@@ -12,7 +22,7 @@ android {
1222

1323
sourceSets {
1424
main {
15-
jniLibs.srcDirs = ["${rootDir}/../build/compiled"]
25+
jniLibs.srcDirs = ["${jniLibsDir}"]
1626
}
1727
}
1828

@@ -26,16 +36,6 @@ dependencies {}
2636
apply plugin: 'maven'
2737

2838
task createAAR(type: Upload) {
29-
def distDir = "${rootDir}/../dist"
30-
31-
def revision = project.findProperty("revision") ?: "".replaceAll("\\s", "")
32-
def i18n = project.findProperty("i18n") ?: ""
33-
34-
doFirst {
35-
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")
36-
if (!i18n) throw new RuntimeException("expecting --project-prop i18n=??? but was empty")
37-
}
38-
3939
project.group = "org.webkit"
4040
def artifactName = Boolean.valueOf(i18n) ? "android-jsc-intl" : "android-jsc"
4141
project.version = "r${revision}"

lib/cppruntime/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
apply plugin: 'com.android.library'
22

3+
def distDir = project.findProperty("distDir") ?: ""
4+
def jniLibsDir = project.findProperty("jniLibsDir") ?: ""
5+
def revision = project.findProperty("revision") ?: "".replaceAll("\\s", "")
6+
7+
if (!distDir) throw new RuntimeException("expecting --project-prop distDir=??? but was empty")
8+
if (!jniLibsDir) throw new RuntimeException("expecting --project-prop jniLibsDir=??? but was empty")
9+
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")
10+
311
android {
412
compileSdkVersion 28
513

@@ -12,7 +20,7 @@ android {
1220

1321
sourceSets {
1422
main {
15-
jniLibs.srcDirs = ["${rootDir}/../build/cppruntime"]
23+
jniLibs.srcDirs = ["${jniLibsDir}"]
1624
}
1725
}
1826
}
@@ -22,14 +30,6 @@ dependencies {}
2230
apply plugin: 'maven'
2331

2432
task createAAR(type: Upload) {
25-
def distDir = "${rootDir}/../dist"
26-
27-
def revision = project.findProperty("revision") ?: "".replaceAll("\\s", "")
28-
29-
doFirst {
30-
if (!revision) throw new RuntimeException("expecting --project-prop revision=??? but was empty")
31-
}
32-
3333
project.group = "org.webkit"
3434
project.version = "r${revision}"
3535

scripts/compile/all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ compile_arch() {
66
echo -e '\033]2;'"compiling toolchain for $JSC_ARCH $FLAVOR"'\007'
77
printf "\n\n\n\t\t=================== compiling toolchain for $JSC_ARCH $FLAVOR ===================\n\n\n"
88
$SCRIPT_DIR/toolchain.sh
9-
9+
1010
echo -e '\033]2;'"compiling icu for $JSC_ARCH $FLAVOR"'\007'
1111
printf "\n\n\n\t\t=================== compiling icu for $JSC_ARCH $FLAVOR ===================\n\n\n"
1212
$SCRIPT_DIR/icu.sh
13-
13+
1414
echo -e '\033]2;'"compiling jsc for $JSC_ARCH $FLAVOR"'\007'
1515
printf "\n\n\n\t\t=================== compiling jsc for $JSC_ARCH $FLAVOR ===================\n\n\n"
1616
$SCRIPT_DIR/jsc.sh

scripts/compile/common.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CROSS_COMPILE_PLATFORM=${!var}
4242
TOOLCHAIN_DIR=$TARGETDIR/toolchains/$CROSS_COMPILE_PLATFORM
4343

4444
# settings
45+
TOOLCHAIN_BIN_STRIP_arm="$TOOLCHAIN_DIR/bin/arm-linux-androideabi-strip"
4546
TOOLCHAIN_LINK_DIR_arm="$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib/armv7-a"
4647
PLATFORM_CFLAGS_arm=" \
4748
-march=armv7-a \
@@ -56,12 +57,14 @@ PLATFORM_LDFLAGS_arm=" \
5657
"
5758
JNI_ARCH_arm=armeabi-v7a
5859

60+
TOOLCHAIN_BIN_STRIP_arm64="$TOOLCHAIN_DIR/bin/aarch64-linux-android-strip"
5961
TOOLCHAIN_LINK_DIR_arm64="$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib"
6062
PLATFORM_LDFLAGS_arm64=" \
6163
-L$TOOLCHAIN_LINK_DIR_arm64 \
6264
"
6365
JNI_ARCH_arm64=arm64-v8a
6466

67+
TOOLCHAIN_BIN_STRIP_x86="$TOOLCHAIN_DIR/bin/i686-linux-android-strip"
6568
TOOLCHAIN_LINK_DIR_x86="$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib"
6669
PLATFORM_CFLAGS_x86=" \
6770
-march=i686 \
@@ -75,6 +78,7 @@ PLATFORM_LDFLAGS_x86=" \
7578
"
7679
JNI_ARCH_x86=x86
7780

81+
TOOLCHAIN_BIN_STRIP_x86_64="$TOOLCHAIN_DIR/bin/x86_64-linux-android-strip"
7882
TOOLCHAIN_LINK_DIR_x86_64="$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib64"
7983
PLATFORM_CFLAGS_x86_64=" \
8084
-march=x86-64 \
@@ -95,6 +99,8 @@ var="PLATFORM_LDFLAGS_$JSC_ARCH"
9599
PLATFORM_LDFLAGS=${!var}
96100
var="JNI_ARCH_$JSC_ARCH"
97101
JNI_ARCH=${!var}
102+
var="TOOLCHAIN_BIN_STRIP_$JSC_ARCH"
103+
TOOLCHAIN_BIN_STRIP=${!var}
98104
var="TOOLCHAIN_LINK_DIR_$JSC_ARCH"
99105
TOOLCHAIN_LINK_DIR=${!var}
100106

@@ -170,9 +176,3 @@ $PLATFORM_LDFLAGS \
170176

171177
JSC_LDFLAGS="$COMMON_LDFLAGS"
172178
JSC_CFLAGS="$COMMON_CFLAGS -DU_STATIC_IMPLEMENTATION=1 -DU_SHOW_CPLUSPLUS_API=0"
173-
174-
INSTALL_DIR=$ROOTDIR/build/compiled/$JNI_ARCH
175-
mkdir -p $INSTALL_DIR
176-
177-
INSTALL_CPPRUNTIME_DIR=$ROOTDIR/build/cppruntime/$JNI_ARCH
178-
mkdir -p $INSTALL_CPPRUNTIME_DIR

scripts/compile/jsc.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,9 @@ $TARGETDIR/webkit/Tools/Scripts/build-webkit \
100100
$BUILD_TYPE_FLAGS \
101101
"
102102

103-
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_DIR
103+
mkdir -p $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
104+
mkdir -p $INSTALL_DIR_I18N/$JNI_ARCH
105+
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_UNSTRIPPED_DIR_I18N/$JNI_ARCH
106+
cp $TARGETDIR/webkit/WebKitBuild/$BUILD_TYPE/lib/libjsc.so $INSTALL_DIR_I18N/$JNI_ARCH
107+
$TOOLCHAIN_BIN_STRIP $INSTALL_DIR_I18N/$JNI_ARCH/libjsc.so
104108
mv $TARGETDIR/webkit/WebKitBuild $TARGETDIR/webkit/${CROSS_COMPILE_PLATFORM}-${FLAVOR}

scripts/compile/toolchain.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ $ANDROID_NDK/build/tools/make_standalone_toolchain.py \
1111
--arch $ARCH \
1212
--stl libc++
1313

14-
cp $TOOLCHAIN_LINK_DIR/libc++_shared.so $INSTALL_CPPRUNTIME_DIR
14+
mkdir -p $INSTALL_CPPRUNTIME_DIR/$JNI_ARCH
15+
cp $TOOLCHAIN_LINK_DIR/libc++_shared.so $INSTALL_CPPRUNTIME_DIR/$JNI_ARCH

scripts/env.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash -e
2+
3+
export ROOTDIR=$PWD
4+
5+
# Intermediated build target dir
6+
export TARGETDIR=$ROOTDIR/build/target
7+
8+
# JSC shared library install dir
9+
export INSTALL_DIR=$ROOTDIR/build/compiled
10+
11+
# JSC unstripped shared library install dir
12+
export INSTALL_UNSTRIPPED_DIR=$ROOTDIR/build/compiled.unstripped
13+
14+
# CPP runtime shared library install dir
15+
export INSTALL_CPPRUNTIME_DIR=$ROOTDIR/build/cppruntime
16+
17+
# Install dir for i18n build variants
18+
export INSTALL_DIR_I18N_true=$INSTALL_DIR/intl
19+
export INSTALL_DIR_I18N_false=$INSTALL_DIR/nointl
20+
export INSTALL_UNSTRIPPED_DIR_I18N_true=$INSTALL_UNSTRIPPED_DIR/intl
21+
export INSTALL_UNSTRIPPED_DIR_I18N_false=$INSTALL_UNSTRIPPED_DIR/nointl

scripts/info.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export REVISION=$(svn info "${URL}" | sed -n 's/^Last Changed Rev: //p')
88
CONFIG=$(node -e "console.log(require('$ROOTDIR/package.json').config)")
99
APPLE_VERSION=$(svn cat "${URL}/Source/WebCore/Configurations/Version.xcconfig" | grep 'MAJOR_VERSION\s=\|MINOR_VERSION\s=\|TINY_VERSION\s=\|MICRO_VERSION\s=\|NANO_VERSION\s=')
1010

11-
if [ -d "$ROOTDIR/build/compiled" ]; then
12-
SIZE=$(du -ah $ROOTDIR/build/compiled)
11+
if [ -d "$INSTALL_DIR_I18N_false" ]; then
12+
SIZE=$(du -ah $INSTALL_DIR_I18N_false)
1313
else
1414
SIZE="0"
1515
fi

scripts/start.sh

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
export ANDROID_API_FOR_ABI_32=16
44
export ANDROID_API_FOR_ABI_64=21
55
export ROOTDIR=$PWD
6-
export TARGETDIR=$ROOTDIR/build/target
6+
7+
source $ROOTDIR/scripts/env.sh
78
source $ROOTDIR/scripts/info.sh
89
export JSC_VERSION=${npm_package_version}
910
export BUILD_TYPE=Release
@@ -64,38 +65,58 @@ prep() {
6465

6566
compile() {
6667
printf "\n\n\t\t===================== starting to compile all archs for i18n="${I18N}" =====================\n\n"
67-
rm -rf $ROOTDIR/build/compiled
68+
local var="INSTALL_DIR_I18N_${I18N}"
69+
export INSTALL_DIR_I18N=${!var}
70+
local var="INSTALL_UNSTRIPPED_DIR_I18N_${I18N}"
71+
export INSTALL_UNSTRIPPED_DIR_I18N=${!var}
72+
rm -rf $INSTALL_DIR_I18N
73+
rm -rf $INSTALL_UNSTRIPPED_DIR_I18N
6874
$ROOTDIR/scripts/compile/all.sh
6975
}
7076

7177
createAAR() {
72-
TARGET=$1
73-
printf "\n\n\t\t===================== create aar :$TARGET: =====================\n\n"
78+
local target=$1
79+
local distDir=$2
80+
local jniLibsDir=$3
81+
local i18n=$4
82+
printf "\n\n\t\t===================== create aar :${target}: =====================\n\n"
7483
cd $ROOTDIR/lib
75-
./gradlew clean :$TARGET:createAAR --project-prop revision="$REVISION" --project-prop i18n="${I18N}"
84+
./gradlew clean :${target}:createAAR \
85+
--project-prop distDir="${distDir}" \
86+
--project-prop jniLibsDir="${jniLibsDir}" \
87+
--project-prop revision="$REVISION" \
88+
--project-prop i18n="${i18n}"
7689
cd $ROOTDIR
77-
unset TARGET
7890
}
7991

8092
copyHeaders() {
81-
printf "\n\n\t\t===================== adding headers to $ROOTDIR/dist/include =====================\n\n"
82-
mkdir -p $ROOTDIR/dist/include
83-
cp -Rf $TARGETDIR/webkit/Source/JavaScriptCore/API/*.h $ROOTDIR/dist/include
93+
local distDir=$1
94+
printf "\n\n\t\t===================== adding headers to ${distDir}/include =====================\n\n"
95+
mkdir -p ${distDir}/include
96+
cp -Rf $TARGETDIR/webkit/Source/JavaScriptCore/API/*.h ${distDir}/include
8497
}
8598

8699
export I18N=false
87100
prep
88101
compile
89-
createAAR "android-jsc"
90102

91103
export I18N=true
92104
prep
93105
compile
94-
createAAR "android-jsc"
95-
96-
createAAR "cppruntime"
97106

98-
copyHeaders
107+
export DISTDIR=${ROOTDIR}/dist
108+
printf "\n\n\t\t===================== create stripped distributions =====================\n\n"
109+
createAAR "android-jsc" ${DISTDIR} ${INSTALL_DIR_I18N_false} "false"
110+
createAAR "android-jsc" ${DISTDIR} ${INSTALL_DIR_I18N_true} "true"
111+
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
112+
copyHeaders ${DISTDIR}
113+
114+
printf "\n\n\t\t===================== create unstripped distributions =====================\n\n"
115+
export DISTDIR=${ROOTDIR}/dist.unstripped
116+
createAAR "android-jsc" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_false} "false"
117+
createAAR "android-jsc" ${DISTDIR} ${INSTALL_UNSTRIPPED_DIR_I18N_true} "true"
118+
createAAR "cppruntime" ${DISTDIR} ${INSTALL_CPPRUNTIME_DIR} "false"
119+
copyHeaders ${DISTDIR}
99120

100121
npm run info
101122

0 commit comments

Comments
 (0)