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

Unified 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 side-by-side diff with in-line comments
Download patch
« build/linux/unbundle/libxml.gn ('K') | « build/linux/unbundle/libxml.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/unbundle/replace_gn_files.py
diff --git a/build/linux/unbundle/replace_gn_files.py b/build/linux/unbundle/replace_gn_files.py
new file mode 100755
index 0000000000000000000000000000000000000000..b6fad77816b225b3bd7a4781c1c6405d58b7f2d8
--- /dev/null
+++ b/build/linux/unbundle/replace_gn_files.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Replaces GN files in tree with files from here that
+make the build use system libraries.
+"""
+
+from __future__ import print_function
+
+import argparse
+import os
+import shutil
+import sys
+
+
+REPLACEMENTS = {
+ 'libxml': 'third_party/libxml/BUILD.gn',
+}
+
+
+def DoMain(argv):
+ my_dirname = os.path.dirname(__file__)
+ source_tree_root = os.path.abspath(
+ os.path.join(my_dirname, '..', '..', '..'))
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--system-libraries', nargs='*', default=[])
+ parser.add_argument('--undo', action='store_true')
+
+ args = parser.parse_args(argv)
+
+ handled_libraries = set()
+ for lib, path in REPLACEMENTS.items():
+ if lib not in args.system_libraries:
+ continue
+ handled_libraries.add(lib)
+
+ if args.undo:
+ # Restore original file, and also remove the backup.
+ # This is meant to restore the source tree to its original state.
+ os.rename(os.path.join(source_tree_root, path + '.orig'),
+ os.path.join(source_tree_root, path))
+ else:
+ # Create a backup copy for --undo.
+ shutil.copyfile(os.path.join(source_tree_root, path),
+ os.path.join(source_tree_root, path + '.orig'))
+
+ # 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.
+ shutil.copyfile(os.path.join(my_dirname, '%s.gn' % lib),
+ os.path.join(source_tree_root, path))
+
+ unhandled_libraries = set(args.system_libraries) - handled_libraries
+ if unhandled_libraries:
+ print('Unrecognized system libraries requested: %s' % ', '.join(
+ sorted(unhandled_libraries)), file=sys.stderr)
+ return 1
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(DoMain(sys.argv[1:]))
« 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