1
|
|
2
|
|
3
|
import sys
|
4
|
import os
|
5
|
import os.path as op
|
6
|
import getopt
|
7
|
import re
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
psrc_product_out = ''
|
28
|
psrc_qssi_out = ''
|
29
|
|
30
|
|
31
|
|
32
|
|
33
|
|
34
|
|
35
|
|
36
|
def rreplace(strings, old, new):
|
37
|
position = strings.rfind(old)
|
38
|
return (strings[:position] + strings[position:].replace(old, new))
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44
|
def copyBinSrc(dstdir, module_type, module_name):
|
45
|
|
46
|
if not op.isdir(dstdir):
|
47
|
os.system('mkdir -p %s'%(dstdir))
|
48
|
|
49
|
if module_type == 'EXECUTABLES':
|
50
|
product_path = '%s/system/bin '%(psrc_product_out) + '%s/vendor/bin '%(psrc_product_out) +\
|
51
|
'%s/product/bin '%(psrc_product_out) + '%s/system/product/bin '%(psrc_product_out)
|
52
|
qssi_path = '%s/system/bin '%(psrc_qssi_out) + '%s/vendor/bin '%(psrc_qssi_out) +\
|
53
|
'%s/product/bin '%(psrc_qssi_out) + '%s/system/product/bin '%(psrc_qssi_out) + '%s/system/system_ext/bin '%(psrc_qssi_out)
|
54
|
os.system('find %s -name %s -execdir cp %s %s \\;'%(product_path,module_name,module_name,dstdir))
|
55
|
if not op.isfile(dstdir + '/' + module_name):
|
56
|
os.system('find %s -name %s -execdir cp %s %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
57
|
if not op.isfile(dstdir + '/' + module_name):
|
58
|
return False
|
59
|
return True
|
60
|
|
61
|
|
62
|
elif module_type == 'SHARED_LIBRARIES_32':
|
63
|
product_path = '%s/obj_arm/SHARED_LIBRARIES '%(psrc_product_out) +\
|
64
|
'%s/system/lib '%(psrc_product_out) + '%s/vendor/lib '%(psrc_product_out) +\
|
65
|
'%s/product/lib '%(psrc_product_out) + '%s/system/product/lib '%(psrc_product_out)
|
66
|
qssi_path = '%s/obj_arm/SHARED_LIBRARIES '%(psrc_qssi_out) +\
|
67
|
'%s/system/lib '%(psrc_qssi_out) + '%s/vendor/lib '%(psrc_qssi_out) +\
|
68
|
'%s/product/lib '%(psrc_qssi_out) + '%s/system/product/lib '%(psrc_qssi_out)
|
69
|
os.system('find %s -name %s.so -execdir cp %s.so %s \\;'%(product_path,module_name,module_name,dstdir))
|
70
|
if not op.isfile(dstdir + '/' + module_name + r'.so'):
|
71
|
os.system('find %s -name %s.so -execdir cp %s.so %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
72
|
if not op.isfile(dstdir + '/' + module_name + r'.so'):
|
73
|
return False
|
74
|
return True
|
75
|
|
76
|
elif module_type == 'SHARED_LIBRARIES_64':
|
77
|
product_path = '%s/obj/SHARED_LIBRARIES '%(psrc_product_out) +\
|
78
|
'%s/system/lib64 '%(psrc_product_out) + '%s/vendor/lib64 '%(psrc_product_out) +\
|
79
|
'%s/product/lib64 '%(psrc_product_out) + '%s/system/product/lib64 '%(psrc_product_out)
|
80
|
qssi_path = '%s/obj/SHARED_LIBRARIES '%(psrc_qssi_out) +\
|
81
|
'%s/system/lib64 '%(psrc_qssi_out) + '%s/vendor/lib64 '%(psrc_qssi_out) +\
|
82
|
'%s/product/lib64 '%(psrc_qssi_out) + '%s/system/product/lib64 '%(psrc_qssi_out)
|
83
|
os.system('find %s -name %s.so -execdir cp %s.so %s \\;'%(product_path,module_name,module_name,dstdir))
|
84
|
if not op.isfile(dstdir + '/' + module_name + r'.so'):
|
85
|
os.system('find %s -name %s.so -execdir cp %s.so %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
86
|
if not op.isfile(dstdir + '/' + module_name + r'.so'):
|
87
|
return False
|
88
|
return True
|
89
|
|
90
|
elif module_type == 'STATIC_LIBRARIES_32':
|
91
|
product_path = '%s/obj_arm/STATIC_LIBRARIES/%s_intermediates/%s.a '%(psrc_product_out,module_name,module_name)
|
92
|
qssi_path = '%s/obj_arm/STATIC_LIBRARIES/%s_intermediates/%s.a '%(psrc_qssi_out,module_name,module_name)
|
93
|
os.system('find %s -name %s.a -execdir cp %s.a %s \\;'%(product_path,module_name,module_name,dstdir))
|
94
|
if not op.isfile(dstdir + '/' + module_name + r'.a'):
|
95
|
os.system('find %s -name %s.a -execdir cp %s.a %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
96
|
if not op.isfile(dstdir + '/' + module_name + r'.a'):
|
97
|
return False
|
98
|
return True
|
99
|
|
100
|
elif module_type == 'STATIC_LIBRARIES_64':
|
101
|
product_path = '%s/obj/STATIC_LIBRARIES/%s_intermediates/%s.a '%(psrc_product_out,module_name,module_name) +\
|
102
|
'%s/obj/STATIC_LIBRARIES/%s_intermediates/%s.a '%(psrc_product_out,module_name,module_name)
|
103
|
qssi_path = '%s/obj/STATIC_LIBRARIES/%s.cfi_intermediates/%s.a '%(psrc_qssi_out,module_name,module_name)
|
104
|
os.system('find %s -name %s.a -execdir cp %s.a %s \\;'%(product_path,module_name,module_name,dstdir))
|
105
|
if not op.isfile(dstdir + '/' + module_name + r'.a'):
|
106
|
os.system('find %s -name %s.a -execdir cp %s.a %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
107
|
if not op.isfile(dstdir + '/' + module_name + r'.a'):
|
108
|
os.system('find %s -name %s.cfi.a -execdir cp %s.cfi.a %s \\;'%(product_path,module_name,module_name,dstdir))
|
109
|
if not op.isfile(dstdir + '/' + module_name + r'.cfi.a'):
|
110
|
return False
|
111
|
return True
|
112
|
|
113
|
elif module_type == 'JAVA_LIBRARIES':
|
114
|
product_path = '%s/obj/JAVA_LIBRARIES/%s_intermediates/javalib.jar '%(psrc_product_out,module_name) +\
|
115
|
'%s/obj/PACKAGING/target_files_intermediates '%(psrc_product_out)
|
116
|
qssi_path = '%s/obj/JAVA_LIBRARIES/%s_intermediates/javalib.jar '%(psrc_qssi_out,module_name) +\
|
117
|
'%s/obj/PACKAGING/target_files_intermediates '%(psrc_qssi_out)
|
118
|
os.system('find %s -name %s.jar -execdir cp %s.jar %s \\;'%(product_path,module_name,module_name,dstdir))
|
119
|
os.system('find %s -name javalib.jar -execdir cp javalib.jar %s \\;'%(product_path,dstdir))
|
120
|
if not op.isfile(dstdir + r'/javalib.jar') and not op.isfile(dstdir + r'/' + module_name + r'.jar'):
|
121
|
os.system('find %s -name %s.jar -execdir cp %s.jar %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
122
|
os.system('find %s -name javalib.jar -execdir cp javalib.jar %s \\;'%(qssi_path,dstdir))
|
123
|
if not op.isfile(dstdir + '/javalib.jar') and not op.isfile(dstdir + r'/' + module_name + r'.jar'):
|
124
|
return False
|
125
|
os.system('mv %s/javalib.jar %s/%s.jar'%(dstdir,dstdir,module_name))
|
126
|
return True
|
127
|
|
128
|
elif module_type == 'APPS':
|
129
|
product_path = '%s/obj/APPS/%s_intermediates/package.apk '%(psrc_product_out,module_name) +\
|
130
|
'%s/obj/PACKAGING/target_files_intermediates '%(psrc_product_out)
|
131
|
qssi_path = '%s/obj/APPS/%s_intermediates/package.apk '%(psrc_qssi_out,module_name) +\
|
132
|
'%s/obj/PACKAGING/target_files_intermediates '%(psrc_qssi_out)
|
133
|
os.system('find %s -name %s.apk -execdir cp %s.apk %s \\;'%(product_path,module_name,module_name,dstdir))
|
134
|
os.system('find %s -name package.apk -execdir cp package.apk %s \\;'%(product_path,dstdir))
|
135
|
if not op.isfile(dstdir + r'/package.apk') and not op.isfile(dstdir + r'/' + module_name + r'.apk'):
|
136
|
os.system('find %s -name %s.apk -execdir cp %s.apk %s \\;'%(qssi_path,module_name,module_name,dstdir))
|
137
|
os.system('find %s -name package.apk -execdir cp package.apk %s \\;'%(qssi_path,dstdir))
|
138
|
if not op.isfile(dstdir + '/package.apk') and not op.isfile(dstdir + r'/' + module_name + r'.apk'):
|
139
|
return False
|
140
|
os.system('mv %s/package.apk %s/%s.apk'%(dstdir,dstdir,module_name))
|
141
|
return True
|
142
|
|
143
|
|
144
|
return False
|
145
|
|
146
|
|
147
|
|
148
|
|
149
|
|
150
|
|
151
|
def writeMakefile(VARS, makefile, module_type, copy_status):
|
152
|
|
153
|
makefile.write('LOCAL_MODULE_OWNER := ' + VARS['LOCAL_MODULE_OWNER'] + '\n')
|
154
|
makefile.write('LOCAL_MODULE_TAGS := ' + VARS['LOCAL_MODULE_TAGS'] + '\n')
|
155
|
makefile.write('LOCAL_MODULE_CLASS := ' + VARS['LOCAL_MODULE_CLASS'] + '\n')
|
156
|
|
157
|
|
158
|
if module_type != 'STATIC_LIBRARIES' and module_type != 'JAVA_LIBRARIES':
|
159
|
makefile.write('LOCAL_MODULE_PATH := ' + VARS['LOCAL_MODULE_PATH'] + '\n')
|
160
|
|
161
|
if module_type != 'EXECUTABLES' and VARS['LOCAL_MODULE_SUFFIX']:
|
162
|
makefile.write('LOCAL_MODULE_SUFFIX := ' + VARS['LOCAL_MODULE_SUFFIX'] + '\n')
|
163
|
|
164
|
|
165
|
makefile.write('LOCAL_SRC_FILES := ' + VARS['LOCAL_SRC_FILES'] + '\n')
|
166
|
|
167
|
if module_type == 'APPS':
|
168
|
makefile.write('LOCAL_MODULE := ' + VARS['LOCAL_MODULE'] + '\n')
|
169
|
|
170
|
if module_type == 'SHARED_LIBRARIES' or module_type == 'STATIC_LIBRARIES':
|
171
|
makefile.write('LOCAL_MULTILIB := ' + VARS['LOCAL_MULTILIB'] + '\n')
|
172
|
if module_type == 'SHARED_LIBRARIES':
|
173
|
makefile.write('LOCAL_STRIP_MODULE := ' + VARS['LOCAL_STRIP_MODULE'] + '\n')
|
174
|
if copy_status == 2 or copy_status == 3:
|
175
|
makefile.write('include $(BUILD_PREBUILT)\n\n')
|
176
|
VARS['LOCAL_MULTILIB'] = r'32'
|
177
|
VARS['LOCAL_SRC_FILES'] = rreplace(VARS['LOCAL_SRC_FILES'], VARS['LOCAL_MODULE'] + r'64', VARS['LOCAL_MODULE'] + r'32')
|
178
|
if module_type == 'SHARED_LIBRARIES':
|
179
|
VARS['LOCAL_MODULE_PATH'] = rreplace(VARS['LOCAL_MODULE_PATH'], r'/lib64', r'/lib')
|
180
|
else:
|
181
|
VARS['LOCAL_MODULE_PATH'] = ''
|
182
|
if copy_status == 1 or copy_status == 3:
|
183
|
makefile.write('# do not include $(CLEAR_VARS)\n')
|
184
|
for k,v in VARS.items():
|
185
|
if v:
|
186
|
makefile.write(k+' := '+v+'\n')
|
187
|
if copy_status == 4 or copy_status == 3 or copy_status == 1:
|
188
|
if module_type == 'HEADER_LIBRARY':
|
189
|
makefile.write('include $(BUILD_HEADER_LIBRARY)\n\n')
|
190
|
elif module_type == 'COPY_HEADERS':
|
191
|
makefile.write('include $(BUILD_COPY_HEADERS)\n\n')
|
192
|
elif module_type == 'HOST_PREBUILT':
|
193
|
makefile.write('include $(BUILD_HOST_PREBUILT)\n\n')
|
194
|
elif module_type == 'MULTI_PREBUILT':
|
195
|
makefile.write('include $(BUILD_MULTI_PREBUILT)\n\n')
|
196
|
elif module_type == 'PHONY_PACKAGE':
|
197
|
makefile.write('include $(BUILD_PHONY_PACKAGE)\n\n')
|
198
|
else:
|
199
|
makefile.write('include $(BUILD_PREBUILT)\n\n')
|
200
|
elif copy_status == 0:
|
201
|
makefile.write('# do not include $(CLEAR_VARS)\n')
|
202
|
for k in VARS:
|
203
|
VARS[k] = ''
|
204
|
VARS['LOCAL_MODULE_OWNER'] = r'qcom'
|
205
|
VARS['LOCAL_MODULE_TAGS'] = r'optional'
|
206
|
|
207
|
|
208
|
def writeBp(clazz, props, bp):
|
209
|
|
210
|
bp.write('\n' + clazz + ' {\n')
|
211
|
for k,v in props.items():
|
212
|
if v and type(v) == str:
|
213
|
bp.write(' ' + k + ': ' + v + '\n')
|
214
|
if clazz != 'android_app_import':
|
215
|
bp.write(''' strip: {
|
216
|
none: ''' + props['strip']['none'] + ''',
|
217
|
keep_symbols: ''' + props['strip']['keep_symbols'] + ''',
|
218
|
},\n''')
|
219
|
if clazz == 'cc_prebuilt_library_shared' or\
|
220
|
clazz == 'cc_prebuilt_library_static':
|
221
|
bp.write(''' multilib: {
|
222
|
lib32: {
|
223
|
srcs: ["''' + props['multilib']['lib32']['srcs'] + '''"],
|
224
|
},
|
225
|
lib64: {
|
226
|
srcs: ["''' + props['multilib']['lib64']['srcs'] + '''"],
|
227
|
},
|
228
|
},\n''')
|
229
|
bp.write('}\n')
|
230
|
bp.flush()
|
231
|
|
232
|
def getExportedHeadersDir(headers):
|
233
|
|
234
|
|
235
|
|
236
|
if not headers:
|
237
|
return None
|
238
|
print('ENV.prebuilt_Ihs path=%s headers=%s'%(ENV.prebuilt_Ihs, headers))
|
239
|
cmdl = 'find %s -type d -name %s'%(ENV.prebuilt_Ihs, headers)
|
240
|
result = os.popen(cmdl).read().strip()
|
241
|
return op.relpath(op.join(op.realpath(result), 'gen'), op.dirname(ENV.prebuilt_Ihs))
|
242
|
|
243
|
|
244
|
|
245
|
LOCAL_MODULE = re.compile(r'^LOCAL_MODULE[\s:]')
|
246
|
LOCAL_PACKAGE_NAME = re.compile(r'^LOCAL_PACKAGE_NAME[\s:]')
|
247
|
def isAndroidMKbuild(f, dir):
|
248
|
VARS = {'LOCAL_MODULE','LOCAL_PACKAGE_NAME'}
|
249
|
getval = lambda l: l.split('=')[-1].lstrip()
|
250
|
with open(op.join(dir, f), 'r', encoding='Windows-1252') as mf:
|
251
|
for line in mf:
|
252
|
line = line.strip()
|
253
|
if LOCAL_MODULE.match(line):
|
254
|
|
255
|
name = getval(line)
|
256
|
index = build_package.find(name)
|
257
|
if index >= 0:
|
258
|
print(name)
|
259
|
return True
|
260
|
|
261
|
elif LOCAL_PACKAGE_NAME.match(line):
|
262
|
|
263
|
name = getval(line)
|
264
|
index = build_package.find(name)
|
265
|
if index >= 0:
|
266
|
print(name)
|
267
|
return True
|
268
|
|
269
|
|
270
|
return False
|
271
|
|
272
|
|
273
|
CLEAR_VARS = re.compile(r'^include\s*\$\(CLEAR_VARS\)')
|
274
|
LOCAL_MODULE = re.compile(r'^LOCAL_MODULE[\s:]')
|
275
|
LOCAL_PACKAGE_NAME = re.compile(r'^LOCAL_PACKAGE_NAME[\s:]')
|
276
|
LOCAL_MODULE_OWNER = re.compile(r'^LOCAL_MODULE_OWNER[\s:]')
|
277
|
LOCAL_MODULE_CLASS = re.compile(r'^LOCAL_MODULE_CLASS[\s:]')
|
278
|
LOCAL_MODULE_TAGS = re.compile(r'^LOCAL_MODULE_TAGS[\s:]')
|
279
|
LOCAL_CERTIFICATE = re.compile(r'^LOCAL_CERTIFICATE[\s:]')
|
280
|
LOCAL_INSTALLED_MODULE_STEM = re.compile(r'^LOCAL_INSTALLED_MODULE_STEM[\s:]')
|
281
|
LOCAL_PRIVILEGED_MODULE = re.compile(r'^LOCAL_PRIVILEGED_MODULE[\s:]')
|
282
|
LOCAL_PROPRIETARY_MODULE = re.compile(r'^LOCAL_PROPRIETARY_MODULE[\s:]')
|
283
|
LOCAL_VENDOR_MODULE = re.compile(r'^LOCAL_VENDOR_MODULE[\s:]')
|
284
|
LOCAL_MODULE_RELATIVE_PATH = re.compile(r'^LOCAL_MODULE_RELATIVE_PATH[\s:]')
|
285
|
LOCAL_MODULE_PATH = re.compile(r'^LOCAL_MODULE_PATH[\s:]')
|
286
|
LOCAL_INIT_RC = re.compile(r'^LOCAL_INIT_RC[\s:]')
|
287
|
LOCAL_32_BIT_ONLY = re.compile(r'^LOCAL_32_BIT_ONLY[\s:]')
|
288
|
LOCAL_SRC_FILES = re.compile(r'^LOCAL_SRC_FILES[\s:]')
|
289
|
LOCAL_PRODUCT_MODULE = re.compile(r'^LOCAL_PRODUCT_MODULE[\s:]')
|
290
|
|
291
|
BUILD_EXECUTABLE = re.compile(r'^include\s*\$\(BUILD_EXECUTABLE\)')
|
292
|
BUILD_HOST_EXECUTABLE = re.compile(r'^include\s*\$\(BUILD_HOST_EXECUTABLE\)')
|
293
|
BUILD_SHARED_LIBRARY = re.compile(r'^include\s*\$\(BUILD_SHARED_LIBRARY\)')
|
294
|
BUILD_HOST_SHARED_LIBRARY = re.compile(r'^include\s*\$\(BUILD_HOST_SHARED_LIBRARY\)')
|
295
|
BUILD_STATIC_LIBRARY = re.compile(r'^include\s*\$\(BUILD_STATIC_LIBRARY\)')
|
296
|
BUILD_HOST_STATIC_LIBRARY = re.compile(r'^include\s*\$\(BUILD_HOST_STATIC_LIBRARY\)')
|
297
|
BUILD_RRO_PACKAGE = re.compile(r'^include\s*\$\(BUILD_RRO_PACKAGE\)')
|
298
|
BUILD_PHONY_PACKAGE = re.compile(r'^include\s*\$\(BUILD_PHONY_PACKAGE\)')
|
299
|
BUILD_PACKAGE = re.compile(r'^include\s*\$\(BUILD_PACKAGE\)')
|
300
|
BUILD_JAVA_LIBRARY = re.compile(r'^include\s*\$\(BUILD_JAVA_LIBRARY\)')
|
301
|
BUILD_STATIC_JAVA_LIBRARY = re.compile(r'^include\s*\$\(BUILD_STATIC_JAVA_LIBRARY\)')
|
302
|
BUILD_PREBUILT = re.compile(r'^include\s*\$\(BUILD_PREBUILT\)')
|
303
|
BUILD_HOST_PREBUILT = re.compile(r'^include\s*\$\(BUILD_HOST_PREBUILT\)')
|
304
|
BUILD_MULTI_PREBUILT = re.compile(r'^include\s*\$\(BUILD_MULTI_PREBUILT\)')
|
305
|
BUILD_HEADER_LIBRARY = re.compile(r'^include\s*\$\(BUILD_HEADER_LIBRARY\)')
|
306
|
BUILD_COPY_HEADERS = re.compile(r'^include\s*\$\(BUILD_COPY_HEADERS\)')
|
307
|
|
308
|
CAMX_BUILD_STATIC_LIBRARY = re.compile(r'^include\s*\$\(CAMX_BUILD_STATIC_LIBRARY\)')
|
309
|
CAMX_BUILD_SHARED_LIBRARY = re.compile(r'^include\s*\$\(CAMX_BUILD_SHARED_LIBRARY\)')
|
310
|
BUILD_NATIVE_TEST = re.compile(r'^include\s*\$\(BUILD_NATIVE_TEST\)')
|
311
|
BUILD_SYSTEM = re.compile(r'^include\s*\$\(BUILD_SYSTEM\)')
|
312
|
|
313
|
|
314
|
BUILD_XXX = re.compile(r'^include\s*\$\(BUILD_')
|
315
|
|
316
|
|
317
|
def parseAndroidMK(Android_mk, mk_dir, localpath = False):
|
318
|
|
319
|
|
320
|
VARS = {'LOCAL_MODULE': '',\
|
321
|
'LOCAL_INIT_RC': '',\
|
322
|
'LOCAL_MODULE_OWNER': r'qcom',\
|
323
|
'LOCAL_INSTALLED_MODULE_STEM': '',\
|
324
|
'LOCAL_MODULE_CLASS': '',\
|
325
|
'LOCAL_MODULE_TAGS': r'optional',\
|
326
|
'LOCAL_CERTIFICATE': '',\
|
327
|
'LOCAL_MODULE_SUFFIX': '',\
|
328
|
'LOCAL_UNINSTALLABLE_MODULE': '',\
|
329
|
'LOCAL_PRIVILEGED_MODULE': '',\
|
330
|
'LOCAL_PROPRIETARY_MODULE': '',\
|
331
|
'LOCAL_VENDOR_MODULE': '',\
|
332
|
'LOCAL_PRODUCT_MODULE': '',\
|
333
|
'LOCAL_SRC_FILES': '',\
|
334
|
'LOCAL_CLASSES_DEX_TOC': '',\
|
335
|
'LOCAL_CLASSES_JACK': '',\
|
336
|
'LOCAL_COPY_DST_DIR': '',\
|
337
|
'LOCAL_MODULE_RELATIVE_PATH': '',\
|
338
|
'LOCAL_MODULE_PATH': ''}
|
339
|
|
340
|
getval = lambda l: l.split('=')[-1].lstrip()
|
341
|
|
342
|
|
343
|
|
344
|
|
345
|
with open(op.join(mk_dir, Android_mk), 'r', encoding='Windows-1252') as mf:
|
346
|
with open(op.join(mk_dir, 'newAndroid.mk'), 'w', encoding='Windows-1252') as mk:
|
347
|
for line in mf:
|
348
|
skip = 'false'
|
349
|
line = line.strip()
|
350
|
if CLEAR_VARS.match(line):
|
351
|
for k in VARS:
|
352
|
VARS[k] = ''
|
353
|
VARS['LOCAL_MODULE_OWNER'] = r'qcom'
|
354
|
VARS['LOCAL_MODULE_TAGS'] = r'optional'
|
355
|
elif LOCAL_MODULE.match(line):
|
356
|
VARS['LOCAL_MODULE'] = getval(line)
|
357
|
elif LOCAL_PACKAGE_NAME.match(line):
|
358
|
VARS['LOCAL_PACKAGE_NAME'] = getval(line)
|
359
|
skip = 'true'
|
360
|
elif LOCAL_MODULE_OWNER.match(line):
|
361
|
VARS['LOCAL_MODULE_OWNER'] = getval(line)
|
362
|
skip = 'true'
|
363
|
elif LOCAL_MODULE_CLASS.match(line):
|
364
|
VARS['LOCAL_MODULE_CLASS'] = getval(line)
|
365
|
skip = 'false'
|
366
|
elif LOCAL_MODULE_TAGS.match(line):
|
367
|
VARS['LOCAL_MODULE_TAGS'] = getval(line)
|
368
|
skip = 'true'
|
369
|
elif LOCAL_CERTIFICATE.match(line):
|
370
|
VARS['LOCAL_CERTIFICATE'] = getval(line)
|
371
|
elif LOCAL_PROPRIETARY_MODULE.match(line):
|
372
|
VARS['LOCAL_PROPRIETARY_MODULE'] = getval(line)
|
373
|
elif LOCAL_PRIVILEGED_MODULE.match(line):
|
374
|
VARS['LOCAL_PRIVILEGED_MODULE'] = getval(line)
|
375
|
elif LOCAL_VENDOR_MODULE.match(line):
|
376
|
VARS['LOCAL_VENDOR_MODULE'] = getval(line)
|
377
|
elif LOCAL_PRODUCT_MODULE.match(line):
|
378
|
VARS['LOCAL_PRODUCT_MODULE'] = getval(line)
|
379
|
elif LOCAL_MODULE_RELATIVE_PATH.match(line):
|
380
|
VARS['LOCAL_MODULE_RELATIVE_PATH'] = getval(line)
|
381
|
elif LOCAL_INSTALLED_MODULE_STEM.match(line):
|
382
|
VARS['LOCAL_INSTALLED_MODULE_STEM'] = getval(line)
|
383
|
elif LOCAL_MODULE_PATH.match(line):
|
384
|
VARS['LOCAL_MODULE_PATH'] = getval(line)
|
385
|
skip = 'true'
|
386
|
elif LOCAL_INIT_RC.match(line):
|
387
|
VARS['LOCAL_INIT_RC'] = getval(line)
|
388
|
elif LOCAL_SRC_FILES.match(line):
|
389
|
VARS['LOCAL_SRC_FILES'] = getval(line)
|
390
|
skip = 'true'
|
391
|
|
392
|
elif BUILD_EXECUTABLE.match(line) or BUILD_NATIVE_TEST.match(line):
|
393
|
skip = 'true'
|
394
|
VARS['LOCAL_MODULE_CLASS'] = r'EXECUTABLES'
|
395
|
dst = mk_dir
|
396
|
|
397
|
if VARS['LOCAL_PROPRIETARY_MODULE'] == 'true' or VARS['LOCAL_VENDOR_MODULE'] == 'true':
|
398
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/bin'
|
399
|
|
400
|
elif VARS['LOCAL_PRODUCT_MODULE'] == 'true':
|
401
|
if args['--lunch'] == 'figure':
|
402
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/product/bin'
|
403
|
elif args['--lunch'] == 'sdm845':
|
404
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/system/product/bin'
|
405
|
|
406
|
else:
|
407
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/system/bin'
|
408
|
|
409
|
if localpath:
|
410
|
dst = op.join(dst, r'../../')
|
411
|
|
412
|
if not copyBinSrc(dst, r'EXECUTABLES', VARS['LOCAL_MODULE']):
|
413
|
copy_status = 0
|
414
|
print('FAILED to copy ' + VARS['LOCAL_MODULE'] + ' to local directory')
|
415
|
else:
|
416
|
copy_status = 4
|
417
|
VARS['LOCAL_SRC_FILES'] = VARS['LOCAL_MODULE']
|
418
|
writeMakefile(VARS, mk, 'EXECUTABLES', copy_status)
|
419
|
|
420
|
elif BUILD_SHARED_LIBRARY.match(line) or CAMX_BUILD_SHARED_LIBRARY.match(line):
|
421
|
VARS['LOCAL_MODULE_CLASS'] = r'SHARED_LIBRARIES'
|
422
|
VARS['LOCAL_MODULE_SUFFIX'] = r'.so'
|
423
|
skip = 'true'
|
424
|
dst = mk_dir
|
425
|
|
426
|
if localpath:
|
427
|
dst = op.join(dst, r'../../')
|
428
|
|
429
|
if VARS['LOCAL_PROPRIETARY_MODULE'] == 'true' or VARS['LOCAL_VENDOR_MODULE'] == 'true' or\
|
430
|
CAMX_BUILD_SHARED_LIBRARY.match(line):
|
431
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/lib'
|
432
|
dst32 = dst + r'/' + VARS['LOCAL_MODULE'] + r'32/'
|
433
|
|
434
|
elif VARS['LOCAL_PRODUCT_MODULE'] == 'true':
|
435
|
if args['--lunch'] == 'figure':
|
436
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/product/lib'
|
437
|
elif args['--lunch'] == 'sdm845':
|
438
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/system/product/lib'
|
439
|
dst32 = dst + r'/' + VARS['LOCAL_MODULE'] + r'32/'
|
440
|
|
441
|
else:
|
442
|
|
443
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/system/lib'
|
444
|
dst32 = dst + r'/' + VARS['LOCAL_MODULE'] + r'32/'
|
445
|
|
446
|
module_name = VARS['LOCAL_MODULE']
|
447
|
VARS['LOCAL_STRIP_MODULE'] = r'false'
|
448
|
|
449
|
|
450
|
copy_status = 3
|
451
|
if not copyBinSrc(dst32, r'SHARED_LIBRARIES_32', module_name):
|
452
|
copy_status -= 1
|
453
|
print('FAILED to copy ' + module_name + '.so to local directory')
|
454
|
|
455
|
|
456
|
VARS['LOCAL_MULTILIB'] = r'64'
|
457
|
dst64 = rreplace(dst32, r'32', r'64')
|
458
|
VARS['LOCAL_MODULE_PATH'] = rreplace(VARS['LOCAL_MODULE_PATH'], r'/lib', r'/lib64')
|
459
|
VARS['LOCAL_SRC_FILES'] = VARS['LOCAL_MODULE'] + r'64/' + module_name + r'.so'
|
460
|
if not copyBinSrc(dst64, r'SHARED_LIBRARIES_64', module_name):
|
461
|
copy_status -= 2
|
462
|
print('FAILED to copy ' + module_name + '.so to local directory')
|
463
|
writeMakefile(VARS, mk, 'SHARED_LIBRARIES', copy_status)
|
464
|
|
465
|
elif BUILD_STATIC_LIBRARY.match(line) or CAMX_BUILD_STATIC_LIBRARY.match(line):
|
466
|
VARS['LOCAL_MODULE_CLASS'] = r'STATIC_LIBRARIES'
|
467
|
VARS['LOCAL_MODULE_SUFFIX'] = r'.a'
|
468
|
skip = 'true'
|
469
|
dst = mk_dir
|
470
|
|
471
|
if localpath:
|
472
|
dst = op.join(dst, r'../../')
|
473
|
|
474
|
|
475
|
dst32 = dst + r'/' + VARS['LOCAL_MODULE'] + r'32/'
|
476
|
copy_status = 3
|
477
|
if not copyBinSrc(dst32, r'STATIC_LIBRARIES_32', VARS['LOCAL_MODULE']):
|
478
|
copy_status -= 1
|
479
|
print('FAILED to copy ' + VARS['LOCAL_MODULE'] + '.a to local directory')
|
480
|
|
481
|
|
482
|
VARS['LOCAL_MULTILIB'] = r'64'
|
483
|
dst64 = rreplace(dst32, r'32', r'64')
|
484
|
VARS['LOCAL_SRC_FILES'] = VARS['LOCAL_MODULE'] + r'64/' + VARS['LOCAL_MODULE'] + r'.a'
|
485
|
if not copyBinSrc(dst64, r'STATIC_LIBRARIES_32', VARS['LOCAL_MODULE']):
|
486
|
copy_status -= 2
|
487
|
print('FAILED to copy ' + VARS['LOCAL_MODULE'] + '.a to local directory')
|
488
|
writeMakefile(VARS, mk, 'STATIC_LIBRARIES', copy_status)
|
489
|
|
490
|
elif BUILD_PACKAGE.match(line) or BUILD_RRO_PACKAGE.match(line):
|
491
|
VARS['LOCAL_MODULE_CLASS'] = r'APPS'
|
492
|
VARS['LOCAL_MODULE_SUFFIX'] = r'.apk'
|
493
|
skip = 'true'
|
494
|
dst = mk_dir
|
495
|
|
496
|
if localpath:
|
497
|
dst = op.join(dst, r'../../')
|
498
|
|
499
|
if not BUILD_RRO_PACKAGE.match(line):
|
500
|
if VARS['LOCAL_PRODUCT_MODULE'] == 'true':
|
501
|
if VARS['LOCAL_PRIVILEGED_MODULE'] == 'true':
|
502
|
if args['--lunch'] == 'figure':
|
503
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/product/priv-app'
|
504
|
elif args['--lunch'] == 'sdm845':
|
505
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/system/product/priv-app'
|
506
|
else:
|
507
|
if args['--lunch'] == 'figure':
|
508
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/product/app'
|
509
|
elif args['--lunch'] == 'sdm845':
|
510
|
VARS['LOCAL_MODULE_PATH'] = r'$(TARGET_PRODUCT_OUT_ROOT)/qssi/system/product/app'
|
511
|
|
512
|
elif VARS['LOCAL_PROPRIETARY_MODULE'] == 'true' or VARS['LOCAL_VENDOR_MODULE'] == 'true':
|
513
|
|
514
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)/app'
|
515
|
|
516
|
elif VARS['LOCAL_PRIVILEGED_MODULE'] == 'true':
|
517
|
|
518
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/system/priv-app'
|
519
|
|
520
|
else:
|
521
|
|
522
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/system/app'
|
523
|
|
524
|
else:
|
525
|
VARS['LOCAL_MODULE_PATH'] = r'$(PRODUCT_OUT)/vendor/overlay'
|
526
|
|
527
|
VARS['LOCAL_SRC_FILES'] = VARS['LOCAL_PACKAGE_NAME'] + r'.apk'
|
528
|
VARS['LOCAL_MODULE'] = VARS['LOCAL_PACKAGE_NAME']
|
529
|
VARS['LOCAL_PACKAGE_NAME'] = ''
|
530
|
if copyBinSrc(dst, r'APPS', VARS['LOCAL_MODULE']):
|
531
|
copy_status = 4
|
532
|
writeMakefile(VARS, mk, 'APPS', copy_status)
|
533
|
else:
|
534
|
print('FAILED to copy ' + VARS['LOCAL_MODULE'] + '.apk to local directory')
|
535
|
|
536
|
elif BUILD_JAVA_LIBRARY.match(line) or BUILD_STATIC_JAVA_LIBRARY.match(line):
|
537
|
VARS['LOCAL_MODULE_CLASS'] = r'JAVA_LIBRARIES'
|
538
|
VARS['LOCAL_MODULE_SUFFIX'] = r'$(COMMON_JAVA_PACKAGE_SUFFIX)'
|
539
|
skip = 'true'
|
540
|
dst = mk_dir
|
541
|
|
542
|
if localpath:
|
543
|
dst = op.join(dst, r'../../')
|
544
|
|
545
|
if BUILD_STATIC_JAVA_LIBRARY.match(line):
|
546
|
VARS['LOCAL_UNINSTALLABLE_MODULE'] = 'true'
|
547
|
|
548
|
if copyBinSrc(dst, r'JAVA_LIBRARIES', VARS['LOCAL_MODULE']):
|
549
|
copy_status = 4
|
550
|
VARS['LOCAL_SRC_FILES'] = VARS['LOCAL_MODULE'] + r'.jar'
|
551
|
writeMakefile(VARS, mk, 'JAVA_LIBRARIES', copy_status)
|
552
|
else:
|
553
|
print('FAILED to copy ' + VARS['LOCAL_MODULE'] + '.jar to local directory')
|
554
|
|
555
|
elif BUILD_PREBUILT.match(line):
|
556
|
skip = 'true'
|
557
|
copy_status = 4
|
558
|
writeMakefile(VARS, mk, 'PREBUILT', copy_status)
|
559
|
|
560
|
elif BUILD_HOST_PREBUILT.match(line):
|
561
|
skip = 'true'
|
562
|
copy_status = 4
|
563
|
writeMakefile(VARS, mk, 'HOST_PREBUILT', copy_status)
|
564
|
|
565
|
elif BUILD_MULTI_PREBUILT.match(line):
|
566
|
skip = 'true'
|
567
|
copy_status = 4
|
568
|
writeMakefile(VARS, mk, 'MULTI_PREBUILT', copy_status)
|
569
|
|
570
|
elif BUILD_HEADER_LIBRARY.match(line):
|
571
|
skip = 'true'
|
572
|
copy_status = 4
|
573
|
writeMakefile(VARS, mk, 'HEADER_LIBRARY', copy_status)
|
574
|
|
575
|
elif BUILD_COPY_HEADERS.match(line):
|
576
|
skip = 'true'
|
577
|
copy_status = 4
|
578
|
writeMakefile(VARS, mk, 'COPY_HEADERS', copy_status)
|
579
|
|
580
|
elif BUILD_PHONY_PACKAGE.match(line):
|
581
|
skip = 'true'
|
582
|
copy_status = 4
|
583
|
writeMakefile(VARS, mk, 'PHONY_PACKAGE', copy_status)
|
584
|
|
585
|
elif BUILD_SYSTEM.match(line):
|
586
|
skip = 'false'
|
587
|
|
588
|
elif BUILD_HOST_SHARED_LIBRARY.match(line) or BUILD_HOST_STATIC_LIBRARY.match(line) or \
|
589
|
BUILD_HOST_EXECUTABLE.match(line):
|
590
|
skip = 'true'
|
591
|
|
592
|
elif BUILD_XXX.match(line):
|
593
|
skip = 'false'
|
594
|
|
595
|
print('NOT supported build type:')
|
596
|
print(VARS)
|
597
|
|
598
|
if skip == 'false':
|
599
|
mk.write(line + '\n')
|
600
|
continue
|
601
|
|
602
|
|
603
|
|
604
|
def isAndroidBPbuild(f, bp_dir):
|
605
|
begin = lambda l: l.split(':')[0].strip()
|
606
|
getrstr = lambda l: l.split(':')[-1].strip()
|
607
|
getval = lambda s: s.rstrip(',').lstrip('"').rstrip('"').strip(',')
|
608
|
|
609
|
with open(op.join(bp_dir, 'Android.bp'), 'r') as bp:
|
610
|
for line in bp:
|
611
|
line_no_strip = line.rstrip()
|
612
|
line = line.strip()
|
613
|
|
614
|
if begin(line) == 'name':
|
615
|
|
616
|
name = getrstr(line)
|
617
|
|
618
|
name = getval(name)
|
619
|
|
620
|
index = build_package.find(name)
|
621
|
|
622
|
if index >= 0:
|
623
|
|
624
|
return True
|
625
|
|
626
|
|
627
|
bp.close()
|
628
|
|
629
|
return False
|
630
|
|
631
|
|
632
|
hidl_interface = re.compile(r'^hidl_interface[\s{]')
|
633
|
cc_library_headers = re.compile(r'^cc_library_headers[\s{]')
|
634
|
hidl_package_root = re.compile(r'^hidl_package_root[\s{]')
|
635
|
cc_test = re.compile(r'^cc_test[\s{]')
|
636
|
bootstrap_go_package = re.compile(r'^bootstrap_go_package[\s{]')
|
637
|
perfHaldefaults = re.compile(r'^perfHaldefaults[\s{]')
|
638
|
|
639
|
java_library = re.compile(r'^java_library[\s{]')
|
640
|
java_library_static = re.compile(r'^java_library_static[\s{]')
|
641
|
prebuilt_etc = re.compile(r'^prebuilt_etc[\s{]')
|
642
|
cc_library_shared = re.compile(r'^cc_library_shared[\s{]')
|
643
|
cc_library_static = re.compile(r'^cc_library_static[\s{]')
|
644
|
cc_binary = re.compile(r'^cc_binary[\s{]')
|
645
|
|
646
|
android_app = re.compile(r'^android_app[\s{]')
|
647
|
cc_library = re.compile(r'^cc_library[\s{]')
|
648
|
filegroup = re.compile(r'^filegroup[\s{]')
|
649
|
sh_binary = re.compile(r'^sh_binary[\s{]')
|
650
|
prebuilt_firmware = re.compile(r'^prebuilt_firmware[\s{]')
|
651
|
prebuilt_etc_host = re.compile(r'^prebuilt_etc_host[\s{]')
|
652
|
cc_defaults = re.compile(r'^cc_defaults[\s{]')
|
653
|
common_cflags = re.compile(r'^common_cflags[\s{]')
|
654
|
soong_config_module_type = re.compile(r'^soong_config_module_type[\s{]')
|
655
|
genrule = re.compile(r'^genrule[\s{]')
|
656
|
filegroup = re.compile(r'^filegroup[\s{]')
|
657
|
cc_binary_host = re.compile(r'^cc_binary_host[\s{]')
|
658
|
export_header_lib_headers = re.compile(r'^export_header_lib_headers[\s{]')
|
659
|
|
660
|
module_end = re.compile(r'^}$')
|
661
|
|
662
|
|
663
|
|
664
|
|
665
|
|
666
|
|
667
|
|
668
|
|
669
|
|
670
|
|
671
|
|
672
|
def parse_one_module(line):
|
673
|
if copy == 'true':
|
674
|
print('line_no_strip_last=%s'%(line_no_strip))
|
675
|
bp.write(line_no_strip + '\n')
|
676
|
|
677
|
|
678
|
def parseAndroidBP(bp, bp_dir):
|
679
|
|
680
|
|
681
|
props = {
|
682
|
'name': '',\
|
683
|
'stem': '',\
|
684
|
'suffix': '',\
|
685
|
'owner': '',\
|
686
|
'init_rc': '',\
|
687
|
'vendor': '',\
|
688
|
'vendor_available': '',\
|
689
|
'product_specific': '',\
|
690
|
'relative_install_path': '',\
|
691
|
'host_supported': '',\
|
692
|
'proprietary': '',\
|
693
|
'certificate': '',\
|
694
|
'defaults': '',\
|
695
|
'installable': '',\
|
696
|
'pack_relocations': '',\
|
697
|
'clang': '',\
|
698
|
'shared_libs': '',\
|
699
|
'export_include_dirs': '',\
|
700
|
'system_ext_specific': '',\
|
701
|
'srcs': '',\
|
702
|
'compile_multilib': '',\
|
703
|
'multilib': {'lib32': {'srcs': ''}, 'lib64': {'srcs': ''}},\
|
704
|
'strip': {'none': 'true', 'keep_symbols': 'true'},\
|
705
|
}
|
706
|
clazz = ''
|
707
|
begin = lambda l: l.split(':')[0].strip()
|
708
|
getrstr = lambda l: l.split(':')[-1].strip()
|
709
|
getval = lambda s: s.rstrip(',').lstrip('[').rstrip(']').strip('"')
|
710
|
with open(op.join(bp_dir, bp), 'r') as f:
|
711
|
with open(op.join(bp_dir, 'newAndroid.bp'), 'w') as bp:
|
712
|
copy = 'ture'
|
713
|
export_generated_headers = ''
|
714
|
for line in f:
|
715
|
print('line=%s'%(line))
|
716
|
|
717
|
line_no_strip = line.rstrip()
|
718
|
line = line.strip()
|
719
|
if hidl_interface.match(line):
|
720
|
copy = 'true'
|
721
|
export_generated_headers = ''
|
722
|
for k in props:
|
723
|
if type(props[k]) == str:
|
724
|
props[k] = ''
|
725
|
clazz = 'hidl_interface'
|
726
|
elif cc_library_headers.match(line):
|
727
|
copy = 'true'
|
728
|
export_generated_headers = ''
|
729
|
for k in props:
|
730
|
if type(props[k]) == str:
|
731
|
props[k] = ''
|
732
|
clazz = 'cc_library_headers'
|
733
|
elif hidl_package_root.match(line):
|
734
|
copy = 'true'
|
735
|
export_generated_headers = ''
|
736
|
for k in props:
|
737
|
if type(props[k]) == str:
|
738
|
props[k] = ''
|
739
|
clazz = 'hidl_package_root'
|
740
|
elif bootstrap_go_package.match(line):
|
741
|
copy = 'true'
|
742
|
export_generated_headers = ''
|
743
|
for k in props:
|
744
|
if type(props[k]) == str:
|
745
|
props[k] = ''
|
746
|
clazz = 'bootstrap_go_package'
|
747
|
elif android_app.match(line):
|
748
|
copy = 'false'
|
749
|
export_generated_headers = ''
|
750
|
for k in props:
|
751
|
if type(props[k]) == str:
|
752
|
props[k] = ''
|
753
|
clazz = 'android_app_import'
|
754
|
elif perfHaldefaults.match(line):
|
755
|
copy = 'true'
|
756
|
export_generated_headers = ''
|
757
|
for k in props:
|
758
|
if type(props[k]) == str:
|
759
|
props[k] = ''
|
760
|
clazz = 'perfHaldefaults'
|
761
|
elif prebuilt_etc.match(line):
|
762
|
copy = 'true'
|
763
|
export_generated_headers = ''
|
764
|
for k in props:
|
765
|
if type(props[k]) == str:
|
766
|
props[k] = ''
|
767
|
clazz = 'prebuilt_etc'
|
768
|
elif genrule.match(line):
|
769
|
copy = 'true'
|
770
|
export_generated_headers = ''
|
771
|
for k in props:
|
772
|
if type(props[k]) == str:
|
773
|
props[k] = ''
|
774
|
clazz = 'genrule'
|
775
|
elif filegroup.match(line):
|
776
|
copy = 'true'
|
777
|
export_generated_headers = ''
|
778
|
for k in props:
|
779
|
if type(props[k]) == str:
|
780
|
props[k] = ''
|
781
|
clazz = 'filegroup'
|
782
|
elif soong_config_module_type.match(line):
|
783
|
copy = 'true'
|
784
|
export_generated_headers = ''
|
785
|
for k in props:
|
786
|
if type(props[k]) == str:
|
787
|
props[k] = ''
|
788
|
clazz = 'soong_config_module_type'
|
789
|
elif prebuilt_etc_host.match(line):
|
790
|
copy = 'true'
|
791
|
export_generated_headers = ''
|
792
|
for k in props:
|
793
|
if type(props[k]) == str:
|
794
|
props[k] = ''
|
795
|
clazz = 'prebuilt_etc_host'
|
796
|
elif cc_binary_host.match(line):
|
797
|
copy = 'true'
|
798
|
export_generated_headers = ''
|
799
|
for k in props:
|
800
|
if type(props[k]) == str:
|
801
|
props[k] = ''
|
802
|
clazz = 'cc_binary_host'
|
803
|
elif cc_defaults.match(line):
|
804
|
copy = 'true'
|
805
|
export_generated_headers = ''
|
806
|
for k in props:
|
807
|
if type(props[k]) == str:
|
808
|
props[k] = ''
|
809
|
clazz = 'cc_defaults'
|
810
|
elif common_cflags.match(line):
|
811
|
copy = 'true'
|
812
|
export_generated_headers = ''
|
813
|
for k in props:
|
814
|
if type(props[k]) == str:
|
815
|
props[k] = ''
|
816
|
clazz = 'common_cflags'
|
817
|
elif sh_binary.match(line):
|
818
|
copy = 'true'
|
819
|
export_generated_headers = ''
|
820
|
for k in props:
|
821
|
if type(props[k]) == str:
|
822
|
props[k] = ''
|
823
|
clazz = 'sh_binary'
|
824
|
|
825
|
|
826
|
|
827
|
|
828
|
|
829
|
|
830
|
|
831
|
elif prebuilt_firmware.match(line):
|
832
|
copy = 'true'
|
833
|
export_generated_headers = ''
|
834
|
for k in props:
|
835
|
if type(props[k]) == str:
|
836
|
props[k] = ''
|
837
|
clazz = 'prebuilt_firmware'
|
838
|
elif cc_test.match(line):
|
839
|
copy = 'false'
|
840
|
export_generated_headers = ''
|
841
|
for k in props:
|
842
|
if type(props[k]) == str:
|
843
|
props[k] = ''
|
844
|
clazz = 'cc_test'
|
845
|
elif cc_library_shared.match(line):
|
846
|
copy = 'false'
|
847
|
export_generated_headers = ''
|
848
|
for k in props:
|
849
|
if type(props[k]) == str:
|
850
|
props[k] = ''
|
851
|
clazz = 'cc_prebuilt_library_shared'
|
852
|
elif cc_library.match(line):
|
853
|
copy = 'false'
|
854
|
export_generated_headers = ''
|
855
|
for k in props:
|
856
|
if type(props[k]) == str:
|
857
|
props[k] = ''
|
858
|
clazz = 'cc_prebuilt_library_shared'
|
859
|
elif cc_library_static.match(line):
|
860
|
copy = 'false'
|
861
|
export_generated_headers = ''
|
862
|
for k in props:
|
863
|
if type(props[k]) == str:
|
864
|
props[k] = ''
|
865
|
clazz = 'cc_prebuilt_library_static'
|
866
|
elif java_library.match(line) or java_library_static.match(line):
|
867
|
copy = 'true'
|
868
|
export_generated_headers = ''
|
869
|
for k in props:
|
870
|
if type(props[k]) == str:
|
871
|
props[k] = ''
|
872
|
clazz = 'not_recognized_class'
|
873
|
elif cc_binary.match(line):
|
874
|
copy = 'false'
|
875
|
export_generated_headers = ''
|
876
|
for k in props:
|
877
|
if type(props[k]) == str:
|
878
|
props[k] = ''
|
879
|
clazz = 'cc_prebuilt_binary'
|
880
|
elif begin(line) == 'name':
|
881
|
props['name'] = getrstr(line)
|
882
|
elif begin(line) == 'stem':
|
883
|
props['stem'] = getrstr(line)
|
884
|
elif begin(line) == 'suffix':
|
885
|
props['suffix'] = getrstr(line)
|
886
|
elif begin(line) == 'init_rc':
|
887
|
props['init_rc'] = getrstr(line)
|
888
|
elif begin(line) == 'owner':
|
889
|
props['owner'] = getrstr(line)
|
890
|
elif begin(line) == 'vendor':
|
891
|
if getrstr(line) == '{':
|
892
|
props['vendor'] = ''
|
893
|
else:
|
894
|
props['vendor'] = getrstr(line)
|
895
|
|
896
|
elif begin(line) == 'vendor_available':
|
897
|
props['vendor_available'] = getrstr(line)
|
898
|
elif begin(line) == 'product_specific':
|
899
|
props['product_specific'] = getrstr(line)
|
900
|
elif begin(line) == 'relative_install_path':
|
901
|
props['relative_install_path'] = getrstr(line)
|
902
|
elif begin(line) == 'proprietary':
|
903
|
props['proprietary'] = getrstr(line)
|
904
|
elif begin(line) == 'certificate':
|
905
|
props['certificate'] = getrstr(line)
|
906
|
elif begin(line) == 'installable':
|
907
|
props['installable'] = getrstr(line)
|
908
|
elif begin(line) == 'host_supported':
|
909
|
props['host_supported'] = getrstr(line)
|
910
|
elif begin(line) == 'pack_relocations':
|
911
|
props['pack_relocations'] = getrstr(line)
|
912
|
elif begin(line) == 'clang':
|
913
|
props['clang'] = getrstr(line)
|
914
|
elif begin(line) == 'export_generated_headers':
|
915
|
export_generated_headers = getrstr(line)
|
916
|
print('wangdqif line=%s'%(line))
|
917
|
print('wangdqif export_generated_headers=%s'%(export_generated_headers))
|
918
|
|
919
|
elif module_end.match(line_no_strip):
|
920
|
if not props['name'] or not clazz:
|
921
|
clazz = ''
|
922
|
print('name1=%s'%(props['name']))
|
923
|
continue
|
924
|
name = getval(props['name'])
|
925
|
initrc = getval(props['init_rc'])
|
926
|
dst = bp_dir
|
927
|
if export_generated_headers:
|
928
|
headers = getval(export_generated_headers)
|
929
|
print('----headers=%s'%(headers))
|
930
|
|
931
|
|
932
|
if clazz == 'cc_prebuilt_library_shared':
|
933
|
props['srcs'] = ''
|
934
|
|
935
|
if 'true' in props['vendor'] or 'true' in props['proprietary']:
|
936
|
dst32 = dst + r'/' + name + r'_32/'
|
937
|
|
938
|
|
939
|
|
940
|
else:
|
941
|
dst32 = dst + r'/' + name + r'_32/'
|
942
|
|
943
|
|
944
|
|
945
|
if props['relative_install_path']:
|
946
|
dst32 = dst + r'/' + name + r'_32/'
|
947
|
|
948
|
|
949
|
if not copyBinSrc(dst32, r'SHARED_LIBRARIES_32', name):
|
950
|
print('FAILED to copy ' + name + '.so to local directory')
|
951
|
props['multilib']['lib32']['srcs'] = name + r'_32/' + name + r'.so'
|
952
|
|
953
|
|
954
|
dst64 = dst + r'/' + name + r'_64/'
|
955
|
if not copyBinSrc(dst64, r'SHARED_LIBRARIES_64', name):
|
956
|
print('FAILED to copy ' + name + '.so to local directory')
|
957
|
props['multilib']['lib64']['srcs'] = name + r'_64/' + name + r'.so'
|
958
|
writeBp(clazz, props, bp)
|
959
|
|
960
|
elif clazz == 'cc_prebuilt_library_static':
|
961
|
props['srcs'] = ''
|
962
|
dst32 = dst + r'/' + name + r'_32/'
|
963
|
dst64 = dst + r'/' + name + r'_64/'
|
964
|
|
965
|
|
966
|
if not copyBinSrc(dst32, r'STATIC_LIBRARIES_32', name):
|
967
|
print('FAILED to copy ' + name + '.a to local directory')
|
968
|
props['multilib']['lib32']['srcs'] = name + r'_32/' + name + r'.a'
|
969
|
|
970
|
|
971
|
if not copyBinSrc(dst64, r'STATIC_LIBRARIES_64', name):
|
972
|
print('FAILED to copy ' + name + '.a to local directory')
|
973
|
props['multilib']['lib64']['srcs'] = name + r'_64/' + name + r'.a'
|
974
|
writeBp(clazz, props, bp)
|
975
|
|
976
|
elif clazz == 'prebuilt_java_library':
|
977
|
props['srcs'] = ''
|
978
|
if not copyBinSrc(dst, r'JAVA_LIBRARIES', name):
|
979
|
print('FAILED to copy ' + name + '.jar to local directory')
|
980
|
else:
|
981
|
os.system('mv %s/javalib.jar %s/%s'%(bp_dir, bp_dir, name + r'.jar'))
|
982
|
props['srcs'] = '["' + name + r'.jar' + '"],'
|
983
|
writeBp(clazz, props, bp)
|
984
|
|
985
|
elif clazz == 'cc_prebuilt_binary':
|
986
|
if not copyBinSrc(dst, r'EXECUTABLES', name):
|
987
|
print('FAILED to copy ' + name + ' to local directory')
|
988
|
props['srcs'] = '["' + name + '"],'
|
989
|
writeBp(clazz, props, bp)
|
990
|
|
991
|
elif clazz == 'android_app_import':
|
992
|
if not copyBinSrc(dst, r'APPS', name):
|
993
|
print('FAILED to copy ' + name + ' to local directory')
|
994
|
|
995
|
props['apk'] = '"' + name + '.apk",'
|
996
|
writeBp(clazz, props, bp)
|
997
|
|
998
|
clazz = ''
|
999
|
|
1000
|
if copy == 'true':
|
1001
|
print('line_no_strip_last=%s'%(line_no_strip))
|
1002
|
bp.write(line_no_strip + '\n')
|
1003
|
|
1004
|
|
1005
|
def printUsage():
|
1006
|
print("使用方法:")
|
1007
|
print(('./tool.py --lunch=taro(编译时的lunch选项) --srcdir=/home/somebody/projects/pixel(项目代码根目录) '
|
1008
|
'--sdkdir=/home/somebody/projects/pixel_sdk(SDK将要存放的目录) --copy=y/n --cmpcpy=n/y'))
|
1009
|
|
1010
|
|
1011
|
def getCmdArgs(argv):
|
1012
|
print(argv)
|
1013
|
if argv[1] in ('--help', 'help', '-h', 'h'):
|
1014
|
printUsage()
|
1015
|
sys.exit(0)
|
1016
|
myargs = {'--lunch': '',\
|
1017
|
'--srcdir': '',\
|
1018
|
'--sdkdir': '',\
|
1019
|
'--copy': '',\
|
1020
|
'--cmpcpy': ''\
|
1021
|
}
|
1022
|
try:
|
1023
|
opts, args = getopt.getopt(argv[1:], "h",\
|
1024
|
["lunch=", "srcdir=", "sdkdir=", "copy=", "cmpcpy="])
|
1025
|
except getopt.GetoptError as err:
|
1026
|
print(err)
|
1027
|
printUsage()
|
1028
|
sys.exit(2)
|
1029
|
for k,v in opts:
|
1030
|
myargs[k] = v
|
1031
|
print(myargs)
|
1032
|
for k,v in myargs.items():
|
1033
|
if not v:
|
1034
|
print('ERROR: %s 未指定'%(k))
|
1035
|
printUsage()
|
1036
|
sys.exit(2)
|
1037
|
if myargs['--copy'] == 'y' and myargs['--cmpcpy'] == 'y'\
|
1038
|
or myargs['--copy'] == 'n' and myargs['--cmpcpy'] == 'n':
|
1039
|
print('ERROR: --copy --cmpcpy 不能指定为相同值')
|
1040
|
printUsage()
|
1041
|
sys.exit(2)
|
1042
|
return myargs
|
1043
|
|
1044
|
|
1045
|
|
1046
|
args = getCmdArgs(sys.argv)
|
1047
|
psrc_ap = op.join(args['--srcdir'], 'LINUX/android')
|
1048
|
psrc_product_out = op.join(args['--srcdir'], 'LINUX/android/out/target/product', args['--lunch'])
|
1049
|
psrc_qssi_out = op.join(args['--srcdir'], 'LINUX/android/out/target/product/qssi')
|
1050
|
|
1051
|
|
1052
|
|
1053
|
is_in_target = True
|
1054
|
psdk = args['--sdkdir']
|
1055
|
psdk_vendor_proprietary = op.join(args['--sdkdir'], 'vendor/qcom/proprietary')
|
1056
|
psdk_product_out = op.join(args['--sdkdir'], 'out/target/product', args['--lunch'])
|
1057
|
psdk_qssi_out = op.join(args['--sdkdir'], 'out/target/product/qssi')
|
1058
|
psdk_complete_product_out = op.join(psdk_vendor_proprietary, 'complete_out', args['--lunch'])
|
1059
|
psdk_complete_qssi_out = op.join(psdk_vendor_proprietary, 'complete_out/qssi')
|
1060
|
proprietary_whitelist = ('')
|
1061
|
|
1062
|
with open('PRODUCT_PACKAGES.txt', 'r') as txt:
|
1063
|
build_package = txt.readline()
|
1064
|
|
1065
|
txt.close()
|
1066
|
|
1067
|
|
1068
|
|
1069
|
if args['--lunch'] == 'figure' or args['--lunch'] == 'sdm710':
|
1070
|
proprietary_whitelist = ('common/', 'prebuilt_HY11/', 'llvm-arm-toolchain-ship/',\
|
1071
|
'commonsys-intf/telephony/interfaces/', 'nqnfc-firmware/', 'qrsp/', \
|
1072
|
'camera-devicetree/','devicetree-4.19/', 'audio-devicetree/', 'display-devicetree/', 'video-devicetree/', 'mmrm-devicetree', 'cvp-devicetree', \
|
1073
|
'resource-overlay/', 'interfaces/', 'sectools/', 'techpack/artifacts/camera/', 'qcril-qmi-services-headers/',\
|
1074
|
'sensors-see/USTA/native/power_scripts/'
|
1075
|
)
|
1076
|
|
1077
|
platform_whitelist = (
|
1078
|
'resource-overlay/kona/'
|
1079
|
)
|
1080
|
|
1081
|
whitelist = list()
|
1082
|
for item in proprietary_whitelist:
|
1083
|
whitelist.append(psdk_vendor_proprietary + r'/' + item)
|
1084
|
|
1085
|
|
1086
|
localpath_list = (op.join(psdk_vendor_proprietary, r'chi-cdk/'), op.join(psdk_vendor_proprietary, r'camx/'))
|
1087
|
print('--psrc_ap=%s------\n\n'%(psrc_ap))
|
1088
|
if args['--copy'] == 'y':
|
1089
|
|
1090
|
if not op.isdir(args['--sdkdir']):
|
1091
|
if os.system('mkdir -p %s'%(psdk)):
|
1092
|
print('FAILED to create SDK dir %s'%(psdk))
|
1093
|
sys.exit(1)
|
1094
|
else:
|
1095
|
|
1096
|
print(psdk_vendor_proprietary)
|
1097
|
for d in os.listdir(psrc_ap):
|
1098
|
if (d != 'out'):
|
1099
|
if os.system('cp -rf %s/%s %s'%(psrc_ap, d, psdk)):
|
1100
|
print('FAILED to copy %s/%s to %s'%(psrc_ap, d, psdk))
|
1101
|
|
1102
|
|
1103
|
os.system('mkdir -p %s'%(op.join(psdk_complete_qssi_out, r'obj')))
|
1104
|
os.system('mkdir -p %s'%(op.join(psdk_complete_product_out, r'obj')))
|
1105
|
os.system('cp -r %s %s'%(op.join(psrc_qssi_out, r'obj/include'), op.join(psdk_complete_qssi_out, r'obj/')))
|
1106
|
os.system('cp -r %s %s'%(op.join(psrc_product_out, r'obj/include'), op.join(psdk_complete_product_out, r'obj/')))
|
1107
|
|
1108
|
|
1109
|
|
1110
|
with open(op.join(psdk_complete_product_out, r'../Android.mk'), 'w') as mf:
|
1111
|
s = ('LOCAL_PATH := $(call my-dir)\nPREBUILT_DIR_PATH := $(LOCAL_PATH)\n'
|
1112
|
'$(shell mkdir $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor $(PRODUCT_OUT)/persist $(PRODUCT_OUT)/obj)\n'
|
1113
|
'$(shell cp -r $(LOCAL_PATH)/' + args['--lunch'] + '/system/* $(PRODUCT_OUT)/system)\n'
|
1114
|
'$(shell cp -r $(LOCAL_PATH)/' + args['--lunch'] + '/vendor/* $(PRODUCT_OUT)/vendor)\n'
|
1115
|
'$(shell cp -r $(LOCAL_PATH)/' + args['--lunch'] + '/persist/* $(PRODUCT_OUT)/persist)\n'
|
1116
|
'$(shell cp -r $(LOCAL_PATH)/' + args['--lunch'] + '/obj/include $(PRODUCT_OUT)/obj)\n'
|
1117
|
'$(shell mkdir $(PRODUCT_OUT)/../qssi/system $(PRODUCT_OUT)/../qssi/vendor $(PRODUCT_OUT)/../qssi/persist $(PRODUCT_OUT)/../qssi/product $(PRODUCT_OUT)/../qssi/obj)\n'
|
1118
|
'$(shell cp -r $(LOCAL_PATH)/qssi/system/* $(PRODUCT_OUT)/../qssi/system)\n'
|
1119
|
'$(shell cp -r $(LOCAL_PATH)/qssi/vendor/* $(PRODUCT_OUT)/../qssi/vendor)\n'
|
1120
|
'$(shell cp -r $(LOCAL_PATH)/qssi/persist/* $(PRODUCT_OUT)/../qssi/persist)\n'
|
1121
|
'$(shell cp -r $(LOCAL_PATH)/qssi/product/* $(PRODUCT_OUT)/../qssi/product)\n'
|
1122
|
'$(shell cp -r $(LOCAL_PATH)/qssi/obj/include $(PRODUCT_OUT)/../qssi/obj)\n')
|
1123
|
mf.write(s)
|
1124
|
|
1125
|
|
1126
|
|
1127
|
print('=======psdk_vendor_proprietary=%s==========\n\n'%(psdk_vendor_proprietary))
|
1128
|
for root, dirs, files in os.walk(psdk_vendor_proprietary):
|
1129
|
root_path = root + r'/'
|
1130
|
if not root_path.startswith(tuple(whitelist)):
|
1131
|
for f in files:
|
1132
|
if f == 'Android.mk':
|
1133
|
|
1134
|
print('\n\n%s'%(op.join(root, f)))
|
1135
|
if not os.system('resc %s'%(root)):
|
1136
|
if not root_path.startswith(tuple(localpath_list)):
|
1137
|
parseAndroidMK('myAndroid.mk', root)
|
1138
|
else:
|
1139
|
parseAndroidMK('myAndroid.mk', root, True)
|
1140
|
os.system('mv %s/Android.mk %s/Android.mk.bak'%(root, root))
|
1141
|
os.system('mv %s/newAndroid.mk %s/Android.mk'%(root, root))
|
1142
|
os.system('rm %s/myAndroid.mk'%(root))
|
1143
|
|
1144
|
|
1145
|
|
1146
|
else:
|
1147
|
print('resc %s failed'%(op.join(root, f)))
|
1148
|
if f == 'Android.bp':
|
1149
|
|
1150
|
|
1151
|
print('\n\n===parseAndroidBP===\n%s\n'%(op.join(root, f)))
|
1152
|
parseAndroidBP(f, root)
|
1153
|
os.system('mv %s/Android.bp %s/Android.bp.bak'%(root, root))
|
1154
|
os.system('mv %s/newAndroid.bp %s/Android.bp'%(root, root))
|
1155
|
|
1156
|
print("+++++++++++++++++++ dulei ++++++++++++++++++++++")
|
1157
|
|
1158
|
os.system('cp %s %s'%(op.join(psdk_vendor_proprietary,'commonsys/gps/libs/addon/Android.mk.bak'),\
|
1159
|
op.join(psdk_vendor_proprietary,'commonsys/gps/libs/addon/Android.mk')))
|
1160
|
os.system('cp %s %s'%(op.join(psdk_vendor_proprietary,'data/ipa_fws/Android.mk.bak'),\
|
1161
|
op.join(psdk_vendor_proprietary,'data/ipa_fws/Android.mk')))
|
1162
|
os.system('cp %s %s'%(op.join(psdk_vendor_proprietary,'qcril/qcril_database/Android.mk.bak'),\
|
1163
|
op.join(psdk_vendor_proprietary,'qcril/qcril_database/Android.mk')))
|
1164
|
os.system('cp %s %s'%(op.join(psdk_vendor_proprietary,'qdssagent/Android.mk.bak'),\
|
1165
|
op.join(psdk_vendor_proprietary,'qdssagent/Android.mk')))
|
1166
|
os.system('cp %s %s'%(op.join(psdk_vendor_proprietary,'sensors-see/registry/Android.mk.bak'),\
|
1167
|
op.join(psdk_vendor_proprietary,'sensors-see/registry/Android.mk')))
|
1168
|
|
1169
|
print("SRC FILES COPIED")
|
1170
|
|
1171
|
if args['--cmpcpy'] == 'y':
|
1172
|
print('coming cmpcpy=y')
|
1173
|
|
1174
|
for top in (op.join(psrc_product_out, 'system'), op.join(psrc_product_out, 'vendor'), op.join(psrc_product_out, 'persist')):
|
1175
|
for root, dirs, files in os.walk(top):
|
1176
|
for f in files:
|
1177
|
f_in_src = op.join(root, f)
|
1178
|
print('f_in_src=%s\n\n'%(f_in_src))
|
1179
|
f_in_sdk = f_in_src.replace(psrc_product_out, psdk_product_out)
|
1180
|
if op.islink(f_in_src):
|
1181
|
continue
|
1182
|
if not op.exists(f_in_sdk):
|
1183
|
dir_in_complete_out = root.replace(psrc_product_out, psdk_complete_product_out)
|
1184
|
if not op.isdir(dir_in_complete_out):
|
1185
|
os.makedirs(dir_in_complete_out)
|
1186
|
os.system('cp %s %s'%(f_in_src, dir_in_complete_out))
|
1187
|
|
1188
|
|
1189
|
for top in (op.join(psrc_qssi_out, 'system'), op.join(psrc_qssi_out, 'vendor'),\
|
1190
|
op.join(psrc_qssi_out, 'persist'), op.join(psrc_qssi_out, 'product')):
|
1191
|
for root, dirs, files in os.walk(top):
|
1192
|
for f in files:
|
1193
|
f_in_src = op.join(root, f)
|
1194
|
print('f_in_src=%s\n\n'%(f_in_src))
|
1195
|
f_in_sdk = f_in_src.replace(psrc_qssi_out, psdk_qssi_out)
|
1196
|
print('f_in_sdk=%s\n\n'%(f_in_sdk))
|
1197
|
if op.islink(f_in_src):
|
1198
|
continue
|
1199
|
if not op.exists(f_in_sdk):
|
1200
|
dir_in_complete_out = root.replace(psrc_qssi_out, psdk_complete_qssi_out)
|
1201
|
if not op.isdir(dir_in_complete_out):
|
1202
|
os.makedirs(dir_in_complete_out)
|
1203
|
os.system('cp %s %s'%(f_in_src, dir_in_complete_out))
|