diff options
author | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-15 16:53:45 +0000 |
---|---|---|
committer | sbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-15 16:53:45 +0000 |
commit | f084f975440a99d4af97993d8b10bb8c9198b127 (patch) | |
tree | 5d779e81ee385530506dbd29b9759436946f1208 /native_client_sdk/src/tools/fix_deps.py | |
parent | e4bf6b7bb5e25b7f21773d18bb8eacd4b24dae3d (diff) | |
download | chromium_src-f084f975440a99d4af97993d8b10bb8c9198b127.zip chromium_src-f084f975440a99d4af97993d8b10bb8c9198b127.tar.gz chromium_src-f084f975440a99d4af97993d8b10bb8c9198b127.tar.bz2 |
[NaCl SDK] Don't reference gcc generated .d files until they have been fixed-up.
The build system in the SDK will now references .deps files which
are generated by fixing up the gcc-generated .d files.
R=noelallen@chromium.org
BUG=259415
Review URL: https://codereview.chromium.org/18618003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src/tools/fix_deps.py')
-rwxr-xr-x | native_client_sdk/src/tools/fix_deps.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/native_client_sdk/src/tools/fix_deps.py b/native_client_sdk/src/tools/fix_deps.py index a10feac..91b4fa7 100755 --- a/native_client_sdk/src/tools/fix_deps.py +++ b/native_client_sdk/src/tools/fix_deps.py @@ -5,10 +5,11 @@ """Fixup GCC-generated dependency files. -Modify GCC generated dependency files in-place so they are more suitable -for including in a GNU Makefile. Without the fixups, deleting or renaming -headers can cause the build to be broken. See: -http://mad-scientist.net/make/autodep.html for more details of the problem. +Modify GCC generated dependency files so they are more suitable for including +in a GNU Makefile. Without the fixups, deleting or renaming headers can cause +the build to be broken. + +See http://mad-scientist.net/make/autodep.html for more details of the problem. """ import os @@ -53,10 +54,13 @@ def ParseLine(line, new_target): return filenames -def FixupDepFile(filename): +def FixupDepFile(filename, output_filename=None): if not os.path.exists(filename): raise Error('File not found: %s' % filename) + if output_filename is None: + output_filename = filename + outlines = [TAG_LINE] deps = [] new_target = True @@ -72,19 +76,30 @@ def FixupDepFile(filename): for dep in deps: outlines.append('%s:\n' % dep) - with open(filename, 'w') as outfile: + with open(output_filename, 'w') as outfile: for line in outlines: outfile.write(line) def main(argv): - usage = "usage: %prog [options] <dep_file ...>" + usage = "usage: %prog [options] <dep_file>" parser = optparse.OptionParser(usage=usage, description=__doc__) - args = parser.parse_args(argv)[1] + parser.add_option('-o', '--output', help='Output filename (defaults to ' + 'input name with .deps extension') + parser.add_option('-c', '--clean', action='store_true', + help='Remove input file after writing output') + options, args = parser.parse_args(argv) if not args: - raise parser.error('expected one or more files as arguments') - for arg in args: - FixupDepFile(arg) + raise parser.error('No input file specified') + if len(args) > 1: + raise parser.error('Only one argument supported') + input_filename = args[0] + output_filename = options.output + if not output_filename: + output_filename = os.path.splitext(input_filename)[0] + '.deps' + FixupDepFile(input_filename, output_filename) + if options.clean and input_filename != output_filename: + os.remove(input_filename) if __name__ == '__main__': |