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

Side by Side Diff: build/linux/unbundle/replace_gn_files.py

Issue 1856753003: unbundle: add replace_gn_files.py and unbundled GN file for libxml (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplify Created 4 years, 8 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """
7 Replaces GN files in tree with files from here that
8 make the build use system libraries.
9 """
10
11 from __future__ import print_function
12
13 import argparse
14 import os
15 import shutil
16 import sys
17
18
19 REPLACEMENTS = {
20 'libxml': 'third_party/libxml/BUILD.gn',
21 }
22
23
24 def DoMain(argv):
25 my_dirname = os.path.dirname(__file__)
26 source_tree_root = os.path.abspath(
27 os.path.join(my_dirname, '..', '..', '..'))
28
29 parser = argparse.ArgumentParser()
30 parser.add_argument('--system-libraries', nargs='*', default=[])
31 parser.add_argument('--undo', action='store_true')
32
33 args = parser.parse_args(argv)
34
35 handled_libraries = set()
36 for lib, path in REPLACEMENTS.items():
37 if lib not in args.system_libraries:
38 continue
39 handled_libraries.add(lib)
40
41 if args.undo:
42 # Restore original file, and also remove the backup.
43 # This is meant to restore the source tree to its original state.
44 os.rename(os.path.join(source_tree_root, path + '.orig'),
45 os.path.join(source_tree_root, path))
46 else:
47 # Create a backup copy for --undo.
48 shutil.copyfile(os.path.join(source_tree_root, path),
49 os.path.join(source_tree_root, path + '.orig'))
50
51 # Copy the gyp file from directory of this script to target path.
Lei Zhang 2016/04/04 21:46:28 s/gyp/gn/ ?
Paweł Hajdan Jr. 2016/04/05 13:22:56 Done.
52 shutil.copyfile(os.path.join(my_dirname, '%s.gn' % lib),
53 os.path.join(source_tree_root, path))
54
55 unhandled_libraries = set(args.system_libraries) - handled_libraries
56 if unhandled_libraries:
57 print('Unrecognized system libraries requested: %s' % ', '.join(
58 sorted(unhandled_libraries)), file=sys.stderr)
59 return 1
60
61 return 0
62
63
64 if __name__ == '__main__':
65 sys.exit(DoMain(sys.argv[1:]))
OLDNEW
« build/linux/unbundle/libxml.gn ('K') | « build/linux/unbundle/libxml.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698