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

Unified Diff: build/linux/unbundle/replace_gyp_files.py

Issue 16121002: Linux: make it possible to undo changes made by replace_gyp_files.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/unbundle/replace_gyp_files.py
diff --git a/build/linux/unbundle/replace_gyp_files.py b/build/linux/unbundle/replace_gyp_files.py
index d0b4915d8a2be6dd03c52ed2cfa20c2071860d4c..1436711a8b3708152f1ee0fe88a10c091fa06873 100755
--- a/build/linux/unbundle/replace_gyp_files.py
+++ b/build/linux/unbundle/replace_gyp_files.py
@@ -9,6 +9,7 @@ make the build use system libraries.
"""
+import optparse
import os.path
import shutil
import sys
@@ -44,16 +45,33 @@ def DoMain(argv):
source_tree_root = os.path.abspath(
os.path.join(my_dirname, '..', '..', '..'))
+ parser = optparse.OptionParser()
+
+ # Accept arguments in gyp command-line syntax, so that the caller can re-use
+ # command-line for this script and gyp.
+ parser.add_option('-D', dest='defines', action='append')
+
+ parser.add_option('--undo', action='store_true')
+
+ options, args = parser.parse_args(argv)
+
for flag, path in REPLACEMENTS.items():
- # Accept arguments in gyp command-line syntax, and ignore other
- # parameters, so that the caller can re-use command-line for this
- # script and gyp.
- if '-D%s=1' % flag not in argv:
+ if '%s=1' % flag not in options.defines:
continue
- # Copy the gyp file from directory of this script to target path.
- shutil.copyfile(os.path.join(my_dirname, os.path.basename(path)),
- os.path.join(source_tree_root, path))
+ if options.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.
+ shutil.copyfile(os.path.join(my_dirname, os.path.basename(path)),
+ os.path.join(source_tree_root, path))
return 0
« 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