summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorRussel Winder <russel@winder.org.uk>2017-07-02 07:02:35 (GMT)
committerRussel Winder <russel@winder.org.uk>2017-07-02 07:02:35 (GMT)
commit09744e75d75f5b9e83ae00096162497a89d0c7ec (patch)
tree31c8ccaa7d7a80ed8665da0b4078e6acb8199155 /src/engine
parent5c58fce9cf4e0fc3e8d0f44ec9181700f1380092 (diff)
parentfe8669695dad03dfe0c9e8b322d3ec86d8301229 (diff)
downloadSCons-09744e75d75f5b9e83ae00096162497a89d0c7ec.zip
SCons-09744e75d75f5b9e83ae00096162497a89d0c7ec.tar.gz
SCons-09744e75d75f5b9e83ae00096162497a89d0c7ec.tar.bz2
Merge mainline.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/ActionTests.py116
-rw-r--r--src/engine/SCons/Tool/__init__.py2
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.py8
-rw-r--r--src/engine/SCons/Tool/zip.py44
4 files changed, 111 insertions, 59 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 82c5e0e..34d9ffc 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -1428,10 +1428,16 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
def LocalFunc():
pass
- func_matches = [
- b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
- b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
- ]
+ if TestCmd.IS_PY3 and TestCmd.IS_WINDOWS:
+ func_matches = [
+ b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()', # PY 3.6
+ b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()', # PY 3.5
+ ]
+ else:
+ func_matches = [
+ b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
+ b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
+ ]
meth_matches = [
b"1, 1, 0, 0,(),(),(d\000\000S),(),()",
@@ -1590,22 +1596,32 @@ class FunctionActionTestCase(unittest.TestCase):
def LocalFunc():
pass
- func_matches = [
- b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
- b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
+ if TestCmd.IS_PY3 and TestCmd.IS_WINDOWS:
+ func_matches = [
+ b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()', # py 3.6
+ b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()' # py 3.5
+ ]
+ meth_matches = [
+ b'1, 1, 0, 0,(),(),(d\x00S\x00),(),()', # py 3.6
+ b'1, 1, 0, 0,(),(),(d\x00\x00S),(),()', # py 3.5
]
- meth_matches = [
- b"1, 1, 0, 0,(),(),(d\000\000S),(),()",
- b"1, 1, 0, 0,(),(),(d\x00\x00S),(),()",
- ]
+ else:
+ func_matches = [
+ b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
+ b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
+ ]
+
+ meth_matches = [
+ b"1, 1, 0, 0,(),(),(d\000\000S),(),()",
+ b"1, 1, 0, 0,(),(),(d\x00\x00S),(),()",
+ ]
def factory(act, **kw):
return SCons.Action.FunctionAction(act, kw)
a = factory(GlobalFunc)
c = a.get_contents(target=[], source=[], env=Environment())
- # assert c in func_matches, repr(c)
assert c in func_matches, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(f) for f in func_matches])
@@ -1642,7 +1658,7 @@ class FunctionActionTestCase(unittest.TestCase):
lc = LocalClass()
a = factory(lc.LocalMethod)
c = a.get_contents(target=[], source=[], env=Environment())
- assert c in meth_matches, repr(c)
+ assert c in meth_matches, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(f) for f in meth_matches])
def test_strfunction(self):
"""Test the FunctionAction.strfunction() method
@@ -1808,10 +1824,16 @@ class LazyActionTestCase(unittest.TestCase):
def LocalFunc():
pass
- func_matches = [
- b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
- b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
- ]
+ if TestCmd.IS_PY3 and TestCmd.IS_WINDOWS:
+ func_matches = [
+ b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()',
+ b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'
+ ]
+ else:
+ func_matches = [
+ b"0, 0, 0, 0,(),(),(d\000\000S),(),()",
+ b"0, 0, 0, 0,(),(),(d\x00\x00S),(),()",
+ ]
meth_matches = [
b"1, 1, 0, 0,(),(),(d\000\000S),(),()",
@@ -1859,10 +1881,16 @@ class ActionCallerTestCase(unittest.TestCase):
def LocalFunc():
pass
- matches = [
- b"d\000\000S",
- b"d\\x00\\x00S"
- ]
+ if TestCmd.IS_PY3 and TestCmd.IS_WINDOWS:
+ matches = [
+ b'd\x00S\x00',
+ b'd\x00\x00S'
+ ]
+ else:
+ matches = [
+ b"d\000\000S",
+ b"d\\x00\\x00S"
+ ]
af = SCons.Action.ActionFactory(GlobalFunc, strfunc)
ac = SCons.Action.ActionCaller(af, [], {})
@@ -1874,10 +1902,11 @@ class ActionCallerTestCase(unittest.TestCase):
c = ac.get_contents([], [], Environment())
assert c in matches, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(f) for f in matches])
- matches = [
- b'd\000\000S',
- b"d\x00\x00S"
- ]
+ # TODO: Same as above, why redefine?
+ # matches = [
+ # b'd\000\000S',
+ # b"d\x00\x00S"
+ # ]
class LocalActFunc(object):
def __call__(self):
@@ -2044,8 +2073,12 @@ class ObjectContentsTestCase(unittest.TestCase):
return a
c = SCons.Action._function_contents(func1)
- expected = bytearray('3, 3, 0, 0,(),(),(|\x00\x00S),(),()','utf-8')
- assert expected == c, "Got\n"+repr(c)+"\nExpected \n"+repr(expected)+"\n"
+ if TestCmd.IS_PY3 and TestCmd.IS_WINDOWS:
+ expected = [b'3, 3, 0, 0,(),(),(|\x00S\x00),(),()',
+ b'3, 3, 0, 0,(),(),(|\x00\x00S),(),()']
+ else:
+ expected = [b'3, 3, 0, 0,(),(),(|\x00\x00S),(),()']
+ assert c in expected, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(e) for e in expected])
# @unittest.skip("Results vary between py2 and py3, not sure if test makes sense to implement")
@@ -2055,8 +2088,21 @@ class ObjectContentsTestCase(unittest.TestCase):
# See definition above
o = TestClass()
c = SCons.Action._object_contents(o)
- expected = bytearray("(i__main__\nTestClass\np1\n(dp2\nS'a'\nS'a'\nsS'b'\nS'b'\nsb.", 'utf-8')
- assert expected == c, "Got\n" + repr(c) + "\nExpected\n" + repr(expected)
+
+ if TestCmd.IS_PY3:
+ if TestCmd.IS_WINDOWS:
+ expected = [b'ccopy_reg\n_reconstructor\nq\x00(c__main__\nTestClass\nq\x01c__builtin__\nobject\nq\x02Ntq\x03Rq\x04}q\x05(X\x01\x00\x00\x00aq\x06h\x06X\x01\x00\x00\x00bq\x07h\x07ub.', # py 3.6
+ b'ccopy_reg\n_reconstructor\nq\x00(c__main__\nTestClass\nq\x01c__builtin__\nobject\nq\x02Ntq\x03Rq\x04}q\x05(X\x01\x00\x00\x00bq\x06h\x06X\x01\x00\x00\x00aq\x07h\x07ub.', # py 3.5
+ ]
+ else:
+ expected = [b'ccopy_reg\n_reconstructor\nq\x00(c__main__\nTestClass\nq\x01c__builtin__\nobject\nq\x02Ntq\x03Rq\x04}q\x05(X\x01\x00\x00\x00bq\x06h\x06X\x01\x00\x00\x00aq\x07h\x07ub.']
+ else:
+ if TestCmd.IS_WINDOWS:
+ expected = [b'(c__main__\nTestClass\nq\x01oq\x02}q\x03(U\x01aU\x01aU\x01bU\x01bub.']
+ else:
+ expected = [b'(c__main__\nTestClass\nq\x01oq\x02}q\x03(U\x01aU\x01aU\x01bU\x01bub.']
+
+ assert c in expected, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(e) for e in expected])
# @unittest.skip("Results vary between py2 and py3, not sure if test makes sense to implement")
def test_code_contents(self):
@@ -2064,8 +2110,16 @@ class ObjectContentsTestCase(unittest.TestCase):
code = compile("print('Hello, World!')", '<string>', 'exec')
c = SCons.Action._code_contents(code)
- expected = bytearray("0, 0, 0, 0,(N.),(),(d\x00\x00GHd\x01\x00S)", 'utf-8')
- assert expected == c, "Got\n" + repr(c) + "\nExpected\n" + repr(expected)
+ if TestCmd.IS_PY3:
+ if TestCmd.IS_WINDOWS:
+ expected = [b'0, 0, 0, 0,(N.),(X\x05\x00\x00\x00printq\x00.),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)',
+ b'0, 0, 0, 0,(N.),(X\x05\x00\x00\x00printq\x00.),(e\x00\x00d\x00\x00\x83\x01\x00\x01d\x01\x00S)'
+ ]
+ else:
+ expected = [b'0, 0, 0, 0,(N.),(X\x05\x00\x00\x00printq\x00.),(e\x00\x00d\x00\x00\x83\x01\x00\x01d\x01\x00S)']
+ else:
+ expected = [b"0, 0, 0, 0,(N.),(),(d\x00\x00GHd\x01\x00S)"]
+ assert c in expected, "Got\n"+repr(c)+"\nExpected one of \n"+"\n".join([repr(e) for e in expected])
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index f022a1f..1ab43e7 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -228,7 +228,7 @@ class Tool(object):
# Not sure what to do in the case that there already
# exists sys.modules[self.name] but the source file is
# different.. ?
- spec.loader.exec_module(module)
+ module = spec.loader.load_module(spec.name)
sys.modules[found_name] = module
if add_to_scons_tools_namespace:
diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py
index d3ea8ae..d60789d 100644
--- a/src/engine/SCons/Tool/docbook/__init__.py
+++ b/src/engine/SCons/Tool/docbook/__init__.py
@@ -43,6 +43,8 @@ import SCons.Script
import SCons.Tool
import SCons.Util
+
+__debug_tool_location = False
# Get full path to this script
scriptpath = os.path.dirname(os.path.realpath(__file__))
@@ -182,8 +184,12 @@ def __detect_cl_tool(env, chainkey, cdict, cpriority=None):
if cpriority is None:
cpriority = cdict.keys()
for cltool in cpriority:
+ if __debug_tool_location:
+ print("DocBook: Looking for %s"%cltool)
clpath = env.WhereIs(cltool)
if clpath:
+ if __debug_tool_location:
+ print("DocBook: Found:%s"%cltool)
env[chainkey] = clpath
if not env[chainkey + 'COM']:
env[chainkey + 'COM'] = cdict[cltool]
@@ -204,7 +210,7 @@ def _detect(env):
__detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority)
__detect_cl_tool(env, 'DOCBOOK_XMLLINT', xmllint_com)
- __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com)
+ __detect_cl_tool(env, 'DOCBOOK_FOP', fop_com, ['fop','xep','jw'])
#
# Scanners
diff --git a/src/engine/SCons/Tool/zip.py b/src/engine/SCons/Tool/zip.py
index 2613bfc..23d540f 100644
--- a/src/engine/SCons/Tool/zip.py
+++ b/src/engine/SCons/Tool/zip.py
@@ -40,31 +40,23 @@ import SCons.Defaults
import SCons.Node.FS
import SCons.Util
-try:
- import zipfile
- internal_zip = 1
-except ImportError:
- internal_zip = 0
-
-if internal_zip:
- zipcompression = zipfile.ZIP_DEFLATED
- def zip(target, source, env):
- compression = env.get('ZIPCOMPRESSION', 0)
- zf = zipfile.ZipFile(str(target[0]), 'w', compression)
- for s in source:
- if s.isdir():
- for dirpath, dirnames, filenames in os.walk(str(s)):
- for fname in filenames:
- path = os.path.join(dirpath, fname)
- if os.path.isfile(path):
- zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))))
- else:
- zf.write(str(s), os.path.relpath(str(s), str(env.get('ZIPROOT', ''))))
- zf.close()
-else:
- zipcompression = 0
- zip = "$ZIP $ZIPFLAGS ${TARGET.abspath} $SOURCES"
-
+import zipfile
+
+zipcompression = zipfile.ZIP_DEFLATED
+def zip(target, source, env):
+ compression = env.get('ZIPCOMPRESSION', 0)
+ zf = zipfile.ZipFile(str(target[0]), 'w', compression)
+ for s in source:
+ if s.isdir():
+ for dirpath, dirnames, filenames in os.walk(str(s)):
+ for fname in filenames:
+ path = os.path.join(dirpath, fname)
+ if os.path.isfile(path):
+
+ zf.write(path, os.path.relpath(path, str(env.get('ZIPROOT', ''))))
+ else:
+ zf.write(str(s), os.path.relpath(str(s), str(env.get('ZIPROOT', ''))))
+ zf.close()
zipAction = SCons.Action.Action(zip, varlist=['ZIPCOMPRESSION'])
@@ -91,7 +83,7 @@ def generate(env):
env['ZIPROOT'] = SCons.Util.CLVar('')
def exists(env):
- return internal_zip or env.Detect('zip')
+ return True
# Local Variables:
# tab-width:4