| 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
|
|
|
|
|