Skip to content

Commit 388ed79

Browse files
committed
Toolchain and icu compilation scripts
1 parent 5aaa1ac commit 388ed79

File tree

6 files changed

+185
-0
lines changed

6 files changed

+185
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. ./fetch_sources.sh
2+
2. ./icu-prep.sh
3+
3. JSC_ARCH=arm ./toolchain.sh
4+
4. JSC_ARCH=arm ./icu.sh

common.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
ROOTDIR=`pwd`
4+
ARCH=$JSC_ARCH
5+
6+
ANDROID_API=21
7+
8+
# platform specific settings
9+
10+
CROSS_COMPILE_PLATFORM_arm="arm-linux-androideabi"
11+
CROSS_COMPILE_PLATFORM_arm64="aarch64-linux-android"
12+
CROSS_COMPILE_PLATFORM_x86="i686-linux-android"
13+
CROSS_COMPILE_PLATFORM_x86_64="x86_64-linux-android"
14+
15+
# arch
16+
var="CROSS_COMPILE_PLATFORM_$JSC_ARCH"
17+
CROSS_COMPILE_PLATFORM=${!var}
18+
TOOLCHAIN_DIR=$ROOTDIR/target/toolchains/$CROSS_COMPILE_PLATFORM
19+
20+
# settings
21+
PLATFORM_CFLAGS_arm=" \
22+
-march=armv7-a \
23+
-mfloat-abi=softfp \
24+
-mfpu=neon \
25+
-mthumb \
26+
"
27+
28+
PLATFORM_LDFLAGS_arm=" \
29+
-L$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib/armv7-a \
30+
-march=armv7-a \
31+
-Wl,--fix-cortex-a8 \
32+
"
33+
34+
PLATFORM_LDFLAGS_arm64=" \
35+
-L$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib \
36+
"
37+
38+
PLATFORM_LDFLAGS_x86=" \
39+
-L$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib \
40+
"
41+
42+
PLATFORM_LDFLAGS_x86_64=" \
43+
-L$TOOLCHAIN_DIR/$CROSS_COMPILE_PLATFORM/lib \
44+
"
45+
46+
# arch
47+
var="PLATFORM_CFLAGS_$JSC_ARCH"
48+
PLATFORM_CFLAGS=${!var}
49+
var="PLATFORM_LDFLAGS_$JSC_ARCH"
50+
PLATFORM_LDFLAGS=${!var}
51+
52+
# checks
53+
err=false
54+
if ! [[ $CROSS_COMPILE_PLATFORM ]]; then echo "set JSC_ARCH to one of {arm,arm64,x86,x86_64}"; err=true; fi
55+
if ! [[ $ANDROID_HOME ]]; then echo "set ANDROID_HOME to android sdk dir"; err=true; fi
56+
if ! [[ $ANDROID_NDK ]]; then echo "set ANDROID_NDK to android ndk dir"; err=true; fi
57+
58+
if [[ $err = true ]]; then exit 1; fi
59+
60+
####
61+
62+
COMMON_LDFLAGS=" \
63+
-fuse-ld=gold \
64+
-Wl,--icf=safe \
65+
-Wl,-z,noexecstack \
66+
-s \
67+
"
68+
69+
COMMON_CFLAGS=" \
70+
-fstack-protector \
71+
-ffunction-sections \
72+
-fomit-frame-pointer \
73+
-fno-strict-aliasing \
74+
-fno-exceptions \
75+
-funwind-tables \
76+
-DPIC \
77+
-fPIC \
78+
-fvisibility=hidden \
79+
-DNDEBUG \
80+
"
81+
82+
COMMON_CXXFLAGS=" \
83+
--std=c++11 \
84+
"
85+
86+
ICU_CFLAGS="$COMMON_CFLAGS $PLATFORM_CFLAGS"
87+
ICU_CXXFLAGS="$COMMON_CXXFLAGS $ICU_CFLAGS"
88+
ICU_LDFLAGS="$COMMON_LDFLAGS $PLATFORM_LDFLAGS"
89+

icu-prep.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
ROOTDIR=`pwd`
4+
5+
patch -p0 < $ROOTDIR/patches/icu.patch
6+
7+
rm -rf $ROOTDIR/target/icu/host
8+
mkdir -p $ROOTDIR/target/icu/host
9+
cd $ROOTDIR/target/icu/host
10+
11+
../source/runConfigureICU Linux --prefix=$PWD/prebuilts \
12+
CFLAGS="-Os" \
13+
CXXFLAGS="--std=c++11"
14+
# maybe speedup compilation somehow
15+
make -j5

icu.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
source './common.sh'
4+
5+
rm -rf $ROOTDIR/target/icu/$CROSS_COMPILE_PLATFORM
6+
mkdir -p $ROOTDIR/target/icu/$CROSS_COMPILE_PLATFORM
7+
cd $ROOTDIR/target/icu/$CROSS_COMPILE_PLATFORM
8+
9+
CROSS_BUILD_DIR=$(realpath ../host)
10+
PATH=$TOOLCHAIN_DIR/bin:$PATH
11+
12+
../source/configure --prefix=$(pwd)/prebuilt \
13+
--host=$CROSS_COMPILE_PLATFORM \
14+
--enable-shared=yes \
15+
--enable-extras=no \
16+
--enable-strict=no \
17+
--enable-icuio=no \
18+
--enable-layout=no \
19+
--enable-layoutex=no \
20+
--enable-tools=no \
21+
--enable-tests=no \
22+
--enable-samples=no \
23+
--enable-dyload=no \
24+
-with-cross-build=$CROSS_BUILD_DIR \
25+
CFLAGS="$ICU_CFLAGS" \
26+
CXXFLAGS="$ICU_CXXFLAGS" \
27+
LDFLAGS="$ICU_LDFLAGS" \
28+
CC=$CROSS_COMPILE_PLATFORM-clang \
29+
CXX=$CROSS_COMPILE_PLATFORM-clang++ \
30+
AR=$CROSS_COMPILE_PLATFORM-ar \
31+
RINLIB=$CROSS_COMPILE_PLATFORM-ranlib \
32+
--with-data-packaging=archive
33+
34+
make -j5
35+
36+
cp stubdata/lib* lib/

patches/icu.patch

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --exclude=.svn -aur icu/source/config/Makefile.inc.in target/icu/source/config/Makefile.inc.in
2+
--- icu/source/config/Makefile.inc.in 2017-05-22 07:24:35.000000000 +0200
3+
+++ target/icu/source/config/Makefile.inc.in 2017-05-16 16:03:46.000000000 +0200
4+
@@ -143,7 +143,7 @@
5+
6+
# Versioned target for a shared library
7+
FINAL_SO_TARGET = $(SO_TARGET).$(SO_TARGET_VERSION)
8+
-MIDDLE_SO_TARGET = $(SO_TARGET).$(SO_TARGET_VERSION_MAJOR)
9+
+MIDDLE_SO_TARGET = $(SO_TARGET)
10+
11+
# Access to important ICU tools.
12+
# Use as follows: $(INVOKE) $(GENRB) arguments ..
13+
diff --exclude=.svn -aur icu/source/config/mh-linux target/icu/source/config/mh-linux
14+
--- icu/source/config/mh-linux 2017-05-22 07:24:35.000000000 +0200
15+
+++ target/icu/source/config/mh-linux 2017-05-19 16:16:50.000000000 +0200
16+
@@ -25,9 +25,12 @@
17+
18+
## Compiler switch to embed a library name
19+
# The initial tab in the next line is to prevent icu-config from reading it.
20+
- LD_SONAME = -Wl,-soname -Wl,$(notdir $(MIDDLE_SO_TARGET))
21+
+ LD_SONAME = -Wl,-soname -Wl,$(notdir $(SO_TARGET))
22+
+ COMMON_STUBNAME = uc_jsc
23+
+ I18N_STUBNAME = i18n_jsc
24+
+ DATA_STUBNAME = data_jsc
25+
#SH# # We can't depend on MIDDLE_SO_TARGET being set.
26+
-#SH# LD_SONAME=
27+
+#SH# LD_SONAME=${SO_TARGET}
28+
29+
## Shared library options
30+
LD_SOOPTIONS= -Wl,-Bsymbolic

toolchain.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
source './common.sh'
4+
5+
rm -rf $TOOLCHAIN_DIR
6+
7+
$ANDROID_NDK/build/tools/make_standalone_toolchain.py \
8+
--api $ANDROID_API \
9+
--install-dir $TOOLCHAIN_DIR \
10+
--arch $ARCH \
11+
--stl libc++

0 commit comments

Comments
 (0)