Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: build/android/gyp/write_build_config.py

Issue 1350363002: Make use of md5_check within write_build_config.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md5-check-3
Patch Set: fix empty libs Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Writes a build_config file. 7 """Writes a build_config file.
8 8
9 The build_config file for a target is a json file containing information about 9 The build_config file for a target is a json file containing information about
10 how to build that target based on the target's dependencies. This includes 10 how to build that target based on the target's dependencies. This includes
(...skipping 14 matching lines...) Expand all
25 a. inputs/deps ensure that the action runs whenever one of the files changes 25 a. inputs/deps ensure that the action runs whenever one of the files changes
26 b. the files are added to the action's depfile 26 b. the files are added to the action's depfile
27 """ 27 """
28 28
29 import optparse 29 import optparse
30 import os 30 import os
31 import sys 31 import sys
32 import xml.dom.minidom 32 import xml.dom.minidom
33 33
34 from util import build_utils 34 from util import build_utils
35 from util import md5_check
35 36
36 import write_ordered_libraries 37 import write_ordered_libraries
37 38
38 class AndroidManifest(object): 39 class AndroidManifest(object):
39 def __init__(self, path): 40 def __init__(self, path):
40 self.path = path 41 self.path = path
41 dom = xml.dom.minidom.parse(path) 42 dom = xml.dom.minidom.parse(path)
42 manifests = dom.getElementsByTagName('manifest') 43 manifests = dom.getElementsByTagName('manifest')
43 assert len(manifests) == 1 44 assert len(manifests) == 1
44 self.manifest = manifests[0] 45 self.manifest = manifests[0]
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 c['jar_path'] for c in all_library_deps 317 c['jar_path'] for c in all_library_deps
317 ] 318 ]
318 } 319 }
319 manifest = AndroidManifest(options.android_manifest) 320 manifest = AndroidManifest(options.android_manifest)
320 deps_info['package_name'] = manifest.GetPackageName() 321 deps_info['package_name'] = manifest.GetPackageName()
321 if not options.tested_apk_config and manifest.GetInstrumentation(): 322 if not options.tested_apk_config and manifest.GetInstrumentation():
322 # This must then have instrumentation only for itself. 323 # This must then have instrumentation only for itself.
323 manifest.CheckInstrumentation(manifest.GetPackageName()) 324 manifest.CheckInstrumentation(manifest.GetPackageName())
324 325
325 library_paths = [] 326 library_paths = []
326 java_libraries_list = [] 327 java_libraries_list_holder = [None]
327 if options.native_libs: 328 libraries = build_utils.ParseGypList(options.native_libs or '[]')
328 libraries = build_utils.ParseGypList(options.native_libs) 329 if libraries:
329 if libraries: 330 def recompute_ordered_libraries():
330 libraries_dir = os.path.dirname(libraries[0]) 331 libraries_dir = os.path.dirname(libraries[0])
331 write_ordered_libraries.SetReadelfPath(options.readelf_path) 332 write_ordered_libraries.SetReadelfPath(options.readelf_path)
332 write_ordered_libraries.SetLibraryDirs([libraries_dir]) 333 write_ordered_libraries.SetLibraryDirs([libraries_dir])
333 all_native_library_deps = ( 334 all_deps = (
334 write_ordered_libraries.GetSortedTransitiveDependenciesForBinaries( 335 write_ordered_libraries.GetSortedTransitiveDependenciesForBinaries(
335 libraries)) 336 libraries))
336 # Create a java literal array with the "base" library names: 337 # Create a java literal array with the "base" library names:
337 # e.g. libfoo.so -> foo 338 # e.g. libfoo.so -> foo
338 java_libraries_list = '{%s}' % ','.join( 339 java_libraries_list_holder[0] = ('{%s}' % ','.join(
339 ['"%s"' % s[3:-3] for s in all_native_library_deps]) 340 ['"%s"' % s[3:-3] for s in all_deps]))
340 library_paths = map( 341 library_paths.extend(
341 write_ordered_libraries.FullLibraryPath, all_native_library_deps) 342 write_ordered_libraries.FullLibraryPath(x) for x in all_deps)
342 343
343 config['native'] = { 344 # This step takes about 600ms on a z620 for chrome_apk, so it's worth
344 'libraries': library_paths, 345 # caching.
345 'java_libraries_list': java_libraries_list 346 md5_check.CallAndRecordIfStale(
346 } 347 recompute_ordered_libraries,
348 record_path=options.build_config + '.nativelibs.md5.stamp',
349 input_paths=libraries,
350 output_paths=[options.build_config])
351 if not library_paths:
352 prev_config = build_utils.ReadJson(options.build_config)
353 java_libraries_list_holder[0] = (
354 prev_config['native']['java_libraries_list'])
355 library_paths.extend(prev_config['native']['libraries'])
356
357 config['native'] = {
358 'libraries': library_paths,
359 'java_libraries_list': java_libraries_list_holder[0],
360 }
347 361
348 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 362 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
349 363
350 if options.depfile: 364 if options.depfile:
351 build_utils.WriteDepfile( 365 build_utils.WriteDepfile(
352 options.depfile, 366 options.depfile,
353 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) 367 deps.AllConfigPaths() + build_utils.GetPythonDependencies())
354 368
355 369
356 if __name__ == '__main__': 370 if __name__ == '__main__':
357 sys.exit(main(sys.argv[1:])) 371 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698