diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-11-20 14:25:23 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-12-04 16:16:00 +0530 |
commit | 17316b2c16cf17ae9692ed2733f776f1082e74e5 (patch) | |
tree | 41d01c05626354750d91813f717eb0083e840acb /gobject/glib-mkenums.in | |
parent | d4cc0b32fd41ef8802b374a6be81f7a38edf2db9 (diff) | |
download | glib-17316b2c16cf17ae9692ed2733f776f1082e74e5.tar.gz |
glib-mkenums: Support reading @rspfiles for arguments
This is needed on Windows where the argument list can exceed the
maximum command-line length when lots of sources are passed to
glib-mkenums.
Diffstat (limited to 'gobject/glib-mkenums.in')
-rwxr-xr-x | gobject/glib-mkenums.in | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in index 985edd2f7..91ad77942 100755 --- a/gobject/glib-mkenums.in +++ b/gobject/glib-mkenums.in @@ -69,6 +69,29 @@ def print_info(msg): print_color(msg, color=Color.GREEN, prefix='INFO') +def get_rspfile_args(rspfile): + ''' + Response files are useful on Windows where there is a command-line character + limit of 8191 because when passing sources as arguments to glib-mkenums this + limit can be exceeded in large codebases. + + There is no specification for response files and each tool that supports it + generally writes them out in slightly different ways, but some sources are: + https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files + https://docs.microsoft.com/en-us/windows/desktop/midl/the-response-file-command + ''' + import shlex + if not os.path.isfile(rspfile): + sys.exit('Response file {!r} does not exist'.format(rspfile)) + try: + with open(rspfile, 'r') as f: + cmdline = f.read() + except OSError as e: + sys.exit('Response file {!r} could not be read: {}' + .format(rspfile, e.strerror)) + return shlex.split(cmdline) + + def write_output(output): global output_stream print(output, file=output_stream) @@ -326,9 +349,17 @@ parser.add_argument('--output', default=None, dest='output') parser.add_argument('--version', '-v', default=False, action='store_true', dest='version', help='Print version information') parser.add_argument('args', nargs='*', - help='Input files') + help='One or more input files, or a single argument @rspfile_path ' + 'pointing to a file that contains the actual arguments') + +# Support reading an rspfile of the form @filename which contains the args +# to be parsed +if len(sys.argv) == 2 and sys.argv[1].startswith('@'): + args = get_rspfile_args(sys.argv[1][1:]) +else: + args = sys.argv[1:] -options = parser.parse_args() +options = parser.parse_args(args) if options.version: print(VERSION_STR) |