1
- #! /usr/ bin/env bash
1
+ #! /bin/sh
2
2
set -euo pipefail
3
+ shopt -s failglob
3
4
4
5
THIS_FILE=$( readlink -f " $0 " )
5
6
BASEDIR=$( dirname " $THIS_FILE " )
@@ -9,8 +10,9 @@ LIB=$BASEDIR/lib-android
9
10
THIRD_PARTY_DIR=$BASEDIR /3rdparty
10
11
THIRD_PARTY_DIR_SLASH_ESCAPED=" ${THIRD_PARTY_DIR// \/ / \\\/ } \/"
11
12
12
- # Based on Android app generate a project for library
13
- if [ ! -d " $LIB " ]; then
13
+ # Generate library gradle project based on Android app
14
+ if ! test -d " $LIB "
15
+ then
14
16
echo " Preparing $LIB "
15
17
16
18
# Copy necessary files from android app to android lib
52
54
# Build 3rdparty libraries
53
55
cd $LIB
54
56
./gradlew assemble
55
- for build_type in $THIRD_PARTY_DIR /built/cmake/* ; do
56
- for build_type_and_abi in $build_type /* ; do
57
- echo " Building LIB: $build_type_and_abi "
58
- cmake --build $build_type_and_abi
57
+
58
+ function wait_on_children_processes() {
59
+ for pid in $pids
60
+ do
61
+ if ! wait $pid
62
+ then
63
+ echo " Build failed. Waiting for other subprocesses..."
64
+ wait
65
+ exit 1
66
+ fi
59
67
done
68
+ }
69
+
70
+ pids=
71
+ for build_target in $THIRD_PARTY_DIR /built/cmake/* /*
72
+ do
73
+ cmake --build $build_target &
74
+ pids=" $pids $! "
60
75
done
76
+ wait_on_children_processes $pids
61
77
62
78
# Build pdf2htmlEX
63
79
cd $APP
64
80
./gradlew assemble
65
- for build_type in $APP /app/.externalNativeBuild/cmake/* ; do
66
- build_type_string=$( basename ${build_type} )
67
- for build_type_and_abi in $build_type /* ; do
68
- abi_string=$( basename ${build_type_and_abi} )
69
- cmake --build $build_type_and_abi --target install
70
-
71
- if [ ! -d " $build_type_and_abi /built/sample_pdfs" ]; then
72
- mkdir $build_type_and_abi /built/sample_pdfs
73
- fi
74
- cp -v $BASEDIR /test/browser_tests/* .pdf $build_type_and_abi /built/sample_pdfs/
75
- done
76
- done
77
-
78
- echo " "
79
- echo " "
80
81
81
- # Pack pdf2htmlEX binaries with UPX
82
- for build_type in $APP /app/.externalNativeBuild/cmake/* ; do
83
- build_type_string=$( basename ${build_type} )
84
- for build_type_and_abi in $build_type /* ; do
85
- abi_string=$( basename ${build_type_and_abi} )
82
+ pids=
83
+ for build_target in $APP /app/.externalNativeBuild/cmake/* /*
84
+ do
85
+ (
86
+ set -euo pipefail
87
+ cmake --build $build_target --target install
86
88
87
- FINAL_BINARY=$build_type_and_abi /built/bin/pdf2htmlEX
89
+ abi=$( basename $build_target )
90
+ build_type=$( basename ${build_target% $abi } )
88
91
89
92
# UPX only works on armeabi-v7a
90
93
# Other ABIs produce segfaults.
91
- if [ " $abi_string " == " armeabi-v7a" ] ; then
92
- upx --ultra-brute --8mib-ram $FINAL_BINARY
93
- upx -t $FINAL_BINARY
94
+ if test $abi = " armeabi-v7a"
95
+ then
96
+ upx --ultra-brute --8mib-ram $build_target /built/bin/pdf2htmlEX
94
97
fi
95
98
96
- FINAL_TAR=$build_type_and_abi /${build_type_string} -${abi_string} -pdf2htmlEX.tar
97
- if [ -f " ${FINAL_TAR} " ]; then
98
- echo " $FINAL_TAR is ready!"
99
- fi
99
+ # Compress binaries and other files into .tar's
100
+ mkdir --parents $build_target /built/sample_pdfs
101
+ cp $BASEDIR /test/browser_tests/* .pdf $build_target /built/sample_pdfs/
100
102
101
- ls -lha $build_type_and_abi /built/bin/pdf2htmlEX
102
- done
103
+ tar --create --file $build_target /$build_type -$abi -pdf2htmlEX.tar --directory $build_target built
104
+ ) &
105
+ pids=" $pids $! "
103
106
done
107
+ wait_on_children_processes $pids
104
108
105
- echo " "
106
- echo " "
107
-
108
- # Compress binaries and other files into .tar's
109
- for build_type in $APP /app/.externalNativeBuild/cmake/* ; do
110
- build_type_string=$( basename ${build_type} )
111
- for build_type_and_abi in $build_type /* ; do
112
- abi_string=$( basename ${build_type_and_abi} )
113
-
114
- FINAL_TAR=$build_type_and_abi /${build_type_string} -${abi_string} -pdf2htmlEX.tar
115
- tar -cf $FINAL_TAR --directory $build_type_and_abi built
116
- tar --list -f $FINAL_TAR
117
- echo " $FINAL_TAR is ready!"
118
- done
109
+ for ft in $APP /app/.externalNativeBuild/cmake/* /* /* -pdf2htmlEX.tar
110
+ do
111
+ echo " $ft is ready!"
119
112
done
113
+
0 commit comments