@@ -22,7 +22,7 @@ allprojects {
22
22
def ndkDebuggable = false ;
23
23
def optimized = project. hasProperty(" optimized" )
24
24
25
- if (optimized) {
25
+ if (optimized) {
26
26
println " Optimized build triggered."
27
27
}
28
28
@@ -34,6 +34,7 @@ for (String runTask : runTasks) {
34
34
}
35
35
}
36
36
37
+
37
38
project. ext. sdkDir = System . getenv(" ANDROID_HOME" )
38
39
def ndkDir = System . getenv(" ANDROID_NDK_HOME" )
39
40
def propertiesFile = project. rootProject. file(' local.properties' )
@@ -45,71 +46,110 @@ if (propertiesFile.exists()) {
45
46
project. ext. ndkDir = ndkDir;
46
47
47
48
48
- class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
49
+ class StripSymbolsTaskExecutionListener implements TaskExecutionListener
50
+ {
49
51
@Override
50
- void beforeExecute (Task task ) {
52
+ void beforeExecute (Task task )
53
+ {
51
54
}
52
55
53
- String getMachineName () {
54
- if (OperatingSystem . current(). isWindows()) {
56
+ String getMachineName ()
57
+ {
58
+ if (OperatingSystem . current(). isWindows())
59
+ {
55
60
return " windows" ;
56
- } else if (OperatingSystem . current(). isMacOsX()) {
61
+ }
62
+ else if (OperatingSystem . current(). isMacOsX())
63
+ {
57
64
return " darwin" ;
58
- } else {
65
+ }
66
+ else
67
+ {
59
68
return " linux" ;
60
69
}
61
70
}
62
71
63
- String getStripToolName (String stripTaskName ) {
72
+ String getStripToolName (String stripTaskName )
73
+ {
64
74
stripTaskName = stripTaskName. toLowerCase();
65
75
def stripToolName = " "
66
- if (stripTaskName. contains(" arm64" )) {
76
+ if (stripTaskName. contains(" arm64" ))
77
+ {
67
78
stripToolName = " aarch64-linux-android-strip" ;
68
- } else if (stripTaskName. contains(" arm" )) {
79
+ }
80
+ else if (stripTaskName. contains(" arm" ))
81
+ {
69
82
stripToolName = " arm-linux-androideabi-strip" ;
70
- } else if (stripTaskName. contains(" mips64" )) {
83
+ }
84
+ else if (stripTaskName. contains(" mips64" ))
85
+ {
71
86
stripToolName = " mips64el-linux-android-strip" ;
72
- } else if (stripTaskName. contains(" mips" )) {
87
+ }
88
+ else if (stripTaskName. contains(" mips" ))
89
+ {
73
90
stripToolName = " mipsel-linux-android-strip" ;
74
- } else if (stripTaskName. contains(" x86_64" )) {
91
+ }
92
+ else if (stripTaskName. contains(" x86_64" ))
93
+ {
75
94
stripToolName = " x86_64-linux-android-strip" ;
76
- } else if (stripTaskName. contains(" x86" )) {
95
+ }
96
+ else if (stripTaskName. contains(" x86" ))
97
+ {
77
98
stripToolName = " i686-linux-android-strip" ;
78
- } else {
99
+ }
100
+ else
101
+ {
79
102
throw new IllegalArgumentException (" NOT SUPPORTED ARCHITECTURE NAME: ${ stripTaskName} " );
80
103
}
81
104
82
- if (OperatingSystem . current(). isWindows()) {
105
+ if (OperatingSystem . current(). isWindows())
106
+ {
83
107
stripToolName + = " .exe" ;
84
108
}
85
109
86
110
return stripToolName;
87
111
}
88
112
89
- String getStripToolDirectory (String stripTaskName ) {
113
+ String getStripToolDirectory (String stripTaskName )
114
+ {
90
115
stripTaskName = stripTaskName. toLowerCase();
91
116
def stripToolDirectory = " "
92
- if (stripTaskName. contains(" arm64" )) {
117
+ if (stripTaskName. contains(" arm64" ))
118
+ {
93
119
stripToolDirectory = " aarch64-linux-android-4.9" ;
94
- } else if (stripTaskName. contains(" arm" )) {
120
+ }
121
+ else if (stripTaskName. contains(" arm" ))
122
+ {
95
123
stripToolDirectory = " arm-linux-androideabi-4.9" ;
96
- } else if (stripTaskName. contains(" mips64" )) {
124
+ }
125
+ else if (stripTaskName. contains(" mips64" ))
126
+ {
97
127
stripToolDirectory = " mips64el-linux-android-4.9" ;
98
- } else if (stripTaskName. contains(" mips" )) {
128
+ }
129
+ else if (stripTaskName. contains(" mips" ))
130
+ {
99
131
stripToolDirectory = " mipsel-linux-android-4.9" ;
100
- } else if (stripTaskName. contains(" x86_64" )) {
132
+ }
133
+ else if (stripTaskName. contains(" x86_64" ))
134
+ {
101
135
stripToolDirectory = " x86_64-4.9" ;
102
- } else if (stripTaskName. contains(" x86" )) {
136
+ }
137
+ else if (stripTaskName. contains(" x86" ))
138
+ {
103
139
stripToolDirectory = " x86-4.9" ;
104
- } else {
140
+ }
141
+ else
142
+ {
105
143
throw new IllegalArgumentException (" NOT SUPPORTED ARCHITECTURE: ${ stripTaskName} " );
106
144
}
107
145
108
146
return stripToolDirectory;
109
147
}
110
148
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
+ {
113
153
println " Found STRIP COMMAND: ${ task.getName()} "
114
154
println " input file " + task. getInputs(). getFiles(). getAsPath();
115
155
println " output dir " + task. getOutputs(). getFiles(). getAsPath();
@@ -130,9 +170,12 @@ class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
130
170
println " Strip tool: ${ stripToolPath} "
131
171
132
172
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
+ {
136
179
command = " ${ stripToolPath} ${ libToStripPath} " ;
137
180
}
138
181
@@ -143,7 +186,8 @@ class StripSymbolsTaskExecutionListener implements TaskExecutionListener {
143
186
}
144
187
}
145
188
146
- if (! ndkDebuggable) {
189
+ if (! ndkDebuggable)
190
+ {
147
191
project. gradle. addListener(new StripSymbolsTaskExecutionListener ())
148
192
}
149
193
@@ -156,7 +200,7 @@ model {
156
200
buildToolsVersion = project. ext. _buildToolsVersion
157
201
158
202
defaultConfig. with {
159
- if (optimized) {
203
+ if (optimized) {
160
204
project. archivesBaseName = " ${ archivesBaseName} -optimized"
161
205
} else {
162
206
project. archivesBaseName = " ${ archivesBaseName} -regular"
@@ -186,35 +230,38 @@ model {
186
230
" -I${ file("src/main/jni/v8_inspector")} " . toString(),
187
231
// "-I${file("src/main/jni/v8_inspector/platform/inspector_protocol/")}".toString(),
188
232
// "-I${file("src/main/jni/v8_inspector/protocol/")}".toString(),
189
- ])
233
+ ])
190
234
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"
193
236
194
237
195
238
CFlags . addAll([" -Wno-error=format-security" , " -g" , " -fno-builtin-stpcpy" ])
196
239
197
240
ldLibs. addAll([" android" , " dl" , " log" , " atomic" , " z" ])
198
241
199
- if (optimized) {
242
+ if (optimized) {
200
243
ldFlags. addAll([" -Wl,--exclude-libs=ALL" , " -Wl,--gc-sections" ])
201
244
}
202
245
ldFlags. addAll([" -Wl,--allow-multiple-definition" ])
203
246
204
247
toolchain = " clang"
205
248
stl = " c++_static"
206
249
207
- abiFilters. addAll([" x86 " , " armeabi-v7a " ])
250
+ abiFilters. addAll([" armeabi-v7a " , " x86 " ])
208
251
209
- if (System . getProperties()[' idea.platform.prefix' ] != null ) {
252
+ if (System . getProperties()[' idea.platform.prefix' ] != null )
253
+ {
210
254
// Built from AndroidStudio
211
255
println " Build from AndroidStudio"
212
256
213
- if (! ndkDebuggable) {
257
+ if (! ndkDebuggable)
258
+ {
214
259
abiFilters. addAll([" x86" , " arm64-v8a" ])
215
260
216
261
}
217
- } else {
262
+ }
263
+ else
264
+ {
218
265
// Built from command line
219
266
abiFilters. addAll([" x86" , " arm64-v8a" ])
220
267
@@ -264,7 +311,8 @@ model {
264
311
265
312
tasks. whenTaskAdded { task ->
266
313
def taskName = task. getName()
267
- if (taskName == " androidRelease" ) {
314
+ if (taskName == " androidRelease" )
315
+ {
268
316
task. dependsOn(setRuntimeCommit)
269
317
task. mustRunAfter setRuntimeCommit
270
318
task. finalizedBy revertVersionFile
@@ -284,28 +332,24 @@ model {
284
332
create(" armeabi-v7a" ) {
285
333
abiFilters. add(" armeabi-v7a" )
286
334
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())
290
335
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_base.a")} " . toString())
291
336
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libplatform.a")} " . toString())
292
337
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libbase.a")} " . toString())
293
338
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_libsampler.a")} " . toString())
294
339
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libv8_nosnapshot.a")} " . toString())
340
+ ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libinspector.a")} " . toString())
295
341
ldLibs. add(" ${ file("src/main/libs/armeabi-v7a/libzip.a")} " . toString())
296
342
}
297
343
298
344
create(" x86" ) {
299
345
abiFilters. add(" x86" )
300
346
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())
304
347
ldLibs. add(" ${ file("src/main/libs/x86/libv8_base.a")} " . toString())
305
348
ldLibs. add(" ${ file("src/main/libs/x86/libv8_libplatform.a")} " . toString())
306
349
ldLibs. add(" ${ file("src/main/libs/x86/libv8_libbase.a")} " . toString())
307
- ldLibs. add(" ${ file("src/main/libs/x86/libv8_nosnapshot.a")} " . toString())
308
350
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())
309
353
ldLibs. add(" ${ file("src/main/libs/x86/libzip.a")} " . toString())
310
354
}
311
355
@@ -315,15 +359,12 @@ model {
315
359
ldFlags. addAll([
316
360
" -L${ file("src/main/libs/arm64-v8a")} " . toString(),
317
361
" -lv8_base" ,
318
- " -lv8_builtins_setup" ,
319
- " -lv8_builtins_generators" ,
320
- " -lv8_base" ,
321
362
" -lv8_libplatform" ,
322
363
" -lv8_libbase" ,
323
364
" -lv8_libsampler" ,
324
365
" -lv8_nosnapshot" ,
325
- " -lzip " ,
326
- " -v "
366
+ " -linspector " ,
367
+ " -lzip "
327
368
])
328
369
329
370
// The correct way of setting these flags is not working hence the workaround above
@@ -351,8 +392,7 @@ model {
351
392
staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_libbase.a" )
352
393
staticLibraryFile = file(" src/main/libs/${ targetPlatform.getName()} /libv8_libsampler.a" )
353
394
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" )
356
396
}
357
397
}
358
398
}
0 commit comments