summaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
authorkonablend <[email protected]>2013-01-25 17:59:50 +0000
committerkonablend <[email protected]>2013-01-25 17:59:50 +0000
commita6c368b69d5b80be655a7264fddec344c0d86b42 (patch)
treed52407179021632c9b819e0682e4ae4206ca8324 /make
parente8eaebade8cd06cec7f8338c122fcb169471308e (diff)
- parse yasm version at configure time
- if version is inadequate, auto enable local yasm git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5202 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'make')
-rw-r--r--make/configure.py105
1 files changed, 101 insertions, 4 deletions
diff --git a/make/configure.py b/make/configure.py
index 3c73d8949..0d9b494cb 100644
--- a/make/configure.py
+++ b/make/configure.py
@@ -818,6 +818,7 @@ class ToolProbe( Action ):
self.name = self.names[0]
self.pretext = self.name
self.pathname = self.names[0]
+ self.minversion = kwargs.get('minversion', None)
def _action( self ):
self.session = []
@@ -832,6 +833,8 @@ class ToolProbe( Action ):
break
if self.fail:
self.msg_end = 'not found'
+ 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',
@@ -847,6 +850,93 @@ class ToolProbe( Action ):
###############################################################################
+###############################################################################
+##
+## version probe: passes --version to command and only cares about first line
+## of output. If probe fails, a default version of '0.0.0' results.
+## The default rexpr is useful for some very simple version strings. A Custom
+## expression would be required for more complex version strings.
+##
+## command = full command and arguments to pipe
+## rexpr = a regular expression which must return named subgroups:
+## name: mandatory. The tool name.
+## svers: mandatory. The whole version tuple to be represented as string.
+## i0: mandatory. First element of version tuple to be parsed as int.
+## i1: optional. Second element of version tuple to be parsed as int.
+## i2: optional. Third element of version tuple to be parsed as int.
+## All matching is case-insensitive.
+## abort = if true configure will exit on probe fail
+## session = result. array of lines (stdout/stderr) from command
+## fail = result. true if probe failed
+## svers = result. string of version tuple
+## ivers = result. int[3] of version tuple
+##
+class VersionProbe( Action ):
+ def __init__( self, command, minversion=None, rexpr=None, abort=False ):
+ super( VersionProbe, self ).__init__( 'version probe', os.path.basename(command[0]), abort )
+ self.command = command
+ self.minversion = minversion
+ if not rexpr:
+ rexpr = '(?P<name>[^.]+)\s+(?P<svers>(?P<i0>\d+)(\.(?P<i1>\d+))?(\.(?P<i2>\d+))?)'
+ self.rexpr = rexpr
+
+ def _action( self ):
+ ## pipe and redirect stderr to stdout; effects communicate result
+ pipe = subprocess.Popen( self.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
+
+ ## read data into memory buffers
+ data = pipe.communicate()
+ self.fail = pipe.returncode != 0
+
+ if data[0]:
+ self.session = data[0].splitlines()
+ else:
+ self.session = []
+
+ self.svers = '0.0.0'
+ self.ivers = [0,0,0]
+
+ try:
+ if not self.fail and self.session and len(self.session):
+ self.fail = True
+ self._parse()
+ self.fail = False
+ self.msg_end = self.svers
+ except Exception, x:
+ self.svers = '0.0.0'
+ self.ivers = [0,0,0]
+ self.msg_end = str(x)
+
+ def _dumpSession( self, printf ):
+ printf( ' + %s\n', ' '.join(self.command) )
+ super( VersionProbe, self )._dumpSession( printf )
+
+ def _parse( self ):
+ mo = re.match( self.rexpr, self.session[0], re.IGNORECASE )
+ md = mo.groupdict()
+ self.svers = md['svers']
+ if 'i0' in md and md['i0']:
+ self.ivers[0] = int(md['i0'])
+ if 'i1' in md and md['i1']:
+ self.ivers[1] = int(md['i1'])
+ if 'i2' in md and md['i2']:
+ self.ivers[2] = int(md['i2'])
+
+ def inadequate( self ):
+ if not self.minversion:
+ return False
+ return self.lesser( self.minversion )
+
+ def lesser( self, ivers ):
+ for i in range(0,3):
+ if self.ivers[i] < ivers[i]:
+ return True
+ elif self.ivers[i] > ivers[i]:
+ return False
+ return False
+
+###############################################################################
+
class SelectTool( Action ):
selects = []
@@ -1281,7 +1371,7 @@ try:
strip = ToolProbe( 'STRIP.exe', 'strip' )
tar = ToolProbe( 'TAR.exe', 'gtar', 'tar' )
wget = ToolProbe( 'WGET.exe', 'wget', abort=False )
- yasm = ToolProbe( 'YASM.exe', 'yasm', abort=False )
+ yasm = ToolProbe( 'YASM.exe', 'yasm', abort=False, minversion=[1,2,0] )
autoconf = ToolProbe( 'AUTOCONF.exe', 'autoconf', abort=False )
automake = ToolProbe( 'AUTOMAKE.exe', 'automake', abort=False )
libtool = ToolProbe( 'LIBTOOL.exe', 'libtool', abort=False )
@@ -1341,12 +1431,19 @@ try:
for action in Action.actions:
action.run()
- ## enable local yasm when yasm probe fails
- if not options.enable_local_yasm and Tools.yasm.fail:
- options.enable_local_yasm = True
+ ## enable local yasm when yasm probe fails or version is too old
+ ## x264 requires 1.2.0+
+ if not options.enable_local_yasm:
+ if Tools.yasm.fail:
+ stdout.write( 'note: enabling local yasm: missing system yasm\n' )
+ options.enable_local_yasm = True
+ elif Tools.yasm.version.inadequate():
+ stdout.write( 'note: enabling local yasm: minimum required version is %s and %s is %s\n' % ('.'.join([str(i) for i in Tools.yasm.version.minversion]),Tools.yasm.pathname,Tools.yasm.version.svers) )
+ options.enable_local_yasm = True
## enable local autotools when any of { autoconf, automake, libtool } probe fails
if not options.enable_local_autotools and (Tools.autoconf.fail or Tools.automake.fail or Tools.libtool.fail):
+ stdout.write( 'note: enabling local autotools\n' )
options.enable_local_autotools = True
if build.system == 'mingw':