@@ -22,7 +22,7 @@ allprojects {
2222def ndkDebuggable = false ;
2323def optimized = project. hasProperty(" optimized" )
2424
25- if (optimized) {
25+ if (optimized) {
2626 println " Optimized build triggered."
2727}
2828
@@ -34,6 +34,7 @@ for (String runTask : runTasks) {
3434 }
3535}
3636
37+
3738project. ext. sdkDir = System . getenv(" ANDROID_HOME" )
3839def ndkDir = System . getenv(" ANDROID_NDK_HOME" )
3940def propertiesFile = project. rootProject. file(' local.properties' )
@@ -45,71 +46,110 @@ if (propertiesFile.exists()) {
4546project. ext. ndkDir = ndkDir;
4647
4748
48- class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
49+ class StripSymbolsTaskExecutionListener implements TaskExecutionListener
50+ {
4951 @Override
50- void beforeExecute (Task task ) {
52+ void beforeExecute (Task task )
53+ {
5154 }
5255
53- String getMachineName () {
54- if (OperatingSystem . current(). isWindows()) {
56+ String getMachineName ()
57+ {
58+ if (OperatingSystem . current(). isWindows())
59+ {
5560 return " windows" ;
56- } else if (OperatingSystem . current(). isMacOsX()) {
61+ }
62+ else if (OperatingSystem . current(). isMacOsX())
63+ {
5764 return " darwin" ;
58- } else {
65+ }
66+ else
67+ {
5968 return " linux" ;
6069 }
6170 }
6271
63- String getStripToolName (String stripTaskName ) {
72+ String getStripToolName (String stripTaskName )
73+ {
6474 stripTaskName = stripTaskName. toLowerCase();
6575 def stripToolName = " "
66- if (stripTaskName. contains(" arm64" )) {
76+ if (stripTaskName. contains(" arm64" ))
77+ {
6778 stripToolName = " aarch64-linux-android-strip" ;
68- } else if (stripTaskName. contains(" arm" )) {
79+ }
80+ else if (stripTaskName. contains(" arm" ))
81+ {
6982 stripToolName = " arm-linux-androideabi-strip" ;
70- } else if (stripTaskName. contains(" mips64" )) {
83+ }
84+ else if (stripTaskName. contains(" mips64" ))
85+ {
7186 stripToolName = " mips64el-linux-android-strip" ;
72- } else if (stripTaskName. contains(" mips" )) {
87+ }
88+ else if (stripTaskName. contains(" mips" ))
89+ {
7390 stripToolName = " mipsel-linux-android-strip" ;
74- } else if (stripTaskName. contains(" x86_64" )) {
91+ }
92+ else if (stripTaskName. contains(" x86_64" ))
93+ {
7594 stripToolName = " x86_64-linux-android-strip" ;
76- } else if (stripTaskName. contains(" x86" )) {
95+ }
96+ else if (stripTaskName. contains(" x86" ))
97+ {
7798 stripToolName = " i686-linux-android-strip" ;
78- } else {
99+ }
100+ else
101+ {
79102 throw new IllegalArgumentException (" NOT SUPPORTED ARCHITECTURE NAME: ${ stripTaskName} " );
80103 }
81104
82- if (OperatingSystem . current(). isWindows()) {
105+ if (OperatingSystem . current(). isWindows())
106+ {
83107 stripToolName + = " .exe" ;
84108 }
85109
86110 return stripToolName;
87111 }
88112
89- String getStripToolDirectory (String stripTaskName ) {
113+ String getStripToolDirectory (String stripTaskName )
114+ {
90115 stripTaskName = stripTaskName. toLowerCase();
91116 def stripToolDirectory = " "
92- if (stripTaskName. contains(" arm64" )) {
117+ if (stripTaskName. contains(" arm64" ))
118+ {
93119 stripToolDirectory = " aarch64-linux-android-4.9" ;
94- } else if (stripTaskName. contains(" arm" )) {
120+ }
121+ else if (stripTaskName. contains(" arm" ))
122+ {
95123 stripToolDirectory = " arm-linux-androideabi-4.9" ;
96- } else if (stripTaskName. contains(" mips64" )) {
124+ }
125+ else if (stripTaskName. contains(" mips64" ))
126+ {
97127 stripToolDirectory = " mips64el-linux-android-4.9" ;
98- } else if (stripTaskName. contains(" mips" )) {
128+ }
129+ else if (stripTaskName. contains(" mips" ))
130+ {
99131 stripToolDirectory = " mipsel-linux-android-4.9" ;
100- } else if (stripTaskName. contains(" x86_64" )) {
132+ }
133+ else if (stripTaskName. contains(" x86_64" ))
134+ {
101135 stripToolDirectory = " x86_64-4.9" ;
102- } else if (stripTaskName. contains(" x86" )) {
136+ }
137+ else if (stripTaskName. contains(" x86" ))
138+ {
103139 stripToolDirectory = " x86-4.9" ;
104- } else {
140+ }
141+ else
142+ {
105143 throw new IllegalArgumentException (" NOT SUPPORTED ARCHITECTURE: ${ stripTaskName} " );
106144 }
107145
108146 return stripToolDirectory;
109147 }
110148
111- void afterExecute (Task task , TaskState taskState ) {
112- if (task. getName(). contains(" stripSymbols" ) && ! taskState. failure) {
149+ void afterExecute (Task task , TaskState taskState )
150+ {
151+ if (task. getName(). contains(" stripSymbols" ) && ! taskState. failure)
152+ {
113153 println " Found STRIP COMMAND: ${ task.getName()} "
114154 println " input file " + task. getInputs(). getFiles(). getAsPath();
115155 println " output dir " + task. getOutputs(). getFiles(). getAsPath();
@@ -130,9 +170,12 @@ class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
130170 println " Strip tool: ${ stripToolPath} "
131171
132172 def command = " " ;
133- if (OperatingSystem . current(). isWindows()) {
134- command = " cmd /c ${ stripToolPath} ${ libToStripPath} " ;
135- } else {
173+ if (OperatingSystem . current(). isWindows())
174+ {
175+ command = " cmd /c ${ stripToolPath} ${ libToStripPath} " ;
176+ }
177+ else
178+ {
136179 command = " ${ stripToolPath} ${ libToStripPath} " ;
137180 }
138181
@@ -143,7 +186,8 @@ class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
143186 }
144187}
145188
146- if (! ndkDebuggable) {
189+ if (! ndkDebuggable)
190+ {
147191 project. gradle. addListener(new StripSymbolsTaskExecutionListener ())
148192}
149193
@@ -156,7 +200,7 @@ model {
156200 buildToolsVersion = project. ext. _buildToolsVersion
157201
158202 defaultConfig. with {
159- if (optimized) {
203+ if (optimized) {
160204 project. archivesBaseName = " ${ archivesBaseName} -optimized"
161205 } else {
162206 project. archivesBaseName = " ${ archivesBaseName} -regular"
@@ -186,35 +230,38 @@ model {
186230 " -I${ file("src/main/jni/v8_inspector")} " . toString(),
187231 // "-I${file("src/main/jni/v8_inspector/platform/inspector_protocol/")}".toString(),
188232 // "-I${file("src/main/jni/v8_inspector/protocol/")}".toString(),
189- ])
233+ ])
190234
191- cppFlags. addAll([" -std=c++11" , " -fexceptions" , " -fno-builtin-stpcpy" , " -D__ANDROID__" ])
192- // , "-DV8_INSPECTOR_USE_STL=1", "-D__GXX_EXPERIMENTAL_CXX0X__=1", "-DHAVE_INSPECTOR"
235+ cppFlags. addAll([" -std=c++11" , " -fexceptions" , " -fno-builtin-stpcpy" , " -DHAVE_INSPECTOR" , " -D__ANDROID__" ]) // , "-DV8_INSPECTOR_USE_STL=1", "-D__GXX_EXPERIMENTAL_CXX0X__=1"
193236
194237
195238 CFlags . addAll([" -Wno-error=format-security" , " -g" , " -fno-builtin-stpcpy" ])
196239
197240 ldLibs. addAll([" android" , " dl" , " log" , " atomic" , " z" ])
198241
199- if (optimized) {
242+ if (optimized) {
200243 ldFlags. addAll([" -Wl,--exclude-libs=ALL" , " -Wl,--gc-sections" ])
201244 }
202245 ldFlags. addAll([" -Wl,--allow-multiple-definition" ])
203246
204247 toolchain = " clang"
205248 stl = " c++_static"
206249
207- abiFilters. addAll([" x86 " , " armeabi-v7a " ])
250+ abiFilters. addAll([" armeabi-v7a " , " x86 " ])
208251
209- if (System . getProperties()[' idea.platform.prefix' ] != null ) {
252+ if (System . getProperties()[' idea.platform.prefix' ] != null )
253+ {
210254 // Built from AndroidStudio
211255 println " Build from AndroidStudio"
212256
213- if (! ndkDebuggable) {
257+ if (! ndkDebuggable)
258+ {
214259 abiFilters. addAll([" x86" , " arm64-v8a" ])
215260
216261 }
217- } else {
262+ }
263+ else
264+ {
218265 // Built from command line
219266 abiFilters. addAll([" x86" , " arm64-v8a" ])
220267
@@ -264,7 +311,8 @@ model {
264311
265312 tasks. whenTaskAdded { task ->
266313 def taskName = task. getName()
267- if (taskName == " androidRelease" ) {
314+ if (taskName == " androidRelease" )
315+ {
268316 task. dependsOn(setRuntimeCommit)
269317 task. mustRunAfter setRuntimeCommit
270318 task. finalizedBy revertVersionFile
@@ -284,28 +332,24 @@ model {
284332 create(" armeabi-v7a" ) {
285333 abiFilters. add(" armeabi-v7a" )
286334
287- ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_base.a")} " . toString())
288- ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_builtins_setup.a")} " . toString())
289- ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_builtins_generators.a")} " . toString())
290335 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_base.a")} " . toString())
291336 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libplatform.a")} " . toString())
292337 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libbase.a")} " . toString())
293338 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libsampler.a")} " . toString())
294339 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_nosnapshot.a")} " . toString())
340+ ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libinspector.a")} " . toString())
295341 ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libzip.a")} " . toString())
296342 }
297343
298344 create(" x86" ) {
299345 abiFilters. add(" x86" )
300346
301- ldLibs. add(" ${ file("src/main/libs/x86/libv8_base.a")} " . toString())
302- ldLibs. add(" ${ file("src/main/libs/x86/libv8_builtins_setup.a")} " . toString())
303- ldLibs. add(" ${ file("src/main/libs/x86/libv8_builtins_generators.a")} " . toString())
304347 ldLibs. add(" ${ file("src/main/libs/x86/libv8_base.a")} " . toString())
305348 ldLibs. add(" ${ file("src/main/libs/x86/libv8_libplatform.a")} " . toString())
306349 ldLibs. add(" ${ file("src/main/libs/x86/libv8_libbase.a")} " . toString())
307- ldLibs. add(" ${ file("src/main/libs/x86/libv8_nosnapshot.a")} " . toString())
308350 ldLibs. add(" ${ file("src/main/libs/x86/libv8_libsampler.a")} " . toString())
351+ ldLibs. add(" ${ file("src/main/libs/x86/libv8_nosnapshot.a")} " . toString())
352+ ldLibs. add(" ${ file("src/main/libs/x86/libinspector.a")} " . toString())
309353 ldLibs. add(" ${ file("src/main/libs/x86/libzip.a")} " . toString())
310354 }
311355
@@ -315,15 +359,12 @@ model {
315359 ldFlags. addAll([
316360 " -L${ file("src/main/libs/arm64-v8a")} " . toString(),
317361 " -lv8_base" ,
318- " -lv8_builtins_setup" ,
319- " -lv8_builtins_generators" ,
320- " -lv8_base" ,
321362 " -lv8_libplatform" ,
322363 " -lv8_libbase" ,
323364 " -lv8_libsampler" ,
324365 " -lv8_nosnapshot" ,
325- " -lzip " ,
326- " -v "
366+ " -linspector " ,
367+ " -lzip "
327368 ])
328369
329370 // The correct way of setting these flags is not working hence the workaround above
@@ -351,8 +392,7 @@ model {
351392 staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_libbase.a" )
352393 staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_libsampler.a" )
353394 staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_nosnapshot.a" )
354- staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_builtins_setup.a" )
355- staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_builtins_generators.a" )
395+ staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libzip.a" )
356396 }
357397 }
358398 }
0 commit comments