diff options
author | Bradley Sepos <[email protected]> | 2019-04-05 05:11:10 -0400 |
---|---|---|
committer | Bradley Sepos <[email protected]> | 2019-04-13 14:05:17 -0400 |
commit | 1f241d8f1a8e1db660c9cc922a2bff87ce09462d (patch) | |
tree | 9821dabf6d207a4f3a014f8e4b116465ad8191b1 /make | |
parent | 0e70205974caf05f0be8dad51fbbcfbf43afa155 (diff) |
make: Further improvements to feature enable/disable in configure.py.
Converts most of configure.py from optparse (deprecated) to argparse. Better fixes #1459.
Diffstat (limited to 'make')
-rw-r--r-- | make/configure.py | 236 | ||||
-rw-r--r-- | make/df-fetch.py | 14 | ||||
-rw-r--r-- | make/df-verify.py | 6 | ||||
-rw-r--r-- | make/lib/hb_distfile.py | 10 |
4 files changed, 141 insertions, 125 deletions
diff --git a/make/configure.py b/make/configure.py index 39ebf46d2..95c4c1b67 100644 --- a/make/configure.py +++ b/make/configure.py @@ -20,8 +20,7 @@ import sys import time from datetime import datetime, timedelta -from optparse import OptionGroup -from optparse import OptionParser +import argparse from sys import stderr from sys import stdout @@ -533,7 +532,6 @@ class IfHost( object ): def __str__( self ): return self.value - ############################################################################### ## ## platform conditional value; loops through list of tuples comparing @@ -656,14 +654,14 @@ class SelectMode( dict ): self.default = None self.mode = self.default - def cli_add_option( self, parser, option ): - parser.add_option( option, default=self.mode, metavar='MODE', + def cli_add_argument( self, parser, option ): + parser.add_argument( option, default=self.mode, metavar='MODE', help='select %s%s: %s' % (self.descr,self.what,self.toString()), - action='callback', callback=self.cli_callback, type='str' ) + action='store_const', const=lambda:'self.cli_callback' ) def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ): if value not in self: - raise optparse.OptionValueError( 'invalid %s%s: %s (choose from: %s)' + raise ArgumentError( 'invalid %s%s: %s (choose from: %s)' % (self.descr,self.what,value,self.toString( True )) ) self.mode = value @@ -928,10 +926,10 @@ class ToolProbe( Action ): elif self.minversion: self.version = VersionProbe( [self.pathname, '--version'], minversion=self.minversion ) - def cli_add_option( self, parser ): - parser.add_option( '--'+self.name, metavar='PROG', + def cli_add_argument( self, parser ): + parser.add_argument( '--'+self.name, metavar='PROG', help='[%s]' % (self.pathname), - action='callback', callback=self.cli_callback, type='str' ) + action='store_const', const=lambda:'self.cli_callback' ) def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ): self.__init__( self.var, value, **self.kwargs ) @@ -1050,10 +1048,10 @@ class SelectTool( Action ): if self.fail: self.msg_end = 'not found' - def cli_add_option( self, parser ): - parser.add_option( '--'+self.name, metavar='MODE', + def cli_add_argument( self, parser ): + parser.add_argument( '--'+self.name, metavar='MODE', help='select %s mode: %s' % (self.name,self.toString()), - action='callback', callback=self.cli_callback, type='str' ) + action='store_const', const=lambda:'self.cli_callback' ) def cli_callback( self, option, opt_str, value, parser, *args, **kwargs ): found = False @@ -1064,7 +1062,7 @@ class SelectTool( Action ): self.run() break if not found: - raise optparse.OptionValueError( 'invalid %s mode: %s (choose from: %s)' + raise ArgumentError( 'invalid %s mode: %s (choose from: %s)' % (self.name,value,self.toString( True )) ) def doc_add( self, doc ): @@ -1256,144 +1254,141 @@ class Option( optparse.Option ): self._conf_record( opt, value ) return optparse.Option.take_action( self, action, dest, opt, value, values, parser ) -def createCLI(): - cli = OptionParser( 'usage: %prog [OPTIONS...] [TARGETS...]' ) - cli.option_class = Option - - cli.description = '' - cli.description += 'Configure %s build system.' % (project.name) +def createCLI( cross = None ): + cli = argparse.ArgumentParser( usage='%s [OPTIONS...] [TARGETS...]' % os.path.basename(__file__), description='Configure %s build system' % project.name ) ## add hidden options - cli.add_option( '--xcode-driver', default='bootstrap', action='store', help=optparse.SUPPRESS_HELP ) + cli.add_argument( '--xcode-driver', default='bootstrap', action='store', help=argparse.SUPPRESS ) ## add general options - cli.add_option( '--force', default=False, action='store_true', help='overwrite existing build config' ) - cli.add_option( '--verbose', default=False, action='store_true', help='increase verbosity' ) + grp = cli.add_argument_group( 'General Options' ) + grp.add_argument( '--force', default=False, action='store_true', help='overwrite existing build config' ) + grp.add_argument( '--verbose', default=False, action='store_true', help='increase verbosity' ) ## add distfile options - grp = OptionGroup( cli, 'Distfile Options' ) - grp.add_option( '--disable-df-fetch', default=False, action='store_true', help='disable distfile downloads' ) - grp.add_option( '--disable-df-verify', default=False, action='store_true', help='disable distfile data verification' ) - grp.add_option( '--df-jobs', default=1, action='store', metavar='N', type='int', help='allow N distfile downloads at once' ) - grp.add_option( '--df-verbose', default=1, action='count', dest='df_verbosity', help='increase distfile tools verbosity' ) - grp.add_option( '--df-accept-url', default=[], action='append', metavar='SPEC', help='accept URLs matching regex pattern' ) - grp.add_option( '--df-deny-url', default=[], action='append', metavar='SPEC', help='deny URLs matching regex pattern' ) - cli.add_option_group( grp ) + grp = cli.add_argument_group( 'Distfile Options' ) + grp.add_argument( '--disable-df-fetch', default=False, action='store_true', help='disable distfile downloads' ) + grp.add_argument( '--disable-df-verify', default=False, action='store_true', help='disable distfile data verification' ) + grp.add_argument( '--df-jobs', action='store', metavar='N', type=int, help='allow N distfile downloads at once' ) + grp.add_argument( '--df-verbose', action='count', dest='df_verbosity', help='increase distfile tools verbosity' ) + grp.add_argument( '--df-accept-url', default=[], action='append', metavar='SPEC', help='accept URLs matching regex pattern' ) + grp.add_argument( '--df-deny-url', default=[], action='append', metavar='SPEC', help='deny URLs matching regex pattern' ) + cli.add_argument_group( grp ) ## add install options - grp = OptionGroup( cli, 'Directory Locations' ) - h = IfHost( 'specify sysroot of SDK for Xcode builds', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--sysroot', default=None, action='store', metavar='DIR', + grp = cli.add_argument_group( 'Directory Locations' ) + h = 'specify sysroot of SDK for Xcode builds' if (host.match('*-*-darwin*') and cross is None) else argparse.SUPPRESS + grp.add_argument( '--sysroot', default=None, action='store', metavar='DIR', help=h ) - grp.add_option( '--src', default=cfg.src_dir, action='store', metavar='DIR', + grp.add_argument( '--src', default=cfg.src_dir, action='store', metavar='DIR', help='specify top-level source dir [%s]' % (cfg.src_dir) ) - grp.add_option( '--build', default=cfg.build_dir, action='store', metavar='DIR', + grp.add_argument( '--build', default=cfg.build_dir, action='store', metavar='DIR', help='specify build scratch/output dir [%s]' % (cfg.build_dir) ) - grp.add_option( '--prefix', default=cfg.prefix_dir, action='store', metavar='DIR', + grp.add_argument( '--prefix', default=cfg.prefix_dir, action='store', metavar='DIR', help='specify install dir for products [%s]' % (cfg.prefix_dir) ) - cli.add_option_group( grp ) + cli.add_argument_group( grp ) ## add feature options - grp = OptionGroup( cli, 'Feature Options' ) + grp = cli.add_argument_group( 'Feature Options' ) - h = IfHost( 'enable assembly code in non-contrib modules', 'NOMATCH*-*-darwin*', 'NOMATCH*-*-linux*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-asm', default=False, action='store_true', help=h ) + h = IfHost( 'enable assembly code in non-contrib modules', 'NOMATCH*-*-darwin*', 'NOMATCH*-*-linux*', none=argparse.SUPPRESS ).value + grp.add_argument( '--enable-asm', default=False, action='store_true', help=h ) - h = IfHost( 'disable GTK GUI', '*-*-linux*', '*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--disable-gtk', default=False, action='store_true', help=h ) + h = IfHost( 'disable GTK GUI', '*-*-linux*', '*-*-freebsd*', none=argparse.SUPPRESS ).value + grp.add_argument( '--disable-gtk', default=False, action='store_true', help=h ) - h = IfHost( 'disable GTK GUI update checks', '*-*-linux*', '*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--disable-gtk-update-checks', default=False, action='store_true', help=h ) + h = IfHost( 'disable GTK GUI update checks', '*-*-linux*', '*-*-freebsd*', none=argparse.SUPPRESS ).value + grp.add_argument( '--disable-gtk-update-checks', default=False, action='store_true', help=h ) - h = IfHost( 'enable GTK GUI (mingw)', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-gtk-mingw', default=False, action='store_true', help=h ) + h = 'enable GTK GUI for Windows' if (cross is not None and 'mingw' in cross) else argparse.SUPPRESS + grp.add_argument( '--enable-gtk-mingw', default=False, action='store_true', help=h ) - h = IfHost( 'disable GStreamer (live preview)', '*-*-linux*', '*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--disable-gst', default=False, action='store_true', help=h ) + h = IfHost( 'disable GStreamer (live preview)', '*-*-linux*', '*-*-freebsd*', none=argparse.SUPPRESS ).value + grp.add_argument( '--disable-gst', default=False, action='store_true', help=h ) - h = IfHost( 'Intel Quick Sync Video (QSV) hardware acceleration (Windows and Linux only)', '*-*-linux*', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-qsv', dest="enable_qsv", default=host.match( '*-*-mingw*' ), action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-qsv', dest="enable_qsv", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = IfHost( 'x265 video encoder', '*-*-*', none=argparse.SUPPRESS ).value + grp.add_argument( '--enable-x265', dest="enable_x265", default=True, action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-x265', dest="enable_x265", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - h = IfHost( 'AMD VCE hardware acceleration (Windows only)', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-vce', dest="enable_vce", default=host.match( '*-*-mingw*' ), action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-vce', dest="enable_vce", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = IfHost( 'FDK AAC audio encoder', '*-*-*', none=argparse.SUPPRESS ).value + grp.add_argument( '--enable-fdk-aac', dest="enable_fdk_aac", default=False, action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-fdk-aac', dest="enable_fdk_aac", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - h = IfHost( 'x265 video encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-x265', dest="enable_x265", default=True, action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-x265', dest="enable_x265", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = IfHost( 'FFmpeg AAC audio encoder', '*-*-*', none=argparse.SUPPRESS ).value + grp.add_argument( '--enable-ffmpeg-aac', dest="enable_ffmpeg_aac", default=(cross is not None and 'mingw' in cross) or not host.match( '*-*-darwin*' ), action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-ffmpeg-aac', dest="enable_ffmpeg_aac", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - h = IfHost( 'FDK AAC audio encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-fdk-aac', dest="enable_fdk_aac", default=False, action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-fdk-aac', dest="enable_fdk_aac", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = 'Nvidia NVENC video encoder (Linux and Windows only)' if (host.match('*-*-linux') or (cross is not None and 'mingw' in cross)) else argparse.SUPPRESS + grp.add_argument( '--enable-nvenc', dest="enable_nvenc", default=True if (cross is not None and 'mingw' in cross) else False, action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-nvenc', dest="enable_nvenc", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - h = IfHost( 'FFmpeg AAC audio encoder', '*-*-*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-ffmpeg-aac', dest="enable_ffmpeg_aac", default=not host.match( '*-*-darwin*' ), action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-ffmpeg-aac', dest="enable_ffmpeg_aac", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = 'Intel Quick Sync Video (QSV) hardware acceleration (Linux and Windows only)' if (host.match('*-*-linux') or (cross is not None and 'mingw' in cross)) else argparse.SUPPRESS + grp.add_argument( '--enable-qsv', dest="enable_qsv", default=(cross is not None and 'mingw' in cross), action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-qsv', dest="enable_qsv", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - h = IfHost( 'Nvidia NVEnc video encoder', '*-*-linux', '*-*-mingw', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--enable-nvenc', dest="enable_nvenc", default=host.match( '*-*-mingw*' ), action='store_true', help=(( 'enable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) - grp.add_option( '--disable-nvenc', dest="enable_nvenc", action='store_false', help=(( 'disable %s' %h ) if h != optparse.SUPPRESS_HELP else h) ) + h = 'AMD VCE hardware acceleration (Windows only)' if (cross is not None and 'mingw' in cross) else argparse.SUPPRESS + grp.add_argument( '--enable-vce', dest="enable_vce", default=(cross is not None and 'mingw' in cross), action='store_true', help=(( 'enable %s' %h ) if h != argparse.SUPPRESS else h) ) + grp.add_argument( '--disable-vce', dest="enable_vce", action='store_false', help=(( 'disable %s' %h ) if h != argparse.SUPPRESS else h) ) - cli.add_option_group( grp ) + cli.add_argument_group( grp ) ## add launch options - grp = OptionGroup( cli, 'Launch Options' ) - grp.add_option( '--launch', default=False, action='store_true', + grp = cli.add_argument_group( 'Launch Options' ) + grp.add_argument( '--launch', default=False, action='store_true', help='launch build, capture log and wait for completion' ) - grp.add_option( '--launch-jobs', default=1, action='store', metavar='N', type='int', + grp.add_argument( '--launch-jobs', default=1, action='store', metavar='N', type=int, help='allow N jobs at once; 0 to match CPU count [1]' ) - grp.add_option( '--launch-args', default=None, action='store', metavar='ARGS', + grp.add_argument( '--launch-args', default=None, action='store', metavar='ARGS', help='specify additional ARGS for launch command' ) - grp.add_option( '--launch-quiet', default=False, action='store_true', + grp.add_argument( '--launch-quiet', default=False, action='store_true', help='do not echo build output while waiting' ) - cli.add_option_group( grp ) + cli.add_argument_group( grp ) ## add compile options - grp = OptionGroup( cli, 'Compiler Options' ) - debugMode.cli_add_option( grp, '--debug' ) - optimizeMode.cli_add_option( grp, '--optimize' ) - arch.mode.cli_add_option( grp, '--arch' ) - grp.add_option( '--cross', default=None, action='store', metavar='SPEC', + grp = cli.add_argument_group( 'Compiler Options' ) + debugMode.cli_add_argument( grp, '--debug' ) + optimizeMode.cli_add_argument( grp, '--optimize' ) + arch.mode.cli_add_argument( grp, '--arch' ) + grp.add_argument( '--cross', default=None, action='store', metavar='SPEC', help='specify GCC cross-compilation spec' ) - h = IfHost( 'specify Mac OS X deployment target for Xcode builds', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--minver', default=None, action='store', metavar='VER', + h = IfHost( 'specify Mac OS X deployment target for Xcode builds', '*-*-darwin*', none=argparse.SUPPRESS ).value + grp.add_argument( '--minver', default=None, action='store', metavar='VER', help=h ) - cli.add_option_group( grp ) + cli.add_argument_group( grp ) ## add Xcode options - if host.match( '*-*-darwin*' ): - grp = OptionGroup( cli, 'Xcode Options' ) - grp.add_option( '--disable-xcode', default=False, action='store_true', + if (host.match('*-*-darwin*') and cross is None): + grp = cli.add_argument_group( 'Xcode Options' ) + grp.add_argument( '--disable-xcode', default=False, action='store_true', help='disable Xcode' ) - grp.add_option( '--xcode-prefix', default=cfg.xcode_prefix_dir, action='store', metavar='DIR', + grp.add_argument( '--xcode-prefix', default=cfg.xcode_prefix_dir, action='store', metavar='DIR', help='specify install dir for Xcode products [%s]' % (cfg.xcode_prefix_dir) ) - grp.add_option( '--xcode-symroot', default='xroot', action='store', metavar='DIR', + grp.add_argument( '--xcode-symroot', default='xroot', action='store', metavar='DIR', help='specify root of the directory hierarchy that contains product files and intermediate build files' ) - xcconfigMode.cli_add_option( grp, '--xcode-config' ) - cli.add_option_group( grp ) + xcconfigMode.cli_add_argument( grp, '--xcode-config' ) + cli.add_argument_group( grp ) ## add tool locations - grp = OptionGroup( cli, 'Tool Basenames and Locations' ) + grp = cli.add_argument_group( 'Tool Basenames and Locations' ) for tool in ToolProbe.tools: - tool.cli_add_option( grp ) - cli.add_option_group( grp ) + tool.cli_add_argument( grp ) + cli.add_argument_group( grp ) ## add tool modes - grp = OptionGroup( cli, 'Tool Options' ) + grp = cli.add_argument_group( 'Tool Options' ) for select in SelectTool.selects: - select.cli_add_option( grp ) - cli.add_option_group( grp ) + select.cli_add_argument( grp ) + cli.add_argument_group( grp ) ## add build options - grp = OptionGroup( cli, 'Build Options' ) - grp.add_option( '--snapshot', default=False, action='store_true', + grp = cli.add_argument_group( 'Build Options' ) + grp.add_argument( '--snapshot', default=False, action='store_true', help='Force a snapshot build' ) - h = IfHost( 'Build extra contribs for flatpak packaging', '*-*-linux*', '*-*-freebsd*', none=optparse.SUPPRESS_HELP ).value - grp.add_option( '--flatpak', default=False, action='store_true', help=h ) - cli.add_option_group( grp ) + h = IfHost( 'Build extra contribs for flatpak packaging', '*-*-linux*', '*-*-freebsd*', none=argparse.SUPPRESS ).value + grp.add_argument( '--flatpak', default=False, action='store_true', help=h ) + cli.add_argument_group( grp ) return cli @@ -1579,9 +1574,25 @@ try: xcconfigMode.default = 'native' xcconfigMode.mode = xcconfigMode.default - ## create CLI and parse - cli = createCLI() - (options,args) = cli.parse_args() + # options is created by parse_known_args(), which is called directly after + # createCLI(). we need cross info for createCLI() to set defaults, and + # cannot parse args twice, so extract the info we need here + cross = None + for i in range(len(sys.argv)): + cross_pattern = re.compile( '^--cross=(.*)$' ) + m = cross_pattern.match( sys.argv[i] ) + if m: + cross = sys.argv[i][8:] + continue + cross_pattern = re.compile( '^--cross(.*)$' ) + m = cross_pattern.match( sys.argv[i] ) + if m and (i + 1 < len(sys.argv)): + cross = sys.argv[i+1] + continue + + # create CLI and parse + cli = createCLI( cross ) + options, args = cli.parse_known_args() ## update cfg with cli directory locations cfg.update_cli( options ) @@ -1869,22 +1880,22 @@ int main() doc.add( 'FEATURE.gtk', int( not options.disable_gtk )) # Disable GTK mingw on unsupported platforms - options.enable_gtk_mingw = False if not host.match( '*-*-mingw*' ) else options.enable_gtk_mingw + options.enable_gtk_mingw = False if not build.system == 'mingw' else options.enable_gtk_mingw doc.add( 'FEATURE.gtk.mingw', int( options.enable_gtk_mingw )) doc.add( 'FEATURE.gtk.update.checks', int( not options.disable_gtk_update_checks )) doc.add( 'FEATURE.gst', int( not options.disable_gst )) # Disable NVENC on unsupported platforms - options.enable_nvenc = False if not (host.match( '*-*-linux*' ) or host.match( '*-*-mingw*' )) else options.enable_nvenc + options.enable_nvenc = False if not (build.system == 'linux' or build.system == 'mingw') else options.enable_nvenc doc.add( 'FEATURE.nvenc', int( options.enable_nvenc )) # Disable QSV on unsupported platforms - options.enable_qsv = False if not (host.match( '*-*-linux*' ) or host.match( '*-*-mingw*' )) else options.enable_qsv + options.enable_qsv = False if not (build.system == 'linux' or build.system == 'mingw') else options.enable_qsv doc.add( 'FEATURE.qsv', int( options.enable_qsv )) # Disable VCE on unsupported platforms - options.enable_vce = False if not host.match( '*-*-mingw*' ) else options.enable_vce + options.enable_vce = False if not build.system == 'mingw' else options.enable_vce doc.add( 'FEATURE.vce', int( options.enable_vce )) doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) )) @@ -2003,11 +2014,16 @@ int main() stdout.write( 'Enable FDK-AAC: %s\n' % options.enable_fdk_aac ) stdout.write( 'Enable FFmpeg AAC: %s\n' % options.enable_ffmpeg_aac ) - if IfHost( True, '*-*-linux*', '*-*-mingw*', none=False ).value is True: - stdout.write( 'Enable NVEnc: %s\n' % options.enable_nvenc ) + if build.system == 'linux' or build.system == 'mingw': + stdout.write( 'Enable NVENC: %s\n' % options.enable_nvenc ) stdout.write( 'Enable QSV: %s\n' % options.enable_qsv ) - if IfHost( True, '*-*-mingw*', none=False ).value is True: + else: + stdout.write( 'Enable NVENC: Not supported on target platform\n' ) + stdout.write( 'Enable QSV: Not supported on target platform\n' ) + if build.system == 'mingw': stdout.write( 'Enable VCE: %s\n' % options.enable_vce ) + else: + stdout.write( 'Enable VCE: Not supported on target platform\n' ) if options.launch: stdout.write( '%s\n' % ('-' * 79) ) diff --git a/make/df-fetch.py b/make/df-fetch.py index efdd6e054..9ee48d598 100644 --- a/make/df-fetch.py +++ b/make/df-fetch.py @@ -75,13 +75,13 @@ class Tool(hb_distfile.Tool): self.parser.prog = self.name self.parser.usage = '%prog [OPTIONS] URL...' self.parser.description = 'Fetch and verify distfile data integrity.' - self.parser.add_option('--disable', default=False, action='store_true', help='do nothing and exit with error') - self.parser.add_option('--jobs', default=1, action='store', metavar='N', type='int', help='allow N download jobs at once') - self.parser.add_option('--sha256', default=None, action='store', metavar='HASH', help='verify sha256 HASH against data') - self.parser.add_option('--accept-url', default=[], action='append', metavar='SPEC', help='accept URL regex pattern') - self.parser.add_option('--deny-url', default=[], action='append', metavar='SPEC', help='deny URL regex pattern') - self.parser.add_option('--exhaust-url', default=None, action='store_true', help='try all active distfiles') - self.parser.add_option('--output', default=None, action='store', metavar='FILE', help='write to FILE') + self.parser.add_argument('--disable', default=False, action='store_true', help='do nothing and exit with error') + self.parser.add_argument('--jobs', default=1, action='store', metavar='N', help='allow N download jobs at once') + self.parser.add_argument('--sha256', default=None, action='store', metavar='HASH', help='verify sha256 HASH against data') + self.parser.add_argument('--accept-url', default=[], action='append', metavar='SPEC', help='accept URL regex pattern') + self.parser.add_argument('--deny-url', default=[], action='append', metavar='SPEC', help='deny URL regex pattern') + self.parser.add_argument('--exhaust-url', default=None, action='store_true', help='try all active distfiles') + self.parser.add_argument('--output', default=None, action='store', metavar='FILE', help='write to FILE') self._parse() def _load_config2(self, parser, data): diff --git a/make/df-verify.py b/make/df-verify.py index f370d930a..e37da259d 100644 --- a/make/df-verify.py +++ b/make/df-verify.py @@ -38,8 +38,8 @@ class Tool(hb_distfile.Tool): self.parser.prog = self.name self.parser.usage = '%prog [OPTIONS] FILE' self.parser.description = 'Verify distfile data integrity.' - self.parser.add_option('--disable', default=False, action='store_true', help='do nothing and exit without error') - self.parser.add_option('--sha256', default=None, action='store', metavar='HASH', help='verify sha256 HASH against data') + self.parser.add_argument('--disable', default=False, action='store_true', help='do nothing and exit without error') + self.parser.add_argument('--sha256', default=None, action='store', metavar='HASH', help='verify sha256 HASH against data') self._parse() def _load_config2(self, parser, data): @@ -72,7 +72,7 @@ class Tool(hb_distfile.Tool): if self.options.disable: self.infof('%s failure; administratively disabled.\n' % self.name) sys.exit(0) - if len(self.args) != 1: + if len(self.args) < 1: raise error('no file specified') filename = self.args[0] if self.options.sha256: diff --git a/make/lib/hb_distfile.py b/make/lib/hb_distfile.py index 28b0706a7..80c61fdcb 100644 --- a/make/lib/hb_distfile.py +++ b/make/lib/hb_distfile.py @@ -16,7 +16,7 @@ import string import sys import traceback -from optparse import OptionParser +import argparse ############################################################################### @@ -28,12 +28,12 @@ class Tool(object): def __init__(self): self.name = os.path.splitext(os.path.basename(sys.argv[0]))[0] - self.parser = OptionParser() - self.parser.add_option('-v', '--verbose', default=Tool.LOG_INFO, action='count', dest='verbosity', help='increase verbosity') - self.parser.add_option('--config', default=None, action='callback', metavar='FILE', type='str', callback=self._load_config, help='specify configuration file') + self.parser = argparse.ArgumentParser() + self.parser.add_argument('-v', '--verbose', default=Tool.LOG_INFO, action='count', dest='verbosity', help='increase verbosity') + self.parser.add_argument('--config', default=None, action='store_const', metavar='FILE', const=lambda:'self._load_config', help='specify configuration file') def _parse(self): - (self.options,self.args) = self.parser.parse_args() + self.options, self.args = self.parser.parse_known_args() ## be sure not to use any methods referencing self.options as we are still parsing args def _load_config(self, option, opt, value, parser): |