summaryrefslogtreecommitdiff
path: root/testing/framework/TestSCons.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/framework/TestSCons.py')
-rw-r--r--testing/framework/TestSCons.py130
1 files changed, 87 insertions, 43 deletions
diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py
index e415291..2228423 100644
--- a/testing/framework/TestSCons.py
+++ b/testing/framework/TestSCons.py
@@ -15,7 +15,7 @@ attributes defined in this subclass.
# Copyright (c) 2001 - 2019 The SCons Foundation
from __future__ import division, print_function
-__revision__ = "testing/framework/TestSCons.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "testing/framework/TestSCons.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import re
@@ -35,7 +35,7 @@ from TestCmd import PIPE
# here provides some independent verification that what we packaged
# conforms to what we expect.
-default_version = '3.0.5'
+default_version = '3.1.0'
python_version_unsupported = (2, 6, 0)
python_version_deprecated = (2, 7, 0)
@@ -44,7 +44,7 @@ python_version_deprecated = (2, 7, 0)
# line must remain "__ VERSION __" (without the spaces) so the built
# version in build/testing/framework/TestSCons.py contains the actual version
# string of the packages that have been built.
-SConsVersion = '3.0.5'
+SConsVersion = '3.1.0'
if SConsVersion == '__' + 'VERSION' + '__':
SConsVersion = default_version
@@ -682,6 +682,9 @@ class TestSCons(TestCommon):
"""
Initialize with a default external environment that uses a local
Java SDK in preference to whatever's found in the default PATH.
+
+ :param version: if set, match only that version
+ :return: the new env.
"""
if not self.external:
try:
@@ -698,11 +701,11 @@ class TestSCons(TestCommon):
if version:
if sys.platform == 'win32':
patterns = [
- 'C:/Program Files*/Java/jdk%s*/bin'%version,
+ 'C:/Program Files*/Java/jdk*%s*/bin' % version,
]
else:
patterns = [
- '/usr/java/jdk%s*/bin' % version,
+ '/usr/java/jdk%s*/bin' % version,
'/usr/lib/jvm/*-%s*/bin' % version,
'/usr/local/j2sdk%s*/bin' % version,
]
@@ -727,7 +730,10 @@ class TestSCons(TestCommon):
def java_where_includes(self,version=None):
"""
- Return java include paths compiling java jni code
+ Find include path needed for compiling java jni code.
+
+ :param version: if set, match only that version
+ :return: path to java headers
"""
import sys
@@ -761,6 +767,14 @@ class TestSCons(TestCommon):
return result
def java_where_java_home(self, version=None):
+ """
+ Find path to what would be JAVA_HOME.
+
+ SCons does not read JAVA_HOME from the environment, so deduce it.
+
+ :param version: if set, match only that version
+ :return: path where JDK components live
+ """
if sys.platform[:6] == 'darwin':
# osx 10.11, 10.12
home_tool = '/usr/libexec/java_home'
@@ -807,6 +821,12 @@ class TestSCons(TestCommon):
self.skip_test("Could not find Java " + java_bin_name + ", skipping test(s).\n")
def java_where_jar(self, version=None):
+ """
+ Find java archiver jar.
+
+ :param version: if set, match only that version
+ :return: path to jar
+ """
ENV = self.java_ENV(version)
if self.detect_tool('jar', ENV=ENV):
where_jar = self.detect('JAR', 'jar', ENV=ENV)
@@ -821,7 +841,10 @@ class TestSCons(TestCommon):
def java_where_java(self, version=None):
"""
- Return a path to the java executable.
+ Find java executable.
+
+ :param version: if set, match only that version
+ :return: path to the java rutime
"""
ENV = self.java_ENV(version)
where_java = self.where_is('java', ENV['PATH'])
@@ -835,7 +858,10 @@ class TestSCons(TestCommon):
def java_where_javac(self, version=None):
"""
- Return a path to the javac compiler.
+ Find java compiler.
+
+ :param version: if set, match only that version
+ :return: path to javac
"""
ENV = self.java_ENV(version)
if self.detect_tool('javac'):
@@ -851,15 +877,17 @@ class TestSCons(TestCommon):
arguments = '-version',
stderr=None,
status=None)
+ # Note recent versions output version info to stdout instead of stderr
if version:
- if self.stderr().find('javac %s' % version) == -1:
+ verf = 'javac %s' % version
+ if self.stderr().find(verf) == -1 and self.stdout().find(verf) == -1:
fmt = "Could not find javac for Java version %s, skipping test(s).\n"
self.skip_test(fmt % version)
else:
- m = re.search(r'javac (\d\.*\d)', self.stderr())
- # Java 11 outputs this to stdout
+ version_re = r'javac (\d*\.*\d)'
+ m = re.search(version_re, self.stderr())
if not m:
- m = re.search(r'javac (\d\.*\d)', self.stdout())
+ m = re.search(version_re, self.stdout())
if m:
version = m.group(1)
@@ -873,6 +901,16 @@ class TestSCons(TestCommon):
return where_javac, version
def java_where_javah(self, version=None):
+ """
+ Find java header generation tool.
+
+ TODO issue #3347 since JDK10, there is no separate javah command,
+ 'javac -h' is used. We should not return a javah from a different
+ installed JDK - how to detect and what to return in this case?
+
+ :param version: if set, match only that version
+ :return: path to javah
+ """
ENV = self.java_ENV(version)
if self.detect_tool('javah'):
where_javah = self.detect('JAVAH', 'javah', ENV=ENV)
@@ -883,6 +921,12 @@ class TestSCons(TestCommon):
return where_javah
def java_where_rmic(self, version=None):
+ """
+ Find java rmic tool.
+
+ :param version: if set, match only that version
+ :return: path to rmic
+ """
ENV = self.java_ENV(version)
if self.detect_tool('rmic'):
where_rmic = self.detect('RMIC', 'rmic', ENV=ENV)
@@ -905,7 +949,7 @@ class TestSCons(TestCommon):
def Qt_dummy_installation(self, dir='qt'):
# create a dummy qt installation
- self.subdir( dir, [dir, 'bin'], [dir, 'include'], [dir, 'lib'] )
+ self.subdir(dir, [dir, 'bin'], [dir, 'include'], [dir, 'lib'])
self.write([dir, 'bin', 'mymoc.py'], """\
import getopt
@@ -913,23 +957,23 @@ import sys
import re
# -w and -z are fake options used in test/QT/QTFLAGS.py
cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:wz', [])
-output = None
impl = 0
opt_string = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'w')
+ if opt == '-o': outfile = arg
elif opt == '-i': impl = 1
else: opt_string = opt_string + ' ' + opt
-output.write("/* mymoc.py%s */\\n" % opt_string)
-for a in args:
- with open(a, 'r') as f:
- contents = f.read()
- a = a.replace('\\\\', '\\\\\\\\')
- subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }'
- if impl:
- contents = re.sub( r'#include.*', '', contents )
- output.write(contents.replace('Q_OBJECT', subst))
-output.close()
+
+with open(outfile, 'w') as ofp:
+ ofp.write("/* mymoc.py%s */\\n" % opt_string)
+ for a in args:
+ with open(a, 'r') as ifp:
+ contents = ifp.read()
+ a = a.replace('\\\\', '\\\\\\\\')
+ subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }'
+ if impl:
+ contents = re.sub(r'#include.*', '', contents)
+ ofp.write(contents.replace('Q_OBJECT', subst))
sys.exit(0)
""")
@@ -944,7 +988,7 @@ source = None
opt_string = ''
for arg in sys.argv[1:]:
if output_arg:
- output = open(arg, 'w')
+ outfile = arg
output_arg = 0
elif impl_arg:
impl = arg
@@ -958,19 +1002,19 @@ for arg in sys.argv[1:]:
else:
if source:
sys.exit(1)
- source = open(arg, 'r')
- sourceFile = arg
-output.write("/* myuic.py%s */\\n" % opt_string)
-if impl:
- output.write( '#include "' + impl + '"\\n' )
- includes = re.findall('<include.*?>(.*?)</include>', source.read())
- for incFile in includes:
- # this is valid for ui.h files, at least
- if os.path.exists(incFile):
- output.write('#include "' + incFile + '"\\n')
-else:
- output.write( '#include "my_qobject.h"\\n' + source.read() + " Q_OBJECT \\n" )
-output.close()
+ source = sourceFile = arg
+
+with open(outfile, 'w') as ofp, open(source, 'r') as ifp:
+ ofp.write("/* myuic.py%s */\\n" % opt_string)
+ if impl:
+ ofp.write('#include "' + impl + '"\\n')
+ includes = re.findall('<include.*?>(.*?)</include>', ifp.read())
+ for incFile in includes:
+ # this is valid for ui.h files, at least
+ if os.path.exists(incFile):
+ ofp.write('#include "' + incFile + '"\\n')
+ else:
+ ofp.write('#include "my_qobject.h"\\n' + ifp.read() + " Q_OBJECT \\n")
sys.exit(0)
""" )
@@ -983,7 +1027,7 @@ void my_qt_symbol(const char *arg);
#include "../include/my_qobject.h"
#include <stdio.h>
void my_qt_symbol(const char *arg) {
- fputs( arg, stdout );
+ fputs(arg, stdout);
}
""")
@@ -991,9 +1035,9 @@ void my_qt_symbol(const char *arg) {
env = Environment()
import sys
if sys.platform == 'win32':
- env.StaticLibrary( 'myqt', 'my_qobject.cpp' )
+ env.StaticLibrary('myqt', 'my_qobject.cpp')
else:
- env.SharedLibrary( 'myqt', 'my_qobject.cpp' )
+ env.SharedLibrary('myqt', 'my_qobject.cpp')
""")
self.run(chdir = self.workpath(dir, 'lib'),
@@ -1036,7 +1080,7 @@ if ARGUMENTS.get('variant_dir', 0):
else:
sconscript = File('SConscript')
Export("env dup")
-SConscript( sconscript )
+SConscript(sconscript)
""" % (self.QT, self.QT_LIB, self.QT_MOC, self.QT_UIC))