summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:06 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:06 +0200
commitefdf3fdbcd2f7654cb8d1209a8b040914437bacd (patch)
tree19f68a3e29675ad73f57f7c639a044290660782f
parent697e33ed224b539a42ff68121f7497f5bbf941b2 (diff)
New upstream version 3.1.0upstream/3.1.0
-rw-r--r--.appveyor.yml2
-rw-r--r--.travis.yml96
-rwxr-xr-xREADME.rst14
-rw-r--r--SConstruct28
-rw-r--r--bin/SConsDoc.py208
-rw-r--r--bin/import-test.py2
-rw-r--r--bin/linecount.py2
-rw-r--r--bin/restore.sh22
-rw-r--r--bin/scons-test.py1
-rw-r--r--bin/update-release-info.py2
-rwxr-xr-xbin/upload-release-files.sh3
-rw-r--r--doc/generated/builders.gen38
-rw-r--r--doc/generated/examples/caching_ex-random_1.xml2
-rw-r--r--doc/generated/examples/troubleshoot_explain1_3.xml2
-rw-r--r--doc/generated/functions.gen34
-rw-r--r--doc/generated/variables.gen11
-rw-r--r--doc/generated/variables.mod2
-rw-r--r--doc/man/scons-time.xml4
-rw-r--r--doc/man/scons.xml16
-rw-r--r--doc/man/sconsign.xml60
-rw-r--r--doc/scons.mod1
-rw-r--r--doc/user/depends.xml11
-rw-r--r--doc/user/less-simple.xml18
-rw-r--r--site_scons/soe_utils.py18
-rwxr-xr-xsrc/Announce.txt2
-rwxr-xr-xsrc/CHANGES.txt98
-rwxr-xr-xsrc/RELEASE.txt98
-rw-r--r--src/engine/MANIFEST.in1
-rw-r--r--src/engine/SCons/Action.py41
-rw-r--r--src/engine/SCons/ActionTests.py36
-rw-r--r--src/engine/SCons/Builder.py25
-rw-r--r--src/engine/SCons/BuilderTests.py28
-rw-r--r--src/engine/SCons/CacheDir.py118
-rw-r--r--src/engine/SCons/CacheDirTests.py2
-rw-r--r--src/engine/SCons/Conftest.py22
-rw-r--r--src/engine/SCons/Debug.py2
-rw-r--r--src/engine/SCons/Defaults.py5
-rw-r--r--src/engine/SCons/DefaultsTests.py8
-rw-r--r--src/engine/SCons/Environment.py70
-rw-r--r--src/engine/SCons/Environment.xml38
-rw-r--r--src/engine/SCons/EnvironmentTests.py83
-rw-r--r--src/engine/SCons/Errors.py6
-rw-r--r--src/engine/SCons/ErrorsTests.py6
-rw-r--r--src/engine/SCons/Executor.py25
-rw-r--r--src/engine/SCons/ExecutorTests.py2
-rw-r--r--src/engine/SCons/Job.py36
-rw-r--r--src/engine/SCons/JobTests.py6
-rw-r--r--src/engine/SCons/Memoize.py2
-rw-r--r--src/engine/SCons/MemoizeTests.py2
-rw-r--r--src/engine/SCons/Node/Alias.py2
-rw-r--r--src/engine/SCons/Node/AliasTests.py2
-rw-r--r--src/engine/SCons/Node/FS.py146
-rw-r--r--src/engine/SCons/Node/FSTests.py714
-rw-r--r--src/engine/SCons/Node/NodeTests.py6
-rw-r--r--src/engine/SCons/Node/Python.py2
-rw-r--r--src/engine/SCons/Node/PythonTests.py2
-rw-r--r--src/engine/SCons/Node/__init__.py98
-rw-r--r--src/engine/SCons/PathList.py2
-rw-r--r--src/engine/SCons/PathListTests.py2
-rw-r--r--src/engine/SCons/Platform/PlatformTests.py55
-rw-r--r--src/engine/SCons/Platform/__init__.py17
-rw-r--r--src/engine/SCons/Platform/__init__.xml11
-rw-r--r--src/engine/SCons/Platform/aix.py2
-rw-r--r--src/engine/SCons/Platform/cygwin.py2
-rw-r--r--src/engine/SCons/Platform/darwin.py13
-rw-r--r--src/engine/SCons/Platform/hpux.py2
-rw-r--r--src/engine/SCons/Platform/irix.py2
-rw-r--r--src/engine/SCons/Platform/mingw.py2
-rw-r--r--src/engine/SCons/Platform/os2.py2
-rw-r--r--src/engine/SCons/Platform/posix.py2
-rw-r--r--src/engine/SCons/Platform/sunos.py2
-rw-r--r--src/engine/SCons/Platform/virtualenv.py2
-rw-r--r--src/engine/SCons/Platform/virtualenvTests.py2
-rw-r--r--src/engine/SCons/Platform/win32.py14
-rw-r--r--src/engine/SCons/SConf.py14
-rw-r--r--src/engine/SCons/SConfTests.py2
-rw-r--r--src/engine/SCons/SConsign.py14
-rw-r--r--src/engine/SCons/SConsignTests.py2
-rw-r--r--src/engine/SCons/Scanner/C.py2
-rw-r--r--src/engine/SCons/Scanner/CTests.py2
-rw-r--r--src/engine/SCons/Scanner/D.py4
-rw-r--r--src/engine/SCons/Scanner/DTests.py2
-rw-r--r--src/engine/SCons/Scanner/Dir.py2
-rw-r--r--src/engine/SCons/Scanner/DirTests.py2
-rw-r--r--src/engine/SCons/Scanner/Fortran.py38
-rw-r--r--src/engine/SCons/Scanner/FortranTests.py137
-rw-r--r--src/engine/SCons/Scanner/IDL.py2
-rw-r--r--src/engine/SCons/Scanner/IDLTests.py2
-rw-r--r--src/engine/SCons/Scanner/LaTeX.py18
-rw-r--r--src/engine/SCons/Scanner/LaTeXTests.py18
-rw-r--r--src/engine/SCons/Scanner/Prog.py2
-rw-r--r--src/engine/SCons/Scanner/ProgTests.py2
-rw-r--r--src/engine/SCons/Scanner/RC.py8
-rw-r--r--src/engine/SCons/Scanner/RCTests.py2
-rw-r--r--src/engine/SCons/Scanner/SWIG.py4
-rw-r--r--src/engine/SCons/Scanner/ScannerTests.py2
-rw-r--r--src/engine/SCons/Scanner/__init__.py4
-rw-r--r--src/engine/SCons/Script/Interactive.py2
-rw-r--r--src/engine/SCons/Script/Main.py36
-rw-r--r--src/engine/SCons/Script/MainTests.py2
-rw-r--r--src/engine/SCons/Script/SConsOptions.py53
-rw-r--r--src/engine/SCons/Script/SConscript.py2
-rw-r--r--src/engine/SCons/Script/SConscriptTests.py2
-rw-r--r--src/engine/SCons/Script/__init__.py2
-rw-r--r--src/engine/SCons/Subst.py8
-rw-r--r--src/engine/SCons/SubstTests.py5
-rw-r--r--src/engine/SCons/Taskmaster.py10
-rw-r--r--src/engine/SCons/TaskmasterTests.py2
-rw-r--r--src/engine/SCons/Tool/386asm.py2
-rw-r--r--src/engine/SCons/Tool/DCommon.py2
-rw-r--r--src/engine/SCons/Tool/FortranCommon.py5
-rw-r--r--src/engine/SCons/Tool/FortranCommonTests.py125
-rw-r--r--src/engine/SCons/Tool/GettextCommon.py58
-rw-r--r--src/engine/SCons/Tool/JavaCommon.py140
-rw-r--r--src/engine/SCons/Tool/JavaCommonTests.py74
-rw-r--r--src/engine/SCons/Tool/MSCommon/__init__.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/arch.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/common.py5
-rw-r--r--src/engine/SCons/Tool/MSCommon/netframework.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/sdk.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py145
-rw-r--r--src/engine/SCons/Tool/MSCommon/vcTests.py180
-rw-r--r--src/engine/SCons/Tool/MSCommon/vs.py15
-rw-r--r--src/engine/SCons/Tool/PharLapCommon.py5
-rw-r--r--src/engine/SCons/Tool/ToolTests.py86
-rw-r--r--src/engine/SCons/Tool/__init__.py96
-rw-r--r--src/engine/SCons/Tool/aixc++.py2
-rw-r--r--src/engine/SCons/Tool/aixcc.py2
-rw-r--r--src/engine/SCons/Tool/aixcxx.py2
-rw-r--r--src/engine/SCons/Tool/aixf77.py2
-rw-r--r--src/engine/SCons/Tool/aixlink.py2
-rw-r--r--src/engine/SCons/Tool/applelink.py2
-rw-r--r--src/engine/SCons/Tool/ar.py2
-rw-r--r--src/engine/SCons/Tool/as.py2
-rw-r--r--src/engine/SCons/Tool/bcc32.py2
-rw-r--r--src/engine/SCons/Tool/c++.py2
-rw-r--r--src/engine/SCons/Tool/cc.py2
-rw-r--r--src/engine/SCons/Tool/clang.py5
-rw-r--r--src/engine/SCons/Tool/clangxx.py5
-rw-r--r--src/engine/SCons/Tool/cvf.py2
-rw-r--r--src/engine/SCons/Tool/cxx.py2
-rw-r--r--src/engine/SCons/Tool/cyglink.py2
-rw-r--r--src/engine/SCons/Tool/default.py2
-rw-r--r--src/engine/SCons/Tool/dmd.py2
-rw-r--r--src/engine/SCons/Tool/docbook/__init__.py182
-rw-r--r--src/engine/SCons/Tool/dvi.py2
-rw-r--r--src/engine/SCons/Tool/dvipdf.py2
-rw-r--r--src/engine/SCons/Tool/dvips.py2
-rw-r--r--src/engine/SCons/Tool/f03.py2
-rw-r--r--src/engine/SCons/Tool/f08.py2
-rw-r--r--src/engine/SCons/Tool/f77.py2
-rw-r--r--src/engine/SCons/Tool/f90.py2
-rw-r--r--src/engine/SCons/Tool/f95.py2
-rw-r--r--src/engine/SCons/Tool/filesystem.py2
-rw-r--r--src/engine/SCons/Tool/fortran.py2
-rw-r--r--src/engine/SCons/Tool/g++.py2
-rw-r--r--src/engine/SCons/Tool/g77.py2
-rw-r--r--src/engine/SCons/Tool/gas.py2
-rw-r--r--src/engine/SCons/Tool/gcc.py2
-rw-r--r--src/engine/SCons/Tool/gdc.py2
-rw-r--r--src/engine/SCons/Tool/gettext_tool.py2
-rw-r--r--src/engine/SCons/Tool/gfortran.py2
-rw-r--r--src/engine/SCons/Tool/gnulink.py2
-rw-r--r--src/engine/SCons/Tool/gs.py2
-rw-r--r--src/engine/SCons/Tool/gxx.py2
-rw-r--r--src/engine/SCons/Tool/hpc++.py2
-rw-r--r--src/engine/SCons/Tool/hpcc.py2
-rw-r--r--src/engine/SCons/Tool/hpcxx.py5
-rw-r--r--src/engine/SCons/Tool/hplink.py2
-rw-r--r--src/engine/SCons/Tool/icc.py2
-rw-r--r--src/engine/SCons/Tool/icl.py2
-rw-r--r--src/engine/SCons/Tool/ifl.py2
-rw-r--r--src/engine/SCons/Tool/ifort.py2
-rw-r--r--src/engine/SCons/Tool/ilink.py2
-rw-r--r--src/engine/SCons/Tool/ilink32.py2
-rw-r--r--src/engine/SCons/Tool/install.py2
-rw-r--r--src/engine/SCons/Tool/intelc.py15
-rw-r--r--src/engine/SCons/Tool/ipkg.py8
-rw-r--r--src/engine/SCons/Tool/jar.py16
-rw-r--r--src/engine/SCons/Tool/javac.py10
-rw-r--r--src/engine/SCons/Tool/javah.py8
-rw-r--r--src/engine/SCons/Tool/latex.py2
-rw-r--r--src/engine/SCons/Tool/ldc.py2
-rw-r--r--src/engine/SCons/Tool/lex.py40
-rw-r--r--src/engine/SCons/Tool/link.py2
-rw-r--r--src/engine/SCons/Tool/linkloc.py2
-rw-r--r--src/engine/SCons/Tool/m4.py2
-rw-r--r--src/engine/SCons/Tool/masm.py2
-rw-r--r--src/engine/SCons/Tool/midl.py2
-rw-r--r--src/engine/SCons/Tool/mingw.py6
-rw-r--r--src/engine/SCons/Tool/msgfmt.py2
-rw-r--r--src/engine/SCons/Tool/msginit.py2
-rw-r--r--src/engine/SCons/Tool/msgmerge.py2
-rw-r--r--src/engine/SCons/Tool/mslib.py11
-rw-r--r--src/engine/SCons/Tool/mslink.py15
-rw-r--r--src/engine/SCons/Tool/mssdk.py2
-rw-r--r--src/engine/SCons/Tool/msvc.py13
-rw-r--r--src/engine/SCons/Tool/msvc.xml1
-rw-r--r--src/engine/SCons/Tool/msvs.py195
-rw-r--r--src/engine/SCons/Tool/msvs.xml38
-rw-r--r--src/engine/SCons/Tool/msvsTests.py181
-rw-r--r--src/engine/SCons/Tool/mwcc.py2
-rw-r--r--src/engine/SCons/Tool/mwld.py2
-rw-r--r--src/engine/SCons/Tool/nasm.py2
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py16
-rw-r--r--src/engine/SCons/Tool/packaging/ipk.py16
-rw-r--r--src/engine/SCons/Tool/packaging/msi.py23
-rw-r--r--src/engine/SCons/Tool/packaging/rpm.py10
-rw-r--r--src/engine/SCons/Tool/packaging/src_tarbz2.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_targz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_tarxz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/src_zip.py2
-rw-r--r--src/engine/SCons/Tool/packaging/tarbz2.py2
-rw-r--r--src/engine/SCons/Tool/packaging/targz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/tarxz.py2
-rw-r--r--src/engine/SCons/Tool/packaging/zip.py2
-rw-r--r--src/engine/SCons/Tool/pdf.py2
-rw-r--r--src/engine/SCons/Tool/pdflatex.py2
-rw-r--r--src/engine/SCons/Tool/pdftex.py2
-rw-r--r--src/engine/SCons/Tool/qt.py35
-rw-r--r--src/engine/SCons/Tool/rmic.py8
-rw-r--r--src/engine/SCons/Tool/rpcgen.py2
-rw-r--r--src/engine/SCons/Tool/rpm.py25
-rw-r--r--src/engine/SCons/Tool/rpmutils.py41
-rw-r--r--src/engine/SCons/Tool/sgiar.py2
-rw-r--r--src/engine/SCons/Tool/sgic++.py2
-rw-r--r--src/engine/SCons/Tool/sgicc.py2
-rw-r--r--src/engine/SCons/Tool/sgicxx.py2
-rw-r--r--src/engine/SCons/Tool/sgilink.py2
-rw-r--r--src/engine/SCons/Tool/sunar.py2
-rw-r--r--src/engine/SCons/Tool/sunc++.py2
-rw-r--r--src/engine/SCons/Tool/suncc.py2
-rw-r--r--src/engine/SCons/Tool/suncxx.py18
-rw-r--r--src/engine/SCons/Tool/sunf77.py2
-rw-r--r--src/engine/SCons/Tool/sunf90.py2
-rw-r--r--src/engine/SCons/Tool/sunf95.py2
-rw-r--r--src/engine/SCons/Tool/sunlink.py2
-rw-r--r--src/engine/SCons/Tool/swig.py5
-rw-r--r--src/engine/SCons/Tool/tar.py2
-rw-r--r--src/engine/SCons/Tool/tex.py4
-rw-r--r--src/engine/SCons/Tool/textfile.py2
-rw-r--r--src/engine/SCons/Tool/tlib.py2
-rw-r--r--src/engine/SCons/Tool/wix.py2
-rw-r--r--src/engine/SCons/Tool/wixTests.py2
-rw-r--r--src/engine/SCons/Tool/xgettext.py55
-rw-r--r--src/engine/SCons/Tool/yacc.py56
-rw-r--r--src/engine/SCons/Tool/zip.py2
-rw-r--r--src/engine/SCons/Util.py102
-rw-r--r--src/engine/SCons/UtilTests.py63
-rw-r--r--src/engine/SCons/Variables/BoolVariable.py2
-rw-r--r--src/engine/SCons/Variables/BoolVariableTests.py2
-rw-r--r--src/engine/SCons/Variables/EnumVariable.py4
-rw-r--r--src/engine/SCons/Variables/EnumVariableTests.py2
-rw-r--r--src/engine/SCons/Variables/ListVariable.py4
-rw-r--r--src/engine/SCons/Variables/ListVariableTests.py2
-rw-r--r--src/engine/SCons/Variables/PackageVariable.py2
-rw-r--r--src/engine/SCons/Variables/PackageVariableTests.py2
-rw-r--r--src/engine/SCons/Variables/PathVariable.py2
-rw-r--r--src/engine/SCons/Variables/PathVariableTests.py2
-rw-r--r--src/engine/SCons/Variables/VariablesTests.py2
-rw-r--r--src/engine/SCons/Variables/__init__.py8
-rw-r--r--src/engine/SCons/Warnings.py10
-rw-r--r--src/engine/SCons/WarningsTests.py2
-rw-r--r--src/engine/SCons/__init__.py12
-rw-r--r--src/engine/SCons/compat/__init__.py27
-rw-r--r--src/engine/SCons/compat/_scons_dbm.py2
-rw-r--r--src/engine/SCons/cpp.py6
-rw-r--r--src/engine/SCons/cppTests.py2
-rw-r--r--src/engine/SCons/exitfuncs.py2
-rw-r--r--src/script/scons-configure-cache.py12
-rw-r--r--src/script/scons-time.py81
-rw-r--r--src/script/scons.bat4
-rwxr-xr-xsrc/script/scons.py12
-rw-r--r--src/script/sconsign.py110
-rwxr-xr-xsrc/setup.py4
-rw-r--r--src/test_files.py2
-rw-r--r--src/test_interrupts.py5
-rw-r--r--src/test_pychecker.py5
-rw-r--r--src/test_setup.py35
-rw-r--r--src/test_strings.py7
-rw-r--r--testing/framework/README.txt2
-rw-r--r--testing/framework/SConscript13
-rw-r--r--testing/framework/TestCmd.py165
-rw-r--r--testing/framework/TestCmdTests.py543
-rw-r--r--testing/framework/TestRuntest.py4
-rw-r--r--testing/framework/TestSCons.py130
-rw-r--r--testing/framework/TestSConsMSVS.py678
-rw-r--r--testing/framework/TestSCons_time.py5
-rw-r--r--testing/framework/TestSConsign.py2
289 files changed, 4099 insertions, 3050 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index cbf7233..d2c63cb 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -217,7 +217,7 @@ build_script:
# Windows run the tests
# NOTE: running powershell from cmd on purpose because it formats the output
# correctly
- - cmd: powershell -Command "& { if($env:COVERAGE -eq 1) { coverage run -p --rcfile=$($env:COVERAGE_PROCESS_START) runtest.py --exclude-list exclude_list.txt -f build_tests.txt } else { C:\\%WINPYTHON%\\python.exe runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt }; if($LastExitCode -eq 2 -Or $LastExitCode -eq 0) { $host.SetShouldExit(0 )} else {$host.SetShouldExit(1)}}"
+ - cmd: powershell -Command "& { if($env:COVERAGE -eq 1) { coverage run -p --rcfile=$($env:COVERAGE_PROCESS_START) runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt } else { C:\\%WINPYTHON%\\python.exe runtest.py -j 2 --exclude-list exclude_list.txt -f build_tests.txt }; if($LastExitCode -eq 2 -Or $LastExitCode -eq 0) { $host.SetShouldExit(0 )} else {$host.SetShouldExit(1)}}"
# linux run the tests
# unset JAVA_TOOL_OPTIONS because newer java prints this to stderr
diff --git a/.travis.yml b/.travis.yml
index a8cb940..8a55575 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,23 @@
dist: trusty
language: python
+# Used: travis encrypt "chat.freenode.net#scons" --add notifications.irc
notifications:
- irc: "chat.freenode.net#scons"
+ irc:
+ secure: TTb+41Bj1qIUc6vj+kDqBME8H3lqXdAe1RWAjjz5hL7bzFah6qCBHNJn4DwzqYs6+Pwuwp+6wFy8hgmQttJnXve4h6GtjtvlWprDqxaC7RkFqMWFDBzDalgbB54Bi4+TTZmSJ1K/duI3LrDaN873nyn+2GBnj+3TiNtgURp1fsJMpPxXJzAsoC8UthEsbx0Zkoal/WF+IfsT2q1yQRmAwB9r/drbahx/FfL16r1QjDbI9y1fKvN5J3PirLUvxtHfuH1r8zq1vlLew2fvldgVRtFv7+Lsk2waG/eiRpMf94V5JWP1rNreV/i4AUbZaTLb3bkrhtvTjSKhvx69Ydm+ygXdRgWOD/KRgqpLNAfA+t/a2J1R++89svQI4dPBpQjlfua1elcDCFddeIslgnjDUPO23Y0o7tHAy8sWkwhTcZH1Wm42uJP6Z6tHTH6+dMLvvZpkq4RUKUcrXvoUvCsVlWMGjcsBX+AEQSFGDJnLtLehO9x0QbgVga/IRKjgpDWgQDZgro3AkGg/zzVj5uFRUoU+rbmEXq9feh5i3HfExAvA3UoEtnQ6uadDyWqtQcLRFmPSWDU82CO+sanGdFL0jBjigE8ubPObzxEAz3Fg1xk56OYBkAdEd+2KEzeO1nqJmrhsnc3c/3+b1cBvaL5ozW4XB4XcWsOi268SoiBrcBo=
addons:
- apt:
- update: true
+ apt:
+ update: true
os:
- linux
install:
- - ./.travis/install.sh
+ # needed for Docbook tests, must be in virtualenv context
+ - pip install lxml==4.3.3
+ # do the rest of the image setup
+ - ./.travis/install.sh
# pypy is not passing atm, but still report build success for now
# allow coverage to fail, so we can still do testing for all platforms
@@ -27,58 +32,73 @@ stages:
- Coverage
- Test
+# Note: Travis does not provide a way to specify the order of
+# jobs within a Stage, which are "run in parallel", but with
+# limitations: from observation four or five are kicked
+# off, then additional jobs as initial ones complete.
+# We want the slowest jobs in the first batch since the
+# faster ones are less than half the time of the slowest,
+# we should be able to finish the Test task in the time of the
+# slowest job rather than (a fast job + the slowest job).
+# Putting the pypy jobs first may help with this, though it's
+# apparently not guaranteed.
+
jobs:
include:
- &test_job
stage: Test
- script: python runtest.py -a -t || if [[ $? == 2 ]]; then true; else false; fi
+ script: python runtest.py -a -t -j 2 || if [[ $? == 2 ]]; then true; else false; fi
before_script: skip
after_success: skip
+ python: pypy3
+ env:
+ - PYVER=pypy3
+ - PYTHON=pypy3
+ sudo: required
+
+ - <<: *test_job
+ python: pypy
+ env:
+ - PYVER=pypy
+ - PYTHON=pypy
+ sudo: required
+
+ - <<: *test_job
python: 2.7
- env:
+ env:
- PYVER=27
- PYTHON=2.7
sudo: required
-
+
- <<: *test_job
python: 3.5
- env:
+ env:
- PYVER=35
- PYTHON=3.5
sudo: required
- <<: *test_job
python: 3.6
- env:
+ env:
- PYVER=36
- PYTHON=3.6
sudo: required
- <<: *test_job
python: 3.7
- env:
+ env:
- PYVER=37
- PYTHON=3.7
sudo: required
- dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
+ dist: xenial # required for Python >= 3.7
- - &slow_test_job
- stage: Test
- script: python runtest.py -a -j 4 -t || if [[ $? == 2 ]]; then true; else false; fi
- before_script: skip
- after_success: skip
- python: pypy
- env:
- - PYVER=pypy
- - PYTHON=pypy
- sudo: required
-
- - <<: *slow_test_job
- python: pypy3
- env:
- - PYVER=pypy3
- - PYTHON=pypy3
+ - <<: *test_job
+ python: 3.8-dev
+ env:
+ - PYVER=38
+ - PYTHON=3.8
sudo: required
+ dist: xenial # required for Python >= 3.7
- &coverage_jobs
@@ -109,7 +129,7 @@ jobs:
- echo "import coverage" | sudo tee --append ${PYSITEDIR}/usercustomize.py
- echo "coverage.process_startup()" | sudo tee --append ${PYSITEDIR}/usercustomize.py
- script:
+ script:
- export TOTAL_BUILD_JOBS=4
# write the coverage config file
- export COVERAGE_PROCESS_START=$PWD/.coveragerc
@@ -128,8 +148,8 @@ jobs:
- if (( ${BUILD_JOB_NUM} == ${TOTAL_BUILD_JOBS} )); then end=$(wc -l < all_tests); fi
- if (( ${start} == 0 )); then start=1; fi
- sed -n ${start},${end}p all_tests > build_tests
- - coverage run -p --rcfile=$PWD/.coveragerc runtest.py -f build_tests || if [[ $? == 2 ]]; then true; else false; fi
-
+ - coverage run -p --rcfile=$PWD/.coveragerc runtest.py -f build_tests -j 2 || if [[ $? == 2 ]]; then true; else false; fi
+
after_script:
- coverage combine
- coverage report
@@ -140,48 +160,48 @@ jobs:
#- python$PYTHON -m pip install --user -U coveralls
#- coveralls --rcfile=$PWD/.coveragerc
- env:
+ env:
- PYVER=27
- PYTHON=2.7
- BUILD_JOB_NUM=1
- <<: *coverage_jobs
- env:
+ env:
- PYVER=27
- PYTHON=2.7
- BUILD_JOB_NUM=2
- <<: *coverage_jobs
- env:
+ env:
- PYVER=27
- PYTHON=2.7
- BUILD_JOB_NUM=3
- <<: *coverage_jobs
- env:
+ env:
- PYVER=27
- PYTHON=2.7
- BUILD_JOB_NUM=4
- <<: *coverage_jobs
python: 3.6
- env:
+ env:
- PYVER=36
- PYTHON=3.6
- BUILD_JOB_NUM=1
- <<: *coverage_jobs
python: 3.6
- env:
+ env:
- PYVER=36
- PYTHON=3.6
- BUILD_JOB_NUM=2
- <<: *coverage_jobs
python: 3.6
- env:
+ env:
- PYVER=36
- PYTHON=3.6
- BUILD_JOB_NUM=3
- <<: *coverage_jobs
python: 3.6
- env:
+ env:
- PYVER=36
- PYTHON=3.6
- BUILD_JOB_NUM=4
diff --git a/README.rst b/README.rst
index ea7667c..07be9a9 100755
--- a/README.rst
+++ b/README.rst
@@ -499,13 +499,13 @@ about `Executing SCons Without Installing`_)::
Depending on the utilities installed on your system, any or all of the
following packages will be built::
- build/dist/scons-3.0.5.tar.gz
- build/dist/scons-3.0.5.zip
- build/dist/scons-doc-3.0.5.tar.gz
- build/dist/scons-local-3.0.5.tar.gz
- build/dist/scons-local-3.0.5.zip
- build/dist/scons-src-3.0.5.tar.gz
- build/dist/scons-src-3.0.5.zip
+ build/dist/scons-3.1.0.tar.gz
+ build/dist/scons-3.1.0.zip
+ build/dist/scons-doc-3.1.0.tar.gz
+ build/dist/scons-local-3.1.0.tar.gz
+ build/dist/scons-local-3.1.0.zip
+ build/dist/scons-src-3.1.0.tar.gz
+ build/dist/scons-src-3.1.0.zip
The SConstruct file is supposed to be smart enough to avoid trying to build
packages for which you don't have the proper utilities installed. For
diff --git a/SConstruct b/SConstruct
index 3a14508..10eabe7 100644
--- a/SConstruct
+++ b/SConstruct
@@ -8,7 +8,7 @@ from __future__ import print_function
copyright_years = '2001 - 2019'
# This gets inserted into the man pages to reflect the month of release.
-month_year = 'March 2019'
+month_year = 'July 2019'
#
# Copyright (c) 2001 - 2019 The SCons Foundation
@@ -49,7 +49,7 @@ import textwrap
import bootstrap
project = 'scons'
-default_version = '3.0.5'
+default_version = '3.1.0'
copyright = "Copyright (c) %s The SCons Foundation" % copyright_years
SConsignFile()
@@ -96,14 +96,16 @@ git_status_lines = []
if git:
cmd = "%s ls-files 2> /dev/null" % git
- git_status_lines = os.popen(cmd, "r").readlines()
+ with os.popen(cmd, "r") as p:
+ git_status_lines = p.readlines()
revision = ARGUMENTS.get('REVISION', '')
def generate_build_id(revision):
return revision
if not revision and git:
- git_hash = os.popen("%s rev-parse HEAD 2> /dev/null" % git, "r").read().strip()
+ with os.popen("%s rev-parse HEAD 2> /dev/null" % git, "r") as p:
+ git_hash = p.read().strip()
def generate_build_id(revision):
result = git_hash
if [l for l in git_status_lines if 'modified' in l]:
@@ -206,7 +208,6 @@ packaging_flavors = [
"(including tests and documentation)."),
('src-zip', "A .zip file containing all the source " +
"(including tests and documentation)."),
-
]
test_tar_gz_dir = os.path.join(build_dir, "test-tar-gz")
@@ -551,7 +552,7 @@ for p in [ scons ]:
#
# Now run everything in src_file through the sed command we
- # concocted to expand SConstruct, 3.0.5, etc.
+ # concocted to expand SConstruct, 3.1.0, etc.
#
for b in src_files:
s = p['filemap'].get(b, b)
@@ -575,10 +576,9 @@ for p in [ scons ]:
def write_src_files(target, source, **kw):
global src_files
src_files.sort()
- f = open(str(target[0]), 'w')
- for file in src_files:
- f.write(file + "\n")
- f.close()
+ with open(str(target[0]), 'w') as f:
+ for file in src_files:
+ f.write(file + "\n")
return 0
env.Command(os.path.join(build, 'MANIFEST'),
MANIFEST_in_list,
@@ -667,14 +667,14 @@ for p in [ scons ]:
def Digestify(target, source, env):
import hashlib
src = source[0].rfile()
- contents = open(str(src),'rb').read()
+ with open(str(src),'rb') as f:
+ contents = f.read()
m = hashlib.md5()
m.update(contents)
sig = m.hexdigest()
bytes = os.stat(str(src))[6]
- open(str(target[0]), 'w').write("MD5 %s %s %d\n" % (sig,
- src.name,
- bytes))
+ with open(str(target[0]), 'w') as f:
+ f.write("MD5 %s %s %d\n" % (sig, src.name, bytes))
env.Command(digest, tar_gz, Digestify)
if not zipit:
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index a6654c2..e44a8db 100644
--- a/bin/SConsDoc.py
+++ b/bin/SConsDoc.py
@@ -112,7 +112,6 @@ Tool example:
</tool>
"""
-import imp
import os.path
import re
import sys
@@ -156,8 +155,8 @@ if not has_etree:
except ImportError:
raise ImportError("Failed to import ElementTree from any known place")
-re_entity = re.compile("\&([^;]+);")
-re_entity_header = re.compile("<!DOCTYPE\s+sconsdoc\s+[^\]]+\]>")
+re_entity = re.compile(r"\&([^;]+);")
+re_entity_header = re.compile(r"<!DOCTYPE\s+sconsdoc\s+[^\]]+\]>")
# Namespace for the SCons Docbook XSD
dbxsd="http://www.scons.org/dbxsd/v1.0"
@@ -179,22 +178,21 @@ def isSConsXml(fpath):
contains the default target namespace definition.
"""
try:
- f = open(fpath,'r')
- content = f.read()
- f.close()
+ with open(fpath,'r') as f:
+ content = f.read()
if content.find('xmlns="%s"' % dbxsd) >= 0:
return True
except:
pass
-
- return False
+
+ return False
def remove_entities(content):
# Cut out entity inclusions
content = re_entity_header.sub("", content, re.M)
# Cut out entities themselves
content = re_entity.sub(lambda match: match.group(1), content)
-
+
return content
default_xsd = os.path.join('doc','xsd','scons.xsd')
@@ -202,11 +200,11 @@ default_xsd = os.path.join('doc','xsd','scons.xsd')
ARG = "dbscons"
class Libxml2ValidityHandler:
-
+
def __init__(self):
self.errors = []
self.warnings = []
-
+
def error(self, msg, data):
if data != ARG:
raise Exception("Error handler did not receive correct argument")
@@ -222,14 +220,14 @@ class DoctypeEntity:
def __init__(self, name_, uri_):
self.name = name_
self.uri = uri_
-
+
def getEntityString(self):
txt = """ <!ENTITY %(perc)s %(name)s SYSTEM "%(uri)s">
%(perc)s%(name)s;
""" % {'perc' : perc, 'name' : self.name, 'uri' : self.uri}
return txt
-
+
class DoctypeDeclaration:
def __init__(self, name_=None):
self.name = name_
@@ -242,23 +240,23 @@ class DoctypeDeclaration:
self.addEntity("functions-mod", "functions.mod")
self.addEntity("tools-mod", "tools.mod")
self.addEntity("variables-mod", "variables.mod")
-
+
def addEntity(self, name, uri):
self.entries.append(DoctypeEntity(name, uri))
-
+
def createDoctype(self):
content = '<!DOCTYPE %s [\n' % self.name
for e in self.entries:
content += e.getEntityString()
content += ']>\n'
-
+
return content
if not has_libxml2:
class TreeFactory:
def __init__(self):
pass
-
+
def newNode(self, tag):
return etree.Element(tag)
@@ -269,22 +267,22 @@ if not has_libxml2:
return etree.Element(tag, nsmap=NSMAP)
return etree.Element(tag)
-
+
def copyNode(self, node):
return copy.deepcopy(node)
-
+
def appendNode(self, parent, child):
parent.append(child)
def hasAttribute(self, node, att):
return att in node.attrib
-
+
def getAttribute(self, node, att):
return node.attrib[att]
-
+
def setAttribute(self, node, att, value):
node.attrib[att] = value
-
+
def getText(self, root):
return root.text
@@ -293,30 +291,27 @@ if not has_libxml2:
def writeGenTree(self, root, fp):
dt = DoctypeDeclaration()
- fp.write(etree.tostring(root, xml_declaration=True,
- encoding="UTF-8", pretty_print=True,
+ fp.write(etree.tostring(root, xml_declaration=True,
+ encoding="UTF-8", pretty_print=True,
doctype=dt.createDoctype()))
def writeTree(self, root, fpath):
- fp = open(fpath, 'w')
- fp.write(etree.tostring(root, xml_declaration=True,
- encoding="UTF-8", pretty_print=True))
- fp.close()
+ with open(fpath, 'w') as fp:
+ fp.write(etree.tostring(root, xml_declaration=True,
+ encoding="UTF-8", pretty_print=True))
def prettyPrintFile(self, fpath):
- fin = open(fpath,'r')
- tree = etree.parse(fin)
- pretty_content = etree.tostring(tree, pretty_print=True)
- fin.close()
-
- fout = open(fpath,'w')
- fout.write(pretty_content)
- fout.close()
+ with open(fpath,'r') as fin:
+ tree = etree.parse(fin)
+ pretty_content = etree.tostring(tree, pretty_print=True)
+
+ with open(fpath,'w') as fout:
+ fout.write(pretty_content)
def decorateWithHeader(self, root):
root.attrib["{"+xsi+"}schemaLocation"] = "%s %s/scons.xsd" % (dbxsd, dbxsd)
return root
-
+
def newXmlTree(self, root):
""" Return a XML file tree with the correct namespaces set,
the element root as top entry and the given header comment.
@@ -325,7 +320,7 @@ if not has_libxml2:
'xsi' : xsi}
t = etree.Element(root, nsmap=NSMAP)
return self.decorateWithHeader(t)
-
+
def validateXml(self, fpath, xmlschema_context):
# Use lxml
xmlschema = etree.XMLSchema(xmlschema_context)
@@ -362,21 +357,21 @@ if not has_libxml2:
current XML toolkit.
"""
return [root]
-
-else:
+
+else:
class TreeFactory:
def __init__(self):
pass
-
+
def newNode(self, tag):
return libxml2.newNode(tag)
def newEtreeNode(self, tag, init_ns=False):
return etree.Element(tag)
-
+
def copyNode(self, node):
return node.copyNode(1)
-
+
def appendNode(self, parent, child):
if hasattr(parent, 'addChild'):
parent.addChild(child)
@@ -387,7 +382,7 @@ else:
if hasattr(node, 'hasProp'):
return node.hasProp(att)
return att in node.attrib
-
+
def getAttribute(self, node, att):
if hasattr(node, 'prop'):
return node.prop(att)
@@ -398,7 +393,7 @@ else:
node.setProp(att, value)
else:
node.attrib[att] = value
-
+
def getText(self, root):
if hasattr(root, 'getContent'):
return root.getContent()
@@ -426,20 +421,18 @@ else:
doc.freeDoc()
def writeTree(self, root, fpath):
- fp = open(fpath, 'w')
- doc = libxml2.newDoc('1.0')
- doc.setRootElement(root)
- fp.write(doc.serialize("UTF-8", 1))
- doc.freeDoc()
- fp.close()
+ with open(fpath, 'w') as fp:
+ doc = libxml2.newDoc('1.0')
+ doc.setRootElement(root)
+ fp.write(doc.serialize("UTF-8", 1))
+ doc.freeDoc()
def prettyPrintFile(self, fpath):
# Read file and resolve entities
doc = libxml2.readFile(fpath, None, libxml2d.XML_PARSE_NOENT)
- fp = open(fpath, 'w')
- # Prettyprint
- fp.write(doc.serialize("UTF-8", 1))
- fp.close()
+ with open(fpath, 'w') as fp:
+ # Prettyprint
+ fp.write(doc.serialize("UTF-8", 1))
# Cleanup
doc.freeDoc()
@@ -448,9 +441,9 @@ else:
ns = root.newNs(dbxsd, None)
xi = root.newNs(xsi, 'xsi')
root.setNs(ns) #put this node in the target namespace
-
+
root.setNsProp(xi, 'schemaLocation', "%s %s/scons.xsd" % (dbxsd, dbxsd))
-
+
return root
def newXmlTree(self, root):
@@ -462,7 +455,7 @@ else:
def validateXml(self, fpath, xmlschema_context):
retval = True
-
+
# Create validation context
validation_context = xmlschema_context.schemaNewValidCtxt()
# Set error/warning handlers
@@ -472,18 +465,18 @@ else:
doc = libxml2.readFile(fpath, None, libxml2.XML_PARSE_NOENT)
doc.xincludeProcessFlags(libxml2.XML_PARSE_NOENT)
err = validation_context.schemaValidateDoc(doc)
-
+
if err or eh.errors:
for e in eh.errors:
print(e.rstrip("\n"))
# import pdb; pdb.set_trace()
print("%s fails to validate" % fpath)
retval = False
-
+
# Cleanup
doc.freeDoc()
del validation_context
-
+
return retval
def findAll(self, root, tag, ns=None, xpath_context=None, nsmap=None):
@@ -507,7 +500,7 @@ else:
expression = "./%s/node()" % tag
if ns:
expression = "./%s:%s/node()" % (ns, tag)
-
+
return xpath_context.xpathEval(expression)
else:
expression = "./{%s}%s/node()" % (nsmap[ns], tag)
@@ -537,7 +530,7 @@ else:
if child.tail:
tail = libxml2.newText(child.tail)
elements.append(tail)
-
+
return elements
def convertElementTree(self, root):
@@ -563,7 +556,7 @@ else:
if root.tail:
tail = libxml2.newText(root.tail)
elements.append(tail)
-
+
return elements
tf = TreeFactory()
@@ -604,7 +597,7 @@ class SConsDocTree:
# Register namespaces
for key, val in self.nsmap.items():
self.xpath_context.xpathRegisterNs(key, val)
-
+
def __del__(self):
if self.doc is not None:
self.doc.freeDoc()
@@ -623,7 +616,7 @@ def validate_all_xml(dpaths, xsdfile=default_xsd):
ctxt = libxml2.schemaNewParserCtxt(xsdfile)
xmlschema_context = ctxt.schemaParse()
del ctxt
-
+
fpaths = []
for dp in dpaths:
if dp.endswith('.xml') and isSConsXml(dp):
@@ -636,13 +629,13 @@ def validate_all_xml(dpaths, xsdfile=default_xsd):
fp = os.path.join(path, f)
if isSConsXml(fp):
fpaths.append(fp)
-
+
fails = []
for idx, fp in enumerate(fpaths):
fpath = os.path.join(path, fp)
print("%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)),
perc, idx+1, len(fpaths),fp))
-
+
if not tf.validateXml(fp, xmlschema_context):
fails.append(fp)
continue
@@ -653,7 +646,7 @@ def validate_all_xml(dpaths, xsdfile=default_xsd):
if fails:
return False
-
+
return True
class Item(object):
@@ -734,10 +727,10 @@ class SConsDocHandler(object):
uses.extend(self.parseItems(u, xpath_context, nsmap))
for s in tf.findAll(domelem, "sets", dbxid, xpath_context, nsmap):
sets.extend(self.parseItems(s, xpath_context, nsmap))
-
+
return sorted(uses), sorted(sets)
- def parseInstance(self, domelem, map, Class,
+ def parseInstance(self, domelem, map, Class,
xpath_context, nsmap, include_entities=True):
name = 'unknown'
if tf.hasAttribute(domelem, 'name'):
@@ -761,24 +754,24 @@ class SConsDocHandler(object):
instance.arguments = []
instance.arguments.append(tf.copyNode(a))
- def parseDomtree(self, root, xpath_context=None, nsmap=None, include_entities=True):
+ def parseDomtree(self, root, xpath_context=None, nsmap=None, include_entities=True):
# Process Builders
for b in tf.findAll(root, "builder", dbxid, xpath_context, nsmap):
- self.parseInstance(b, self.builders, Builder,
+ self.parseInstance(b, self.builders, Builder,
xpath_context, nsmap, include_entities)
# Process Functions
for f in tf.findAll(root, "scons_function", dbxid, xpath_context, nsmap):
- self.parseInstance(f, self.functions, Function,
+ self.parseInstance(f, self.functions, Function,
xpath_context, nsmap, include_entities)
# Process Tools
for t in tf.findAll(root, "tool", dbxid, xpath_context, nsmap):
- self.parseInstance(t, self.tools, Tool,
+ self.parseInstance(t, self.tools, Tool,
xpath_context, nsmap, include_entities)
# Process CVars
for c in tf.findAll(root, "cvar", dbxid, xpath_context, nsmap):
- self.parseInstance(c, self.cvars, ConstructionVariable,
+ self.parseInstance(c, self.cvars, ConstructionVariable,
xpath_context, nsmap, include_entities)
-
+
def parseContent(self, content, include_entities=True):
""" Parses the given content as XML file. This method
is used when we generate the basic lists of entities
@@ -799,27 +792,48 @@ class SConsDocHandler(object):
t.parseXmlFile(fpath)
# Parse it
self.parseDomtree(t.root, t.xpath_context, t.nsmap)
-
+
# lifted from Ka-Ping Yee's way cool pydoc module.
-def importfile(path):
- """Import a Python source file or compiled file given its path."""
- magic = imp.get_magic()
- file = open(path, 'r')
- if file.read(len(magic)) == magic:
- kind = imp.PY_COMPILED
- else:
- kind = imp.PY_SOURCE
- file.close()
- filename = os.path.basename(path)
- name, ext = os.path.splitext(filename)
- file = open(path, 'r')
- try:
- module = imp.load_module(name, file, path, (ext, 'r', kind))
- except ImportError as e:
- sys.stderr.write("Could not import %s: %s\n" % (path, e))
- return None
- file.close()
- return module
+if sys.version_info[0] == 2:
+ def importfile(path):
+ """Import a Python source file or compiled file given its path."""
+ import imp
+ magic = imp.get_magic()
+ with open(path, 'r') as ifp:
+ if ifp.read(len(magic)) == magic:
+ kind = imp.PY_COMPILED
+ else:
+ kind = imp.PY_SOURCE
+ filename = os.path.basename(path)
+ name, ext = os.path.splitext(filename)
+ with open(path, 'r') as ifp:
+ try:
+ module = imp.load_module(name, ifp, path, (ext, 'r', kind))
+ except ImportError as e:
+ sys.stderr.write("Could not import %s: %s\n" % (path, e))
+ return None
+ return module
+
+else: # PY3 version, from newer pydoc
+ def importfile(path):
+ """Import a Python source file or compiled file given its path."""
+ import importlib
+ from pydoc import ErrorDuringImport
+ magic = importlib.util.MAGIC_NUMBER
+ with open(path, 'rb') as ifp:
+ is_bytecode = magic == ifp.read(len(magic))
+ filename = os.path.basename(path)
+ name, ext = os.path.splitext(filename)
+ if is_bytecode:
+ loader = importlib._bootstrap_external.SourcelessFileLoader(name, path)
+ else:
+ loader = importlib._bootstrap_external.SourceFileLoader(name, path)
+ # XXX We probably don't need to pass in the loader here.
+ spec = importlib.util.spec_from_file_location(name, path, loader=loader)
+ try:
+ return importlib._bootstrap._load(spec)
+ except:
+ raise ErrorDuringImport(path, sys.exc_info())
# Local Variables:
# tab-width:4
diff --git a/bin/import-test.py b/bin/import-test.py
index 4fc4f06..2290edd 100644
--- a/bin/import-test.py
+++ b/bin/import-test.py
@@ -25,7 +25,7 @@
# """ triple-quotes will need to have their contents edited by hand.
#
-__revision__ = "bin/import-test.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "bin/import-test.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
diff --git a/bin/linecount.py b/bin/linecount.py
index 57a64e2..8f9973f 100644
--- a/bin/linecount.py
+++ b/bin/linecount.py
@@ -23,7 +23,7 @@
# interesting one for most purposes.
from __future__ import division, print_function
-__revision__ = "bin/linecount.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "bin/linecount.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/bin/restore.sh b/bin/restore.sh
index 5fcdb08..c8db2c0 100644
--- a/bin/restore.sh
+++ b/bin/restore.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
#
-# Simple hack script to restore __revision__, __COPYRIGHT_, 3.0.5
+# Simple hack script to restore __revision__, __COPYRIGHT_, 3.1.0
# and other similar variables to what gets checked in to source. This
# comes in handy when people send in diffs based on the released source.
#
@@ -24,7 +24,7 @@ for i in `find $DIRS -name '*.py'`; do
ed $i <<EOF
g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2019 The SCons Foundation/p
w
-/^__revision__ = /s/= .*/= "bin/restore.sh 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"/p
+/^__revision__ = /s/= .*/= "bin/restore.sh e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"/p
w
q
EOF
@@ -35,7 +35,7 @@ for i in `find $DIRS -name 'scons.bat'`; do
ed $i <<EOF
g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2019 The SCons Foundation/p
w
-/^@REM src\/script\/scons.bat/s/@REM .* knight/@REM bin/restore.sh 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog/p
+/^@REM src\/script\/scons.bat/s/@REM .* knight/@REM bin/restore.sh e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan/p
w
q
EOF
@@ -44,15 +44,15 @@ done
for i in `find $DIRS -name '__init__.py' -o -name 'scons.py' -o -name 'sconsign.py'`; do
header $i
ed $i <<EOF
-/^__version__ = /s/= .*/= "3.0.5"/p
+/^__version__ = /s/= .*/= "3.1.0"/p
w
-/^__build__ = /s/= .*/= "103260fce95bf5db1c35fb2371983087d85dd611"/p
+/^__build__ = /s/= .*/= "e724ae812eb96f4858a132f5b8c769724744faf6"/p
w
-/^__buildsys__ = /s/= .*/= "Williams-MBP-2"/p
+/^__buildsys__ = /s/= .*/= "kufra"/p
w
-/^__date__ = /s/= .*/= "2019-07-13 18:25:30"/p
+/^__date__ = /s/= .*/= "2019-07-21 00:04:47"/p
w
-/^__developer__ = /s/= .*/= "bdbaddog"/p
+/^__developer__ = /s/= .*/= "bdeegan"/p
w
q
EOF
@@ -61,7 +61,7 @@ done
for i in `find $DIRS -name 'setup.py'`; do
header $i
ed $i <<EOF
-/^ *version = /s/= .*/= "3.0.5",/p
+/^ *version = /s/= .*/= "3.1.0",/p
w
q
EOF
@@ -72,9 +72,9 @@ for i in `find $DIRS -name '*.txt'`; do
ed $i <<EOF
g/Copyright (c) 2001.*SCons Foundation/s//Copyright (c) 2001 - 2019 The SCons Foundation/p
w
-/# [^ ]* 0.96.[CD][0-9]* [0-9\/]* [0-9:]* knight$/s/.*/# bin/restore.sh 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog/p
+/# [^ ]* 0.96.[CD][0-9]* [0-9\/]* [0-9:]* knight$/s/.*/# bin/restore.sh e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan/p
w
-/Version [0-9][0-9]*\.[0-9][0-9]*/s//Version 3.0.5/p
+/Version [0-9][0-9]*\.[0-9][0-9]*/s//Version 3.1.0/p
w
q
EOF
diff --git a/bin/scons-test.py b/bin/scons-test.py
index dd54dd1..d4ddfc9 100644
--- a/bin/scons-test.py
+++ b/bin/scons-test.py
@@ -18,7 +18,6 @@ from __future__ import print_function
import atexit
import getopt
-import imp
import os
import os.path
import sys
diff --git a/bin/update-release-info.py b/bin/update-release-info.py
index de3d164..c2b3d19 100644
--- a/bin/update-release-info.py
+++ b/bin/update-release-info.py
@@ -58,7 +58,7 @@ In 'post' mode, files are prepared for the next release cycle:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "bin/update-release-info.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "bin/update-release-info.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
diff --git a/bin/upload-release-files.sh b/bin/upload-release-files.sh
index 9a09206..577203e 100755
--- a/bin/upload-release-files.sh
+++ b/bin/upload-release-files.sh
@@ -35,7 +35,7 @@ $RSYNC $RSYNCOPTS \
Announce.txt CHANGES.txt RELEASE.txt \
$SF_USER@$SF_MACHINE:$SF_TOPDIR/scons-local/$VERSION/
-Source packages:
+# Source packages:
$RSYNC $RSYNCOPTS \
scons-src-$VERSION.tar.gz \
scons-src-$VERSION.zip \
@@ -48,7 +48,6 @@ $RSYNC $RSYNCOPTS \
$SF_USER@$SF_MACHINE:$SF_TOPDIR/
-
#
# scons.org stuff:
#
diff --git a/doc/generated/builders.gen b/doc/generated/builders.gen
index dc05443..7c62558 100644
--- a/doc/generated/builders.gen
+++ b/doc/generated/builders.gen
@@ -849,14 +849,16 @@ Compile files for languages defined in <filename>LINGUAS</filename> file
latest installed version, or the version specified by
<link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="cv-MSVS_VERSION"><envar>$MSVS_VERSION</envar></link> in the Environment constructor). For
Visual Studio 6, it will generate a <filename>.dsp</filename>
- file. For Visual Studio 7 (.NET) and later versions, it will
- generate a <filename>.vcproj</filename> file.
+ file. For Visual Studio 7, 8, and 9, it will
+ generate a <filename>.vcproj</filename> file. For Visual
+ Studio 10 and later, it will generate a
+ <filename>.vcxproj</filename> file.
</para>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
By default, this also generates a solution file for the
specified project, a <filename>.dsw</filename> file for
Visual Studio 6 or a <filename>.sln</filename> file for
- Visual Studio 7 (.NET). This behavior may be disabled by
+ Visual Studio 7 and later. This behavior may be disabled by
specifying <literal>auto_build_solution=0</literal> when you
call <function xmlns="http://www.scons.org/dbxsd/v1.0">MSVSProject</function>, in which case you presumably want to
build the solution file(s) by calling the <function xmlns="http://www.scons.org/dbxsd/v1.0">MSVSSolution</function>
@@ -929,6 +931,36 @@ Compile files for languages defined in <filename>LINGUAS</filename> file
</listitem>
</varlistentry>
<varlistentry>
+ <term>cppdefines</term>
+ <listitem>
+ <para>
+ Preprocessor definitions for the different variants.
+ The number of <literal>cppdefines</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPDEFINES</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>cpppaths</term>
+ <listitem>
+ <para>
+ Compiler include paths for the different variants.
+ The number of <literal>cpppaths</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPPATH</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>buildtarget</term>
<listitem>
<para>
diff --git a/doc/generated/examples/caching_ex-random_1.xml b/doc/generated/examples/caching_ex-random_1.xml
index 0a432e9..58ff6ae 100644
--- a/doc/generated/examples/caching_ex-random_1.xml
+++ b/doc/generated/examples/caching_ex-random_1.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<screen xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">% <userinput>scons -Q</userinput>
-cc -o f5.o -c f5.c
cc -o f3.o -c f3.c
cc -o f2.o -c f2.c
+cc -o f5.o -c f5.c
cc -o f1.o -c f1.c
cc -o f4.o -c f4.c
cc -o prog f1.o f2.o f3.o f4.o f5.o
diff --git a/doc/generated/examples/troubleshoot_explain1_3.xml b/doc/generated/examples/troubleshoot_explain1_3.xml
index ebc13f8..04b09fd 100644
--- a/doc/generated/examples/troubleshoot_explain1_3.xml
+++ b/doc/generated/examples/troubleshoot_explain1_3.xml
@@ -3,5 +3,5 @@
cp file.in file.oout
scons: warning: Cannot find target file.out after building
-File "/home/bdeegan/devel/scons/git/as_scons/src/script/scons.py", line 204, in &lt;module&gt;
+File "/home/bdeegan/devel/scons/git/as_scons/bootstrap/src/script/scons.py", line 204, in &lt;module&gt;
</screen>
diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen
index 9fc9d4b..5e8bebb 100644
--- a/doc/generated/functions.gen
+++ b/doc/generated/functions.gen
@@ -480,7 +480,7 @@ string, in which case a list will be returned instead of a string.
</para>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-If
+If
<varname>delete_existing</varname>
is 0, then adding a path that already exists
will not move it to the end; it will stay where it is in the list.
@@ -518,7 +518,7 @@ then any value(s) that already exist in the
construction variable will
<emphasis>not</emphasis>
be added again to the list.
-However, if delete_existing is 1,
+However, if delete_existing is 1,
existing matching values are removed first, so
existing values in the arg list move to the end of the list.
</para>
@@ -820,12 +820,14 @@ env4 = env.Clone(tools = ['msvc', MyTool])
<para xmlns="http://www.scons.org/dbxsd/v1.0">
The
<varname>parse_flags</varname>
-keyword argument is also recognized:
+keyword argument is also recognized to allow merging command-line
+style arguments into the appropriate construction
+variables (see <link xmlns="http://www.scons.org/dbxsd/v1.0" linkend="f-MergeFlags"><function>env.MergeFlags</function></link>).
</para>
<example_commands xmlns="http://www.scons.org/dbxsd/v1.0">
# create an environment for compiling programs that use wxWidgets
-wx_env = env.Clone(parse_flags = '!wx-config --cflags --cxxflags')
+wx_env = env.Clone(parse_flags='!wx-config --cflags --cxxflags')
</example_commands>
</listitem>
</varlistentry>
@@ -1137,6 +1139,17 @@ size, or content signature.
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+<term><parameter>repo_node</parameter></term>
+<listitem>
+<para>
+Use this node instead of the one specified by
+<varname>dependency</varname>
+ to determine if the dependency has changed.
+</para>
+</listitem>
+</varlistentry>
+
</variablelist>
</para>
@@ -1173,7 +1186,7 @@ Example:
</para>
<example_commands xmlns="http://www.scons.org/dbxsd/v1.0">
-def my_decider(dependency, target, prev_ni):
+def my_decider(dependency, target, prev_ni, repo_node=None):
return not os.path.exists(str(target))
env.Decider(my_decider)
@@ -2531,9 +2544,9 @@ as the dependency.
</para>
<para xmlns="http://www.scons.org/dbxsd/v1.0">
-Note that this will only remove the dependencies listed from
-the files built by default. It will still be built if that
-dependency is needed by another object being built.
+Note that this will only remove the dependencies listed from
+the files built by default. It will still be built if that
+dependency is needed by another object being built.
See the third and forth examples below.
</para>
@@ -2941,6 +2954,9 @@ and added to the following construction variables:
-frameworkdir= FRAMEWORKPATH
-include CCFLAGS
-isysroot CCFLAGS, LINKFLAGS
+-isystem CCFLAGS
+-iquote CCFLAGS
+-idirafter CCFLAGS
-I CPPPATH
-l LIBS
-L LIBPATH
@@ -3151,7 +3167,7 @@ then any value(s) that already exist in the
construction variable will
<emphasis>not</emphasis>
be added again to the list.
-However, if delete_existing is 1,
+However, if delete_existing is 1,
existing matching values are removed first, so
existing values in the arg list move to the front of the list.
</para>
diff --git a/doc/generated/variables.gen b/doc/generated/variables.gen
index c7048b4..28dfc59 100644
--- a/doc/generated/variables.gen
+++ b/doc/generated/variables.gen
@@ -4495,6 +4495,7 @@ constructor; setting it later has no effect.
<para xmlns="http://www.scons.org/dbxsd/v1.0">
Valid values for Windows are
+<literal>14.2</literal>,
<literal>14.1</literal>,
<literal>14.0</literal>,
<literal>14.0Exp</literal>,
@@ -7343,6 +7344,16 @@ The suffix used for tar file names.
</para>
</listitem>
</varlistentry>
+ <varlistentry id="cv-TEMPFILEARGJOIN">
+ <term>TEMPFILEARGJOIN</term>
+ <listitem>
+<para xmlns="http://www.scons.org/dbxsd/v1.0">
+The string (or character) to be used to join the arguments passed to TEMPFILE when command line exceeds the limit set by <envar xmlns="http://www.scons.org/dbxsd/v1.0">$MAXLINELENGTH</envar>.
+The default value is a space. However for MSVC, MSLINK the default is a line seperator characters as defined by os.linesep.
+Note this value is used literally and not expanded by the subst logic.
+</para>
+</listitem>
+ </varlistentry>
<varlistentry id="cv-TEMPFILEPREFIX">
<term>TEMPFILEPREFIX</term>
<listitem>
diff --git a/doc/generated/variables.mod b/doc/generated/variables.mod
index 28c08dc..47576f4 100644
--- a/doc/generated/variables.mod
+++ b/doc/generated/variables.mod
@@ -544,6 +544,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY cv-TARGET_OS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TARGET_OS</envar>">
<!ENTITY cv-TARGETS "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TARGETS</envar>">
<!ENTITY cv-TARSUFFIX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TARSUFFIX</envar>">
+<!ENTITY cv-TEMPFILEARGJOIN "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TEMPFILEARGJOIN</envar>">
<!ENTITY cv-TEMPFILEPREFIX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TEMPFILEPREFIX</envar>">
<!ENTITY cv-TEMPFILESUFFIX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TEMPFILESUFFIX</envar>">
<!ENTITY cv-TEX "<envar xmlns='http://www.scons.org/dbxsd/v1.0'>$TEX</envar>">
@@ -1183,6 +1184,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT.
<!ENTITY cv-link-TARGET_OS "<link linkend='cv-TARGET_OS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TARGET_OS</envar></link>">
<!ENTITY cv-link-TARGETS "<link linkend='cv-TARGETS' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TARGETS</envar></link>">
<!ENTITY cv-link-TARSUFFIX "<link linkend='cv-TARSUFFIX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TARSUFFIX</envar></link>">
+<!ENTITY cv-link-TEMPFILEARGJOIN "<link linkend='cv-TEMPFILEARGJOIN' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TEMPFILEARGJOIN</envar></link>">
<!ENTITY cv-link-TEMPFILEPREFIX "<link linkend='cv-TEMPFILEPREFIX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TEMPFILEPREFIX</envar></link>">
<!ENTITY cv-link-TEMPFILESUFFIX "<link linkend='cv-TEMPFILESUFFIX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TEMPFILESUFFIX</envar></link>">
<!ENTITY cv-link-TEX "<link linkend='cv-TEX' xmlns='http://www.scons.org/dbxsd/v1.0'><envar>$TEX</envar></link>">
diff --git a/doc/man/scons-time.xml b/doc/man/scons-time.xml
index 80dc041..7251c9f 100644
--- a/doc/man/scons-time.xml
+++ b/doc/man/scons-time.xml
@@ -32,8 +32,8 @@
<refmeta>
<refentrytitle>SCONS-TIME</refentrytitle>
<manvolnum>1</manvolnum>
-<refmiscinfo class='source'>SCons 3.0.5</refmiscinfo>
-<refmiscinfo class='manual'>SCons 3.0.5</refmiscinfo>
+<refmiscinfo class='source'>SCons 3.1.0</refmiscinfo>
+<refmiscinfo class='manual'>SCons 3.1.0</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>scons-time</refname>
diff --git a/doc/man/scons.xml b/doc/man/scons.xml
index 2f5eb32..dd9fbdd 100644
--- a/doc/man/scons.xml
+++ b/doc/man/scons.xml
@@ -75,8 +75,8 @@
<refmeta>
<refentrytitle>SCONS</refentrytitle>
<manvolnum>1</manvolnum>
-<refmiscinfo class='source'>SCons 3.0.5</refmiscinfo>
-<refmiscinfo class='manual'>SCons 3.0.5</refmiscinfo>
+<refmiscinfo class='source'>SCons 3.1.0</refmiscinfo>
+<refmiscinfo class='manual'>SCons 3.1.0</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>scons</refname>
@@ -2043,7 +2043,7 @@ env['BAR'] = 'bar'
construction variables may also be set or modified by the
<emphasis>parse_flags</emphasis>
keyword argument, which applies the
-<emphasis role="bold">ParseFlags</emphasis>
+&f-link-env-MergeFlags;
method (described below) to the argument value
after all other processing is completed.
This is useful either if the exact content of the flags is unknown
@@ -2051,7 +2051,7 @@ This is useful either if the exact content of the flags is unknown
or if the flags are distributed to a number of construction variables.</para>
<literallayout class="monospaced">
-env = Environment(parse_flags = '-Iinclude -DEBUG -lm')
+env = Environment(parse_flags='-Iinclude -DEBUG -lm')
</literallayout>
<para>This example adds 'include' to
@@ -2439,10 +2439,14 @@ see the descriptions of these variables, below, for more information.)</para>
<para>It is also possible to use the
<emphasis>parse_flags</emphasis>
-keyword argument in an override:</para>
+keyword argument in an override,
+to merge command-line style arguments
+into the appropriate construction variables
+(see &f-link-env-MergeFlags;).
+</para>
<literallayout class="monospaced">
-env = Program('hello', 'hello.c', parse_flags = '-Iinclude -DEBUG -lm')
+env = Program('hello', 'hello.c', parse_flags='-Iinclude -DEBUG -lm')
</literallayout>
<para>This example adds 'include' to
diff --git a/doc/man/sconsign.xml b/doc/man/sconsign.xml
index 2f0d66c..f70bb62 100644
--- a/doc/man/sconsign.xml
+++ b/doc/man/sconsign.xml
@@ -32,20 +32,19 @@
<refmeta>
<refentrytitle>SCONSIGN</refentrytitle>
<manvolnum>1</manvolnum>
-<refmiscinfo class='source'>SCons 3.0.5</refmiscinfo>
-<refmiscinfo class='manual'>SCons 3.0.5</refmiscinfo>
+<refmiscinfo class='source'>SCons 3.1.0</refmiscinfo>
+<refmiscinfo class='manual'>SCons 3.1.0</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>sconsign</refname>
-<refpurpose>print SCons .sconsign file information</refpurpose>
+<refpurpose>print SCons signature file information</refpurpose>
</refnamediv>
<!-- body begins here -->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<command>sconsign</command>
<arg choice='opt' rep='repeat'><replaceable>options</replaceable></arg>
- <arg choice='plain'><replaceable>file</replaceable></arg>
- <arg choice='opt'><replaceable>...</replaceable></arg>
+ <arg choice='opt' rep='repeat'><replaceable>file</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -54,30 +53,38 @@
<para>The
<command>sconsign</command>
command
-displays the contents of one or more
-<markup>.sconsign</markup>
+displays the contents of one or more signature
+("<markup>sconsign</markup>")
files specified by the user.</para>
<para>By default,
<command>sconsign</command>
dumps the entire contents of the
specified file(s).
-Each entry is printed in the following format:</para>
+Without the verbose option,
+each entry is printed in the following format:</para>
-<para> file: signature timestamp length
- implicit_dependency_1: signature timestamp length
- implicit_dependency_2: signature timestamp length
- action_signature [action string]</para>
+<literallayout class="monospaced">
+file: signature timestamp length
+ implicit_dependency_1: signature timestamp length
+ implicit_dependency_2: signature timestamp length
+ ...
+ action_signature [action string]
+</literallayout>
<para><emphasis role="bold">None</emphasis>
is printed
-in place of any missing timestamp, bsig, or csig
+in place of any missing timestamp, build signature ("bsig"),
+or content signature ("csig")
values for
any entry
or any of its dependencies.
If the entry has no implicit dependencies,
or no build action,
-the lines are simply omitted.</para>
+the lines are simply omitted.
+The verbose option expands the display into a more human
+readable format.
+</para>
<para>By default,
<command>sconsign</command>
@@ -90,7 +97,7 @@ signature entries for
more than one directory
(that is,
was specified by the
-<emphasis role="bold">SConsignFile ()</emphasis>
+<emphasis role="bold">SConsignFile</emphasis>
function).
Any
<emphasis>file</emphasis>
@@ -103,13 +110,21 @@ for a single directory.
If neither of those is true,
<command>sconsign</command>
attempts to guess the format.
-If that does not work,
+If that does not work,
an explicit format
may be specified using the
<option>-f</option>
or
<option>--format=</option>
-options.</para>
+options.
+</para>
+<para>
+If there are no
+<emphasis>file</emphasis>
+arguments, the name
+<filename>.sconsign.dblite</filename>
+is assumed.
+</para>
</refsect1>
@@ -175,7 +190,7 @@ Legal values are
<emphasis role="bold">dbm</emphasis>
(the DBM format used
when the
-<emphasis role="bold">SConsignFile</emphasis>()
+<emphasis role="bold">SConsignFile</emphasis>
function is used)
or
<command>sconsign</command>
@@ -197,7 +212,7 @@ file in each directory).</para>
<term>-i, --implicit</term>
<listitem>
<para>Prints the list of cached implicit dependencies
-for all entries or the the specified entries.</para>
+for all entries or for the specified entries.</para>
</listitem>
</varlistentry>
@@ -206,8 +221,8 @@ for all entries or the the specified entries.</para>
<listitem>
<para>Prints a pretty-printed representation
of the raw Python dictionary that holds
-build information about individual entry
-(both the entry itself or its implicit dependencies).
+build information about individual entries
+(both the entry itself and its implicit dependencies).
An entry's build action is still printed in its usual format.</para>
</listitem>
@@ -244,7 +259,8 @@ for all entries or the specified entries.</para>
<term>SCONS_LIB_DIR</term>
<listitem>
<para>Specifies the directory that contains the SCons Python module directory
-(e.g. /home/aroach/scons-src-0.01/src/engine).
+(e.g.
+<filename class='directory'>/home/aroach/scons-src-0.01/src/engine</filename>).
on the command line.</para>
</listitem>
diff --git a/doc/scons.mod b/doc/scons.mod
index ea9ad4e..cf46e3b 100644
--- a/doc/scons.mod
+++ b/doc/scons.mod
@@ -67,6 +67,7 @@
<!ENTITY Action "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>Action</classname>">
<!ENTITY ActionBase "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>ActionBase</classname>">
+<!ENTITY BuildInfo "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>BuildInfo</classname>">
<!ENTITY CommandAction "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>CommandAction</classname>">
<!ENTITY FunctionAction "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>FunctionAction</classname>">
<!ENTITY ListAction "<classname xmlns='http://www.scons.org/dbxsd/v1.0'>ListAction</classname>">
diff --git a/doc/user/depends.xml b/doc/user/depends.xml
index 35372e7..bb0a142 100644
--- a/doc/user/depends.xml
+++ b/doc/user/depends.xml
@@ -517,7 +517,7 @@ cc -o hello hello.o
<scons_example name="depends_function">
<file name="SConstruct" printme="1">
Program('hello.c')
-def decide_if_changed(dependency, target, prev_ni):
+def decide_if_changed(dependency, target, prev_ni, repo_node=None):
if dependency.get_timestamp() != prev_ni.timestamp:
dep = str(dependency)
tgt = str(target)
@@ -561,6 +561,13 @@ int main() { printf("Hello, world!\n"); }
</para>
+ <para>
+ The fourth argument <varname>repo_node</varname>,
+ is the &Node; to use if it is not None when comparing &BuildInfo;.
+ This is typically only set when the target node only exists in a
+ &Repository;
+ </para>
+
<variablelist>
<varlistentry>
@@ -637,7 +644,7 @@ int main() { printf("Hello, world!\n"); }
<sconstruct>
env = Environment()
-def config_file_decider(dependency, target, prev_ni):
+def config_file_decider(dependency, target, prev_ni, repo_node=None):
import os.path
# We always have to init the .csig value...
diff --git a/doc/user/less-simple.xml b/doc/user/less-simple.xml
index 6de1075..e8ff44a 100644
--- a/doc/user/less-simple.xml
+++ b/doc/user/less-simple.xml
@@ -2,7 +2,7 @@
<!DOCTYPE sconsdoc [
<!ENTITY % scons SYSTEM "../scons.mod">
%scons;
-
+
<!ENTITY % builders-mod SYSTEM "../generated/builders.mod">
%builders-mod;
<!ENTITY % functions-mod SYSTEM "../generated/functions.mod">
@@ -257,7 +257,7 @@ Program('program', Glob('*.c'))
(see <xref linkend="chap-variants"></xref>, below)
and repositories
(see <xref linkend="chap-repositories"></xref>, below),
- excluding some files
+ excluding some files
and returning strings rather than Nodes.
</para>
@@ -311,7 +311,7 @@ Program('hello', ['hello.c'])
</para>
<important>
-
+
<para>
Although &SCons; functions
@@ -359,7 +359,7 @@ Program('program2', common_sources + ['program2.c'])
<para>
One drawback to the use of a Python list
- for source files is that
+ for source files is that
each file name must be enclosed in quotes
(either single quotes or double quotes).
This can get cumbersome and difficult to read
@@ -675,8 +675,10 @@ env.SharedLibrary('word', 'word.cpp',
<para>
- It is also possible to use the <literal>parse_flags</literal> keyword argument in an
- override:
+ It is also possible to use the <literal>parse_flags</literal>
+ keyword argument in an override to merge command-line
+ style arguments into the appropriate construction
+ variables (see &f-link-env-MergeFlags;).
</para>
@@ -688,7 +690,7 @@ env.SharedLibrary('word', 'word.cpp',
</para>
<programlisting>
-env = Program('hello', 'hello.c', parse_flags = '-Iinclude -DEBUG -lm')
+env = Program('hello', 'hello.c', parse_flags='-Iinclude -DEBUG -lm')
</programlisting>
<para>
@@ -701,4 +703,4 @@ env = Program('hello', 'hello.c', parse_flags = '-Iinclude -DEBUG -lm')
</section>
-</chapter> \ No newline at end of file
+</chapter>
diff --git a/site_scons/soe_utils.py b/site_scons/soe_utils.py
index 451c7de..3b87dee 100644
--- a/site_scons/soe_utils.py
+++ b/site_scons/soe_utils.py
@@ -17,16 +17,14 @@ def soelim(target, source, env):
t = str(target[0])
s = str(source[0])
dir, f = os.path.split(s)
- tfp = open(t, 'w')
- sfp = open(s, 'r')
- for line in sfp.readlines():
- if line[:4] in ['.so ', "'so "]:
- sofile = os.path.join(dir, line[4:-1])
- tfp.write(open(sofile, 'r').read())
- else:
- tfp.write(line)
- sfp.close()
- tfp.close()
+ with open(t, 'w') as tfp, open(s, 'r') as sfp:
+ for line in sfp.readlines():
+ if line[:4] in ['.so ', "'so "]:
+ sofile = os.path.join(dir, line[4:-1])
+ with open(sofile, 'r') as f:
+ tfp.write(f.read())
+ else:
+ tfp.write(line)
def soscan(node, env, path):
c = node.get_text_contents()
diff --git a/src/Announce.txt b/src/Announce.txt
index 324b9fc..2ceb8bc 100755
--- a/src/Announce.txt
+++ b/src/Announce.txt
@@ -18,7 +18,7 @@ So that everyone using SCons can help each other learn how to use it more
effectively, please go to http://scons.org/lists.html#users to sign up for
the scons-users mailing list.
-RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700
+RELEASE 3.1.0 - Mon, 20 Jul 2019 16:59:23 -0700
Please consult the RELEASE.txt file for a summary of changes since the last
release and consult the CHANGES.txt file for complete a list of changes
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index c46a804..a23140c 100755
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -4,6 +4,102 @@
Change Log
+RELEASE 3.1.0 - Mon, 20 Jul 2019 16:59:23 -0700
+
+ From Joseph Brill:
+ - Code to supply correct version-specifier argument to vswhere for
+ VS version selection.
+
+ From William Deegan:
+ - Enhanced --debug=explain output. Now the separate components of the dependency list are split up
+ as follows:
+
+ scons: rebuilding `file3' because:
+ the dependency order changed:
+ ->Sources
+ Old:xxx New:zzz
+ Old:yyy New:yyy
+ Old:zzz New:xxx
+ ->Depends
+ ->Implicit
+ Old:/usr/bin/python New:/usr/bin/python
+ - Fix Issue #3350 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError.
+ - Fix spurious rebuilds on second build for cases where builder has > 1 target and the source file
+ is generated. This was causing the > 1th target to not have it's implicit list cleared when the source
+ file was actually built, leaving an implicit list similar to follows for 2nd and higher target
+ ['/usr/bin/python', 'xxx', 'yyy', 'zzz']
+ This was getting persisted to SConsign and on rebuild it would be corrected to be similar to this
+ ['zzz', 'yyy', 'xxx', '/usr/bin/python']
+ Which would trigger a rebuild because the order changed.
+ The fix involved added logic to mark all shared targets as peers and then ensure they're implicit
+ list is all cleared together.
+ - Fix Issue #3349 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError.
+ Renamed to SConsEnvironmentError
+ - Fix Issue #3350 - mslink failing when too many objects. This is resolved by adding TEMPFILEARGJOIN variable
+ which specifies what character to join all the argements output into the tempfile. The default remains a space
+ when mslink, msvc, or mslib tools are loaded they change the TEMPFILEARGJOIN to be a line separator (\r\n on win32)
+ - Fix performance degradation for MD5-timestamp decider. NOTE: This changes the Decider() function arguments.
+ From:
+ def my_decider(dependency, target, prev_ni):
+ To:
+ def my_decider(dependency, target, prev_ni, repo_node):
+ Where repo_node is the repository (or other) node to use to check if the node is out of date instead of dependency.
+
+ From Peter Diener:
+ - Additional fix to issue #3135 - Also handle 'pure' and 'elemental' type bound procedures
+ - Fix issue #3135 - Handle Fortran submodules and type bound procedures
+
+ From Adam Gross:
+ - Upgraded and improved Visual Studio solution/project generation code using the MSVSProject builder.
+ - Added support for Visual Studio 2017 and 2019.
+ - Added support for the following per-variant parameters to the builder:
+ - cpppaths: Provides per-variant include paths.
+ - cppdefines: Provides per-variant preprocessor definitions.
+
+ From Michael Hartmann:
+ - Fix handling of Visual Studio Compilers to properly reject any unknown HOST_PLATFORM or TARGET_PLATFORM
+
+ From Bert Huijben:
+ - Added support for Visual Studio 2019 toolset.
+
+ From Mathew Robinson:
+ - Update cache debug output to include cache hit rate.
+ - No longer unintentionally hide exceptions in Action.py
+ - Allow builders and pseudo-builders to inherit from OverrideEnvironments
+
+ From Leonard de Ruijter:
+ - Add logic to derive correct version argument to vswhere
+
+ From Lukas Schrangl:
+ - Enable LaTeX scanner to find more than one include per line
+
+ From Mats Wichmann:
+ - scons-time takes more care closing files and uses safer mkdtemp to avoid
+ possible races on multi-job runs.
+ - Use importlib to dynamically load tool and platform modules instead of imp module
+ - sconsign: default to .sconsign.dblite if no filename is specified.
+ Be more informative in case of unsupported pickle protocol (py2 only).
+ - Fix issue #3336 - on Windows, paths were being added to PATH even if
+ tools were not found in those paths.
+ - More fixes for newer Java versions (since 9): handle new jdk directory
+ naming (jdk-X.Y instead of jdkX.Y) on Windows; handle two-digit major
+ version. Docstrings improved.
+ - Fixups for pylint: exception types, redefined functions,
+ globals, etc. Some old code removed to resolve issues (hashlib is
+ always present on modern Pythons; no longer need the code for
+ 2.5-and-earlier optparse). cmp is not a builtin function in Py3,
+ drop one (unused) use; replace one. Fix another instance of
+ renaming to SConsEnvironmentError. Trailing whitespace.
+ Consistently use not is/in (if not x is y -> if x is not y).
+ - Add a PY3-only function for setting up the cachedir that should be less
+ prone to races. Add a hack to the PY2 version (from Issue #3351) to
+ be less prone to a race in the check for old-style cache.
+ - Fix coding error in docbook tool only exercised when using python lxml
+ - Recognize two additional GNU compiler header directory options in
+ ParseFlags: -iquote and -idirafter.
+ - Fix more re patterns that contain \ but not specified as raw strings
+ (affects scanners for D, LaTeX, swig)
+
RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700
@@ -24,7 +120,7 @@ RELEASE 3.0.5 - Mon, 26 Mar 2019 15:04:42 -0700
From Maciej Kumorek:
- Update the MSVC tool to include the nologo flag by default in RCFLAGS
- From Daniel Moody:
+From Daniel Moody:
- Change the default for AppendENVPath to delete_existing=0, so path
order will not be changed, unless explicitly set (Issue #3276)
- Fixed bug which threw error when running SCons on windows system with no MSVC installed.
diff --git a/src/RELEASE.txt b/src/RELEASE.txt
index 90cc745..9d0e092 100755
--- a/src/RELEASE.txt
+++ b/src/RELEASE.txt
@@ -1,43 +1,77 @@
-A new SCons release, 3.0.5, is now available on the SCons download page:
+ A new SCons checkpoint release, 3.1.0, is now available
+ on the SCons download page:
- https://scons.org/pages/download.html
+ https://scons.org/pages/download.html
+ Here is a summary of the changes since 3.0.5:
-Here is a summary of the changes since 3.0.4:
+ NEW FUNCTIONALITY
-CHANGED/ENHANCED EXISTING FUNCTIONALITY
+ - Added variable TEMPFILEARGJOIN to specify how to join arguments written
+ to temp files used when command lines exceed MAXLINELENGTH when the
+ command uses $TEMPFILE{...}
+ - Support for MSVC 2019
+ - Upgraded and improved Visual Studio solution/project generation code using the MSVSProject builder.
+ - Added support for Visual Studio 2017 and 2019.
+ - Added support for the following per-variant parameters to the builder:
+ - cpppaths: Provides per-variant include paths.
+ - cppdefines: Provides per-variant preprocessor definitions.
- - Change the default for AppendENVPath to delete_existing=0, so path
- order will not be changed, unless explicitly set (Issue #3276)
- - Add lex construction variable LEXUNISTD for turning off unix headers on windows
- - Update lex tool to use win_flex on windows if available
- - Add the textfile tool to the default tool list
-FIXES
+ CHANGED/ENHANCED EXISTING FUNCTIONALITY
- - Fix Issue #3283 - Handle using --config=force in combination with Decider('MD5-timestamp').
- 3.0.2 in fix for issue #2980 added that deciders can throw DeciderNeedsNode exception.
- The Configure logic directly calls the decider when using --config=force but wasn't handling
- that exception. This would yield minimally configure tests using TryLink() not running and
- leaving TypeError Nonetype exception in config.log
- - Fix Issue #3303 - Handle --config=force overwriting the Environment passed into Configure()'s
- Decider and not clearing it when the configure context is completed.
- - Add default paths for yacc tool on windows to include cygwin, mingw, and chocolatey
- - Fix issue #2799 - Fix mingw tool to respect SHCCCOMSTR, SHLINKCOMSTR and LDMODULECOMSTR
- - Fix Issue #3329 - Add support for MS SDK V10.0A (which is commonly installed with VS2017)
- - Fix Issue #3333 - Add support for finding vswhere under 32 bit windows installs.
- - Update the MSVC tool to include the nologo flag by default in RCFLAGS
- - Fixed bug which threw error when running SCons on windows system with no MSVC installed.
+ - Fix performance degradation for MD5-timestamp decider. NOTE: This changes the Decider() function arguments.
+ From:
+ def my_decider(dependency, target, prev_ni):
+ To:
+ def my_decider(dependency, target, prev_ni, repo_node):
+ Where repo_node is the repository (or other) node to use to check if the node is out of date instead of dependency.
+ - Enhanced --debug=explain output. Now the separate components of the dependency list are split up
+ as follows:
-IMPROVEMENTS
- - Do not store build host+user name if reproducible builds are wanted
+ scons: rebuilding `file3' because:
+ the dependency order changed:
+ ->Sources
+ Old:xxx New:zzz
+ Old:yyy New:yyy
+ Old:zzz New:xxx
+ ->Depends
+ ->Implicit
+ Old:/usr/bin/python New:/usr/bin/python
+ - Changed: Pseudo-builders now inherit OverrideEnvironments. For
+ example when calling a pseudo-builder from another
+ pseudo-builder the override variables passed to the first
+ pseudo-builder call had to be explicitly passed on to the
+ internal pseudo-builder call. Now the second pseudo-builder call
+ will automatically inherit these override values.
-git shortlog --no-merges -ns 3.0.4..HEAD
- 34 William Deegan
- 33 Mats Wichmann
- 18 Daniel
- 4 Daniel Moody
- 3 Bernhard M. Wiedemann
- 2 Maciej Kumorek
+ FIXES
+ - Fix Issue #3350 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError.
+ - Fix spurious rebuilds on second build for cases where builder has > 1 target and the source file
+ is generated. This was causing the > 1th target to not have it's implicit list cleared when the source
+ file was actually built, leaving an implicit list similar to follows for 2nd and higher target
+ ['/usr/bin/python', 'xxx', 'yyy', 'zzz']
+ This was getting persisted to SConsign and on rebuild it would be corrected to be similar to this
+ ['zzz', 'yyy', 'xxx', '/usr/bin/python']
+ Which would trigger a rebuild because the order changed.
+ The fix involved added logic to mark all shared targets as peers and then ensure they're implicit
+ list is all cleared together.
+ - Fix Issue #3349 - SCons Exception EnvironmentError is conflicting with Python's EnvironmentError.
+ Renamed to SConsEnvironmentError
+ - Fix Issue #3350 - mslink failing when too many objects. This is resolved by adding TEMPFILEARGJOIN variable
+ which specifies what character to join all the argements output into the tempfile. The default remains a space
+ when mslink, msvc, or mslib tools are loaded they change the TEMPFILEARGJOIN to be a line separator (\r\n on win32)
+ - Additional fix to issue #3135 - Also handle 'pure' and 'elemental' type bound procedures
+
+ - Fix handling of Visual Studio Compilers to properly reject any unknown HOST_PLATFORM or TARGET_PLATFORM
+ - Enable LaTeX scanner to find more than one include per line
+
+ under which they would be observed), or major code cleanups
+
+ Thanks to CURLY, LARRY, and MOE for their contributions to this release.
+ Contributors are listed alphabetically by their last name.
+
+Copyright (c) 2001 - 2019 The SCons Foundation
+src/RELEASE.txt e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan
diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in
index 39aba6c..3125824 100644
--- a/src/engine/MANIFEST.in
+++ b/src/engine/MANIFEST.in
@@ -1,4 +1,5 @@
SCons/__init__.py
+SCons/__main__.py
SCons/Action.py
SCons/Builder.py
SCons/compat/*.py
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index f1ca2cf..b541256 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -98,7 +98,7 @@ way for wrapping up the functions.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Action.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Action.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import pickle
@@ -211,7 +211,7 @@ def _object_contents(obj):
def _code_contents(code, docstring=None):
- """Return the signature contents of a code object.
+ r"""Return the signature contents of a code object.
By providing direct access to the code object of the
function, Python makes this extremely easy. Hooray!
@@ -534,7 +534,7 @@ class ActionBase(object):
result = self.get_presig(target, source, env)
if not isinstance(result,(bytes, bytearray)):
- result = bytearray("",'utf-8').join([ SCons.Util.to_bytes(r) for r in result ])
+ result = bytearray(result, 'utf-8')
else:
# Make a copy and put in bytearray, without this the contents returned by get_presig
# can be changed by the logic below, appending with each call and causing very
@@ -767,16 +767,22 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
it'll have to be tweaked to get the full desired functionality.
one special arg (so far?), 'error', to tell what to do with exceptions.
"""
- # allow std{in,out,err} to be "'devnull'"
- io = kw.get('stdin')
- if is_String(io) and io == 'devnull':
- kw['stdin'] = open(os.devnull)
- io = kw.get('stdout')
- if is_String(io) and io == 'devnull':
- kw['stdout'] = open(os.devnull, 'w')
- io = kw.get('stderr')
- if is_String(io) and io == 'devnull':
- kw['stderr'] = open(os.devnull, 'w')
+ # allow std{in,out,err} to be "'devnull'". This is like
+ # subprocess.DEVNULL, which does not exist for Py2. Use the
+ # subprocess one if possible.
+ # Clean this up when Py2 support is dropped
+ try:
+ from subprocess import DEVNULL
+ except ImportError:
+ DEVNULL = None
+
+ for stream in 'stdin', 'stdout', 'stderr':
+ io = kw.get(stream)
+ if is_String(io) and io == 'devnull':
+ if DEVNULL:
+ kw[stream] = DEVNULL
+ else:
+ kw[stream] = open(os.devnull, "r+")
# Figure out what shell environment to use
ENV = kw.get('env', None)
@@ -802,7 +808,7 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
kw['env'] = new_env
try:
- pobj = subprocess.Popen(cmd, **kw)
+ pobj = subprocess.Popen(cmd, **kw)
except EnvironmentError as e:
if error == 'raise': raise
# return a dummy Popen instance that only returns error
@@ -820,9 +826,10 @@ def _subproc(scons_env, cmd, error = 'ignore', **kw):
finally:
# clean up open file handles stored in parent's kw
for k, v in kw.items():
- if hasattr(v, 'close'):
+ if inspect.ismethod(getattr(v, 'close', None)):
v.close()
- return pobj
+
+ return pobj
class CommandAction(_ActionAction):
@@ -1091,7 +1098,7 @@ class LazyAction(CommandGeneratorAction, CommandAction):
def get_parent_class(self, env):
c = env.get(self.var)
- if is_String(c) and not '\n' in c:
+ if is_String(c) and '\n' not in c:
return CommandAction
return CommandGeneratorAction
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 1b11eea..9372240 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/ActionTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/ActionTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Define a null function and a null class for use as builder actions.
@@ -44,6 +44,7 @@ import re
import sys
import types
import unittest
+import subprocess
import SCons.Action
import SCons.Environment
@@ -1529,6 +1530,7 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
(3, 5): bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'),
(3, 6): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
(3, 7): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
+ (3, 8): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
}
meth_matches = [
@@ -1554,19 +1556,19 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
assert c == func_matches[sys.version_info[:2]], "Got\n" + repr(c) + "\nExpected \n" + repr(
func_matches[sys.version_info[:2]])
- def f_global(target, source, env, for_signature):
+ def f_global2(target, source, env, for_signature):
return SCons.Action.Action(GlobalFunc, varlist=['XYZ'])
- def f_local(target, source, env, for_signature):
+ def f_local2(target, source, env, for_signature):
return SCons.Action.Action(LocalFunc, varlist=['XYZ'])
matches_foo = func_matches[sys.version_info[:2]] + b'foo'
- a = self.factory(f_global)
+ a = self.factory(f_global2)
c = a.get_contents(target=[], source=[], env=env)
assert c in matches_foo, repr(c)
- a = self.factory(f_local)
+ a = self.factory(f_local2)
c = a.get_contents(target=[], source=[], env=env)
assert c in matches_foo, repr(c)
@@ -1707,6 +1709,7 @@ class FunctionActionTestCase(unittest.TestCase):
(3, 5): bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'),
(3, 6): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
(3, 7): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
+ (3, 8): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
}
@@ -1715,6 +1718,7 @@ class FunctionActionTestCase(unittest.TestCase):
(3, 5): bytearray(b'1, 1, 0, 0,(),(),(d\x00\x00S),(),()'),
(3, 6): bytearray(b'1, 1, 0, 0,(),(),(d\x00S\x00),(),()'),
(3, 7): bytearray(b'1, 1, 0, 0,(),(),(d\x00S\x00),(),()'),
+ (3, 8): bytearray(b'1, 1, 0, 0,(),(),(d\x00S\x00),(),()'),
}
def factory(act, **kw):
@@ -1959,6 +1963,7 @@ class LazyActionTestCase(unittest.TestCase):
(3, 5): bytearray(b'0, 0, 0, 0,(),(),(d\x00\x00S),(),()'),
(3, 6): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
(3, 7): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
+ (3, 8): bytearray(b'0, 0, 0, 0,(),(),(d\x00S\x00),(),()'),
}
meth_matches = [
@@ -2017,6 +2022,7 @@ class ActionCallerTestCase(unittest.TestCase):
(3, 5): b'd\x00\x00S',
(3, 6): b'd\x00S\x00',
(3, 7): b'd\x00S\x00',
+ (3, 8): b'd\x00S\x00',
}
@@ -2217,6 +2223,7 @@ class ObjectContentsTestCase(unittest.TestCase):
(3, 5): bytearray(b'3, 3, 0, 0,(),(),(|\x00\x00S),(),()'),
(3, 6): bytearray(b'3, 3, 0, 0,(),(),(|\x00S\x00),(),()'),
(3, 7): bytearray(b'3, 3, 0, 0,(),(),(|\x00S\x00),(),()'),
+ (3, 8): bytearray(b'3, 3, 0, 0,(),(),(|\x00S\x00),(),()'),
}
c = SCons.Action._function_contents(func1)
@@ -2242,6 +2249,8 @@ class ObjectContentsTestCase(unittest.TestCase):
b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01|\x00_\x00d\x02|\x00_\x01d\x00S\x00),(),(),2, 2, 0, 0,(),(),(d\x00S\x00),(),()}}{{{a=a,b=b}}}"),
(3, 7): bytearray(
b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01|\x00_\x00d\x02|\x00_\x01d\x00S\x00),(),(),2, 2, 0, 0,(),(),(d\x00S\x00),(),()}}{{{a=a,b=b}}}"),
+ (3, 8): bytearray(
+ b"{TestClass:__main__}[[[(<class \'object\'>, ()), [(<class \'__main__.TestClass\'>, (<class \'object\'>,))]]]]{{1, 1, 0, 0,(a,b),(a,b),(d\x01|\x00_\x00d\x02|\x00_\x01d\x00S\x00),(),(),2, 2, 0, 0,(),(),(d\x00S\x00),(),()}}{{{a=a,b=b}}}"),
}
assert c == expected[sys.version_info[:2]], "Got\n" + repr(c) + "\nExpected \n" + "\n" + repr(
@@ -2259,11 +2268,28 @@ class ObjectContentsTestCase(unittest.TestCase):
(3, 5): bytearray(b'0, 0, 0, 0,(Hello, World!),(print),(e\x00\x00d\x00\x00\x83\x01\x00\x01d\x01\x00S)'),
(3, 6): bytearray(b'0, 0, 0, 0,(Hello, World!),(print),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)'),
(3, 7): bytearray(b'0, 0, 0, 0,(Hello, World!),(print),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)'),
+ (3, 8): bytearray(b'0, 0, 0, 0,(Hello, World!),(print),(e\x00d\x00\x83\x01\x01\x00d\x01S\x00)'),
}
assert c == expected[sys.version_info[:2]], "Got\n" + repr(c) + "\nExpected \n" + "\n" + repr(expected[
sys.version_info[:2]])
+ def test_uncaught_exception_bubbles(self):
+ """Test that _subproc bubbles uncaught exceptions"""
+ try:
+ pobj = SCons.Action._subproc(Environment(),
+ None,
+ stdin='devnull',
+ stderr='devnull',
+ stdout=subprocess.PIPE)
+ pobj.wait()
+ except EnvironmentError:
+ pass
+ except Exception:
+ # pass the test
+ return
+
+ raise Exception("expected a non-EnvironmentError exception")
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index 512fcf7..7777436 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -98,7 +98,7 @@ There are the following methods for internal use within this module:
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Builder.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Builder.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import collections
@@ -274,7 +274,7 @@ def Builder(**kw):
result = BuilderBase(**kw)
- if not composite is None:
+ if composite is not None:
result = CompositeBuilder(result, composite)
return result
@@ -293,7 +293,7 @@ def _node_errors(builder, env, tlist, slist):
if t.has_explicit_builder():
# Check for errors when the environments are different
# No error if environments are the same Environment instance
- if (not t.env is None and not t.env is env and
+ if (t.env is not None and t.env is not env and
# Check OverrideEnvironment case - no error if wrapped Environments
# are the same instance, and overrides lists match
not (getattr(t.env, '__subject', 0) is getattr(env, '__subject', 1) and
@@ -309,7 +309,7 @@ def _node_errors(builder, env, tlist, slist):
else:
try:
msg = "Two environments with different actions were specified for the same target: %s\n(action 1: %s)\n(action 2: %s)" % (t,t_contents.decode('utf-8'),contents.decode('utf-8'))
- except UnicodeDecodeError as e:
+ except UnicodeDecodeError:
msg = "Two environments with different actions were specified for the same target: %s"%t
raise UserError(msg)
if builder.multi:
@@ -424,7 +424,7 @@ class BuilderBase(object):
if name:
self.name = name
self.executor_kw = {}
- if not chdir is _null:
+ if chdir is not _null:
self.executor_kw['chdir'] = chdir
self.is_explicit = is_explicit
@@ -554,8 +554,10 @@ class BuilderBase(object):
result = []
if target is None: target = [None]*len(source)
for tgt, src in zip(target, source):
- if not tgt is None: tgt = [tgt]
- if not src is None: src = [src]
+ if tgt is not None:
+ tgt = [tgt]
+ if src is not None:
+ src = [src]
result.extend(self._execute(env, tgt, src, overwarn))
return SCons.Node.NodeList(result)
@@ -563,6 +565,13 @@ class BuilderBase(object):
tlist, slist = self._create_nodes(env, target, source)
+ # If there is more than one target ensure that if we need to reset
+ # the implicit list to new scan of dependency all targets implicit lists
+ # are cleared. (SCons GH Issue #2811 and MongoDB SERVER-33111)
+ if len(tlist) > 1:
+ for t in tlist:
+ t.target_peers = tlist
+
# Check for errors with the specified target/source lists.
_node_errors(self, env, tlist, slist)
@@ -744,7 +753,7 @@ class BuilderBase(object):
for s in SCons.Util.flatten(source):
if SCons.Util.is_String(s):
match_suffix = match_src_suffix(env.subst(s))
- if not match_suffix and not '.' in s:
+ if not match_suffix and '.' not in s:
src_suf = self.get_src_suffix(env)
s = self._adjustixes(s, None, src_suf)[0]
else:
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 255eced..dd9a917 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/BuilderTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/BuilderTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -409,10 +409,6 @@ class BuilderTestCase(unittest.TestCase):
builder = SCons.Builder.Builder(generator=generator)
assert builder.action.generator == generator
- def test_get_name(self):
- """Test the get_name() method
- """
-
def test_cmp(self):
"""Test simple comparisons of Builder objects
"""
@@ -552,7 +548,7 @@ class BuilderTestCase(unittest.TestCase):
def test_src_suffix(self):
"""Test Builder creation with a specified source file suffix
-
+
Make sure that the '.' separator is appended to the
beginning if it isn't already present.
"""
@@ -685,7 +681,7 @@ class BuilderTestCase(unittest.TestCase):
pass
if (len(source) == 1 and len(target) == 1):
env['CNT'][0] = env['CNT'][0] + 1
-
+
env = Environment()
infiles = []
outfiles = []
@@ -732,8 +728,8 @@ class BuilderTestCase(unittest.TestCase):
pass
else:
assert 0
-
-
+
+
def test_lists(self):
"""Testing handling lists of targets and source"""
def function2(target, source, env, tlist = [outfile, outfile2], **kw):
@@ -881,7 +877,7 @@ class BuilderTestCase(unittest.TestCase):
def func(self):
pass
-
+
scanner = SCons.Scanner.Base(func, name='fooscan')
b1 = SCons.Builder.Builder(action='bld', target_scanner=scanner)
@@ -890,8 +886,8 @@ class BuilderTestCase(unittest.TestCase):
assert b1 == b2
assert b1 != b3
-
- def test_src_scanner(slf):
+
+ def test_src_scanner(self):
"""Testing ability to set a source file scanner through a builder."""
class TestScanner(object):
def key(self, env):
@@ -1245,7 +1241,7 @@ class BuilderTestCase(unittest.TestCase):
for t in target:
t.builder = nb
return [nn], source
-
+
builder=SCons.Builder.Builder(action='foo',
emitter=emit,
target_factory=MyNode,
@@ -1321,7 +1317,7 @@ class BuilderTestCase(unittest.TestCase):
builder2 = SCons.Builder.Builder(action='foo',
emitter='$EMITTERLIST',
node_factory=MyNode)
-
+
env = Environment(EMITTERLIST = [emit2a, emit2b])
tgts = builder2(env, target='target-2', source='aaa.2')
@@ -1419,7 +1415,7 @@ class BuilderTestCase(unittest.TestCase):
b6 = SCons.Builder.Builder(action='foo')
assert isinstance(b4, SCons.Builder.CompositeBuilder)
assert isinstance(b4.action, SCons.Action.CommandGeneratorAction)
-
+
env = Environment(BUILDERS={'bldr1': b1,
'bldr2': b2,
'bldr3': b3,
@@ -1481,7 +1477,7 @@ class CompositeBuilderTestCase(unittest.TestCase):
tgt = builder(env, source=[])
assert tgt == [], tgt
-
+
assert isinstance(builder, SCons.Builder.CompositeBuilder)
assert isinstance(builder.action, SCons.Action.CommandGeneratorAction)
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index 73df784..c9e8ea7 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/CacheDir.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/CacheDir.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
CacheDir support
@@ -35,6 +35,7 @@ import sys
import SCons.Action
import SCons.Warnings
+from SCons.Util import PY3
cache_enabled = True
cache_debug = False
@@ -46,10 +47,12 @@ def CacheRetrieveFunc(target, source, env):
t = target[0]
fs = t.fs
cd = env.get_CacheDir()
+ cd.requests += 1
cachedir, cachefile = cd.cachepath(t)
if not fs.exists(cachefile):
cd.CacheDebug('CacheRetrieve(%s): %s not in cache\n', t, cachefile)
return 1
+ cd.hits += 1
cd.CacheDebug('CacheRetrieve(%s): retrieving from %s\n', t, cachefile)
if SCons.Action.execute_actions:
if fs.islink(cachefile):
@@ -111,7 +114,7 @@ def CachePushFunc(target, source, env):
# has beaten us creating the directory.
if not fs.isdir(cachedir):
msg = errfmt % (str(target), cachefile)
- raise SCons.Errors.EnvironmentError(msg)
+ raise SCons.Errors.SConsEnvironmentError(msg)
try:
if fs.islink(t.get_internal_path()):
@@ -139,34 +142,97 @@ warned = dict()
class CacheDir(object):
def __init__(self, path):
+ """
+ Initialize a CacheDir object.
+
+ The cache configuration is stored in the object. It
+ is read from the config file in the supplied path if
+ one exists, if not the config file is created and
+ the default config is written, as well as saved in the object.
+ """
+ self.requests = 0
+ self.hits = 0
self.path = path
self.current_cache_debug = None
self.debugFP = None
self.config = dict()
if path is None:
return
- # See if there's a config file in the cache directory. If there is,
- # use it. If there isn't, and the directory exists and isn't empty,
- # produce a warning. If the directory doesn't exist or is empty,
- # write a config file.
+
+ if PY3:
+ self._readconfig3(path)
+ else:
+ self._readconfig2(path)
+
+
+ def _readconfig3(self, path):
+ """
+ Python3 version of reading the cache config.
+
+ If directory or config file do not exist, create. Take advantage
+ of Py3 capability in os.makedirs() and in file open(): just try
+ the operation and handle failure appropriately.
+
+ Omit the check for old cache format, assume that's old enough
+ there will be none of those left to worry about.
+
+ :param path: path to the cache directory
+ """
+ config_file = os.path.join(path, 'config')
+ try:
+ os.makedirs(path, exist_ok=True)
+ except FileExistsError:
+ pass
+ except OSError:
+ msg = "Failed to create cache directory " + path
+ raise SCons.Errors.EnvironmentError(msg)
+
+ try:
+ with open(config_file, 'x') as config:
+ self.config['prefix_len'] = 2
+ try:
+ json.dump(self.config, config)
+ except Exception:
+ msg = "Failed to write cache configuration for " + path
+ raise SCons.Errors.EnvironmentError(msg)
+ except FileExistsError:
+ try:
+ with open(config_file) as config:
+ self.config = json.load(config)
+ except ValueError:
+ msg = "Failed to read cache configuration for " + path
+ raise SCons.Errors.EnvironmentError(msg)
+
+
+ def _readconfig2(self, path):
+ """
+ Python2 version of reading cache config.
+
+ See if there is a config file in the cache directory. If there is,
+ use it. If there isn't, and the directory exists and isn't empty,
+ produce a warning. If the directory does not exist or is empty,
+ write a config file.
+
+ :param path: path to the cache directory
+ """
config_file = os.path.join(path, 'config')
if not os.path.exists(config_file):
- # A note: There is a race hazard here, if two processes start and
+ # A note: There is a race hazard here if two processes start and
# attempt to create the cache directory at the same time. However,
- # python doesn't really give you the option to do exclusive file
- # creation (it doesn't even give you the option to error on opening
- # an existing file for writing...). The ordering of events here
- # as an attempt to alleviate this, on the basis that it's a pretty
- # unlikely occurence (it'd require two builds with a brand new cache
+ # Python 2.x does not give you the option to do exclusive file
+ # creation (not even the option to error on opening an existing
+ # file for writing...). The ordering of events here is an attempt
+ # to alleviate this, on the basis that it's a pretty unlikely
+ # occurrence (would require two builds with a brand new cache
# directory)
- if os.path.isdir(path) and len(os.listdir(path)) != 0:
+ if os.path.isdir(path) and any(f != "config" for f in os.listdir(path)):
self.config['prefix_len'] = 1
# When building the project I was testing this on, the warning
# was output over 20 times. That seems excessive
global warned
if self.path not in warned:
msg = "Please upgrade your cache by running " +\
- " scons-configure-cache.py " + self.path
+ "scons-configure-cache.py " + self.path
SCons.Warnings.warn(SCons.Warnings.CacheVersionWarning, msg)
warned[self.path] = True
else:
@@ -177,24 +243,24 @@ class CacheDir(object):
# If someone else is trying to create the directory at
# the same time as me, bad things will happen
msg = "Failed to create cache directory " + path
- raise SCons.Errors.EnvironmentError(msg)
-
+ raise SCons.Errors.SConsEnvironmentError(msg)
+
self.config['prefix_len'] = 2
if not os.path.exists(config_file):
try:
with open(config_file, 'w') as config:
json.dump(self.config, config)
- except:
+ except Exception:
msg = "Failed to write cache configuration for " + path
- raise SCons.Errors.EnvironmentError(msg)
+ raise SCons.Errors.SConsEnvironmentError(msg)
else:
try:
with open(config_file) as config:
self.config = json.load(config)
except ValueError:
msg = "Failed to read cache configuration for " + path
- raise SCons.Errors.EnvironmentError(msg)
-
+ raise SCons.Errors.SConsEnvironmentError(msg)
+
def CacheDebug(self, fmt, target, cachefile):
if cache_debug != self.current_cache_debug:
@@ -207,9 +273,19 @@ class CacheDir(object):
self.current_cache_debug = cache_debug
if self.debugFP:
self.debugFP.write(fmt % (target, os.path.split(cachefile)[1]))
+ self.debugFP.write("requests: %d, hits: %d, misses: %d, hit rate: %.2f%%\n" %
+ (self.requests, self.hits, self.misses, self.hit_ratio))
+
+ @property
+ def hit_ratio(self):
+ return (100.0 * self.hits / self.requests if self.requests > 0 else 100)
+
+ @property
+ def misses(self):
+ return self.requests - self.hits
def is_enabled(self):
- return cache_enabled and not self.path is None
+ return cache_enabled and self.path is not None
def is_readonly(self):
return cache_readonly
diff --git a/src/engine/SCons/CacheDirTests.py b/src/engine/SCons/CacheDirTests.py
index 6b644d3..f96dab5 100644
--- a/src/engine/SCons/CacheDirTests.py
+++ b/src/engine/SCons/CacheDirTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/CacheDirTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/CacheDirTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import shutil
diff --git a/src/engine/SCons/Conftest.py b/src/engine/SCons/Conftest.py
index 84aa992..1163aa3 100644
--- a/src/engine/SCons/Conftest.py
+++ b/src/engine/SCons/Conftest.py
@@ -354,7 +354,7 @@ def CheckHeader(context, header_name, header = None, language = None,
context.Display("Checking for %s header file %s... " % (lang, header_name))
ret = context.CompileProg(text, suffix)
- _YesNoResult(context, ret, "HAVE_" + header_name, text,
+ _YesNoResult(context, ret, "HAVE_" + header_name, text,
"Define to 1 if you have the <%s> header file." % header_name)
return ret
@@ -439,7 +439,7 @@ def CheckTypeSize(context, type_name, header = None, language = None, expect = N
Returns:
status : int
0 if the check failed, or the found size of the type if the check succeeded."""
-
+
# Include "confdefs.h" first, so that the header can use HAVE_HEADER_H.
if context.headerfilename:
includetext = '#include "%s"' % context.headerfilename
@@ -454,8 +454,8 @@ def CheckTypeSize(context, type_name, header = None, language = None, expect = N
context.Display("Cannot check for %s type: %s\n" % (type_name, msg))
return msg
- src = includetext + header
- if not expect is None:
+ src = includetext + header
+ if expect is not None:
# Only check if the given size is the right one
context.Display('Checking %s is %d bytes... ' % (type_name, expect))
@@ -477,7 +477,7 @@ int main(void)
st = context.CompileProg(src % (type_name, expect), suffix)
if not st:
context.Display("yes\n")
- _Have(context, "SIZEOF_%s" % type_name, expect,
+ _Have(context, "SIZEOF_%s" % type_name, expect,
"The size of `%s', as computed by sizeof." % type_name)
return expect
else:
@@ -541,7 +541,7 @@ def CheckDeclaration(context, symbol, includes = None, language = None):
Returns:
status : bool
True if the check failed, False if succeeded."""
-
+
# Include "confdefs.h" first, so that the header can use HAVE_HEADER_H.
if context.headerfilename:
includetext = '#include "%s"' % context.headerfilename
@@ -556,7 +556,7 @@ def CheckDeclaration(context, symbol, includes = None, language = None):
context.Display("Cannot check for declaration %s: %s\n" % (symbol, msg))
return msg
- src = includetext + includes
+ src = includetext + includes
context.Display('Checking whether %s is declared... ' % symbol)
src = src + r"""
@@ -677,7 +677,7 @@ return 0;
"Define to 1 if you have the `%s' library." % lib_name)
if oldLIBS != -1 and (ret or not autoadd):
context.SetLIBS(oldLIBS)
-
+
if not ret:
return ret
@@ -704,7 +704,7 @@ def CheckProg(context, prog_name):
#
def _YesNoResult(context, ret, key, text, comment = None):
- """
+ r"""
Handle the result of a test with a "yes" or "no" result.
:Parameters:
@@ -723,7 +723,7 @@ def _YesNoResult(context, ret, key, text, comment = None):
def _Have(context, key, have, comment = None):
- """
+ r"""
Store result of a test in context.havedict and context.headerfilename.
:Parameters:
@@ -751,7 +751,7 @@ def _Have(context, key, have, comment = None):
line = "#define %s %d\n" % (key_up, have)
else:
line = "#define %s %s\n" % (key_up, str(have))
-
+
if comment is not None:
lines = "\n/* %s */\n" % comment + line
else:
diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py
index 34ce70d..c19862a 100644
--- a/src/engine/SCons/Debug.py
+++ b/src/engine/SCons/Debug.py
@@ -31,7 +31,7 @@ caller_trace()
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Debug.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Debug.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index c2dc70a..30c0052 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -33,7 +33,7 @@ from distutils.msvccompiler.
#
from __future__ import division
-__revision__ = "src/engine/SCons/Defaults.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Defaults.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -193,7 +193,7 @@ def chmod_func(dest, mode):
SCons.Node.FS.invalidate_node_memos(dest)
if not SCons.Util.is_List(dest):
dest = [dest]
- if SCons.Util.is_String(mode) and not 0 in [i in digits for i in mode]:
+ if SCons.Util.is_String(mode) and 0 not in [i in digits for i in mode]:
mode = int(mode, 8)
if not SCons.Util.is_String(mode):
for element in dest:
@@ -582,6 +582,7 @@ ConstructionEnvironment = {
'__DSHLIBVERSIONFLAGS' : '${__libversionflags(__env__,"DSHLIBVERSION","_DSHLIBVERSIONFLAGS")}',
'TEMPFILE' : NullCmdGenerator,
+ 'TEMPFILEARGJOIN': ' ',
'Dir' : Variable_Method_Caller('TARGET', 'Dir'),
'Dirs' : Variable_Method_Caller('TARGET', 'Dirs'),
'File' : Variable_Method_Caller('TARGET', 'File'),
diff --git a/src/engine/SCons/DefaultsTests.py b/src/engine/SCons/DefaultsTests.py
index 5a4e1cb..4e0328a 100644
--- a/src/engine/SCons/DefaultsTests.py
+++ b/src/engine/SCons/DefaultsTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/DefaultsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/DefaultsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -69,11 +69,11 @@ class DefaultsTestCase(unittest.TestCase):
test.write(file, "test\n")
try:
mkdir_func(file)
- except os.error as e:
+ except OSError as e:
pass
else:
- fail("expected os.error")
-
+ self.fail("expected OSError")
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 759ff16..31a4721 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -31,7 +31,7 @@ Environment
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Environment.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Environment.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import copy
@@ -608,7 +608,7 @@ class SubstitutionEnvironment(object):
Removes the specified function's MethodWrapper from the
added_methods list, so we don't re-bind it when making a clone.
"""
- self.added_methods = [dm for dm in self.added_methods if not dm.method is function]
+ self.added_methods = [dm for dm in self.added_methods if dm.method is not function]
def Override(self, overrides):
"""
@@ -719,6 +719,12 @@ class SubstitutionEnvironment(object):
elif append_next_arg_to == '-isystem':
t = ('-isystem', arg)
dict['CCFLAGS'].append(t)
+ elif append_next_arg_to == '-iquote':
+ t = ('-iquote', arg)
+ dict['CCFLAGS'].append(t)
+ elif append_next_arg_to == '-idirafter':
+ t = ('-idirafter', arg)
+ dict['CCFLAGS'].append(t)
elif append_next_arg_to == '-arch':
t = ('-arch', arg)
dict['CCFLAGS'].append(t)
@@ -791,7 +797,7 @@ class SubstitutionEnvironment(object):
elif arg[0] == '+':
dict['CCFLAGS'].append(arg)
dict['LINKFLAGS'].append(arg)
- elif arg in ['-include', '-isysroot', '-isystem', '-arch']:
+ elif arg in ['-include', '-isysroot', '-isystem', '-iquote', '-idirafter', '-arch']:
append_next_arg_to = arg
else:
dict['CCFLAGS'].append(arg)
@@ -858,18 +864,21 @@ class SubstitutionEnvironment(object):
return self
-def default_decide_source(dependency, target, prev_ni):
+def default_decide_source(dependency, target, prev_ni, repo_node=None):
f = SCons.Defaults.DefaultEnvironment().decide_source
- return f(dependency, target, prev_ni)
+ return f(dependency, target, prev_ni, repo_node)
-def default_decide_target(dependency, target, prev_ni):
+
+def default_decide_target(dependency, target, prev_ni, repo_node=None):
f = SCons.Defaults.DefaultEnvironment().decide_target
- return f(dependency, target, prev_ni)
+ return f(dependency, target, prev_ni, repo_node)
+
def default_copy_from_cache(src, dst):
f = SCons.Defaults.DefaultEnvironment().copy_from_cache
return f(src, dst)
+
class Base(SubstitutionEnvironment):
"""Base class for "real" construction Environments. These are the
primary objects used to communicate dependency and construction
@@ -1342,7 +1351,7 @@ class Base(SubstitutionEnvironment):
dk = list(filter(lambda x, val=val: x not in val, dk))
self._dict[key] = dk + [val]
else:
- if not val in dk:
+ if val not in dk:
self._dict[key] = dk + [val]
else:
if key == 'CPPDEFINES':
@@ -1428,30 +1437,30 @@ class Base(SubstitutionEnvironment):
_warn_copy_deprecated = False
return self.Clone(*args, **kw)
- def _changed_build(self, dependency, target, prev_ni):
- if dependency.changed_state(target, prev_ni):
+ def _changed_build(self, dependency, target, prev_ni, repo_node=None):
+ if dependency.changed_state(target, prev_ni, repo_node):
return 1
- return self.decide_source(dependency, target, prev_ni)
+ return self.decide_source(dependency, target, prev_ni, repo_node)
- def _changed_content(self, dependency, target, prev_ni):
- return dependency.changed_content(target, prev_ni)
+ def _changed_content(self, dependency, target, prev_ni, repo_node=None):
+ return dependency.changed_content(target, prev_ni, repo_node)
- def _changed_source(self, dependency, target, prev_ni):
+ def _changed_source(self, dependency, target, prev_ni, repo_node=None):
target_env = dependency.get_build_env()
type = target_env.get_tgt_sig_type()
if type == 'source':
- return target_env.decide_source(dependency, target, prev_ni)
+ return target_env.decide_source(dependency, target, prev_ni, repo_node)
else:
- return target_env.decide_target(dependency, target, prev_ni)
+ return target_env.decide_target(dependency, target, prev_ni, repo_node)
- def _changed_timestamp_then_content(self, dependency, target, prev_ni):
- return dependency.changed_timestamp_then_content(target, prev_ni)
+ def _changed_timestamp_then_content(self, dependency, target, prev_ni, repo_node=None):
+ return dependency.changed_timestamp_then_content(target, prev_ni, repo_node)
- def _changed_timestamp_newer(self, dependency, target, prev_ni):
- return dependency.changed_timestamp_newer(target, prev_ni)
+ def _changed_timestamp_newer(self, dependency, target, prev_ni, repo_node=None):
+ return dependency.changed_timestamp_newer(target, prev_ni, repo_node)
- def _changed_timestamp_match(self, dependency, target, prev_ni):
- return dependency.changed_timestamp_match(target, prev_ni)
+ def _changed_timestamp_match(self, dependency, target, prev_ni, repo_node=None):
+ return dependency.changed_timestamp_match(target, prev_ni, repo_node)
def _copy_from_cache(self, src, dst):
return self.fs.copy(src, dst)
@@ -1722,7 +1731,7 @@ class Base(SubstitutionEnvironment):
dk = [x for x in dk if x not in val]
self._dict[key] = [val] + dk
else:
- if not val in dk:
+ if val not in dk:
self._dict[key] = [val] + dk
else:
if delete_existing:
@@ -2299,7 +2308,20 @@ class OverrideEnvironment(Base):
# Methods that make this class act like a proxy.
def __getattr__(self, name):
- return getattr(self.__dict__['__subject'], name)
+ attr = getattr(self.__dict__['__subject'], name)
+ # Here we check if attr is one of the Wrapper classes. For
+ # example when a pseudo-builder is being called from an
+ # OverrideEnvironment.
+ #
+ # These wrappers when they're constructed capture the
+ # Environment they are being constructed with and so will not
+ # have access to overrided values. So we rebuild them with the
+ # OverrideEnvironment so they have access to overrided values.
+ if isinstance(attr, (MethodWrapper, BuilderWrapper)):
+ return attr.clone(self)
+ else:
+ return attr
+
def __setattr__(self, name, value):
setattr(self.__dict__['__subject'], name, value)
diff --git a/src/engine/SCons/Environment.xml b/src/engine/SCons/Environment.xml
index 71b11e6..9b392d5 100644
--- a/src/engine/SCons/Environment.xml
+++ b/src/engine/SCons/Environment.xml
@@ -549,7 +549,7 @@ string, in which case a list will be returned instead of a string.
</para>
<para>
-If
+If
<varname>delete_existing</varname>
is 0, then adding a path that already exists
will not move it to the end; it will stay where it is in the list.
@@ -588,7 +588,7 @@ then any value(s) that already exist in the
construction variable will
<emphasis>not</emphasis>
be added again to the list.
-However, if delete_existing is 1,
+However, if delete_existing is 1,
existing matching values are removed first, so
existing values in the arg list move to the end of the list.
</para>
@@ -883,12 +883,14 @@ env4 = env.Clone(tools = ['msvc', MyTool])
<para>
The
<varname>parse_flags</varname>
-keyword argument is also recognized:
+keyword argument is also recognized to allow merging command-line
+style arguments into the appropriate construction
+variables (see &f-link-env-MergeFlags;).
</para>
<example_commands>
# create an environment for compiling programs that use wxWidgets
-wx_env = env.Clone(parse_flags = '!wx-config --cflags --cxxflags')
+wx_env = env.Clone(parse_flags='!wx-config --cflags --cxxflags')
</example_commands>
</summary>
</scons_function>
@@ -1211,6 +1213,17 @@ size, or content signature.
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+<term><parameter>repo_node</parameter></term>
+<listitem>
+<para>
+Use this node instead of the one specified by
+<varname>dependency</varname>
+ to determine if the dependency has changed.
+</para>
+</listitem>
+</varlistentry>
+
</variablelist>
</para>
@@ -1247,7 +1260,7 @@ Example:
</para>
<example_commands>
-def my_decider(dependency, target, prev_ni):
+def my_decider(dependency, target, prev_ni, repo_node=None):
return not os.path.exists(str(target))
env.Decider(my_decider)
@@ -1880,9 +1893,9 @@ as the dependency.
</para>
<para>
-Note that this will only remove the dependencies listed from
-the files built by default. It will still be built if that
-dependency is needed by another object being built.
+Note that this will only remove the dependencies listed from
+the files built by default. It will still be built if that
+dependency is needed by another object being built.
See the third and forth examples below.
</para>
@@ -1954,8 +1967,8 @@ not as separate arguments to
<para>
New values are prepended to the environment variable by default,
-unless prepend=0 is specified.
-Duplicate values are always eliminated,
+unless prepend=0 is specified.
+Duplicate values are always eliminated,
since this function calls
&f-link-AppendENVPath;
or
@@ -2294,6 +2307,9 @@ and added to the following construction variables:
-frameworkdir= FRAMEWORKPATH
-include CCFLAGS
-isysroot CCFLAGS, LINKFLAGS
+-isystem CCFLAGS
+-iquote CCFLAGS
+-idirafter CCFLAGS
-I CPPPATH
-l LIBS
-L LIBPATH
@@ -2489,7 +2505,7 @@ then any value(s) that already exist in the
construction variable will
<emphasis>not</emphasis>
be added again to the list.
-However, if delete_existing is 1,
+However, if delete_existing is 1,
existing matching values are removed first, so
existing values in the arg list move to the front of the list.
</para>
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index b97ac5c..1ce1007 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -23,7 +23,7 @@
from __future__ import print_function
-__revision__ = "src/engine/SCons/EnvironmentTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/EnvironmentTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -74,7 +74,7 @@ def diff_dict(d1, d2):
s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n"
else:
s1 = s1 + " " + repr(k) + " : " + repr(d1[k]) + "\n"
- elif k in env2:
+ elif k in d2:
s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n"
s1 = s1 + "}\n"
s2 = s2 + "}\n"
@@ -263,39 +263,39 @@ class SubstitutionTestCase(unittest.TestCase):
nodes = env.arg2nodes("Util.py UtilTests.py", Factory)
assert len(nodes) == 1, nodes
assert isinstance(nodes[0], X)
- assert nodes[0].name == "Util.py UtilTests.py"
+ assert nodes[0].name == "Util.py UtilTests.py", nodes[0].name
nodes = env.arg2nodes(u"Util.py UtilTests.py", Factory)
assert len(nodes) == 1, nodes
assert isinstance(nodes[0], X)
- assert nodes[0].name == u"Util.py UtilTests.py"
+ assert nodes[0].name == u"Util.py UtilTests.py", nodes[0].name
nodes = env.arg2nodes(["Util.py", "UtilTests.py"], Factory)
assert len(nodes) == 2, nodes
assert isinstance(nodes[0], X)
assert isinstance(nodes[1], X)
- assert nodes[0].name == "Util.py"
- assert nodes[1].name == "UtilTests.py"
+ assert nodes[0].name == "Util.py", nodes[0].name
+ assert nodes[1].name == "UtilTests.py", nodes[1].name
n1 = Factory("Util.py")
nodes = env.arg2nodes([n1, "UtilTests.py"], Factory)
assert len(nodes) == 2, nodes
assert isinstance(nodes[0], X)
assert isinstance(nodes[1], X)
- assert nodes[0].name == "Util.py"
- assert nodes[1].name == "UtilTests.py"
+ assert nodes[0].name == "Util.py", nodes[0].name
+ assert nodes[1].name == "UtilTests.py", nodes[1].name
class SConsNode(SCons.Node.Node):
pass
nodes = env.arg2nodes(SConsNode())
assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], SConsNode), node
+ assert isinstance(nodes[0], SConsNode), nodes[0]
class OtherNode(object):
pass
nodes = env.arg2nodes(OtherNode())
assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], OtherNode), node
+ assert isinstance(nodes[0], OtherNode), nodes[0]
def lookup_a(str, F=Factory):
if str[0] == 'a':
@@ -484,7 +484,7 @@ class SubstitutionTestCase(unittest.TestCase):
env = SubstitutionEnvironment(AAA = '$BBB', BBB = '$CCC', CCC = 'c')
l = env.subst_list("$AAA ${AAA}A ${AAA}B $BBB")
- assert l == [["c", "cA", "cB", "c"]], mystr
+ assert l == [["c", "cA", "cB", "c"]], l
env = SubstitutionEnvironment(AAA = '$BBB', BBB = '$CCC', CCC = [ 'a', 'b\nc' ])
lst = env.subst_list([ "$AAA", "B $CCC" ])
@@ -800,7 +800,9 @@ sys.exit(0)
"-fopenmp " + \
"-mno-cygwin -mwindows " + \
"-arch i386 -isysroot /tmp " + \
- "-isystem /usr/include/foo " + \
+ "-iquote /usr/include/foo1 " + \
+ "-isystem /usr/include/foo2 " + \
+ "-idirafter /usr/include/foo3 " + \
"+DD64 " + \
"-DFOO -DBAR=value -D BAZ "
@@ -809,10 +811,12 @@ sys.exit(0)
assert d['ASFLAGS'] == ['-as'], d['ASFLAGS']
assert d['CFLAGS'] == ['-std=c99']
assert d['CCFLAGS'] == ['-X', '-Wa,-as',
- '-pthread', '-fopenmp', '-mno-cygwin',
- ('-arch', 'i386'), ('-isysroot', '/tmp'),
- ('-isystem', '/usr/include/foo'),
- '+DD64'], repr(d['CCFLAGS'])
+ '-pthread', '-fopenmp', '-mno-cygwin',
+ ('-arch', 'i386'), ('-isysroot', '/tmp'),
+ ('-iquote', '/usr/include/foo1'),
+ ('-isystem', '/usr/include/foo2'),
+ ('-idirafter', '/usr/include/foo3'),
+ '+DD64'], repr(d['CCFLAGS'])
assert d['CXXFLAGS'] == ['-std=c++0x'], repr(d['CXXFLAGS'])
assert d['CPPDEFINES'] == ['FOO', ['BAR', 'value'], 'BAZ'], d['CPPDEFINES']
assert d['CPPFLAGS'] == ['-Wp,-cpp'], d['CPPFLAGS']
@@ -1195,7 +1199,7 @@ env4.builder1.env, env3)
test_it('foo.bar')
test_it('foo-bar')
- def test_autogenerate(dict):
+ def test_autogenerate(self):
"""Test autogenerating variables in a dictionary."""
drive, p = os.path.splitdrive(os.getcwd())
@@ -1206,9 +1210,9 @@ env4.builder1.env, env3)
drive, path = os.path.splitdrive(path)
return drive.lower() + path
- env = dict.TestEnvironment(LIBS = [ 'foo', 'bar', 'baz' ],
- LIBLINKPREFIX = 'foo',
- LIBLINKSUFFIX = 'bar')
+ env = self.TestEnvironment(LIBS = [ 'foo', 'bar', 'baz' ],
+ LIBLINKPREFIX = 'foo',
+ LIBLINKSUFFIX = 'bar')
def RDirs(pathlist, fs=env.fs):
return fs.Dir('xx').Rfindalldirs(pathlist)
@@ -2022,7 +2026,9 @@ def generate(env):
"-pthread " + \
"-mno-cygwin -mwindows " + \
"-arch i386 -isysroot /tmp " + \
- "-isystem /usr/include/foo " + \
+ "-iquote /usr/include/foo1 " + \
+ "-isystem /usr/include/foo2 " + \
+ "-idirafter /usr/include/foo3 " + \
"+DD64 " + \
"-DFOO -DBAR=value")
env.ParseConfig("fake $COMMAND")
@@ -2031,7 +2037,9 @@ def generate(env):
assert env['CCFLAGS'] == ['', '-X', '-Wa,-as',
'-pthread', '-mno-cygwin',
('-arch', 'i386'), ('-isysroot', '/tmp'),
- ('-isystem', '/usr/include/foo'),
+ ('-iquote', '/usr/include/foo1'),
+ ('-isystem', '/usr/include/foo2'),
+ ('-idirafter', '/usr/include/foo3'),
'+DD64'], env['CCFLAGS']
assert env['CPPDEFINES'] == ['FOO', ['BAR', 'value']], env['CPPDEFINES']
assert env['CPPFLAGS'] == ['', '-Wp,-cpp'], env['CPPFLAGS']
@@ -2433,16 +2441,16 @@ f5: \
exc_caught = None
try:
env.Tool('does_not_exist')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
exc_caught = 1
- assert exc_caught, "did not catch expected EnvironmentError"
+ assert exc_caught, "did not catch expected SConsEnvironmentError"
exc_caught = None
try:
env.Tool('$NONE')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
exc_caught = 1
- assert exc_caught, "did not catch expected EnvironmentError"
+ assert exc_caught, "did not catch expected SConsEnvironmentError"
# Use a non-existent toolpath directory just to make sure we
# can call Tool() with the keyword argument.
@@ -3272,11 +3280,11 @@ def generate(env):
s = e.src_builder()
assert s is None, s
- def test_SourceSignatures(type):
+ def test_SourceSignatures(self):
"""Test the SourceSignatures() method"""
import SCons.Errors
- env = type.TestEnvironment(M = 'MD5', T = 'timestamp')
+ env = self.TestEnvironment(M = 'MD5', T = 'timestamp')
exc_caught = None
try:
@@ -3312,7 +3320,7 @@ def generate(env):
def test_Split(self):
"""Test the Split() method"""
- env = self.TestEnvironment(FOO='fff', BAR='bbb')
+ env = self.TestEnvironment(FOO = 'fff', BAR = 'bbb')
s = env.Split("foo bar")
assert s == ["foo", "bar"], s
s = env.Split("$FOO bar")
@@ -3326,11 +3334,11 @@ def generate(env):
s = env.Split("$FOO$BAR")
assert s == ["fffbbb"], s
- def test_TargetSignatures(type):
+ def test_TargetSignatures(self):
"""Test the TargetSignatures() method"""
import SCons.Errors
- env = type.TestEnvironment(B = 'build', C = 'content')
+ env = self.TestEnvironment(B='build', C='content')
exc_caught = None
try:
@@ -3397,7 +3405,7 @@ def generate(env):
- def test_Environment_global_variable(type):
+ def test_Environment_global_variable(self):
"""Test setting Environment variable to an Environment.Base subclass"""
class MyEnv(SCons.Environment.Base):
def xxx(self, string):
@@ -3579,6 +3587,10 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
def setUp(self):
env = Environment()
env._dict = {'XXX' : 'x', 'YYY' : 'y'}
+ def verify_value(env, key, value, *args, **kwargs):
+ """Verifies that key is value on the env this is called with."""
+ assert env[key] == value
+ env.AddMethod(verify_value)
env2 = OverrideEnvironment(env, {'XXX' : 'x2'})
env3 = OverrideEnvironment(env2, {'XXX' : 'x3', 'YYY' : 'y3', 'ZZZ' : 'z3'})
self.envs = [ env, env2, env3 ]
@@ -3769,6 +3781,13 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
# """Test the OverrideEnvironment WhereIs() method"""
# pass
+ def test_PseudoBuilderInherits(self):
+ """Test that pseudo-builders inherit the overrided values."""
+ env, env2, env3 = self.envs
+ env.verify_value('XXX', 'x')
+ env2.verify_value('XXX', 'x2')
+ env3.verify_value('XXX', 'x3')
+
def test_Dir(self):
"""Test the OverrideEnvironment Dir() method"""
env, env2, env3 = self.envs
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py
index 58ef92e..28f58be 100644
--- a/src/engine/SCons/Errors.py
+++ b/src/engine/SCons/Errors.py
@@ -28,7 +28,7 @@ and user errors in SCons.
"""
-__revision__ = "src/engine/SCons/Errors.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Errors.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import shutil
import SCons.Util
@@ -124,7 +124,7 @@ class UserError(Exception):
class StopError(Exception):
pass
-class EnvironmentError(Exception):
+class SConsEnvironmentError(Exception):
pass
class MSVCError(IOError):
@@ -184,7 +184,7 @@ def convert_to_BuildError(status, exc_info=None):
filename=filename,
exc_info=exc_info)
- elif isinstance(status, (EnvironmentError, OSError, IOError)):
+ elif isinstance(status, (SConsEnvironmentError, OSError, IOError)):
# If an IOError/OSError happens, raise a BuildError.
# Report the name of the file or directory that caused the
# error, which might be different from the target being built
diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py
index 088224d..a1bc048 100644
--- a/src/engine/SCons/ErrorsTests.py
+++ b/src/engine/SCons/ErrorsTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/ErrorsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/ErrorsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import errno
import os
@@ -101,10 +101,10 @@ class ErrorsTestCase(unittest.TestCase):
assert e.node == "node"
def test_convert_EnvironmentError_to_BuildError(self):
- """Test the convert_to_BuildError function on EnvironmentError
+ """Test the convert_to_BuildError function on SConsEnvironmentError
exceptions.
"""
- ee = SCons.Errors.EnvironmentError("test env error")
+ ee = SCons.Errors.SConsEnvironmentError("test env error")
be = SCons.Errors.convert_to_BuildError(ee)
assert be.errstr == "test env error"
assert be.status == 2
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index 10fc73f..c6ffe81 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -28,7 +28,7 @@ Nodes.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Executor.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Executor.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import collections
@@ -36,15 +36,16 @@ import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Errors
import SCons.Memoize
+import SCons.Util
from SCons.compat import with_metaclass, NoSlotsPyPy
class Batch(object):
"""Remembers exact association between targets
and sources of executor."""
-
+
__slots__ = ('targets',
'sources')
-
+
def __init__(self, targets=[], sources=[]):
self.targets = targets
self.sources = sources
@@ -71,7 +72,7 @@ class TSList(collections.UserList):
return nl[i]
def __getslice__(self, i, j):
nl = self.func()
- i = max(i, 0); j = max(j, 0)
+ i, j = max(i, 0), max(j, 0)
return nl[i:j]
def __str__(self):
nl = self.func()
@@ -127,13 +128,13 @@ def execute_action_list(obj, target, kw):
status = act(*args, **kw)
if isinstance(status, SCons.Errors.BuildError):
status.executor = obj
- raise status
+ raise status # TODO pylint E0702: raising int not allowed
elif status:
msg = "Error %s" % status
raise SCons.Errors.BuildError(
- errstr=msg,
+ errstr=msg,
node=obj.batches[0].targets,
- executor=obj,
+ executor=obj,
action=act)
return status
@@ -572,7 +573,6 @@ def AddBatchExecutor(key, executor):
nullenv = None
-import SCons.Util
class NullEnvironment(SCons.Util.Null):
import SCons.CacheDir
_CacheDir_path = None
@@ -597,7 +597,7 @@ class Null(object, with_metaclass(NoSlotsPyPy)):
disassociate Builders from Nodes entirely, so we're not
going to worry about unit tests for this--at least for now.
"""
-
+
__slots__ = ('pre_actions',
'post_actions',
'env',
@@ -613,9 +613,10 @@ class Null(object, with_metaclass(NoSlotsPyPy)):
'action_list',
'_do_execute',
'_execute_str')
-
+
def __init__(self, *args, **kw):
- if SCons.Debug.track_instances: logInstanceCreation(self, 'Executor.Null')
+ if SCons.Debug.track_instances:
+ logInstanceCreation(self, 'Executor.Null')
self.batches = [Batch(kw['targets'][:], [])]
def get_build_env(self):
return get_NullEnvironment()
@@ -649,7 +650,7 @@ class Null(object, with_metaclass(NoSlotsPyPy)):
"""Morph this Null executor to a real Executor object."""
batches = self.batches
self.__class__ = Executor
- self.__init__([])
+ self.__init__([])
self.batches = batches
# The following methods require morphing this Null Executor to a
diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py
index 03b8480..353e6f2 100644
--- a/src/engine/SCons/ExecutorTests.py
+++ b/src/engine/SCons/ExecutorTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/ExecutorTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/ExecutorTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Job.py b/src/engine/SCons/Job.py
index 45bca62..12ba19f 100644
--- a/src/engine/SCons/Job.py
+++ b/src/engine/SCons/Job.py
@@ -29,7 +29,7 @@ stop, and wait on jobs.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Job.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Job.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -53,14 +53,14 @@ interrupt_msg = 'Build interrupted.'
class InterruptState(object):
- def __init__(self):
- self.interrupted = False
+ def __init__(self):
+ self.interrupted = False
- def set(self):
- self.interrupted = True
+ def set(self):
+ self.interrupted = True
- def __call__(self):
- return self.interrupted
+ def __call__(self):
+ return self.interrupted
class Jobs(object):
@@ -87,7 +87,7 @@ class Jobs(object):
stack_size = explicit_stack_size
if stack_size is None:
stack_size = default_stack_size
-
+
try:
self.job = Parallel(taskmaster, num, stack_size)
self.num_jobs = num
@@ -172,14 +172,14 @@ class Serial(object):
"""
def __init__(self, taskmaster):
- """Create a new serial job given a taskmaster.
+ """Create a new serial job given a taskmaster.
The taskmaster's next_task() method should return the next task
that needs to be executed, or None if there are no more tasks. The
taskmaster's executed() method will be called for each task when it
is successfully executed, or failed() will be called if it failed to
execute (e.g. execute() raised an exception)."""
-
+
self.taskmaster = taskmaster
self.interrupted = InterruptState()
@@ -188,7 +188,7 @@ class Serial(object):
and executing them, and return when there are no more tasks. If a task
fails to execute (i.e. execute() raises an exception), then the job will
stop."""
-
+
while True:
task = self.taskmaster.next_task()
@@ -199,7 +199,7 @@ class Serial(object):
task.prepare()
if task.needs_execute():
task.execute()
- except Exception as e:
+ except Exception:
if self.interrupted():
try:
raise SCons.Errors.BuildError(
@@ -269,7 +269,7 @@ else:
def __init__(self, num, stack_size, interrupted):
"""Create the request and reply queues, and 'num' worker threads.
-
+
One must specify the stack size of the worker threads. The
stack size is specified in kilobytes.
"""
@@ -277,11 +277,11 @@ else:
self.resultsQueue = queue.Queue(0)
try:
- prev_size = threading.stack_size(stack_size*1024)
+ prev_size = threading.stack_size(stack_size*1024)
except AttributeError as e:
# Only print a warning if the stack size has been
# explicitly set.
- if not explicit_stack_size is None:
+ if explicit_stack_size is not None:
msg = "Setting stack size is unsupported by this version of Python:\n " + \
e.args[0]
SCons.Warnings.warn(SCons.Warnings.StackSizeWarning, msg)
@@ -322,7 +322,7 @@ else:
self.requestQueue.put(None)
# Wait for all of the workers to terminate.
- #
+ #
# If we don't do this, later Python versions (2.4, 2.5) often
# seem to raise exceptions during shutdown. This happens
# in requestQueue.get(), as an assertion failure that
@@ -339,7 +339,7 @@ else:
self.workers = []
class Parallel(object):
- """This class is used to execute tasks in parallel, and is somewhat
+ """This class is used to execute tasks in parallel, and is somewhat
less efficient than Serial, but is appropriate for parallel builds.
This class is thread safe.
@@ -373,7 +373,7 @@ else:
an exception), then the job will stop."""
jobs = 0
-
+
while True:
# Start up as many available tasks as we're
# allowed to.
diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py
index 7db99e7..d46ab30 100644
--- a/src/engine/SCons/JobTests.py
+++ b/src/engine/SCons/JobTests.py
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/JobTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/JobTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
import random
@@ -73,7 +73,7 @@ class DummyLock(object):
def release(self):
pass
-class NoThreadsException(object):
+class NoThreadsException(Exception):
"raised by the ParallelTestCase if threads are not supported"
def __str__(self):
@@ -206,7 +206,7 @@ class Taskmaster(object):
self.parallel_list = [0] * (n+1)
self.found_parallel = False
self.Task = Task
-
+
# 'guard' guards 'task_begin_list' and 'task_end_list'
try:
import threading
diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py
index 85670c1..f7b45bf 100644
--- a/src/engine/SCons/Memoize.py
+++ b/src/engine/SCons/Memoize.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Memoize.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Memoize.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Memoizer
diff --git a/src/engine/SCons/MemoizeTests.py b/src/engine/SCons/MemoizeTests.py
index 790791f..f3b5329 100644
--- a/src/engine/SCons/MemoizeTests.py
+++ b/src/engine/SCons/MemoizeTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/MemoizeTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/MemoizeTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py
index 9ea2fe0..a9defb6 100644
--- a/src/engine/SCons/Node/Alias.py
+++ b/src/engine/SCons/Node/Alias.py
@@ -30,7 +30,7 @@ This creates a hash of global Aliases (dummy targets).
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Node/Alias.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/Alias.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import collections
diff --git a/src/engine/SCons/Node/AliasTests.py b/src/engine/SCons/Node/AliasTests.py
index 21829b6..764ac67 100644
--- a/src/engine/SCons/Node/AliasTests.py
+++ b/src/engine/SCons/Node/AliasTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Node/AliasTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/AliasTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 6319ace..21ccecc 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -33,7 +33,7 @@ that can be used by scripts or modules looking for the canonical default.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Node/FS.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/FS.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import fnmatch
import os
@@ -57,7 +57,6 @@ import SCons.Util
import SCons.Warnings
from SCons.Debug import Trace
-from . import DeciderNeedsNode
print_duplicate = 0
@@ -282,7 +281,7 @@ def set_duplicate(duplicate):
'copy' : _copy_func
}
- if not duplicate in Valid_Duplicates:
+ if duplicate not in Valid_Duplicates:
raise SCons.Errors.InternalError("The argument of set_duplicate "
"should be in Valid_Duplicates")
global Link_Funcs
@@ -480,7 +479,7 @@ class EntryProxy(SCons.Util.Proxy):
return SCons.Subst.SpecialAttrWrapper(r, entry.name + "_posix")
def __get_windows_path(self):
- """Return the path with \ as the path separator,
+ r"""Return the path with \ as the path separator,
regardless of platform."""
if OS_SEP == '\\':
return self
@@ -531,7 +530,7 @@ class EntryProxy(SCons.Util.Proxy):
except KeyError:
try:
attr = SCons.Util.Proxy.__getattr__(self, name)
- except AttributeError as e:
+ except AttributeError:
# Raise our own AttributeError subclass with an
# overridden __str__() method that identifies the
# name of the entry that caused the exception.
@@ -699,13 +698,13 @@ class Base(SCons.Node.Node):
@SCons.Memoize.CountMethodCall
def stat(self):
- try:
+ try:
return self._memo['stat']
- except KeyError:
+ except KeyError:
pass
- try:
+ try:
result = self.fs.stat(self.get_abspath())
- except os.error:
+ except os.error:
result = None
self._memo['stat'] = result
@@ -719,16 +718,16 @@ class Base(SCons.Node.Node):
def getmtime(self):
st = self.stat()
- if st:
+ if st:
return st[stat.ST_MTIME]
- else:
+ else:
return None
def getsize(self):
st = self.stat()
- if st:
+ if st:
return st[stat.ST_SIZE]
- else:
+ else:
return None
def isdir(self):
@@ -1418,7 +1417,7 @@ class FS(LocalFS):
self.Top.addRepository(d)
def PyPackageDir(self, modulename):
- """Locate the directory of a given python module name
+ r"""Locate the directory of a given python module name
For example scons might resolve to
Windows: C:\Python27\Lib\site-packages\scons-2.5.1
@@ -1689,7 +1688,7 @@ class Dir(Base):
return result
def addRepository(self, dir):
- if dir != self and not dir in self.repositories:
+ if dir != self and dir not in self.repositories:
self.repositories.append(dir)
dir._tpath = '.'
self.__clearRepositoryCache()
@@ -1729,7 +1728,7 @@ class Dir(Base):
if self is other:
result = '.'
- elif not other in self._path_elements:
+ elif other not in self._path_elements:
try:
other_dir = other.get_dir()
except AttributeError:
@@ -2261,7 +2260,7 @@ class RootDir(Dir):
this directory.
"""
- __slots__ = ['_lookupDict']
+ __slots__ = ('_lookupDict', )
def __init__(self, drive, fs):
if SCons.Debug.track_instances: logInstanceCreation(self, 'Node.FS.RootDir')
@@ -2467,7 +2466,7 @@ class FileNodeInfo(SCons.Node.NodeInfoBase):
"""
state = getattr(self, '__dict__', {}).copy()
for obj in type(self).mro():
- for name in getattr(obj,'__slots__',()):
+ for name in getattr(obj, '__slots__', ()):
if hasattr(self, name):
state[name] = getattr(self, name)
@@ -2511,7 +2510,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase):
or count of any of these could yield writing wrong csig, and then false positive
rebuilds
"""
- __slots__ = ('dependency_map')
+ __slots__ = ['dependency_map', ]
current_version_id = 2
def __setattr__(self, key, value):
@@ -3283,14 +3282,14 @@ class File(Base):
self._memo['changed'] = has_changed
return has_changed
- def changed_content(self, target, prev_ni):
+ def changed_content(self, target, prev_ni, repo_node=None):
cur_csig = self.get_csig()
try:
return cur_csig != prev_ni.csig
except AttributeError:
return 1
- def changed_state(self, target, prev_ni):
+ def changed_state(self, target, prev_ni, repo_node=None):
return self.state != SCons.Node.up_to_date
@@ -3317,13 +3316,26 @@ class File(Base):
len(binfo.bimplicitsigs)) == 0:
return {}
-
- # store this info so we can avoid regenerating it.
- binfo.dependency_map = { str(child):signature for child, signature in zip(chain(binfo.bsources, binfo.bdepends, binfo.bimplicit),
+ binfo.dependency_map = { child:signature for child, signature in zip(chain(binfo.bsources, binfo.bdepends, binfo.bimplicit),
chain(binfo.bsourcesigs, binfo.bdependsigs, binfo.bimplicitsigs))}
return binfo.dependency_map
+ # @profile
+ def _add_strings_to_dependency_map(self, dmap):
+ """
+ In the case comparing node objects isn't sufficient, we'll add the strings for the nodes to the dependency map
+ :return:
+ """
+
+ first_string = str(next(iter(dmap)))
+
+ # print("DMAP:%s"%id(dmap))
+ if first_string not in dmap:
+ string_dict = {str(child): signature for child, signature in dmap.items()}
+ dmap.update(string_dict)
+ return dmap
+
def _get_previous_signatures(self, dmap):
"""
Return a list of corresponding csigs from previous
@@ -3342,37 +3354,62 @@ class File(Base):
if len(dmap) == 0:
if MD5_TIMESTAMP_DEBUG: print("Nothing dmap shortcutting")
return None
+ elif MD5_TIMESTAMP_DEBUG: print("len(dmap):%d"%len(dmap))
+
- if MD5_TIMESTAMP_DEBUG: print("len(dmap):%d"%len(dmap))
- # First try the simple name for node
- c_str = str(self)
- if MD5_TIMESTAMP_DEBUG: print("Checking :%s"%c_str)
- df = dmap.get(c_str, None)
+ # First try retrieving via Node
+ if MD5_TIMESTAMP_DEBUG: print("Checking if self is in map:%s id:%s type:%s"%(str(self), id(self), type(self)))
+ df = dmap.get(self, False)
if df:
return df
-
+
+ # Now check if self's repository file is in map.
+ rf = self.rfile()
+ if MD5_TIMESTAMP_DEBUG: print("Checking if self.rfile is in map:%s id:%s type:%s"%(str(rf), id(rf), type(rf)))
+ rfm = dmap.get(rf, False)
+ if rfm:
+ return rfm
+
+ # get default string for node and then also string swapping os.altsep for os.sep (/ for \)
+ c_strs = [str(self)]
+
if os.altsep:
- c_str = c_str.replace(os.sep, os.altsep)
- df = dmap.get(c_str, None)
- if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
+ c_strs.append(c_strs[0].replace(os.sep, os.altsep))
+
+ # In some cases the dependency_maps' keys are already strings check.
+ # Check if either string is now in dmap.
+ for s in c_strs:
+ if MD5_TIMESTAMP_DEBUG: print("Checking if str(self) is in map :%s" % s)
+ df = dmap.get(s, False)
+ if df:
+ return df
+
+ # Strings don't exist in map, add them and try again
+ # If there are no strings in this dmap, then add them.
+ # This may not be necessary, we could walk the nodes in the dmap and check each string
+ # rather than adding ALL the strings to dmap. In theory that would be n/2 vs 2n str() calls on node
+ # if not dmap.has_strings:
+ dmap = self._add_strings_to_dependency_map(dmap)
+
+ # In some cases the dependency_maps' keys are already strings check.
+ # Check if either string is now in dmap.
+ for s in c_strs:
+ if MD5_TIMESTAMP_DEBUG: print("Checking if str(self) is in map (now with strings) :%s" % s)
+ df = dmap.get(s, False)
if df:
return df
+ # Lastly use nodes get_path() to generate string and see if that's in dmap
if not df:
try:
# this should yield a path which matches what's in the sconsign
c_str = self.get_path()
- df = dmap.get(c_str, None)
- if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
- if df:
- return df
-
if os.altsep:
c_str = c_str.replace(os.sep, os.altsep)
- df = dmap.get(c_str, None)
- if MD5_TIMESTAMP_DEBUG: print("-->%s"%df)
- if df:
- return df
+
+ if MD5_TIMESTAMP_DEBUG: print("Checking if self.get_path is in map (now with strings) :%s" % s)
+
+ df = dmap.get(c_str, None)
except AttributeError as e:
raise FileBuildInfoFileToCsigMappingError("No mapping from file name to content signature for :%s"%c_str)
@@ -3387,21 +3424,17 @@ class File(Base):
file and just copy the prev_ni provided. If the prev_ni
is wrong. It will propagate it.
See: https://github.com/SCons/scons/issues/2980
-
+
Args:
self - dependency
target - target
prev_ni - The NodeInfo object loaded from previous builds .sconsign
- node - Node instance. This is the only changed* function which requires
- node to function. So if we detect that it's not passed.
- we throw DeciderNeedsNode, and caller should handle this and pass node.
+ node - Node instance. Check this node for file existence/timestamp
+ if specified.
- Returns:
+ Returns:
Boolean - Indicates if node(File) has changed.
"""
- if node is None:
- # We need required node argument to get BuildInfo to function
- raise DeciderNeedsNode(self.changed_timestamp_then_content)
# Now get sconsign name -> csig map and then get proper prev_ni if possible
bi = node.get_stored_info().binfo
@@ -3433,7 +3466,6 @@ class File(Base):
print("Mismatch self.changed_timestamp_match(%s, prev_ni) old:%s new:%s"%(str(target), old, new))
new_prev_ni = self._get_previous_signatures(dependency_map)
-
if not new:
try:
# NOTE: We're modifying the current node's csig in a query.
@@ -3443,13 +3475,13 @@ class File(Base):
return False
return self.changed_content(target, new_prev_ni)
- def changed_timestamp_newer(self, target, prev_ni):
+ def changed_timestamp_newer(self, target, prev_ni, repo_node=None):
try:
return self.get_timestamp() > target.get_timestamp()
except AttributeError:
return 1
- def changed_timestamp_match(self, target, prev_ni):
+ def changed_timestamp_match(self, target, prev_ni, repo_node=None):
"""
Return True if the timestamps don't match or if there is no previous timestamp
:param target:
@@ -3462,14 +3494,18 @@ class File(Base):
return 1
def is_up_to_date(self):
+ """Check for whether the Node is current
+ In all cases self is the target we're checking to see if it's up to date
+ """
+
T = 0
if T: Trace('is_up_to_date(%s):' % self)
if not self.exists():
if T: Trace(' not self.exists():')
- # The file doesn't exist locally...
+ # The file (always a target) doesn't exist locally...
r = self.rfile()
if r != self:
- # ...but there is one in a Repository...
+ # ...but there is one (always a target) in a Repository...
if not self.changed(r):
if T: Trace(' changed(%s):' % r)
# ...and it's even up-to-date...
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 021d433..2366a4d 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -22,7 +22,7 @@
#
from __future__ import division, print_function
-__revision__ = "src/engine/SCons/Node/FSTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/FSTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -47,54 +47,73 @@ built_it = None
scanner_count = 0
+
class Scanner(object):
def __init__(self, node=None):
global scanner_count
scanner_count = scanner_count + 1
self.hash = scanner_count
self.node = node
+
def path(self, env, dir, target=None, source=None):
return ()
+
def __call__(self, node, env, path):
return [self.node]
+
def __hash__(self):
return self.hash
+
def select(self, node):
return self
+
def recurse_nodes(self, nodes):
return nodes
+
class Environment(object):
def __init__(self):
self.scanner = Scanner()
+
def Dictionary(self, *args):
return {}
+
def autogenerate(self, **kw):
return {}
+
def get_scanner(self, skey):
return self.scanner
+
def Override(self, overrides):
return self
+
def _update(self, dict):
pass
+
class Action(object):
def __call__(self, targets, sources, env, **kw):
global built_it
if kw.get('execute', 1):
built_it = 1
return 0
+
def show(self, string):
pass
+
def get_contents(self, target, source, env):
- return bytearray("",'utf-8')
+ return bytearray("", 'utf-8')
+
def genstring(self, target, source, env):
return ""
+
def strfunction(self, targets, sources, env):
return ""
+
def get_implicit_deps(self, target, source, env):
return []
+
class Builder(object):
def __init__(self, factory, action=Action()):
self.factory = factory
@@ -110,6 +129,7 @@ class Builder(object):
def source_factory(self, name):
return self.factory(name)
+
class _tempdirTestCase(unittest.TestCase):
def setUp(self):
self.save_cwd = os.getcwd()
@@ -121,10 +141,11 @@ class _tempdirTestCase(unittest.TestCase):
def tearDown(self):
os.chdir(self.save_cwd)
+
class VariantDirTestCase(unittest.TestCase):
def runTest(self):
"""Test variant dir functionality"""
- test=TestCmd(workdir='')
+ test = TestCmd(workdir='')
fs = SCons.Node.FS.FS()
f1 = fs.File('build/test1')
@@ -169,30 +190,30 @@ class VariantDirTestCase(unittest.TestCase):
test.subdir(['rep1', 'build', 'var2'])
# A source file in the source directory
- test.write([ 'work', 'src', 'test.in' ], 'test.in')
+ test.write(['work', 'src', 'test.in'], 'test.in')
# A source file in a subdir of the source directory
- test.subdir([ 'work', 'src', 'new_dir' ])
- test.write([ 'work', 'src', 'new_dir', 'test9.out' ], 'test9.out\n')
+ test.subdir(['work', 'src', 'new_dir'])
+ test.write(['work', 'src', 'new_dir', 'test9.out'], 'test9.out\n')
# A source file in the repository
- test.write([ 'rep1', 'src', 'test2.in' ], 'test2.in')
+ test.write(['rep1', 'src', 'test2.in'], 'test2.in')
# Some source files in the variant directory
- test.write([ 'work', 'build', 'var2', 'test.in' ], 'test.old')
- test.write([ 'work', 'build', 'var2', 'test2.in' ], 'test2.old')
+ test.write(['work', 'build', 'var2', 'test.in'], 'test.old')
+ test.write(['work', 'build', 'var2', 'test2.in'], 'test2.old')
# An old derived file in the variant directories
- test.write([ 'work', 'build', 'var1', 'test.out' ], 'test.old')
- test.write([ 'work', 'build', 'var2', 'test.out' ], 'test.old')
+ test.write(['work', 'build', 'var1', 'test.out'], 'test.old')
+ test.write(['work', 'build', 'var2', 'test.out'], 'test.old')
# And just in case we are weird, a derived file in the source
# dir.
- test.write([ 'work', 'src', 'test.out' ], 'test.out.src')
+ test.write(['work', 'src', 'test.out'], 'test.out.src')
# A derived file in the repository
- test.write([ 'rep1', 'build', 'var1', 'test2.out' ], 'test2.out_rep')
- test.write([ 'rep1', 'build', 'var2', 'test2.out' ], 'test2.out_rep')
+ test.write(['rep1', 'build', 'var1', 'test2.out'], 'test2.out_rep')
+ test.write(['rep1', 'build', 'var2', 'test2.out'], 'test2.out_rep')
os.chdir(test.workpath('work'))
@@ -211,8 +232,8 @@ class VariantDirTestCase(unittest.TestCase):
f2out_2.builder = 1
fs.Repository(test.workpath('rep1'))
- assert f1.srcnode().get_internal_path() == os.path.normpath('src/test.in'),\
- f1.srcnode().get_internal_path()
+ assert f1.srcnode().get_internal_path() == os.path.normpath('src/test.in'), \
+ f1.srcnode().get_internal_path()
# str(node) returns source path for duplicate = 0
assert str(f1) == os.path.normpath('src/test.in'), str(f1)
# Build path does not exist
@@ -222,26 +243,26 @@ class VariantDirTestCase(unittest.TestCase):
# And duplicate=0 should also work just like a Repository
assert f1.rexists()
# rfile() should point to the source path
- assert f1.rfile().get_internal_path() == os.path.normpath('src/test.in'),\
- f1.rfile().get_internal_path()
+ assert f1.rfile().get_internal_path() == os.path.normpath('src/test.in'), \
+ f1.rfile().get_internal_path()
- assert f2.srcnode().get_internal_path() == os.path.normpath('src/test.in'),\
- f2.srcnode().get_internal_path()
+ assert f2.srcnode().get_internal_path() == os.path.normpath('src/test.in'), \
+ f2.srcnode().get_internal_path()
# str(node) returns build path for duplicate = 1
assert str(f2) == os.path.normpath('build/var2/test.in'), str(f2)
# Build path exists
assert f2.exists()
# ...and exists() should copy the file from src to build path
- assert test.read(['work', 'build', 'var2', 'test.in']) == bytearray('test.in','utf-8'),\
- test.read(['work', 'build', 'var2', 'test.in'])
+ assert test.read(['work', 'build', 'var2', 'test.in']) == bytearray('test.in', 'utf-8'), \
+ test.read(['work', 'build', 'var2', 'test.in'])
# Since exists() is true, so should rexists() be
assert f2.rexists()
f3 = fs.File('build/var1/test2.in')
f4 = fs.File('build/var2/test2.in')
- assert f3.srcnode().get_internal_path() == os.path.normpath('src/test2.in'),\
- f3.srcnode().get_internal_path()
+ assert f3.srcnode().get_internal_path() == os.path.normpath('src/test2.in'), \
+ f3.srcnode().get_internal_path()
# str(node) returns source path for duplicate = 0
assert str(f3) == os.path.normpath('src/test2.in'), str(f3)
# Build path does not exist
@@ -251,22 +272,22 @@ class VariantDirTestCase(unittest.TestCase):
# But we do have a file in the Repository
assert f3.rexists()
# rfile() should point to the source path
- assert f3.rfile().get_internal_path() == os.path.normpath(test.workpath('rep1/src/test2.in')),\
- f3.rfile().get_internal_path()
+ assert f3.rfile().get_internal_path() == os.path.normpath(test.workpath('rep1/src/test2.in')), \
+ f3.rfile().get_internal_path()
- assert f4.srcnode().get_internal_path() == os.path.normpath('src/test2.in'),\
- f4.srcnode().get_internal_path()
+ assert f4.srcnode().get_internal_path() == os.path.normpath('src/test2.in'), \
+ f4.srcnode().get_internal_path()
# str(node) returns build path for duplicate = 1
assert str(f4) == os.path.normpath('build/var2/test2.in'), str(f4)
# Build path should exist
assert f4.exists()
# ...and copy over the file into the local build path
- assert test.read(['work', 'build', 'var2', 'test2.in']) == bytearray('test2.in','utf-8')
+ assert test.read(['work', 'build', 'var2', 'test2.in']) == bytearray('test2.in', 'utf-8')
# should exist in repository, since exists() is true
assert f4.rexists()
# rfile() should point to ourselves
- assert f4.rfile().get_internal_path() == os.path.normpath('build/var2/test2.in'),\
- f4.rfile().get_internal_path()
+ assert f4.rfile().get_internal_path() == os.path.normpath('build/var2/test2.in'), \
+ f4.rfile().get_internal_path()
f5 = fs.File('build/var1/test.out')
f6 = fs.File('build/var2/test.out')
@@ -274,12 +295,12 @@ class VariantDirTestCase(unittest.TestCase):
assert f5.exists()
# We should not copy the file from the source dir, since this is
# a derived file.
- assert test.read(['work', 'build', 'var1', 'test.out']) == bytearray('test.old','utf-8')
+ assert test.read(['work', 'build', 'var1', 'test.out']) == bytearray('test.old', 'utf-8')
assert f6.exists()
# We should not copy the file from the source dir, since this is
# a derived file.
- assert test.read(['work', 'build', 'var2', 'test.out']) == bytearray('test.old','utf-8')
+ assert test.read(['work', 'build', 'var2', 'test.out']) == bytearray('test.old', 'utf-8')
f7 = fs.File('build/var1/test2.out')
f8 = fs.File('build/var2/test2.out')
@@ -292,8 +313,8 @@ class VariantDirTestCase(unittest.TestCase):
assert not f8.exists()
assert f8.rexists()
- assert f8.rfile().get_internal_path() == os.path.normpath(test.workpath('rep1/build/var2/test2.out')),\
- f8.rfile().get_internal_path()
+ assert f8.rfile().get_internal_path() == os.path.normpath(test.workpath('rep1/build/var2/test2.out')), \
+ f8.rfile().get_internal_path()
# Verify the Mkdir and Link actions are called
d9 = fs.Dir('build/var2/new_dir')
@@ -302,6 +323,7 @@ class VariantDirTestCase(unittest.TestCase):
class MkdirAction(Action):
def __init__(self, dir_made):
self.dir_made = dir_made
+
def __call__(self, target, source, env, executor=None):
if executor:
target = executor.get_all_targets()
@@ -310,8 +332,10 @@ class VariantDirTestCase(unittest.TestCase):
save_Link = SCons.Node.FS.Link
link_made = []
+
def link_func(target, source, env, link_made=link_made):
link_made.append(target)
+
SCons.Node.FS.Link = link_func
try:
@@ -332,10 +356,10 @@ class VariantDirTestCase(unittest.TestCase):
# happen if you switch from duplicate=1 to duplicate=0, then
# delete a source file. At one time, this would cause exists()
# to return a 1 but get_contents() to throw.
- test.write([ 'work', 'build', 'var1', 'asourcefile' ], 'stuff')
+ test.write(['work', 'build', 'var1', 'asourcefile'], 'stuff')
f10 = fs.File('build/var1/asourcefile')
assert f10.exists()
- assert f10.get_contents() == bytearray('stuff','utf-8'), f10.get_contents()
+ assert f10.get_contents() == bytearray('stuff', 'utf-8'), f10.get_contents()
f11 = fs.File('src/file11')
t, m = f11.alter_targets()
@@ -361,8 +385,10 @@ class VariantDirTestCase(unittest.TestCase):
fIO = fs.File("build/var2/IOError")
save_Link = SCons.Node.FS.Link
+
def Link_IOError(target, source, env):
raise IOError(17, "Link_IOError")
+
SCons.Node.FS.Link = SCons.Action.Action(Link_IOError, None)
test.write(['work', 'src', 'IOError'], "work/src/IOError\n")
@@ -379,16 +405,16 @@ class VariantDirTestCase(unittest.TestCase):
SCons.Node.FS.Link = save_Link
# Test to see if Link() works...
- test.subdir('src','build')
+ test.subdir('src', 'build')
test.write('src/foo', 'src/foo\n')
os.chmod(test.workpath('src/foo'), stat.S_IRUSR)
SCons.Node.FS.Link(fs.File(test.workpath('build/foo')),
fs.File(test.workpath('src/foo')),
None)
os.chmod(test.workpath('src/foo'), stat.S_IRUSR | stat.S_IWRITE)
- st=os.stat(test.workpath('build/foo'))
+ st = os.stat(test.workpath('build/foo'))
assert (stat.S_IMODE(st[stat.ST_MODE]) & stat.S_IWRITE), \
- stat.S_IMODE(st[stat.ST_MODE])
+ stat.S_IMODE(st[stat.ST_MODE])
# This used to generate a UserError when we forbid the source
# directory from being outside the top-level SConstruct dir.
@@ -404,8 +430,8 @@ class VariantDirTestCase(unittest.TestCase):
exc_caught = 1
assert exc_caught, "Should have caught a UserError."
finally:
- test.unlink( "src/foo" )
- test.unlink( "build/foo" )
+ test.unlink("src/foo")
+ test.unlink("build/foo")
fs = SCons.Node.FS.FS()
fs.VariantDir('build', 'src1')
@@ -424,18 +450,20 @@ class VariantDirTestCase(unittest.TestCase):
# Test against a former bug. Make sure we can get a repository
# path for the variant directory itself!
- fs=SCons.Node.FS.FS(test.workpath('work'))
- test.subdir('work')
+ fs = SCons.Node.FS.FS(test.workpath('work'))
+
+ # not needed this subdir is created above near line 188
+ # test.subdir('work')
fs.VariantDir('build/var3', 'src', duplicate=0)
d1 = fs.Dir('build/var3')
r = d1.rdir()
assert r == d1, "%s != %s" % (r, d1)
# verify the link creation attempts in file_link()
- class LinkSimulator (object):
+ class LinkSimulator(object):
"""A class to intercept os.[sym]link() calls and track them."""
- def __init__( self, duplicate, link, symlink, copy ) :
+ def __init__(self, duplicate, link, symlink, copy):
self.duplicate = duplicate
self.have = {}
self.have['hard'] = link
@@ -447,27 +475,28 @@ class VariantDirTestCase(unittest.TestCase):
if self.have[link]:
self.links_to_be_called.append(link)
- def link_fail( self , src , dest ) :
+ def link_fail(self, src, dest):
next_link = self.links_to_be_called.pop(0)
assert next_link == "hard", \
- "Wrong link order: expected %s to be called "\
- "instead of hard" % next_link
- raise OSError( "Simulating hard link creation error." )
+ "Wrong link order: expected %s to be called " \
+ "instead of hard" % next_link
+ raise OSError("Simulating hard link creation error.")
- def symlink_fail( self , src , dest ) :
+ def symlink_fail(self, src, dest):
next_link = self.links_to_be_called.pop(0)
assert next_link == "soft", \
- "Wrong link order: expected %s to be called "\
- "instead of soft" % next_link
- raise OSError( "Simulating symlink creation error." )
+ "Wrong link order: expected %s to be called " \
+ "instead of soft" % next_link
+ raise OSError("Simulating symlink creation error.")
- def copy( self , src , dest ) :
+ def copy(self, src, dest):
next_link = self.links_to_be_called.pop(0)
assert next_link == "copy", \
- "Wrong link order: expected %s to be called "\
- "instead of copy" % next_link
+ "Wrong link order: expected %s to be called " \
+ "instead of copy" % next_link
# copy succeeds, but use the real copy
self.have['copy'](src, dest)
+
# end class LinkSimulator
try:
@@ -539,33 +568,33 @@ class VariantDirTestCase(unittest.TestCase):
fs.VariantDir('work/src/b1/b2', 'work/src')
dir_list = [
- 'work/src',
- 'work/src/b1',
- 'work/src/b1/b2',
- 'work/src/b1/b2/b1',
- 'work/src/b1/b2/b1/b2',
- 'work/src/b1/b2/b1/b2/b1',
- 'work/src/b1/b2/b1/b2/b1/b2',
+ 'work/src',
+ 'work/src/b1',
+ 'work/src/b1/b2',
+ 'work/src/b1/b2/b1',
+ 'work/src/b1/b2/b1/b2',
+ 'work/src/b1/b2/b1/b2/b1',
+ 'work/src/b1/b2/b1/b2/b1/b2',
]
srcnode_map = {
- 'work/src/b1/b2' : 'work/src',
- 'work/src/b1/b2/f' : 'work/src/f',
- 'work/src/b1/b2/b1' : 'work/src/b1/',
- 'work/src/b1/b2/b1/f' : 'work/src/b1/f',
- 'work/src/b1/b2/b1/b2' : 'work/src/b1/b2',
- 'work/src/b1/b2/b1/b2/f' : 'work/src/b1/b2/f',
- 'work/src/b1/b2/b1/b2/b1' : 'work/src/b1/b2/b1',
- 'work/src/b1/b2/b1/b2/b1/f' : 'work/src/b1/b2/b1/f',
- 'work/src/b1/b2/b1/b2/b1/b2' : 'work/src/b1/b2/b1/b2',
- 'work/src/b1/b2/b1/b2/b1/b2/f' : 'work/src/b1/b2/b1/b2/f',
+ 'work/src/b1/b2': 'work/src',
+ 'work/src/b1/b2/f': 'work/src/f',
+ 'work/src/b1/b2/b1': 'work/src/b1/',
+ 'work/src/b1/b2/b1/f': 'work/src/b1/f',
+ 'work/src/b1/b2/b1/b2': 'work/src/b1/b2',
+ 'work/src/b1/b2/b1/b2/f': 'work/src/b1/b2/f',
+ 'work/src/b1/b2/b1/b2/b1': 'work/src/b1/b2/b1',
+ 'work/src/b1/b2/b1/b2/b1/f': 'work/src/b1/b2/b1/f',
+ 'work/src/b1/b2/b1/b2/b1/b2': 'work/src/b1/b2/b1/b2',
+ 'work/src/b1/b2/b1/b2/b1/b2/f': 'work/src/b1/b2/b1/b2/f',
}
alter_map = {
- 'work/src' : 'work/src/b1/b2',
- 'work/src/f' : 'work/src/b1/b2/f',
- 'work/src/b1' : 'work/src/b1/b2/b1',
- 'work/src/b1/f' : 'work/src/b1/b2/b1/f',
+ 'work/src': 'work/src/b1/b2',
+ 'work/src/f': 'work/src/b1/b2/f',
+ 'work/src/b1': 'work/src/b1/b2/b1',
+ 'work/src/b1/f': 'work/src/b1/b2/b1/f',
}
errors = 0
@@ -608,6 +637,7 @@ class VariantDirTestCase(unittest.TestCase):
self.assertFalse(errors)
+
class BaseTestCase(_tempdirTestCase):
def test_stat(self):
"""Test the Base.stat() method"""
@@ -703,18 +733,21 @@ class BaseTestCase(_tempdirTestCase):
nonexistent = fs.Entry('nonexistent')
assert not nonexistent.islink()
+
class DirNodeInfoTestCase(_tempdirTestCase):
def test___init__(self):
"""Test DirNodeInfo initialization"""
ddd = self.fs.Dir('ddd')
ni = SCons.Node.FS.DirNodeInfo()
+
class DirBuildInfoTestCase(_tempdirTestCase):
def test___init__(self):
"""Test DirBuildInfo initialization"""
ddd = self.fs.Dir('ddd')
bi = SCons.Node.FS.DirBuildInfo()
+
class FileNodeInfoTestCase(_tempdirTestCase):
def test___init__(self):
"""Test FileNodeInfo initialization"""
@@ -760,6 +793,7 @@ class FileNodeInfoTestCase(_tempdirTestCase):
size = st[stat.ST_SIZE]
assert ni.size != size, (ni.size, size)
+
class FileBuildInfoTestCase(_tempdirTestCase):
def test___init__(self):
"""Test File.BuildInfo initialization"""
@@ -821,6 +855,7 @@ class FileBuildInfoTestCase(_tempdirTestCase):
format = bi1.format()
assert format == expect, (repr(expect), repr(format))
+
class FSTestCase(_tempdirTestCase):
def test_needs_normpath(self):
"""Test the needs_normpath Regular expression
@@ -862,7 +897,6 @@ class FSTestCase(_tempdirTestCase):
"/a./",
"/a../",
-
".a",
"..a",
"/.a",
@@ -871,7 +905,7 @@ class FSTestCase(_tempdirTestCase):
"..a/",
"/.a/",
"/..a/",
- ]
+ ]
for p in do_not_need_normpath:
assert needs_normpath_match(p) is None, p
@@ -919,7 +953,7 @@ class FSTestCase(_tempdirTestCase):
"../a",
"a/./a",
"a/../a",
- ]
+ ]
for p in needs_normpath:
assert needs_normpath_match(p) is not None, p
@@ -952,7 +986,7 @@ class FSTestCase(_tempdirTestCase):
assert isinstance(d1, SCons.Node.FS.Dir)
assert d1.cwd is d1, d1
- f1 = fs.File('f1', directory = d1)
+ f1 = fs.File('f1', directory=d1)
assert isinstance(f1, SCons.Node.FS.File)
d1_f1 = os.path.join('d1', 'f1')
@@ -1035,6 +1069,7 @@ class FSTestCase(_tempdirTestCase):
if p[0] == os.sep:
p = drive + p
return p
+
path = strip_slash(path_)
abspath = strip_slash(abspath_)
up_path = strip_slash(up_path_)
@@ -1048,51 +1083,51 @@ class FSTestCase(_tempdirTestCase):
name = os.sep
if dir.up() is None:
- dir_up_path = dir.get_internal_path()
+ dir_up_path = dir.get_internal_path()
else:
- dir_up_path = dir.up().get_internal_path()
+ dir_up_path = dir.up().get_internal_path()
assert dir.name == name, \
- "dir.name %s != expected name %s" % \
- (dir.name, name)
+ "dir.name %s != expected name %s" % \
+ (dir.name, name)
assert dir.get_internal_path() == path, \
- "dir.path %s != expected path %s" % \
- (dir.get_internal_path(), path)
+ "dir.path %s != expected path %s" % \
+ (dir.get_internal_path(), path)
assert str(dir) == path, \
- "str(dir) %s != expected path %s" % \
- (str(dir), path)
+ "str(dir) %s != expected path %s" % \
+ (str(dir), path)
assert dir.get_abspath() == abspath, \
- "dir.abspath %s != expected absolute path %s" % \
- (dir.get_abspath(), abspath)
+ "dir.abspath %s != expected absolute path %s" % \
+ (dir.get_abspath(), abspath)
assert dir_up_path == up_path, \
- "dir.up().path %s != expected parent path %s" % \
- (dir_up_path, up_path)
+ "dir.up().path %s != expected parent path %s" % \
+ (dir_up_path, up_path)
for sep in seps:
def Dir_test(lpath, path_, abspath_, up_path_, sep=sep, func=_do_Dir_test):
return func(lpath, path_, abspath_, up_path_, sep)
-
- Dir_test('/', '/', '/', '/')
- Dir_test('', './', sub_dir, sub)
- Dir_test('foo', 'foo/', sub_dir_foo, './')
- Dir_test('foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
- Dir_test('/foo', '/foo/', '/foo/', '/')
- Dir_test('/foo/bar', '/foo/bar/', '/foo/bar/', '/foo/')
- Dir_test('..', sub, sub, wp)
- Dir_test('foo/..', './', sub_dir, sub)
- Dir_test('../foo', sub_foo, sub_foo, sub)
- Dir_test('.', './', sub_dir, sub)
- Dir_test('./.', './', sub_dir, sub)
- Dir_test('foo/./bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
- Dir_test('#../foo', sub_foo, sub_foo, sub)
- Dir_test('#/../foo', sub_foo, sub_foo, sub)
- Dir_test('#foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
- Dir_test('#/foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
- Dir_test('#', './', sub_dir, sub)
+
+ Dir_test('/', '/', '/', '/')
+ Dir_test('', './', sub_dir, sub)
+ Dir_test('foo', 'foo/', sub_dir_foo, './')
+ Dir_test('foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
+ Dir_test('/foo', '/foo/', '/foo/', '/')
+ Dir_test('/foo/bar', '/foo/bar/', '/foo/bar/', '/foo/')
+ Dir_test('..', sub, sub, wp)
+ Dir_test('foo/..', './', sub_dir, sub)
+ Dir_test('../foo', sub_foo, sub_foo, sub)
+ Dir_test('.', './', sub_dir, sub)
+ Dir_test('./.', './', sub_dir, sub)
+ Dir_test('foo/./bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
+ Dir_test('#../foo', sub_foo, sub_foo, sub)
+ Dir_test('#/../foo', sub_foo, sub_foo, sub)
+ Dir_test('#foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
+ Dir_test('#/foo/bar', 'foo/bar/', sub_dir_foo_bar, 'foo/')
+ Dir_test('#', './', sub_dir, sub)
try:
- f2 = fs.File(sep.join(['f1', 'f2']), directory = d1)
+ f2 = fs.File(sep.join(['f1', 'f2']), directory=d1)
except TypeError as x:
assert str(x) == ("Tried to lookup File '%s' as a Dir." %
d1_f1), x
@@ -1134,16 +1169,15 @@ class FSTestCase(_tempdirTestCase):
e1 = fs.Entry(p)
e2 = fs.Entry(path)
assert e1 is e2, (e1, e2)
- a=str(e1)
- b=str(e2)
- assert a == b, ("Strings should match for same file/node\n%s\n%s"%(a,b))
-
+ a = str(e1)
+ b = str(e2)
+ assert a == b, ("Strings should match for same file/node\n%s\n%s" % (a, b))
# Test for a bug in 0.04 that did not like looking up
# dirs with a trailing slash on Windows.
- d=fs.Dir('./')
+ d = fs.Dir('./')
assert d.get_internal_path() == '.', d.get_abspath()
- d=fs.Dir('foo/')
+ d = fs.Dir('foo/')
assert d.get_internal_path() == 'foo', d.get_abspath()
# Test for sub-classing of node building.
@@ -1151,7 +1185,7 @@ class FSTestCase(_tempdirTestCase):
built_it = None
assert not built_it
- d1.add_source([SCons.Node.Node()]) # XXX FAKE SUBCLASS ATTRIBUTE
+ d1.add_source([SCons.Node.Node()]) # XXX FAKE SUBCLASS ATTRIBUTE
d1.builder_set(Builder(fs.File))
d1.reset_executor()
d1.env_set(Environment())
@@ -1160,7 +1194,7 @@ class FSTestCase(_tempdirTestCase):
built_it = None
assert not built_it
- f1.add_source([SCons.Node.Node()]) # XXX FAKE SUBCLASS ATTRIBUTE
+ f1.add_source([SCons.Node.Node()]) # XXX FAKE SUBCLASS ATTRIBUTE
f1.builder_set(Builder(fs.File))
f1.reset_executor()
f1.env_set(Environment())
@@ -1244,9 +1278,11 @@ class FSTestCase(_tempdirTestCase):
class MyScanner(Scanner):
call_count = 0
+
def __call__(self, node, env, path):
self.call_count = self.call_count + 1
return Scanner.__call__(self, node, env, path)
+
s = MyScanner(xyz)
deps = f12.get_found_includes(env, s, t1)
@@ -1265,8 +1301,6 @@ class FSTestCase(_tempdirTestCase):
assert deps == [xyz], deps
assert s.call_count == 3, s.call_count
-
-
# Make sure we can scan this file even if the target isn't
# a file that has a scanner (it might be an Alias, e.g.).
class DummyNode(object):
@@ -1296,7 +1330,7 @@ class FSTestCase(_tempdirTestCase):
f1 = fs.File(test.workpath("do_i_exist"))
assert not f1.exists()
- test.write("do_i_exist","\n")
+ test.write("do_i_exist", "\n")
assert not f1.exists(), "exists() call not cached"
f1.built()
assert f1.exists(), "exists() call caching not reset"
@@ -1310,14 +1344,14 @@ class FSTestCase(_tempdirTestCase):
# get_contents() returns the binary contents.
test.write("binary_file", "Foo\x1aBar")
f1 = fs.File(test.workpath("binary_file"))
- assert f1.get_contents() == bytearray("Foo\x1aBar",'utf-8'), f1.get_contents()
+ assert f1.get_contents() == bytearray("Foo\x1aBar", 'utf-8'), f1.get_contents()
# This tests to make sure we can decode UTF-8 text files.
test_string = u"Foo\x1aBar"
test.write("utf8_file", test_string.encode('utf-8'))
f1 = fs.File(test.workpath("utf8_file"))
assert eval('f1.get_text_contents() == u"Foo\x1aBar"'), \
- f1.get_text_contents()
+ f1.get_text_contents()
# Check for string which doesn't have BOM and isn't valid
# ASCII
@@ -1325,11 +1359,11 @@ class FSTestCase(_tempdirTestCase):
test.write('latin1_file', test_string)
f1 = fs.File(test.workpath("latin1_file"))
assert f1.get_text_contents() == test_string.decode('latin-1'), \
- f1.get_text_contents()
+ f1.get_text_contents()
def nonexistent(method, s):
try:
- x = method(s, create = 0)
+ x = method(s, create=0)
except SCons.Errors.UserError:
pass
else:
@@ -1367,15 +1401,15 @@ class FSTestCase(_tempdirTestCase):
f = fs.File('f_local')
assert f._local == 0
- #XXX test_is_up_to_date() for directories
+ # XXX test_is_up_to_date() for directories
- #XXX test_sconsign() for directories
+ # XXX test_sconsign() for directories
- #XXX test_set_signature() for directories
+ # XXX test_set_signature() for directories
- #XXX test_build() for directories
+ # XXX test_build() for directories
- #XXX test_root()
+ # XXX test_root()
# test Entry.get_contents()
e = fs.Entry('does_not_exist')
@@ -1387,7 +1421,7 @@ class FSTestCase(_tempdirTestCase):
try:
e = fs.Entry('file')
c = e.get_contents()
- assert c == bytearray("file\n",'utf-8'), c
+ assert c == bytearray("file\n", 'utf-8'), c
assert e.__class__ == SCons.Node.FS.File
finally:
test.unlink("file")
@@ -1541,7 +1575,7 @@ class FSTestCase(_tempdirTestCase):
f = fs.Entry('foo/bar/baz')
assert f.for_signature() == 'baz', f.for_signature()
assert f.get_string(0) == os.path.normpath('foo/bar/baz'), \
- f.get_string(0)
+ f.get_string(0)
assert f.get_string(1) == 'baz', f.get_string(1)
def test_drive_letters(self):
@@ -1556,26 +1590,26 @@ class FSTestCase(_tempdirTestCase):
drive, path = os.path.splitdrive(x)
return 'X:' + path
- wp = drive_workpath([''])
+ wp = drive_workpath([''])
if wp[-1] in (os.sep, '/'):
- tmp = os.path.split(wp[:-1])[0]
+ tmp = os.path.split(wp[:-1])[0]
else:
- tmp = os.path.split(wp)[0]
+ tmp = os.path.split(wp)[0]
- parent_tmp = os.path.split(tmp)[0]
+ parent_tmp = os.path.split(tmp)[0]
if parent_tmp == 'X:':
parent_tmp = 'X:' + os.sep
- tmp_foo = os.path.join(tmp, 'foo')
+ tmp_foo = os.path.join(tmp, 'foo')
- foo = drive_workpath(['foo'])
- foo_bar = drive_workpath(['foo', 'bar'])
- sub = drive_workpath(['sub', ''])
- sub_dir = drive_workpath(['sub', 'dir', ''])
- sub_dir_foo = drive_workpath(['sub', 'dir', 'foo', ''])
+ foo = drive_workpath(['foo'])
+ foo_bar = drive_workpath(['foo', 'bar'])
+ sub = drive_workpath(['sub', ''])
+ sub_dir = drive_workpath(['sub', 'dir', ''])
+ sub_dir_foo = drive_workpath(['sub', 'dir', 'foo', ''])
sub_dir_foo_bar = drive_workpath(['sub', 'dir', 'foo', 'bar', ''])
- sub_foo = drive_workpath(['sub', 'foo', ''])
+ sub_foo = drive_workpath(['sub', 'foo', ''])
fs = SCons.Node.FS.FS()
@@ -1594,22 +1628,23 @@ class FSTestCase(_tempdirTestCase):
if p[-1] == os.sep and len(p) > 3:
p = p[:-1]
return p
+
path = strip_slash(path_)
up_path = strip_slash(up_path_)
name = path.split(os.sep)[-1]
assert dir.name == name, \
- "dir.name %s != expected name %s" % \
- (dir.name, name)
+ "dir.name %s != expected name %s" % \
+ (dir.name, name)
assert dir.get_internal_path() == path, \
- "dir.path %s != expected path %s" % \
- (dir.get_internal_path(), path)
+ "dir.path %s != expected path %s" % \
+ (dir.get_internal_path(), path)
assert str(dir) == path, \
- "str(dir) %s != expected path %s" % \
- (str(dir), path)
+ "str(dir) %s != expected path %s" % \
+ (str(dir), path)
assert dir.up().get_internal_path() == up_path, \
- "dir.up().path %s != expected parent path %s" % \
- (dir.up().get_internal_path(), up_path)
+ "dir.up().path %s != expected parent path %s" % \
+ (dir.up().get_internal_path(), up_path)
save_os_path = os.path
save_os_sep = os.sep
@@ -1620,26 +1655,25 @@ class FSTestCase(_tempdirTestCase):
SCons.Node.FS.initialize_do_splitdrive()
for sep in seps:
-
def Dir_test(lpath, path_, up_path_, sep=sep, func=_do_Dir_test):
return func(lpath, path_, up_path_, sep)
- Dir_test('#X:', wp, tmp)
- Dir_test('X:foo', foo, wp)
- Dir_test('X:foo/bar', foo_bar, foo)
- Dir_test('X:/foo', 'X:/foo', 'X:/')
- Dir_test('X:/foo/bar', 'X:/foo/bar/', 'X:/foo/')
- Dir_test('X:..', tmp, parent_tmp)
- Dir_test('X:foo/..', wp, tmp)
- Dir_test('X:../foo', tmp_foo, tmp)
- Dir_test('X:.', wp, tmp)
- Dir_test('X:./.', wp, tmp)
- Dir_test('X:foo/./bar', foo_bar, foo)
- Dir_test('#X:../foo', tmp_foo, tmp)
- Dir_test('#X:/../foo', tmp_foo, tmp)
- Dir_test('#X:foo/bar', foo_bar, foo)
- Dir_test('#X:/foo/bar', foo_bar, foo)
- Dir_test('#X:/', wp, tmp)
+ Dir_test('#X:', wp, tmp)
+ Dir_test('X:foo', foo, wp)
+ Dir_test('X:foo/bar', foo_bar, foo)
+ Dir_test('X:/foo', 'X:/foo', 'X:/')
+ Dir_test('X:/foo/bar', 'X:/foo/bar/', 'X:/foo/')
+ Dir_test('X:..', tmp, parent_tmp)
+ Dir_test('X:foo/..', wp, tmp)
+ Dir_test('X:../foo', tmp_foo, tmp)
+ Dir_test('X:.', wp, tmp)
+ Dir_test('X:./.', wp, tmp)
+ Dir_test('X:foo/./bar', foo_bar, foo)
+ Dir_test('#X:../foo', tmp_foo, tmp)
+ Dir_test('#X:/../foo', tmp_foo, tmp)
+ Dir_test('#X:foo/bar', foo_bar, foo)
+ Dir_test('#X:/foo/bar', foo_bar, foo)
+ Dir_test('#X:/', wp, tmp)
finally:
os.path = save_os_path
os.sep = save_os_sep
@@ -1670,24 +1704,24 @@ class FSTestCase(_tempdirTestCase):
path = strip_slash(path)
return '//' + path[1:]
- wp = unc_workpath([''])
+ wp = unc_workpath([''])
if wp[-1] in (os.sep, '/'):
- tmp = os.path.split(wp[:-1])[0]
+ tmp = os.path.split(wp[:-1])[0]
else:
- tmp = os.path.split(wp)[0]
+ tmp = os.path.split(wp)[0]
- parent_tmp = os.path.split(tmp)[0]
+ parent_tmp = os.path.split(tmp)[0]
- tmp_foo = os.path.join(tmp, 'foo')
+ tmp_foo = os.path.join(tmp, 'foo')
- foo = unc_workpath(['foo'])
- foo_bar = unc_workpath(['foo', 'bar'])
- sub = unc_workpath(['sub', ''])
- sub_dir = unc_workpath(['sub', 'dir', ''])
- sub_dir_foo = unc_workpath(['sub', 'dir', 'foo', ''])
+ foo = unc_workpath(['foo'])
+ foo_bar = unc_workpath(['foo', 'bar'])
+ sub = unc_workpath(['sub', ''])
+ sub_dir = unc_workpath(['sub', 'dir', ''])
+ sub_dir_foo = unc_workpath(['sub', 'dir', 'foo', ''])
sub_dir_foo_bar = unc_workpath(['sub', 'dir', 'foo', 'bar', ''])
- sub_foo = unc_workpath(['sub', 'foo', ''])
+ sub_foo = unc_workpath(['sub', 'foo', ''])
fs = SCons.Node.FS.FS()
@@ -1708,22 +1742,22 @@ class FSTestCase(_tempdirTestCase):
name = path.split(os.sep)[-1]
if dir.up() is None:
- dir_up_path = dir.get_internal_path()
+ dir_up_path = dir.get_internal_path()
else:
- dir_up_path = dir.up().get_internal_path()
+ dir_up_path = dir.up().get_internal_path()
assert dir.name == name, \
- "dir.name %s != expected name %s" % \
- (dir.name, name)
+ "dir.name %s != expected name %s" % \
+ (dir.name, name)
assert dir.get_internal_path() == path, \
- "dir.path %s != expected path %s" % \
- (dir.get_internal_path(), path)
+ "dir.path %s != expected path %s" % \
+ (dir.get_internal_path(), path)
assert str(dir) == path, \
- "str(dir) %s != expected path %s" % \
- (str(dir), path)
+ "str(dir) %s != expected path %s" % \
+ (str(dir), path)
assert dir_up_path == up_path, \
- "dir.up().path %s != expected parent path %s" % \
- (dir.up().get_internal_path(), up_path)
+ "dir.up().path %s != expected parent path %s" % \
+ (dir.up().get_internal_path(), up_path)
save_os_path = os.path
save_os_sep = os.sep
@@ -1734,28 +1768,27 @@ class FSTestCase(_tempdirTestCase):
SCons.Node.FS.initialize_do_splitdrive()
for sep in seps:
-
def Dir_test(lpath, path_, up_path_, sep=sep, func=_do_Dir_test):
return func(lpath, path_, up_path_, sep)
- Dir_test('//foo', '//foo', '//')
- Dir_test('//foo/bar', '//foo/bar', '//foo')
- Dir_test('//', '//', '//')
- Dir_test('//..', '//', '//')
- Dir_test('//foo/..', '//', '//')
- Dir_test('//../foo', '//foo', '//')
- Dir_test('//.', '//', '//')
- Dir_test('//./.', '//', '//')
- Dir_test('//foo/./bar', '//foo/bar', '//foo')
- Dir_test('//foo/../bar', '//bar', '//')
- Dir_test('//foo/../../bar', '//bar', '//')
- Dir_test('//foo/bar/../..', '//', '//')
- Dir_test('#//', wp, tmp)
- Dir_test('#//../foo', tmp_foo, tmp)
- Dir_test('#//../foo', tmp_foo, tmp)
- Dir_test('#//foo/bar', foo_bar, foo)
- Dir_test('#//foo/bar', foo_bar, foo)
- Dir_test('#//', wp, tmp)
+ Dir_test('//foo', '//foo', '//')
+ Dir_test('//foo/bar', '//foo/bar', '//foo')
+ Dir_test('//', '//', '//')
+ Dir_test('//..', '//', '//')
+ Dir_test('//foo/..', '//', '//')
+ Dir_test('//../foo', '//foo', '//')
+ Dir_test('//.', '//', '//')
+ Dir_test('//./.', '//', '//')
+ Dir_test('//foo/./bar', '//foo/bar', '//foo')
+ Dir_test('//foo/../bar', '//bar', '//')
+ Dir_test('//foo/../../bar', '//bar', '//')
+ Dir_test('//foo/bar/../..', '//', '//')
+ Dir_test('#//', wp, tmp)
+ Dir_test('#//../foo', tmp_foo, tmp)
+ Dir_test('#//../foo', tmp_foo, tmp)
+ Dir_test('#//foo/bar', foo_bar, foo)
+ Dir_test('#//foo/bar', foo_bar, foo)
+ Dir_test('#//', wp, tmp)
finally:
os.path = save_os_path
os.sep = save_os_sep
@@ -1810,7 +1843,7 @@ class FSTestCase(_tempdirTestCase):
d1 = fs.Dir('d1')
d2 = d1.Dir('d2')
dirs = os.path.normpath(d2.get_abspath()).split(os.sep)
- above_path = os.path.join(*['..']*len(dirs) + ['above'])
+ above_path = os.path.join(*['..'] * len(dirs) + ['above'])
above = d2.Dir(above_path)
def test_lookup_abs(self):
@@ -1828,13 +1861,13 @@ class FSTestCase(_tempdirTestCase):
return
test = self.test
fs = self.fs
- path='//servername/C$/foo'
+ path = '//servername/C$/foo'
f = self.fs._lookup('//servername/C$/foo', fs.Dir('#'), SCons.Node.FS.File)
# before the fix in this commit, this returned 'C:\servername\C$\foo'
# Should be a normalized Windows UNC path as below.
assert str(f) == r'\\servername\C$\foo', \
- 'UNC path %s got looked up as %s'%(path, f)
-
+ 'UNC path %s got looked up as %s' % (path, f)
+
def test_unc_drive_letter(self):
"""Test drive-letter lookup for windows UNC-style directories"""
if sys.platform not in ('win32',):
@@ -1869,56 +1902,56 @@ class FSTestCase(_tempdirTestCase):
d3_d4_f = d3_d4.File('f')
cases = [
- d1, d1, '.',
- d1, d1_f, 'f',
- d1, d1_d2, 'd2',
- d1, d1_d2_f, 'd2/f',
- d1, d3, '../d3',
- d1, d3_f, '../d3/f',
- d1, d3_d4, '../d3/d4',
- d1, d3_d4_f, '../d3/d4/f',
-
- d1_f, d1, '.',
- d1_f, d1_f, 'f',
- d1_f, d1_d2, 'd2',
- d1_f, d1_d2_f, 'd2/f',
- d1_f, d3, '../d3',
- d1_f, d3_f, '../d3/f',
- d1_f, d3_d4, '../d3/d4',
- d1_f, d3_d4_f, '../d3/d4/f',
-
- d1_d2, d1, '..',
- d1_d2, d1_f, '../f',
- d1_d2, d1_d2, '.',
- d1_d2, d1_d2_f, 'f',
- d1_d2, d3, '../../d3',
- d1_d2, d3_f, '../../d3/f',
- d1_d2, d3_d4, '../../d3/d4',
- d1_d2, d3_d4_f, '../../d3/d4/f',
-
- d1_d2_f, d1, '..',
- d1_d2_f, d1_f, '../f',
- d1_d2_f, d1_d2, '.',
- d1_d2_f, d1_d2_f, 'f',
- d1_d2_f, d3, '../../d3',
- d1_d2_f, d3_f, '../../d3/f',
- d1_d2_f, d3_d4, '../../d3/d4',
- d1_d2_f, d3_d4_f, '../../d3/d4/f',
+ d1, d1, '.',
+ d1, d1_f, 'f',
+ d1, d1_d2, 'd2',
+ d1, d1_d2_f, 'd2/f',
+ d1, d3, '../d3',
+ d1, d3_f, '../d3/f',
+ d1, d3_d4, '../d3/d4',
+ d1, d3_d4_f, '../d3/d4/f',
+
+ d1_f, d1, '.',
+ d1_f, d1_f, 'f',
+ d1_f, d1_d2, 'd2',
+ d1_f, d1_d2_f, 'd2/f',
+ d1_f, d3, '../d3',
+ d1_f, d3_f, '../d3/f',
+ d1_f, d3_d4, '../d3/d4',
+ d1_f, d3_d4_f, '../d3/d4/f',
+
+ d1_d2, d1, '..',
+ d1_d2, d1_f, '../f',
+ d1_d2, d1_d2, '.',
+ d1_d2, d1_d2_f, 'f',
+ d1_d2, d3, '../../d3',
+ d1_d2, d3_f, '../../d3/f',
+ d1_d2, d3_d4, '../../d3/d4',
+ d1_d2, d3_d4_f, '../../d3/d4/f',
+
+ d1_d2_f, d1, '..',
+ d1_d2_f, d1_f, '../f',
+ d1_d2_f, d1_d2, '.',
+ d1_d2_f, d1_d2_f, 'f',
+ d1_d2_f, d3, '../../d3',
+ d1_d2_f, d3_f, '../../d3/f',
+ d1_d2_f, d3_d4, '../../d3/d4',
+ d1_d2_f, d3_d4_f, '../../d3/d4/f',
]
if sys.platform in ('win32',):
- x_d1 = fs.Dir(r'X:\d1')
- x_d1_d2 = x_d1.Dir('d2')
- y_d1 = fs.Dir(r'Y:\d1')
- y_d1_d2 = y_d1.Dir('d2')
- y_d2 = fs.Dir(r'Y:\d2')
+ x_d1 = fs.Dir(r'X:\d1')
+ x_d1_d2 = x_d1.Dir('d2')
+ y_d1 = fs.Dir(r'Y:\d1')
+ y_d1_d2 = y_d1.Dir('d2')
+ y_d2 = fs.Dir(r'Y:\d2')
win32_cases = [
- x_d1, x_d1, '.',
- x_d1, x_d1_d2, 'd2',
- x_d1, y_d1, r'Y:\d1',
- x_d1, y_d1_d2, r'Y:\d1\d2',
- x_d1, y_d2, r'Y:\d2',
+ x_d1, x_d1, '.',
+ x_d1, x_d1_d2, 'd2',
+ x_d1, y_d1, r'Y:\d1',
+ x_d1, y_d1_d2, r'Y:\d1\d2',
+ x_d1, y_d2, r'Y:\d2',
]
cases.extend(win32_cases)
@@ -1939,14 +1972,15 @@ class FSTestCase(_tempdirTestCase):
def test_proxy(self):
"""Test a Node.FS object wrapped in a proxy instance"""
f1 = self.fs.File('fff')
+
class MyProxy(SCons.Util.Proxy):
__str__ = SCons.Util.Delegate('__str__')
+
p = MyProxy(f1)
f2 = self.fs.Entry(p)
assert f1 is f2, (f1, str(f1), f2, str(f2))
-
class DirTestCase(_tempdirTestCase):
def test__morph(self):
@@ -1963,8 +1997,10 @@ class DirTestCase(_tempdirTestCase):
def test_subclass(self):
"""Test looking up subclass of Dir nodes"""
+
class DirSubclass(SCons.Node.FS.Dir):
pass
+
sd = self.fs._lookup('special_dir', None, DirSubclass, create=1)
sd.must_be_same(SCons.Node.FS.Dir)
@@ -2011,9 +2047,9 @@ class DirTestCase(_tempdirTestCase):
test.subdir('d')
test.write(['d', 'g'], "67890\n")
test.write(['d', 'f'], "12345\n")
- test.subdir(['d','sub'])
- test.write(['d', 'sub','h'], "abcdef\n")
- test.subdir(['d','empty'])
+ test.subdir(['d', 'sub'])
+ test.write(['d', 'sub', 'h'], "abcdef\n")
+ test.subdir(['d', 'empty'])
d = self.fs.Dir('d')
g = self.fs.File(os.path.join('d', 'g'))
@@ -2026,10 +2062,10 @@ class DirTestCase(_tempdirTestCase):
assert e.get_contents() == '', e.get_contents()
assert e.get_text_contents() == '', e.get_text_contents()
- assert e.get_csig()+" empty" == files[0], files
- assert f.get_csig()+" f" == files[1], files
- assert g.get_csig()+" g" == files[2], files
- assert s.get_csig()+" sub" == files[3], files
+ assert e.get_csig() + " empty" == files[0], files
+ assert f.get_csig() + " f" == files[1], files
+ assert g.get_csig() + " g" == files[2], files
+ assert s.get_csig() + " sub" == files[3], files
def test_implicit_re_scans(self):
"""Test that adding entries causes a directory to be re-scanned
@@ -2087,7 +2123,7 @@ class DirTestCase(_tempdirTestCase):
d = self.fs.Dir('d')
r = self.fs.Dir('r')
d.addRepository(r)
-
+
assert d.rentry_exists_on_disk('exists')
assert d.rentry_exists_on_disk('rexists')
assert not d.rentry_exists_on_disk('does_not_exist')
@@ -2193,7 +2229,7 @@ class DirTestCase(_tempdirTestCase):
SCons.Node._is_derived_map[2] = return_true
SCons.Node._exists_map[5] = return_true
-
+
test.subdir('src0')
test.write(['src0', 'on-disk-f1'], "src0/on-disk-f1\n")
test.write(['src0', 'on-disk-f2'], "src0/on-disk-f2\n")
@@ -2341,6 +2377,7 @@ class DirTestCase(_tempdirTestCase):
r = sub.file_on_disk('dir')
assert not r, r
+
class EntryTestCase(_tempdirTestCase):
def test_runTest(self):
"""Test methods specific to the Entry sub-class.
@@ -2391,16 +2428,20 @@ class EntryTestCase(_tempdirTestCase):
class MyCalc(object):
def __init__(self, val):
self.max_drift = 0
+
class M(object):
def __init__(self, val):
self.val = val
+
def collect(self, args):
result = 0
for a in args:
result += a
return result
+
def signature(self, executor):
return self.val + 222
+
self.module = M(val)
test.subdir('e5d')
@@ -2412,13 +2453,14 @@ class EntryTestCase(_tempdirTestCase):
self.fs.Entry('#topdir/a/b/c')
-
class FileTestCase(_tempdirTestCase):
def test_subclass(self):
"""Test looking up subclass of File nodes"""
+
class FileSubclass(SCons.Node.FS.File):
pass
+
sd = self.fs._lookup('special_file', None, FileSubclass, create=1)
sd.must_be_same(SCons.Node.FS.File)
@@ -2462,7 +2504,8 @@ class FileTestCase(_tempdirTestCase):
build_f1.clear()
build_f1.linked = None
assert not build_f1.exists(), "%s did not realize that %s disappeared" % (build_f1, src_f1)
- assert not os.path.exists(build_f1.get_abspath()), "%s did not get removed after %s was removed" % (build_f1, src_f1)
+ assert not os.path.exists(build_f1.get_abspath()), "%s did not get removed after %s was removed" % (
+ build_f1, src_f1)
def test_changed(self):
"""
@@ -2471,6 +2514,7 @@ class FileTestCase(_tempdirTestCase):
when using CacheDir and Timestamp-MD5 decider.
This is for issue #2980
"""
+
# node should have
# 1 source (for example main.cpp)
# 0 depends
@@ -2527,18 +2571,18 @@ class FileTestCase(_tempdirTestCase):
self.csig = csig
self.timestamp = timestamp
- #Create nodes
+ # Create nodes
fs = SCons.Node.FS.FS()
d = self.fs.Dir('.')
- node = ChangedNode('main.o',d,fs) # main.o
- s1 = ChangedNode('main.cpp',d,fs) # main.cpp
- s1.timestamp = 2 # this changed
- i1 = ChangedNode('alpha.h',d,fs) # alpha.h - The bug is caused because the second build adds this file
- i1.timestamp = 2 # This is the new file.
- i2 = ChangedNode('beta.h',d,fs) # beta.h
- i3 = ChangedNode('gamma.h',d,fs) # gamma.h - In the bug beta.h's csig from binfo overwrites this ones
- i4 = ChangedNode('/usr/bin/g++',d,fs) # /usr/bin/g++
+ node = ChangedNode('main.o', d, fs) # main.o
+ s1 = ChangedNode('main.cpp', d, fs) # main.cpp
+ s1.timestamp = 2 # this changed
+ i1 = ChangedNode('alpha.h', d, fs) # alpha.h - The bug is caused because the second build adds this file
+ i1.timestamp = 2 # This is the new file.
+ i2 = ChangedNode('beta.h', d, fs) # beta.h
+ i3 = ChangedNode('gamma.h', d, fs) # gamma.h - In the bug beta.h's csig from binfo overwrites this ones
+ i4 = ChangedNode('/usr/bin/g++', d, fs) # /usr/bin/g++
node.add_source([s1])
node.add_dependency([])
@@ -2569,34 +2613,35 @@ class FileTestCase(_tempdirTestCase):
# "bdepends","bdependsigs", "bimplicit", "bimplicitsigs"
bi = sconsign_entry.binfo
bi.bsources = ['main.cpp']
- bi.bsourcesigs=[FakeNodeInfo('main.cpp',1),]
+ bi.bsourcesigs = [FakeNodeInfo('main.cpp', 1), ]
bi.bdepends = []
bi.bdependsigs = []
- bi.bimplicit = ['beta.h','gamma.h']
- bi.bimplicitsigs = [FakeNodeInfo('beta.h',1), FakeNodeInfo('gamma.h',1)]
+ bi.bimplicit = ['beta.h', 'gamma.h']
+ bi.bimplicitsigs = [FakeNodeInfo('beta.h', 1), FakeNodeInfo('gamma.h', 1)]
ni = sconsign_entry.ninfo
# We'll set the following attributes (which are lists): sources, depends, implicit lists
- #Set timestamp-md5
- #Call changed
- #Check results
+ # Set timestamp-md5
+ # Call changed
+ # Check results
node.build_env = ChangedEnvironment()
changed = node.changed()
# change to true to debug
if False:
- print("Changed:%s"%changed)
- print("%15s -> csig:%s"%(s1.name, s1.ninfo.csig))
- print("%15s -> csig:%s"%(i1.name, i1.ninfo.csig))
- print("%15s -> csig:%s"%(i2.name, i2.ninfo.csig))
- print("%15s -> csig:%s"%(i3.name, i3.ninfo.csig))
- print("%15s -> csig:%s"%(i4.name, i4.ninfo.csig))
+ print("Changed:%s" % changed)
+ print("%15s -> csig:%s" % (s1.name, s1.ninfo.csig))
+ print("%15s -> csig:%s" % (i1.name, i1.ninfo.csig))
+ print("%15s -> csig:%s" % (i2.name, i2.ninfo.csig))
+ print("%15s -> csig:%s" % (i3.name, i3.ninfo.csig))
+ print("%15s -> csig:%s" % (i4.name, i4.ninfo.csig))
- self.assertEqual(i2.name,i2.ninfo.csig, "gamma.h's fake csig should equal gamma.h but equals:%s"%i2.ninfo.csig)
+ self.assertEqual(i2.name, i2.ninfo.csig,
+ "gamma.h's fake csig should equal gamma.h but equals:%s" % i2.ninfo.csig)
class GlobTestCase(_tempdirTestCase):
@@ -2665,7 +2710,6 @@ class GlobTestCase(_tempdirTestCase):
self.sub_dir3_jjj = self.sub_dir3.File('jjj')
self.sub_dir3_lll = self.sub_dir3.File('lll')
-
def do_cases(self, cases, **kwargs):
# First, execute all of the cases with string=True and verify
@@ -2713,17 +2757,17 @@ class GlobTestCase(_tempdirTestCase):
join = os.path.join
cases = (
- ('ggg', ['ggg'], [self.ggg]),
+ ('ggg', ['ggg'], [self.ggg]),
- ('subdir1', ['subdir1'], [self.subdir1]),
+ ('subdir1', ['subdir1'], [self.subdir1]),
- ('subdir1/jjj', [join('subdir1', 'jjj')], [self.subdir1_jjj]),
+ ('subdir1/jjj', [join('subdir1', 'jjj')], [self.subdir1_jjj]),
- ('disk-aaa', ['disk-aaa'], None),
+ ('disk-aaa', ['disk-aaa'], None),
- ('disk-sub', ['disk-sub'], None),
+ ('disk-sub', ['disk-sub'], None),
- ('both-aaa', ['both-aaa'], []),
+ ('both-aaa', ['both-aaa'], []),
)
self.do_cases(cases)
@@ -2818,8 +2862,8 @@ class GlobTestCase(_tempdirTestCase):
"""Test globbing for things that don't exist"""
cases = (
- ('does_not_exist', [], []),
- ('no_subdir/*', [], []),
+ ('does_not_exist', [], []),
+ ('no_subdir/*', [], []),
('subdir?/no_file', [], []),
)
@@ -2927,7 +2971,7 @@ class GlobTestCase(_tempdirTestCase):
assert g == expect, str(g) + " is not sorted, but should be!"
g = self.fs.Glob('disk-*', strings=True)
- expect = [ 'disk-aaa', 'disk-bbb', 'disk-ccc', 'disk-sub' ]
+ expect = ['disk-aaa', 'disk-bbb', 'disk-ccc', 'disk-sub']
assert g == expect, str(g) + " is not sorted, but should be!"
@@ -3060,10 +3104,13 @@ class RepositoryTestCase(_tempdirTestCase):
def test_rdir(self):
"""Test the Dir.rdir() method"""
+
def return_true(obj):
return 1
+
def return_false(obj):
return 0
+
SCons.Node._exists_map[5] = return_true
SCons.Node._exists_map[6] = return_false
SCons.Node._is_derived_map[2] = return_true
@@ -3113,10 +3160,13 @@ class RepositoryTestCase(_tempdirTestCase):
def test_rfile(self):
"""Test the File.rfile() method"""
+
def return_true(obj):
return 1
+
def return_false(obj):
return 0
+
SCons.Node._exists_map[5] = return_true
SCons.Node._exists_map[6] = return_false
SCons.Node._is_derived_map[2] = return_true
@@ -3255,7 +3305,7 @@ class RepositoryTestCase(_tempdirTestCase):
test.write(["rep3", "contents"], "Con\x1aTents\n")
try:
c = fs.File("contents").get_contents()
- assert c == bytearray("Con\x1aTents\n",'utf-8'), "got '%s'" % c
+ assert c == bytearray("Con\x1aTents\n", 'utf-8'), "got '%s'" % c
finally:
test.unlink(["rep3", "contents"])
@@ -3274,8 +3324,8 @@ class RepositoryTestCase(_tempdirTestCase):
class FakeUnicodeString(collections.UserString):
def encode(self, encoding):
return str(self)
- test_string = FakeUnicodeString("Con\x1aTents\n")
+ test_string = FakeUnicodeString("Con\x1aTents\n")
# Test with ASCII.
test.write(["rep3", "contents"], test_string.encode('ascii'))
@@ -3301,14 +3351,13 @@ class RepositoryTestCase(_tempdirTestCase):
finally:
test.unlink(["rep3", "contents"])
- #def test_is_up_to_date(self):
-
+ # def test_is_up_to_date(self):
class find_fileTestCase(unittest.TestCase):
def runTest(self):
"""Testing find_file function"""
- test = TestCmd(workdir = '')
+ test = TestCmd(workdir='')
test.write('./foo', 'Some file\n')
test.write('./foo2', 'Another file\n')
test.subdir('same')
@@ -3321,9 +3370,9 @@ class find_fileTestCase(unittest.TestCase):
os.chdir(test.workpath(""))
node_derived = fs.File(test.workpath('bar/baz'))
- node_derived.builder_set(1) # Any non-zero value.
+ node_derived.builder_set(1) # Any non-zero value.
node_pseudo = fs.File(test.workpath('pseudo'))
- node_pseudo.set_src_builder(1) # Any non-zero value.
+ node_pseudo.set_src_builder(1) # Any non-zero value.
paths = tuple(map(fs.Dir, ['.', 'same', './bar']))
nodes = [SCons.Node.FS.find_file('foo', paths)]
@@ -3376,12 +3425,13 @@ class find_fileTestCase(unittest.TestCase):
finally:
sys.stdout = save_sys_stdout
+
class StringDirTestCase(unittest.TestCase):
def runTest(self):
"""Test using a string as the second argument of
File() and Dir()"""
- test = TestCmd(workdir = '')
+ test = TestCmd(workdir='')
test.subdir('sub')
fs = SCons.Node.FS.FS(test.workpath(''))
@@ -3392,10 +3442,11 @@ class StringDirTestCase(unittest.TestCase):
assert str(f) == os.path.join('sub', 'file')
assert not f.exists()
+
class stored_infoTestCase(unittest.TestCase):
def runTest(self):
"""Test how we store build information"""
- test = TestCmd(workdir = '')
+ test = TestCmd(workdir='')
test.subdir('sub')
fs = SCons.Node.FS.FS(test.workpath(''))
@@ -3408,9 +3459,10 @@ class stored_infoTestCase(unittest.TestCase):
class Null(object):
def __init__(self):
self.xyzzy = 7
+
def get_entry(self, name):
return self.Null()
-
+
def test_sconsign(node):
return MySConsign()
@@ -3420,10 +3472,11 @@ class stored_infoTestCase(unittest.TestCase):
bi = f.get_stored_info()
assert bi.xyzzy == 7, bi
+
class has_src_builderTestCase(unittest.TestCase):
def runTest(self):
"""Test the has_src_builder() method"""
- test = TestCmd(workdir = '')
+ test = TestCmd(workdir='')
fs = SCons.Node.FS.FS(test.workpath(''))
os.chdir(test.workpath(''))
test.subdir('sub1')
@@ -3442,9 +3495,9 @@ class has_src_builderTestCase(unittest.TestCase):
sub1.set_src_builder(b1)
test.write(['sub1', 'f2'], "sub1/f2\n")
- h = f1.has_src_builder() # cached from previous call
+ h = f1.has_src_builder() # cached from previous call
assert not h, h
- h = f1.has_builder() # cached from previous call
+ h = f1.has_builder() # cached from previous call
assert not h, h
h = f2.has_src_builder()
assert not h, h
@@ -3456,6 +3509,7 @@ class has_src_builderTestCase(unittest.TestCase):
assert h, h
assert f3.builder is b1, f3.builder
+
class prepareTestCase(unittest.TestCase):
def runTest(self):
"""Test the prepare() method"""
@@ -3463,6 +3517,7 @@ class prepareTestCase(unittest.TestCase):
class MyFile(SCons.Node.FS.File):
def _createDir(self, update=None):
raise SCons.Errors.StopError
+
def exists(self):
return None
@@ -3479,6 +3534,7 @@ class prepareTestCase(unittest.TestCase):
class MkdirAction(Action):
def __init__(self, dir_made):
self.dir_made = dir_made
+
def __call__(self, target, source, env, executor=None):
if executor:
target = executor.get_all_targets()
@@ -3503,7 +3559,6 @@ class prepareTestCase(unittest.TestCase):
dir.prepare()
-
class SConstruct_dirTestCase(unittest.TestCase):
def runTest(self):
"""Test setting the SConstruct directory"""
@@ -3513,7 +3568,6 @@ class SConstruct_dirTestCase(unittest.TestCase):
assert fs.SConstruct_dir.get_internal_path() == 'xxx'
-
class CacheDirTestCase(unittest.TestCase):
def test_get_cachedir_csig(self):
@@ -3524,7 +3578,6 @@ class CacheDirTestCase(unittest.TestCase):
assert r == 'd41d8cd98f00b204e9800998ecf8427e', r
-
class clearTestCase(unittest.TestCase):
def runTest(self):
"""Test clearing FS nodes of cached data."""
@@ -3534,11 +3587,11 @@ class clearTestCase(unittest.TestCase):
e = fs.Entry('e')
assert not e.exists()
assert not e.rexists()
- assert str(e) == 'e', str(d)
+ assert str(e) == 'e', str(e)
e.clear()
assert not e.exists()
assert not e.rexists()
- assert str(e) == 'e', str(d)
+ assert str(e) == 'e', str(e)
d = fs.Dir(test.workpath('d'))
test.subdir('d')
@@ -3552,10 +3605,10 @@ class clearTestCase(unittest.TestCase):
assert str(d) == test.workpath('d'), str(d)
# Now verify clear() resets the cache
d.clear()
- assert not d.exists()
+ assert not d.exists()
assert not d.rexists()
assert str(d) == test.workpath('d'), str(d)
-
+
f = fs.File(test.workpath('f'))
test.write(test.workpath('f'), 'file f')
assert f.exists()
@@ -3573,7 +3626,6 @@ class clearTestCase(unittest.TestCase):
assert str(f) == test.workpath('f'), str(f)
-
class disambiguateTestCase(unittest.TestCase):
def runTest(self):
"""Test calling the disambiguate() method."""
@@ -3635,6 +3687,7 @@ class disambiguateTestCase(unittest.TestCase):
f = build_nonexistant.disambiguate()
assert f.__class__ is fff.__class__, f.__class__
+
class postprocessTestCase(unittest.TestCase):
def runTest(self):
"""Test calling the postprocess() method."""
@@ -3650,11 +3703,10 @@ class postprocessTestCase(unittest.TestCase):
f.postprocess()
-
class SpecialAttrTestCase(unittest.TestCase):
def runTest(self):
"""Test special attributes of file nodes."""
- test=TestCmd(workdir='')
+ test = TestCmd(workdir='')
fs = SCons.Node.FS.FS(test.workpath('work'))
f = fs.Entry('foo/bar/baz.blat').get_subst_proxy()
@@ -3809,11 +3861,10 @@ class SpecialAttrTestCase(unittest.TestCase):
assert caught, "did not catch expected AttributeError"
-
class SaveStringsTestCase(unittest.TestCase):
def runTest(self):
"""Test caching string values of nodes."""
- test=TestCmd(workdir='')
+ test = TestCmd(workdir='')
def setup(fs):
fs.Dir('src')
@@ -3867,13 +3918,13 @@ class SaveStringsTestCase(unittest.TestCase):
s = list(map(str, nodes))
expect = list(map(os.path.normpath, ['src/f', 'd1/f', 'd0/b', 'd1/b']))
- assert s == expect, 'node str() not cached: %s'%s
+ assert s == expect, 'node str() not cached: %s' % s
class AbsolutePathTestCase(unittest.TestCase):
def test_root_lookup_equivalence(self):
"""Test looking up /fff vs. fff in the / directory"""
- test=TestCmd(workdir='')
+ test = TestCmd(workdir='')
fs = SCons.Node.FS.FS('/')
@@ -3887,7 +3938,6 @@ class AbsolutePathTestCase(unittest.TestCase):
os.chdir(save_cwd)
-
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 39b928b..ce44b7d 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Node/NodeTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/NodeTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -271,7 +271,7 @@ class NodeInfoBaseTestCase(unittest.TestCase):
f = ni1.format()
assert f == ['x', 'y', 'z'], f
-
+
field_list = ['xxx', 'zzz', 'aaa']
f = ni1.format(field_list)
@@ -751,7 +751,7 @@ class NodeTestCase(unittest.TestCase):
e = node.exists()
assert e == 1, e
- def test_exists(self):
+ def test_exists_repo(self):
"""Test evaluating whether a Node exists locally or in a repository.
"""
node = SCons.Node.Node()
diff --git a/src/engine/SCons/Node/Python.py b/src/engine/SCons/Node/Python.py
index 30daf9a..d338051 100644
--- a/src/engine/SCons/Node/Python.py
+++ b/src/engine/SCons/Node/Python.py
@@ -27,7 +27,7 @@ Python nodes.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Node/Python.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/Python.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Node
diff --git a/src/engine/SCons/Node/PythonTests.py b/src/engine/SCons/Node/PythonTests.py
index 2b35f00..98137c7 100644
--- a/src/engine/SCons/Node/PythonTests.py
+++ b/src/engine/SCons/Node/PythonTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Node/PythonTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/PythonTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 564e8de..5455bd6 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -43,13 +43,18 @@ from __future__ import print_function
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Node/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Node/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import collections
import copy
from itertools import chain
+try:
+ from itertools import zip_longest
+except ImportError:
+ from itertools import izip_longest as zip_longest
+
import SCons.Debug
from SCons.Debug import logInstanceCreation
import SCons.Executor
@@ -103,9 +108,9 @@ implicit_deps_changed = 0
# A variable that can be set to an interface-specific function be called
# to annotate a Node with information about its creation.
-def do_nothing(node): pass
+def do_nothing_node(node): pass
-Annotate = do_nothing
+Annotate = do_nothing_node
# Gets set to 'True' if we're running in interactive mode. Is
# currently used to release parts of a target's info during
@@ -248,25 +253,10 @@ _target_from_source_map = {0 : target_from_source_none,
# used by it.
#
-
-class DeciderNeedsNode(Exception):
- """
- Indicate that the decider needs the node as well as the target and the dependency.
- Normally the node and the target are the same, but in the case of repository
- They may be different. Also the NodeInfo is retrieved from the node
- """
- def __init__(self, call_this_decider):
- """
- :param call_this_decider: to return the decider to call directly since deciders
- are called through several levels of indirection
- """
- self.decider = call_this_decider
-
-
#
# First, the single decider functions
#
-def changed_since_last_build_node(node, target, prev_ni):
+def changed_since_last_build_node(node, target, prev_ni, repo_node=None):
"""
Must be overridden in a specific subclass to return True if this
@@ -287,7 +277,7 @@ def changed_since_last_build_node(node, target, prev_ni):
raise NotImplementedError
-def changed_since_last_build_alias(node, target, prev_ni):
+def changed_since_last_build_alias(node, target, prev_ni, repo_node=None):
cur_csig = node.get_csig()
try:
return cur_csig != prev_ni.csig
@@ -295,24 +285,24 @@ def changed_since_last_build_alias(node, target, prev_ni):
return 1
-def changed_since_last_build_entry(node, target, prev_ni):
+def changed_since_last_build_entry(node, target, prev_ni, repo_node=None):
node.disambiguate()
- return _decider_map[node.changed_since_last_build](node, target, prev_ni)
+ return _decider_map[node.changed_since_last_build](node, target, prev_ni, repo_node)
-def changed_since_last_build_state_changed(node, target, prev_ni):
+def changed_since_last_build_state_changed(node, target, prev_ni, repo_node=None):
return node.state != SCons.Node.up_to_date
-def decide_source(node, target, prev_ni):
- return target.get_build_env().decide_source(node, target, prev_ni)
+def decide_source(node, target, prev_ni, repo_node=None):
+ return target.get_build_env().decide_source(node, target, prev_ni, repo_node)
-def decide_target(node, target, prev_ni):
- return target.get_build_env().decide_target(node, target, prev_ni)
+def decide_target(node, target, prev_ni, repo_node=None):
+ return target.get_build_env().decide_target(node, target, prev_ni, repo_node)
-def changed_since_last_build_python(node, target, prev_ni):
+def changed_since_last_build_python(node, target, prev_ni, repo_node=None):
cur_csig = node.get_csig()
try:
return cur_csig != prev_ni.csig
@@ -529,6 +519,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
__slots__ = ['sources',
'sources_set',
+ 'target_peers',
'_specific_sources',
'depends',
'depends_set',
@@ -784,6 +775,25 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
for parent in self.waiting_parents:
parent.implicit = None
+ # Handle issue where builder emits more than one target and
+ # the source file for the builder is generated.
+ # in that case only the first target was getting it's .implicit
+ # cleared when the source file is built (second scan).
+ # leaving only partial implicits from scan before source file is generated
+ # typically the compiler only. Then scanned files are appended
+ # This is persisted to sconsign and rebuild causes false rebuilds
+ # because the ordering of the implicit list then changes to what it
+ # should have been.
+ # This is at least the following bugs
+ # https://github.com/SCons/scons/issues/2811
+ # https://jira.mongodb.org/browse/SERVER-33111
+ try:
+ for peer in parent.target_peers:
+ peer.implicit = None
+ except AttributeError:
+ pass
+
+
self.clear()
if self.pseudo:
@@ -1160,7 +1170,7 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
binfo.bactsig = SCons.Util.MD5signature(executor.get_contents())
if self._specific_sources:
- sources = [s for s in self.sources if not s in ignore_set]
+ sources = [s for s in self.sources if s not in ignore_set]
else:
sources = executor.get_unignored_sources(self, self.ignore)
@@ -1480,17 +1490,11 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
result = True
for child, prev_ni in zip(children, then):
- try:
- if _decider_map[child.changed_since_last_build](child, self, prev_ni):
- if t: Trace(': %s changed' % child)
- result = True
- except DeciderNeedsNode as e:
- if e.decider(self, prev_ni, node=node):
- if t: Trace(': %s changed' % child)
- result = True
+ if _decider_map[child.changed_since_last_build](child, self, prev_ni, node):
+ if t: Trace(': %s changed' % child)
+ result = True
if self.has_builder():
- import SCons.Util
contents = self.get_executor().get_contents()
newsig = SCons.Util.MD5signature(contents)
if bi.bactsig != newsig:
@@ -1647,14 +1651,14 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
lines = []
- removed = [x for x in old_bkids if not x in new_bkids]
+ removed = [x for x in old_bkids if x not in new_bkids]
if removed:
removed = [stringify(r) for r in removed]
fmt = "`%s' is no longer a dependency\n"
lines.extend([fmt % s for s in removed])
for k in new_bkids:
- if not k in old_bkids:
+ if k not in old_bkids:
lines.append("`%s' is a new dependency\n" % stringify(k))
else:
try:
@@ -1666,9 +1670,16 @@ class Node(object, with_metaclass(NoSlotsPyPy)):
lines.append("`%s' changed\n" % stringify(k))
if len(lines) == 0 and old_bkids != new_bkids:
- lines.append("the dependency order changed:\n" +
- "%sold: %s\n" % (' '*15, list(map(stringify, old_bkids))) +
- "%snew: %s\n" % (' '*15, list(map(stringify, new_bkids))))
+ lines.append("the dependency order changed:\n")
+ lines.append("->Sources\n")
+ for (o,n) in zip_longest(old.bsources, new.bsources, fillvalue=None):
+ lines.append("Old:%s\tNew:%s\n"%(o,n))
+ lines.append("->Depends\n")
+ for (o,n) in zip_longest(old.bdepends, new.bdepends, fillvalue=None):
+ lines.append("Old:%s\tNew:%s\n"%(o,n))
+ lines.append("->Implicit\n")
+ for (o,n) in zip_longest(old.bimplicit, new.bimplicit, fillvalue=None):
+ lines.append("Old:%s\tNew:%s\n"%(o,n))
if len(lines) == 0:
def fmt_with_title(title, strlines):
@@ -1711,7 +1722,6 @@ class Walker(object):
This is depth-first, children are visited before the parent.
The Walker object can be initialized with any node, and
returns the next node on the descent with each get_next() call.
- 'kids_func' is an optional function that will be called to
get the children of a node instead of calling 'children'.
'cycle_func' is an optional function that will be called
when a cycle is detected.
diff --git a/src/engine/SCons/PathList.py b/src/engine/SCons/PathList.py
index 98a160c..d6a01e7 100644
--- a/src/engine/SCons/PathList.py
+++ b/src/engine/SCons/PathList.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/PathList.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/PathList.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """SCons.PathList
diff --git a/src/engine/SCons/PathListTests.py b/src/engine/SCons/PathListTests.py
index ea9e3ff..0a18fbe 100644
--- a/src/engine/SCons/PathListTests.py
+++ b/src/engine/SCons/PathListTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/PathListTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/PathListTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py
index 21dbf18..7941625 100644
--- a/src/engine/SCons/Platform/PlatformTests.py
+++ b/src/engine/SCons/Platform/PlatformTests.py
@@ -21,18 +21,20 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/PlatformTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/PlatformTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
import collections
import unittest
+import os
import SCons.Errors
import SCons.Platform
import SCons.Environment
import SCons.Action
+
class Environment(collections.UserDict):
def Detect(self, cmd):
return cmd
@@ -40,6 +42,7 @@ class Environment(collections.UserDict):
def AppendENVPath(self, key, value):
pass
+
class PlatformTestCase(unittest.TestCase):
def test_Platform(self):
"""Test the Platform() function"""
@@ -110,13 +113,14 @@ class PlatformTestCase(unittest.TestCase):
p = SCons.Platform.Platform('_does_not_exist_')
except SCons.Errors.UserError:
pass
- else:
+ else: # TODO pylint E0704: bare raise not inside except
raise
env = Environment()
SCons.Platform.Platform()(env)
assert env != {}, env
+
class TempFileMungeTestCase(unittest.TestCase):
def test_MAXLINELENGTH(self):
""" Test different values for MAXLINELENGTH with the same
@@ -138,22 +142,58 @@ class TempFileMungeTestCase(unittest.TestCase):
env['OVERSIMPLIFIED'] = 'command'
expanded_cmd = env.subst(defined_cmd)
# Call the tempfile munger
- cmd = t(None,None,env,0)
+ cmd = t(None, None, env, 0)
assert cmd == defined_cmd, cmd
# Let MAXLINELENGTH equal the string's length
env['MAXLINELENGTH'] = len(expanded_cmd)
- cmd = t(None,None,env,0)
+ cmd = t(None, None, env, 0)
assert cmd == defined_cmd, cmd
# Finally, let the actual tempfile mechanism kick in
# Disable printing of actions...
old_actions = SCons.Action.print_actions
SCons.Action.print_actions = 0
env['MAXLINELENGTH'] = len(expanded_cmd)-1
- cmd = t(None,None,env,0)
+ cmd = t(None, None, env, 0)
# ...and restoring its setting.
SCons.Action.print_actions = old_actions
assert cmd != defined_cmd, cmd
+ def test_TEMPFILEARGJOINBYTE(self):
+ """
+ Test argument join byte TEMPFILEARGJOINBYTE
+ """
+
+ # Init class with cmd, such that the fully expanded
+ # string reads "a test command line".
+ # Note, how we're using a command string here that is
+ # actually longer than the substituted one. This is to ensure
+ # that the TempFileMunge class internally really takes the
+ # length of the expanded string into account.
+ defined_cmd = "a $VERY $OVERSIMPLIFIED line"
+ t = SCons.Platform.TempFileMunge(defined_cmd)
+ env = SCons.Environment.SubstitutionEnvironment(tools=[])
+ # Setting the line length high enough...
+ env['MAXLINELENGTH'] = 1024
+ env['VERY'] = 'test'
+ env['OVERSIMPLIFIED'] = 'command'
+ env['TEMPFILEARGJOINBYTE'] = os.linesep
+ expanded_cmd = env.subst(defined_cmd)
+
+ # For tempfilemunge to operate.
+ old_actions = SCons.Action.print_actions
+ SCons.Action.print_actions = 0
+ env['MAXLINELENGTH'] = len(expanded_cmd)-1
+ cmd = t(None, None, env, 0)
+ # print("CMD is:%s"%cmd)
+
+ with open(cmd[-1],'rb') as f:
+ file_content = f.read()
+ # print("Content is:[%s]"%file_content)
+ # ...and restoring its setting.
+ SCons.Action.print_actions = old_actions
+ assert file_content != env['TEMPFILEARGJOINBYTE'].join(['test','command','line'])
+
+
def test_tempfilecreation_once(self):
# Init class with cmd, such that the fully expanded
# string reads "a test command line".
@@ -173,9 +213,11 @@ class TempFileMungeTestCase(unittest.TestCase):
old_actions = SCons.Action.print_actions
SCons.Action.print_actions = 0
# Create an instance of object derived class to allow setattrb
- class Node(object) :
+
+ class Node(object):
class Attrs(object):
pass
+
def __init__(self):
self.attributes = self.Attrs()
target = [Node()]
@@ -185,6 +227,7 @@ class TempFileMungeTestCase(unittest.TestCase):
assert cmd != defined_cmd, cmd
assert cmd == getattr(target[0].attributes, 'tempfile_cmdlist', None)
+
class PlatformEscapeTestCase(unittest.TestCase):
def test_posix_escape(self):
""" Check that paths with parens are escaped properly
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
index ab4b293..8da1e9d 100644
--- a/src/engine/SCons/Platform/__init__.py
+++ b/src/engine/SCons/Platform/__init__.py
@@ -43,11 +43,11 @@ their own platform definition.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Platform/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
-import imp
+import importlib
import os
import sys
import tempfile
@@ -101,13 +101,8 @@ def platform_module(name = platform_default()):
eval(full_name)
else:
try:
- file, path, desc = imp.find_module(name,
- sys.modules['SCons.Platform'].__path__)
- try:
- mod = imp.load_module(full_name, file, path, desc)
- finally:
- if file:
- file.close()
+ # the specific platform module is a relative import
+ mod = importlib.import_module("." + name, __name__)
except ImportError:
try:
import zipimport
@@ -231,8 +226,10 @@ class TempFileMunge(object):
prefix = '@'
args = list(map(SCons.Subst.quote_spaces, cmd[1:]))
- os.write(fd, bytearray(" ".join(args) + "\n",'utf-8'))
+ join_char = env.get('TEMPFILEARGJOIN',' ')
+ os.write(fd, bytearray(join_char.join(args) + "\n",'utf-8'))
os.close(fd)
+
# XXX Using the SCons.Action.print_actions value directly
# like this is bogus, but expedient. This class should
# really be rewritten as an Action that defines the
diff --git a/src/engine/SCons/Platform/__init__.xml b/src/engine/SCons/Platform/__init__.xml
index 60bfb38..d4c2a21 100644
--- a/src/engine/SCons/Platform/__init__.xml
+++ b/src/engine/SCons/Platform/__init__.xml
@@ -257,4 +257,15 @@ The default is '.lnk'.
</summary>
</cvar>
+<cvar name="TEMPFILEARGJOIN">
+<summary>
+<para>
+The string (or character) to be used to join the arguments passed to TEMPFILE when command line exceeds the limit set by &cv-MAXLINELENGTH;.
+The default value is a space. However for MSVC, MSLINK the default is a line seperator characters as defined by os.linesep.
+Note this value is used literally and not expanded by the subst logic.
+</para>
+</summary>
+</cvar>
+
+
</sconsdoc>
diff --git a/src/engine/SCons/Platform/aix.py b/src/engine/SCons/Platform/aix.py
index ba10ae6..70fbb35 100644
--- a/src/engine/SCons/Platform/aix.py
+++ b/src/engine/SCons/Platform/aix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/aix.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/aix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import subprocess
diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py
index 7538f0a..70b6443 100644
--- a/src/engine/SCons/Platform/cygwin.py
+++ b/src/engine/SCons/Platform/cygwin.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/cygwin.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/cygwin.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
diff --git a/src/engine/SCons/Platform/darwin.py b/src/engine/SCons/Platform/darwin.py
index fc6e890..d5861d9 100644
--- a/src/engine/SCons/Platform/darwin.py
+++ b/src/engine/SCons/Platform/darwin.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/darwin.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/darwin.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import posix
import os
@@ -56,12 +56,11 @@ def generate(env):
for file in filelist:
if os.path.isfile(file):
- f = open(file, 'r')
- lines = f.readlines()
- for line in lines:
- if line:
- env.AppendENVPath('PATHOSX', line.strip('\n'))
- f.close()
+ with open(file, 'r') as f:
+ lines = f.readlines()
+ for line in lines:
+ if line:
+ env.AppendENVPath('PATHOSX', line.strip('\n'))
# Not sure why this wasn't the case all along?
if env['ENV'].get('PATHOSX', False) and os.environ.get('SCONS_USE_MAC_PATHS', False):
diff --git a/src/engine/SCons/Platform/hpux.py b/src/engine/SCons/Platform/hpux.py
index ccda01e..6867212 100644
--- a/src/engine/SCons/Platform/hpux.py
+++ b/src/engine/SCons/Platform/hpux.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/hpux.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/hpux.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import posix
diff --git a/src/engine/SCons/Platform/irix.py b/src/engine/SCons/Platform/irix.py
index 38f0f26..a382e71 100644
--- a/src/engine/SCons/Platform/irix.py
+++ b/src/engine/SCons/Platform/irix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/irix.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/irix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import posix
diff --git a/src/engine/SCons/Platform/mingw.py b/src/engine/SCons/Platform/mingw.py
index 95fb2e4..c03c9c8 100644
--- a/src/engine/SCons/Platform/mingw.py
+++ b/src/engine/SCons/Platform/mingw.py
@@ -27,7 +27,7 @@ Platform-specific initialization for the MinGW system.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/mingw.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/mingw.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
diff --git a/src/engine/SCons/Platform/os2.py b/src/engine/SCons/Platform/os2.py
index bc49c88..ebabe3d 100644
--- a/src/engine/SCons/Platform/os2.py
+++ b/src/engine/SCons/Platform/os2.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/os2.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/os2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import win32
def generate(env):
diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
index 27c3f3a..780c764 100644
--- a/src/engine/SCons/Platform/posix.py
+++ b/src/engine/SCons/Platform/posix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/posix.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/posix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import errno
import os
diff --git a/src/engine/SCons/Platform/sunos.py b/src/engine/SCons/Platform/sunos.py
index b54be76..6aa54aa 100644
--- a/src/engine/SCons/Platform/sunos.py
+++ b/src/engine/SCons/Platform/sunos.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/sunos.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/sunos.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import posix
diff --git a/src/engine/SCons/Platform/virtualenv.py b/src/engine/SCons/Platform/virtualenv.py
index e24fb7a..9fb3e45 100644
--- a/src/engine/SCons/Platform/virtualenv.py
+++ b/src/engine/SCons/Platform/virtualenv.py
@@ -26,7 +26,7 @@ Support for virtualenv.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/virtualenv.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/virtualenv.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
diff --git a/src/engine/SCons/Platform/virtualenvTests.py b/src/engine/SCons/Platform/virtualenvTests.py
index f560f2e..891fdb3 100644
--- a/src/engine/SCons/Platform/virtualenvTests.py
+++ b/src/engine/SCons/Platform/virtualenvTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/virtualenvTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/virtualenvTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index f64081c..ea567a2 100644
--- a/src/engine/SCons/Platform/win32.py
+++ b/src/engine/SCons/Platform/win32.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/win32.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/win32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -193,7 +193,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
# actually do the spawn
try:
- args = [sh, '/C', escape(' '.join(args)) ]
+ args = [sh, '/C', escape(' '.join(args))]
ret = spawnve(os.P_WAIT, sh, args, env)
except OSError as e:
# catch any error
@@ -207,15 +207,17 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
# and do clean up stuff
if stdout is not None and stdoutRedirected == 0:
try:
- stdout.write(open( tmpFileStdout, "r" ).read())
- os.remove( tmpFileStdout )
+ with open(tmpFileStdout, "r" ) as tmp:
+ stdout.write(tmp.read())
+ os.remove(tmpFileStdout)
except (IOError, OSError):
pass
if stderr is not None and stderrRedirected == 0:
try:
- stderr.write(open( tmpFileStderr, "r" ).read())
- os.remove( tmpFileStderr )
+ with open(tmpFileStderr, "r" ) as tmp:
+ stderr.write(tmp.read())
+ os.remove(tmpFileStderr)
except (IOError, OSError):
pass
return ret
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index e0cd35d..7409c50 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -35,7 +35,7 @@ libraries are installed, if some command line options are supported etc.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/SConf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/SConf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -56,7 +56,6 @@ import SCons.Warnings
import SCons.Conftest
from SCons.Debug import Trace
-from SCons.Node import DeciderNeedsNode
# Turn off the Conftest error logging
SCons.Conftest.LogInputFiles = 0
@@ -247,6 +246,7 @@ class SConfBuildTask(SCons.Taskmaster.AlwaysTask):
# ConfigureCacheError and if yes, reraise the exception
exc_type = self.exc_info()[0]
if issubclass(exc_type, SConfError):
+ # TODO pylint E0704: bare raise not inside except
raise
elif issubclass(exc_type, SCons.Errors.BuildError):
# we ignore Build Errors (occurs, when a test doesn't pass)
@@ -406,12 +406,10 @@ class SConfBase(object):
# that the correct .sconsign info will get calculated
# and keep the build state consistent.
def force_build(dependency, target, prev_ni,
- env_decider=env.decide_source,
- node=None):
+ repo_node=None,
+ env_decider=env.decide_source):
try:
- env_decider(dependency, target, prev_ni)
- except DeciderNeedsNode as e:
- e.decider(target, prev_ni, node=target)
+ env_decider(dependency, target, prev_ni, repo_node)
except Exception as e:
raise e
return True
@@ -787,7 +785,7 @@ class SConfBase(object):
self.active = 0
sconf_global = None
- if not self.config_h is None:
+ if self.config_h is not None:
_ac_config_hs[self.config_h] = self.config_h_text
self.env.fs = self.lastEnvFs
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index 678147c..bfa4871 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/SConfTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/SConfTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
diff --git a/src/engine/SCons/SConsign.py b/src/engine/SCons/SConsign.py
index e01026d..e003933 100644
--- a/src/engine/SCons/SConsign.py
+++ b/src/engine/SCons/SConsign.py
@@ -29,7 +29,7 @@ Writing and reading information to the .sconsign file or files.
from __future__ import print_function
-__revision__ = "src/engine/SCons/SConsign.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/SConsign.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -76,7 +76,8 @@ def Get_DataBase(dir):
except KeyError:
path = d.entry_abspath(DB_Name)
try: db = DataBase[d] = DB_Module.open(path, mode)
- except (IOError, OSError): pass
+ except (IOError, OSError):
+ pass
else:
if mode != "r":
DB_sync_list.append(db)
@@ -334,10 +335,15 @@ class DirFile(Dir):
Dir.__init__(self, fp, dir)
except KeyboardInterrupt:
raise
- except:
+ except Exception:
SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
"Ignoring corrupt .sconsign file: %s"%self.sconsign)
+ try:
+ fp.close()
+ except AttributeError:
+ pass
+
global sig_files
sig_files.append(self)
@@ -417,7 +423,7 @@ def File(name, dbm_module=None):
else:
ForDirectory = DB
DB_Name = name
- if not dbm_module is None:
+ if dbm_module is not None:
DB_Module = dbm_module
# Local Variables:
diff --git a/src/engine/SCons/SConsignTests.py b/src/engine/SCons/SConsignTests.py
index e8e9231..1ae1f47 100644
--- a/src/engine/SCons/SConsignTests.py
+++ b/src/engine/SCons/SConsignTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/SConsignTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/SConsignTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py
index 703ccc3..206de5f 100644
--- a/src/engine/SCons/Scanner/C.py
+++ b/src/engine/SCons/Scanner/C.py
@@ -27,7 +27,7 @@ This module implements the dependency scanner for C/C++ code.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/C.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/C.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Node.FS
import SCons.Scanner
diff --git a/src/engine/SCons/Scanner/CTests.py b/src/engine/SCons/Scanner/CTests.py
index d39f206..8e1e3b3 100644
--- a/src/engine/SCons/Scanner/CTests.py
+++ b/src/engine/SCons/Scanner/CTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/CTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/CTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
diff --git a/src/engine/SCons/Scanner/D.py b/src/engine/SCons/Scanner/D.py
index 2fc577c..1ad9e89 100644
--- a/src/engine/SCons/Scanner/D.py
+++ b/src/engine/SCons/Scanner/D.py
@@ -30,7 +30,7 @@ Coded by Andy Friesen
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/D.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/D.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Scanner
@@ -46,7 +46,7 @@ class D(SCons.Scanner.Classic):
name = "DScanner",
suffixes = '$DSUFFIXES',
path_variable = 'DPATH',
- regex = '(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)'
+ regex = r'(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)'
)
def find_include(self, include, source_dir, path):
diff --git a/src/engine/SCons/Scanner/DTests.py b/src/engine/SCons/Scanner/DTests.py
index e649a88..f115eb0 100644
--- a/src/engine/SCons/Scanner/DTests.py
+++ b/src/engine/SCons/Scanner/DTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/DTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/DTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
diff --git a/src/engine/SCons/Scanner/Dir.py b/src/engine/SCons/Scanner/Dir.py
index ea4a351..be8ae6c 100644
--- a/src/engine/SCons/Scanner/Dir.py
+++ b/src/engine/SCons/Scanner/Dir.py
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Scanner/Dir.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/Dir.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Node.FS
import SCons.Scanner
diff --git a/src/engine/SCons/Scanner/DirTests.py b/src/engine/SCons/Scanner/DirTests.py
index 3ce0fa1..71e527f 100644
--- a/src/engine/SCons/Scanner/DirTests.py
+++ b/src/engine/SCons/Scanner/DirTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/DirTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/DirTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py
index 0431660..d315bc9 100644
--- a/src/engine/SCons/Scanner/Fortran.py
+++ b/src/engine/SCons/Scanner/Fortran.py
@@ -26,7 +26,7 @@ This module implements the dependency scanner for Fortran code.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Scanner/Fortran.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/Fortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
@@ -187,7 +187,7 @@ def FortranScan(path_variable="FORTRANPATH"):
# (\w+) : match the module name that is being USE'd
#
#
- use_regex = "(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"
+ use_regex = r"(?i)(?:^|;)\s*USE(?:\s+|(?:(?:\s*,\s*(?:NON_)?INTRINSIC)?\s*::))\s*(\w+)"
# The INCLUDE statement regex matches the following:
@@ -275,7 +275,7 @@ def FortranScan(path_variable="FORTRANPATH"):
# set of semicolon-separated INCLUDE statements
# (as allowed by the F2003 standard)
- include_regex = """(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
+ include_regex = r"""(?i)(?:^|['">]\s*;)\s*INCLUDE\s+(?:\w+_)?[<"'](.+?)(?=["'>])"""
# The MODULE statement regex finds module definitions by matching
# the following:
@@ -285,21 +285,29 @@ def FortranScan(path_variable="FORTRANPATH"):
# but *not* the following:
#
# MODULE PROCEDURE procedure_name
+# MODULE SUBROUTINE subroutine_name
+# MODULE FUNCTION function_name
+# MODULE PURE SUBROUTINE|FUNCTION subroutine_name|function_name
+# MODULE ELEMENTAL SUBROUTINE|FUNCTION subroutine_name|function_name
#
# Here is a breakdown of the regex:
#
-# (?i) : regex is case insensitive
-# ^\s* : any amount of white space
-# MODULE : match the string MODULE, case insensitive
-# \s+ : match one or more white space characters
-# (?!PROCEDURE) : but *don't* match if the next word matches
-# PROCEDURE (negative lookahead assertion),
-# case insensitive
-# (\w+) : match one or more alphanumeric characters
-# that make up the defined module name and
-# save it in a group
-
- def_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+# (?i) : regex is case insensitive
+# ^\s* : any amount of white space
+# MODULE : match the string MODULE, case
+# insensitive
+# \s+ : match one or more white space
+# characters
+# (?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)
+# : but *don't* match if the next word
+# matches PROCEDURE, SUBROUTINE,
+# FUNCTION, PURE or ELEMENTAL (negative
+# lookahead assertion), case insensitive
+# (\w+) : match one or more alphanumeric
+# characters that make up the defined
+# module name and save it in a group
+
+ def_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)"""
scanner = F90Scanner("FortranScan",
"$FORTRANSUFFIXES",
diff --git a/src/engine/SCons/Scanner/FortranTests.py b/src/engine/SCons/Scanner/FortranTests.py
index 08072aa..5bf4be6 100644
--- a/src/engine/SCons/Scanner/FortranTests.py
+++ b/src/engine/SCons/Scanner/FortranTests.py
@@ -21,11 +21,10 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/FortranTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/FortranTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
-import sys
import unittest
import SCons.Scanner.Fortran
@@ -33,17 +32,16 @@ import SCons.Node.FS
import SCons.Warnings
import TestCmd
-import TestUnit
original = os.getcwd()
-test = TestCmd.TestCmd(workdir = '')
+test = TestCmd.TestCmd(workdir='')
os.chdir(test.workpath(''))
# create some source files and headers:
-test.write('fff1.f',"""
+test.write('fff1.f', """
PROGRAM FOO
INCLUDE 'f1.f'
include 'f2.f'
@@ -51,7 +49,7 @@ test.write('fff1.f',"""
END
""")
-test.write('fff2.f',"""
+test.write('fff2.f', """
PROGRAM FOO
INCLUDE 'f2.f'
include 'd1/f2.f'
@@ -60,30 +58,28 @@ test.write('fff2.f',"""
END
""")
-test.write('fff3.f',"""
+test.write('fff3.f', """
PROGRAM FOO
INCLUDE 'f3.f' ; INCLUDE\t'd1/f3.f'
STOP
END
""")
-
# for Emacs -> "
test.subdir('d1', ['d1', 'd2'])
-headers = ['fi.f', 'never.f',
- 'd1/f1.f', 'd1/f2.f', 'd1/f3.f', 'd1/fi.f',
- 'd1/d2/f1.f', 'd1/d2/f2.f', 'd1/d2/f3.f',
- 'd1/d2/f4.f', 'd1/d2/fi.f']
+test_headers = ['fi.f', 'never.f',
+ 'd1/f1.f', 'd1/f2.f', 'd1/f3.f', 'd1/fi.f',
+ 'd1/d2/f1.f', 'd1/d2/f2.f', 'd1/d2/f3.f',
+ 'd1/d2/f4.f', 'd1/d2/fi.f']
-for h in headers:
+for h in test_headers:
test.write(h, "\n")
-
test.subdir('include', 'subdir', ['subdir', 'include'])
-test.write('fff4.f',"""
+test.write('fff4.f', """
PROGRAM FOO
INCLUDE 'f4.f'
STOP
@@ -93,7 +89,7 @@ test.write('fff4.f',"""
test.write('include/f4.f', "\n")
test.write('subdir/include/f4.f', "\n")
-test.write('fff5.f',"""
+test.write('fff5.f', """
PROGRAM FOO
INCLUDE 'f5.f'
INCLUDE 'not_there.f'
@@ -104,7 +100,7 @@ test.write('fff5.f',"""
test.write('f5.f', "\n")
test.subdir('repository', ['repository', 'include'],
- [ 'repository', 'src' ])
+ ['repository', 'src'])
test.subdir('work', ['work', 'src'])
test.write(['repository', 'include', 'iii.f'], "\n")
@@ -117,26 +113,25 @@ test.write(['work', 'src', 'fff.f'], """
END
""")
-test.write([ 'work', 'src', 'aaa.f'], """
+test.write(['work', 'src', 'aaa.f'], """
PROGRAM FOO
INCLUDE 'bbb.f'
STOP
END
""")
-test.write([ 'work', 'src', 'bbb.f'], "\n")
+test.write(['work', 'src', 'bbb.f'], "\n")
-test.write([ 'repository', 'src', 'ccc.f'], """
+test.write(['repository', 'src', 'ccc.f'], """
PROGRAM FOO
INCLUDE 'ddd.f'
STOP
END
""")
-test.write([ 'repository', 'src', 'ddd.f'], "\n")
+test.write(['repository', 'src', 'ddd.f'], "\n")
-
-test.write('fff90a.f90',"""
+test.write('fff90a.f90', """
PROGRAM FOO
! Test comments - these includes should NOT be picked up
@@ -194,18 +189,19 @@ USE mod25 ! Test USE statement at the beginning of line
END
""")
-modules = ['mod01.mod', 'mod02.mod', 'mod03.mod', 'mod04.mod', 'mod05.mod',
- 'mod06.mod', 'mod07.mod', 'mod08.mod', 'mod09.mod', 'mod10.mod',
- 'mod11.mod', 'mod12.mod', 'mod13.mod', 'mod14.mod', 'mod15.mod',
- 'mod16.mod', 'mod17.mod', 'mod18.mod', 'mod19.mod', 'mod20.mod',
- 'mod21.mod', 'mod22.mod', 'mod23.mod', 'mod24.mod', 'mod25.mod']
+test_modules = ['mod01.mod', 'mod02.mod', 'mod03.mod', 'mod04.mod', 'mod05.mod',
+ 'mod06.mod', 'mod07.mod', 'mod08.mod', 'mod09.mod', 'mod10.mod',
+ 'mod11.mod', 'mod12.mod', 'mod13.mod', 'mod14.mod', 'mod15.mod',
+ 'mod16.mod', 'mod17.mod', 'mod18.mod', 'mod19.mod', 'mod20.mod',
+ 'mod21.mod', 'mod22.mod', 'mod23.mod', 'mod24.mod', 'mod25.mod']
-for m in modules:
+for m in test_modules:
test.write(m, "\n")
test.subdir('modules')
test.write(['modules', 'use.mod'], "\n")
+
# define some helpers:
class DummyEnvironment(object):
@@ -215,7 +211,7 @@ class DummyEnvironment(object):
def Dictionary(self, *args):
if not args:
- return { 'FORTRANPATH': self.path, 'FORTRANMODSUFFIX' : ".mod" }
+ return {'FORTRANPATH': self.path, 'FORTRANMODSUFFIX': ".mod"}
elif len(args) == 1 and args[0] == 'FORTRANPATH':
return self.path
else:
@@ -224,13 +220,13 @@ class DummyEnvironment(object):
def has_key(self, key):
return key in self.Dictionary()
- def __getitem__(self,key):
+ def __getitem__(self, key):
return self.Dictionary()[key]
- def __setitem__(self,key,value):
+ def __setitem__(self, key, value):
self.Dictionary()[key] = value
- def __delitem__(self,key):
+ def __delitem__(self, key):
del self.Dictionary()[key]
def subst(self, arg, target=None, source=None, conv=None):
@@ -255,11 +251,13 @@ class DummyEnvironment(object):
def File(self, filename):
return self.fs.File(filename)
+
def deps_match(self, deps, headers):
scanned = list(map(os.path.normpath, list(map(str, deps))))
expect = list(map(os.path.normpath, headers))
self.assertTrue(scanned == expect, "expect %s != scanned %s" % (expect, scanned))
+
# define some tests:
class FortranScannerTestCase1(unittest.TestCase):
@@ -275,6 +273,7 @@ class FortranScannerTestCase1(unittest.TestCase):
test.unlink('f1.f')
test.unlink('f2.f')
+
class FortranScannerTestCase2(unittest.TestCase):
def runTest(self):
test.write('f1.f', "\n")
@@ -288,6 +287,7 @@ class FortranScannerTestCase2(unittest.TestCase):
test.unlink('f1.f')
test.unlink('f2.f')
+
class FortranScannerTestCase3(unittest.TestCase):
def runTest(self):
env = DummyEnvironment([test.workpath("d1")])
@@ -297,6 +297,7 @@ class FortranScannerTestCase3(unittest.TestCase):
headers = ['d1/f1.f', 'd1/f2.f']
deps_match(self, deps, headers)
+
class FortranScannerTestCase4(unittest.TestCase):
def runTest(self):
test.write(['d1', 'f2.f'], " INCLUDE 'fi.f'\n")
@@ -308,6 +309,7 @@ class FortranScannerTestCase4(unittest.TestCase):
deps_match(self, deps, headers)
test.write(['d1', 'f2.f'], "\n")
+
class FortranScannerTestCase5(unittest.TestCase):
def runTest(self):
env = DummyEnvironment([test.workpath("d1")])
@@ -317,6 +319,7 @@ class FortranScannerTestCase5(unittest.TestCase):
headers = ['d1/f2.f', 'd1/d2/f2.f', 'd1/f2.f']
deps_match(self, deps, headers)
+
class FortranScannerTestCase6(unittest.TestCase):
def runTest(self):
test.write('f2.f', "\n")
@@ -324,19 +327,21 @@ class FortranScannerTestCase6(unittest.TestCase):
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
deps = s(env.File('fff2.f'), env, path)
- headers = ['d1/f2.f', 'd1/d2/f2.f', 'f2.f']
+ headers = ['d1/f2.f', 'd1/d2/f2.f', 'f2.f']
deps_match(self, deps, headers)
test.unlink('f2.f')
+
class FortranScannerTestCase7(unittest.TestCase):
def runTest(self):
env = DummyEnvironment([test.workpath("d1/d2"), test.workpath("d1")])
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
deps = s(env.File('fff2.f'), env, path)
- headers = ['d1/f2.f', 'd1/d2/f2.f', 'd1/d2/f2.f']
+ headers = ['d1/f2.f', 'd1/d2/f2.f', 'd1/d2/f2.f']
deps_match(self, deps, headers)
+
class FortranScannerTestCase8(unittest.TestCase):
def runTest(self):
test.write('f2.f', "\n")
@@ -344,10 +349,11 @@ class FortranScannerTestCase8(unittest.TestCase):
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
deps = s(env.File('fff2.f'), env, path)
- headers = ['d1/f2.f', 'd1/d2/f2.f', 'f2.f']
+ headers = ['d1/f2.f', 'd1/d2/f2.f', 'f2.f']
deps_match(self, deps, headers)
test.unlink('f2.f')
+
class FortranScannerTestCase9(unittest.TestCase):
def runTest(self):
test.write('f3.f', "\n")
@@ -356,9 +362,11 @@ class FortranScannerTestCase9(unittest.TestCase):
path = s.path(env)
n = env.File('fff3.f')
+
def my_rexists(s):
s.Tag('rexists_called', 1)
return SCons.Node._rexists_map[s.GetTag('old_rexists')](s)
+
n.Tag('old_rexists', n._func_rexists)
SCons.Node._rexists_map[3] = my_rexists
n._func_rexists = 3
@@ -369,10 +377,11 @@ class FortranScannerTestCase9(unittest.TestCase):
# scanned, essential for cooperation with VariantDir functionality.
assert n.GetTag('rexists_called')
- headers = ['d1/f3.f', 'f3.f']
+ headers = ['d1/f3.f', 'f3.f']
deps_match(self, deps, headers)
test.unlink('f3.f')
+
class FortranScannerTestCase10(unittest.TestCase):
def runTest(self):
env = DummyEnvironment(["include"])
@@ -380,18 +389,20 @@ class FortranScannerTestCase10(unittest.TestCase):
path = s.path(env)
deps1 = s(env.File('fff4.f'), env, path)
env.fs.chdir(env.Dir('subdir'))
- dir = env.fs.getcwd()
+ test_dir = env.fs.getcwd()
env.fs.chdir(env.Dir(''))
- path = s.path(env, dir)
+ path = s.path(env, test_dir)
deps2 = s(env.File('#fff4.f'), env, path)
- headers1 = list(map(test.workpath, ['include/f4.f']))
- headers2 = ['include/f4.f']
+ headers1 = [test.workpath(f) for f in ['include/f4.f']]
+ headers2 = ['include/f4.f']
deps_match(self, deps1, headers1)
deps_match(self, deps2, headers2)
+
class FortranScannerTestCase11(unittest.TestCase):
def runTest(self):
SCons.Warnings.enableWarningClass(SCons.Warnings.DependencyWarning)
+
class TestOut(object):
def __call__(self, x):
self.out = x
@@ -407,7 +418,8 @@ class FortranScannerTestCase11(unittest.TestCase):
# Did we catch the warning from not finding not_there.f?
assert to.out
- deps_match(self, deps, [ 'f5.f' ])
+ deps_match(self, deps, ['f5.f'])
+
class FortranScannerTestCase12(unittest.TestCase):
def runTest(self):
@@ -421,6 +433,7 @@ class FortranScannerTestCase12(unittest.TestCase):
deps_match(self, deps, ['f4.f'])
test.unlink('include/fff4.f')
+
class FortranScannerTestCase13(unittest.TestCase):
def runTest(self):
os.chdir(test.workpath('work'))
@@ -429,9 +442,9 @@ class FortranScannerTestCase13(unittest.TestCase):
# Create a derived file in a directory that does not exist yet.
# This was a bug at one time.
- f1=fs.File('include2/jjj.f')
- f1.builder=1
- env = DummyEnvironment(['include','include2'])
+ f1 = fs.File('include2/jjj.f')
+ f1.builder = 1
+ env = DummyEnvironment(['include', 'include2'])
env.fs = fs
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
@@ -439,6 +452,7 @@ class FortranScannerTestCase13(unittest.TestCase):
deps_match(self, deps, [test.workpath('repository/include/iii.f'), 'include2/jjj.f'])
os.chdir(test.workpath(''))
+
class FortranScannerTestCase14(unittest.TestCase):
def runTest(self):
os.chdir(test.workpath('work'))
@@ -451,15 +465,16 @@ class FortranScannerTestCase14(unittest.TestCase):
s = SCons.Scanner.Fortran.FortranScan()
path = s.path(env)
deps1 = s(fs.File('build1/aaa.f'), env, path)
- deps_match(self, deps1, [ 'build1/bbb.f' ])
+ deps_match(self, deps1, ['build1/bbb.f'])
deps2 = s(fs.File('build2/aaa.f'), env, path)
- deps_match(self, deps2, [ 'src/bbb.f' ])
+ deps_match(self, deps2, ['src/bbb.f'])
deps3 = s(fs.File('build1/ccc.f'), env, path)
- deps_match(self, deps3, [ 'build1/ddd.f' ])
+ deps_match(self, deps3, ['build1/ddd.f'])
deps4 = s(fs.File('build2/ccc.f'), env, path)
- deps_match(self, deps4, [ test.workpath('repository/src/ddd.f') ])
+ deps_match(self, deps4, [test.workpath('repository/src/ddd.f')])
os.chdir(test.workpath(''))
+
class FortranScannerTestCase15(unittest.TestCase):
def runTest(self):
class SubstEnvironment(DummyEnvironment):
@@ -468,6 +483,7 @@ class FortranScannerTestCase15(unittest.TestCase):
return test.workpath("d1")
else:
return arg
+
test.write(['d1', 'f2.f'], " INCLUDE 'fi.f'\n")
env = SubstEnvironment(["$junk"])
s = SCons.Scanner.Fortran.FortranScan()
@@ -477,6 +493,7 @@ class FortranScannerTestCase15(unittest.TestCase):
deps_match(self, deps, headers)
test.write(['d1', 'f2.f'], "\n")
+
class FortranScannerTestCase16(unittest.TestCase):
def runTest(self):
test.write('f1.f', "\n")
@@ -512,28 +529,10 @@ class FortranScannerTestCase16(unittest.TestCase):
test.unlink('f9.f')
test.unlink('f10.f')
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(FortranScannerTestCase1())
- suite.addTest(FortranScannerTestCase2())
- suite.addTest(FortranScannerTestCase3())
- suite.addTest(FortranScannerTestCase4())
- suite.addTest(FortranScannerTestCase5())
- suite.addTest(FortranScannerTestCase6())
- suite.addTest(FortranScannerTestCase7())
- suite.addTest(FortranScannerTestCase8())
- suite.addTest(FortranScannerTestCase9())
- suite.addTest(FortranScannerTestCase10())
- suite.addTest(FortranScannerTestCase11())
- suite.addTest(FortranScannerTestCase12())
- suite.addTest(FortranScannerTestCase13())
- suite.addTest(FortranScannerTestCase14())
- suite.addTest(FortranScannerTestCase15())
- suite.addTest(FortranScannerTestCase16())
- return suite
+
if __name__ == "__main__":
- TestUnit.run(suite())
+ unittest.main()
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Scanner/IDL.py b/src/engine/SCons/Scanner/IDL.py
index 52bd1c5..88226e6 100644
--- a/src/engine/SCons/Scanner/IDL.py
+++ b/src/engine/SCons/Scanner/IDL.py
@@ -28,7 +28,7 @@ Definition Language) files.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/IDL.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/IDL.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Node.FS
import SCons.Scanner
diff --git a/src/engine/SCons/Scanner/IDLTests.py b/src/engine/SCons/Scanner/IDLTests.py
index 6ad35c5..9bc4e5a 100644
--- a/src/engine/SCons/Scanner/IDLTests.py
+++ b/src/engine/SCons/Scanner/IDLTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/IDLTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/IDLTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
import sys
diff --git a/src/engine/SCons/Scanner/LaTeX.py b/src/engine/SCons/Scanner/LaTeX.py
index 0385ca0..8afe5b0 100644
--- a/src/engine/SCons/Scanner/LaTeX.py
+++ b/src/engine/SCons/Scanner/LaTeX.py
@@ -27,7 +27,7 @@ This module implements the dependency scanner for LaTeX code.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/LaTeX.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/LaTeX.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
@@ -179,15 +179,7 @@ class LaTeX(SCons.Scanner.Base):
'inputfrom', 'subinputfrom']
def __init__(self, name, suffixes, graphics_extensions, *args, **kw):
-
- # We have to include \n with the % we exclude from the first part
- # part of the regex because the expression is compiled with re.M.
- # Without the \n, the ^ could match the beginning of a *previous*
- # line followed by one or more newline characters (i.e. blank
- # lines), interfering with a match on the next line.
- # add option for whitespace before the '[options]' or the '{filename}'
regex = r'''
- ^[^%\n]*
\\(
include
| includegraphics(?:\s*\[[^\]]+\])?
@@ -348,7 +340,7 @@ class LaTeX(SCons.Scanner.Base):
# Cache the includes list in node so we only scan it once:
# path_dict = dict(list(path))
# add option for whitespace (\s) before the '['
- noopt_cre = re.compile('\s*\[.*$')
+ noopt_cre = re.compile(r'\s*\[.*$')
if node.includes is not None:
includes = node.includes
else:
@@ -372,9 +364,9 @@ class LaTeX(SCons.Scanner.Base):
inc_list = include[2].split(',')
else:
inc_list = include[1].split(',')
- for j in range(len(inc_list)):
- split_includes.append( (inc_type, inc_subdir, inc_list[j]) )
- #
+ for inc in inc_list:
+ split_includes.append((inc_type, inc_subdir, inc))
+
includes = split_includes
node.includes = includes
diff --git a/src/engine/SCons/Scanner/LaTeXTests.py b/src/engine/SCons/Scanner/LaTeXTests.py
index 4f8ec16..8750000 100644
--- a/src/engine/SCons/Scanner/LaTeXTests.py
+++ b/src/engine/SCons/Scanner/LaTeXTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/LaTeXTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/LaTeXTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -61,6 +61,12 @@ test.write('test3.latex',r"""
\includegraphics[width=60mm]{inc5.xyz}
""")
+test.write('test4.latex',r"""
+\include{inc1}\include{inc2}
+\only<1>{\includegraphics{inc5.xyz}}%
+\only<2>{\includegraphics{inc7.png}}
+""")
+
test.subdir('subdir')
test.write('inc1.tex',"\n")
@@ -73,6 +79,7 @@ test.write(['subdir', 'inc3c.tex'], "\n")
test.write(['subdir', 'inc4.eps'], "\n")
test.write('inc5.xyz', "\n")
test.write('inc6.tex', "\n")
+test.write('inc7.png', "\n")
test.write('incNO.tex', "\n")
# define some helpers:
@@ -155,6 +162,15 @@ class LaTeXScannerTestCase3(unittest.TestCase):
files = ['inc5.xyz', 'subdir/inc4.eps']
deps_match(self, deps, files)
+class LaTeXScannerTestCase4(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
+ s = SCons.Scanner.LaTeX.LaTeXScanner()
+ path = s.path(env)
+ deps = s(env.File('test4.latex'), env, path)
+ files = ['inc1.tex', 'inc2.tex', 'inc5.xyz', 'inc7.png']
+ deps_match(self, deps, files)
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py
index cabe6af..2ae3c68 100644
--- a/src/engine/SCons/Scanner/Prog.py
+++ b/src/engine/SCons/Scanner/Prog.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/Prog.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/Prog.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Node
import SCons.Node.FS
diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py
index 619f844..7dae37c 100644
--- a/src/engine/SCons/Scanner/ProgTests.py
+++ b/src/engine/SCons/Scanner/ProgTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/ProgTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/ProgTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
diff --git a/src/engine/SCons/Scanner/RC.py b/src/engine/SCons/Scanner/RC.py
index ccd7ebd..4f0cee2 100644
--- a/src/engine/SCons/Scanner/RC.py
+++ b/src/engine/SCons/Scanner/RC.py
@@ -28,7 +28,7 @@ Definition Language) files.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/RC.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/RC.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
@@ -48,9 +48,9 @@ def RCScan():
"""Return a prototype Scanner instance for scanning RC source files"""
res_re= r'^(?:\s*#\s*(?:include)|' \
- '.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \
- '\s*.*?)' \
- '\s*(<|"| )([^>"\s]+)(?:[>"\s])*$'
+ r'.*?\s+(?:ICON|BITMAP|CURSOR|HTML|FONT|MESSAGETABLE|TYPELIB|REGISTRY|D3DFX)' \
+ r'\s*.*?)' \
+ r'\s*(<|"| )([^>"\s]+)(?:[>"\s])*$'
resScanner = SCons.Scanner.ClassicCPP("ResourceScanner",
"$RCSUFFIXES",
"CPPPATH",
diff --git a/src/engine/SCons/Scanner/RCTests.py b/src/engine/SCons/Scanner/RCTests.py
index 3012350..2915985 100644
--- a/src/engine/SCons/Scanner/RCTests.py
+++ b/src/engine/SCons/Scanner/RCTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/RCTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/RCTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
import sys
diff --git a/src/engine/SCons/Scanner/SWIG.py b/src/engine/SCons/Scanner/SWIG.py
index 777474c..5f2a3e3 100644
--- a/src/engine/SCons/Scanner/SWIG.py
+++ b/src/engine/SCons/Scanner/SWIG.py
@@ -27,14 +27,14 @@ This module implements the dependency scanner for SWIG code.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/SWIG.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/SWIG.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Scanner
SWIGSuffixes = [ '.i' ]
def SWIGScanner():
- expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)'
+ expr = r'^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)'
scanner = SCons.Scanner.ClassicCPP("SWIGScanner", ".i", "SWIGPATH", expr)
return scanner
diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py
index 7e2720c..64842d4 100644
--- a/src/engine/SCons/Scanner/ScannerTests.py
+++ b/src/engine/SCons/Scanner/ScannerTests.py
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Scanner/ScannerTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/ScannerTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py
index 693fae7..feff12a 100644
--- a/src/engine/SCons/Scanner/__init__.py
+++ b/src/engine/SCons/Scanner/__init__.py
@@ -27,7 +27,7 @@ The Scanner package for the SCons software construction utility.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Scanner/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Scanner/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
@@ -207,7 +207,7 @@ class Base(object):
self = self.select(node)
- if not self.argument is _null:
+ if self.argument is not _null:
node_list = self.function(node, env, path, self.argument)
else:
node_list = self.function(node, env, path)
diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py
index 35e32c2..3d70728 100644
--- a/src/engine/SCons/Script/Interactive.py
+++ b/src/engine/SCons/Script/Interactive.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Script/Interactive.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/Interactive.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
SCons interactive mode
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 0d626cb..878f824 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -38,7 +38,7 @@ deprecated_python_version = (2, 7, 0)
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Script/Main.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/Main.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -68,6 +68,20 @@ import SCons.Warnings
import SCons.Script.Interactive
+# Global variables
+first_command_start = None
+last_command_end = None
+print_objects = 0
+print_memoizer = 0
+print_stacktrace = 0
+print_time = 0
+sconscript_time = 0
+cumulative_command_time = 0
+exit_status = 0 # final exit status, assume success by default
+this_build_status = 0 # "exit status" of an individual build
+num_jobs = None
+delayed_warnings = []
+
def fetch_win32_parallel_msg():
# A subsidiary function that exists solely to isolate this import
@@ -87,15 +101,14 @@ def revert_io():
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__
+
class SConsPrintHelpException(Exception):
pass
+
display = SCons.Util.display
progress_display = SCons.Util.DisplayEngine()
-first_command_start = None
-last_command_end = None
-
class Progressor(object):
prev = ''
@@ -443,19 +456,6 @@ def python_version_deprecated(version=sys.version_info):
return version < deprecated_python_version
-# Global variables
-
-print_objects = 0
-print_memoizer = 0
-print_stacktrace = 0
-print_time = 0
-sconscript_time = 0
-cumulative_command_time = 0
-exit_status = 0 # final exit status, assume success by default
-this_build_status = 0 # "exit status" of an individual build
-num_jobs = None
-delayed_warnings = []
-
class FakeOptionParser(object):
"""
A do-nothing option parser, used for the initial OptionsParser variable.
@@ -1170,7 +1170,7 @@ def _build_targets(fs, options, targets, target_top):
# -U, local SConscript Default() targets
target_top = fs.Dir(target_top)
def check_dir(x, target_top=target_top):
- if hasattr(x, 'cwd') and not x.cwd is None:
+ if hasattr(x, 'cwd') and x.cwd is not None:
cwd = x.cwd.srcnode()
return cwd == target_top
else:
diff --git a/src/engine/SCons/Script/MainTests.py b/src/engine/SCons/Script/MainTests.py
index 64d3e0f..752ea0a 100644
--- a/src/engine/SCons/Script/MainTests.py
+++ b/src/engine/SCons/Script/MainTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/MainTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/MainTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index 8f31fd8..5651c96 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConsOptions.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConsOptions.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import optparse
import re
@@ -147,7 +147,7 @@ class SConsValues(optparse.Values):
"""
Sets an option from an SConscript file.
"""
- if not name in self.settable:
+ if name not in self.settable:
raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name)
if name == 'num_jobs':
@@ -167,7 +167,7 @@ class SConsValues(optparse.Values):
value = str(value)
except ValueError:
raise SCons.Errors.UserError("A string is required: %s"%repr(value))
- if not value in SCons.Node.FS.Valid_Duplicates:
+ if value not in SCons.Node.FS.Valid_Duplicates:
raise SCons.Errors.UserError("Not a valid duplication style: %s" % value)
# Set the duplicate style right away so it can affect linking
# of SConscript files.
@@ -226,39 +226,8 @@ class SConsOption(optparse.Option):
fmt = "option %s: nargs='?' is incompatible with short options"
raise SCons.Errors.UserError(fmt % self._short_opts[0])
- try:
- _orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS
-
- _orig_CHECK_METHODS = optparse.Option.CHECK_METHODS
-
- except AttributeError:
- # optparse.Option had no CONST_ACTIONS before Python 2.5.
-
- _orig_CONST_ACTIONS = ("store_const",)
-
- def _check_const(self):
- if self.action not in self.CONST_ACTIONS and self.const is not None:
- raise OptionError(
- "'const' must not be supplied for action %r" % self.action,
- self)
-
- # optparse.Option collects its list of unbound check functions
- # up front. This sucks because it means we can't just override
- # the _check_const() function like a normal method, we have to
- # actually replace it in the list. This seems to be the most
- # straightforward way to do that.
-
- _orig_CHECK_METHODS = [optparse.Option._check_action,
- optparse.Option._check_type,
- optparse.Option._check_choice,
- optparse.Option._check_dest,
- _check_const,
- optparse.Option._check_nargs,
- optparse.Option._check_callback]
-
- CHECK_METHODS = _orig_CHECK_METHODS + [_check_nargs_optional]
-
- CONST_ACTIONS = _orig_CONST_ACTIONS + optparse.Option.TYPED_ACTIONS
+ CHECK_METHODS = optparse.Option.CHECK_METHODS + [_check_nargs_optional]
+ CONST_ACTIONS = optparse.Option.CONST_ACTIONS + optparse.Option.TYPED_ACTIONS
class SConsOptionGroup(optparse.OptionGroup):
"""
@@ -364,7 +333,7 @@ class SConsOptionParser(optparse.OptionParser):
in self.largs, so that any value overridden on the
command line is immediately available if the user turns
around and does a GetOption() right away.
-
+
We mimic the processing of the single args
in the original OptionParser._process_args(), but here we
allow exact matches for long-opts only (no partial
@@ -375,7 +344,7 @@ class SConsOptionParser(optparse.OptionParser):
command-line arguments that
1. haven't been processed so far (self.largs), but
2. are possibly not added to the list of options yet.
-
+
So, when we only have a value for "--myargument" yet,
a command-line argument of "--myarg=test" would set it.
Responsible for this behaviour is the method
@@ -384,7 +353,7 @@ class SConsOptionParser(optparse.OptionParser):
be unique.
This would lead to further confusion, because we might want
to add another option "--myarg" later on (see issue #2929).
-
+
"""
rargs = []
largs_restore = []
@@ -401,7 +370,7 @@ class SConsOptionParser(optparse.OptionParser):
if "=" in l:
# Split into option and value
lopt = l.split("=", 1)
-
+
if lopt[0] in self._long_opt:
# Argument is already known
rargs.append('='.join(lopt))
@@ -416,7 +385,7 @@ class SConsOptionParser(optparse.OptionParser):
skip = True
else:
rargs.append(l)
-
+
# Parse the filtered list
self.parse_args(rargs, self.values)
# Restore the list of remaining arguments for the
@@ -690,7 +659,7 @@ def Parser(version):
metavar="TYPE")
def opt_duplicate(option, opt, value, parser):
- if not value in SCons.Node.FS.Valid_Duplicates:
+ if value not in SCons.Node.FS.Valid_Duplicates:
raise OptionValueError(opt_invalid('duplication', value,
SCons.Node.FS.Valid_Duplicates))
setattr(parser.values, option.dest, value)
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index ea239e0..9687c29 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -27,7 +27,7 @@ files.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Script/SConscript.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConscript.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
import SCons.Action
diff --git a/src/engine/SCons/Script/SConscriptTests.py b/src/engine/SCons/Script/SConscriptTests.py
index fb06ac4..c1232e8 100644
--- a/src/engine/SCons/Script/SConscriptTests.py
+++ b/src/engine/SCons/Script/SConscriptTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConscriptTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConscriptTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Script.SConscript
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 834c70d..cf2e472 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -34,7 +34,7 @@ it goes here.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Script/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import time
start_time = time.time()
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index 4fc8461..1e0d423 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -26,7 +26,7 @@ SCons string substitution.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Subst.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Subst.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import collections
import re
@@ -350,7 +350,7 @@ _rm_split = re.compile(r'(?<!\$)(\$[()])')
_regex_remove = [ _rm, None, _rm_split ]
def _rm_list(list):
- return [l for l in list if not l in ('$(', '$)')]
+ return [l for l in list if l not in ('$(', '$)')]
def _remove_list(list):
result = []
@@ -468,7 +468,7 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={
s = lvars[key]
elif key in self.gvars:
s = self.gvars[key]
- elif not NameError in AllowableExceptions:
+ elif NameError not in AllowableExceptions:
raise_exception(NameError(key), lvars['TARGETS'], s)
else:
return ''
@@ -690,7 +690,7 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, gv
s = lvars[key]
elif key in self.gvars:
s = self.gvars[key]
- elif not NameError in AllowableExceptions:
+ elif NameError not in AllowableExceptions:
raise_exception(NameError(), lvars['TARGETS'], s)
else:
return
diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py
index 0da1faf..49a9a2f 100644
--- a/src/engine/SCons/SubstTests.py
+++ b/src/engine/SCons/SubstTests.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/SubstTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/SubstTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -132,6 +132,7 @@ class SubstTestCase(unittest.TestCase):
def __str__(self):
return self.value
+ # only use of this is currently commented out below
def function_foo(arg):
pass
@@ -1046,7 +1047,7 @@ class scons_subst_list_TestCase(SubstTestCase):
node = scons_subst_list("$NODE", env, mode=SUBST_SIG, conv=s, gvars=gvars)
assert node == [[n1]], node
- def test_subst_list_overriding_gvars(self):
+ def test_subst_list_overriding_gvars2(self):
"""Test scons_subst_list(): supplying an overriding gvars dictionary"""
env = DummyEnv({'XXX' : 'xxx'})
result = scons_subst_list('$XXX', env, gvars=env.Dictionary())
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
index d8d8224..29e48ac 100644
--- a/src/engine/SCons/Taskmaster.py
+++ b/src/engine/SCons/Taskmaster.py
@@ -27,10 +27,10 @@ import sys
__doc__ = """
Generic Taskmaster module for the SCons build engine.
=====================================================
-
+
This module contains the primary interface(s) between a wrapping user
interface and the SCons build engine. There are two key classes here:
-
+
Taskmaster
----------
This is the main engine for walking the dependency graph and
@@ -54,7 +54,7 @@ __doc__ = """
target(s) that it decides need to be evaluated and/or built.
"""
-__revision__ = "src/engine/SCons/Taskmaster.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Taskmaster.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from itertools import chain
import operator
@@ -477,7 +477,7 @@ class Task(object):
for s in t.side_effects:
if s.get_state() == NODE_EXECUTING:
s.set_state(NODE_NO_STATE)
-
+
# The side-effects may have been transferred to
# NODE_NO_STATE by executed_with{,out}_callbacks, but was
# not taken out of the waiting parents/pending children
@@ -551,7 +551,7 @@ class Task(object):
try:
exc_type, exc_value, exc_traceback = exc
except ValueError:
- exc_type, exc_value = exc
+ exc_type, exc_value = exc # pylint: disable=unbalanced-tuple-unpacking
exc_traceback = None
# raise exc_type(exc_value).with_traceback(exc_traceback)
diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py
index d31a8d5..218870e 100644
--- a/src/engine/SCons/TaskmasterTests.py
+++ b/src/engine/SCons/TaskmasterTests.py
@@ -22,7 +22,7 @@
#
from __future__ import division
-__revision__ = "src/engine/SCons/TaskmasterTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/TaskmasterTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
diff --git a/src/engine/SCons/Tool/386asm.py b/src/engine/SCons/Tool/386asm.py
index 930b431..1121c3d 100644
--- a/src/engine/SCons/Tool/386asm.py
+++ b/src/engine/SCons/Tool/386asm.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/386asm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/386asm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.PharLapCommon import addPharLapPaths
import SCons.Util
diff --git a/src/engine/SCons/Tool/DCommon.py b/src/engine/SCons/Tool/DCommon.py
index 169f95d..f6b6000 100644
--- a/src/engine/SCons/Tool/DCommon.py
+++ b/src/engine/SCons/Tool/DCommon.py
@@ -31,7 +31,7 @@ Coded by Russel Winder (russel@winder.org.uk)
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/DCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/DCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/FortranCommon.py b/src/engine/SCons/Tool/FortranCommon.py
index 27646f0..11f1eb7 100644
--- a/src/engine/SCons/Tool/FortranCommon.py
+++ b/src/engine/SCons/Tool/FortranCommon.py
@@ -28,7 +28,7 @@ Stuff for processing Fortran, common to all fortran dialects.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/FortranCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/FortranCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
import os.path
@@ -64,7 +64,8 @@ def _fortranEmitter(target, source, env):
if not node.exists() and not node.is_derived():
print("Could not locate " + str(node.name))
return ([], [])
- mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ # This has to match the def_regex in the Fortran scanner
+ mod_regex = r"""(?i)^\s*MODULE\s+(?!PROCEDURE|SUBROUTINE|FUNCTION|PURE|ELEMENTAL)(\w+)"""
cre = re.compile(mod_regex,re.M)
# Retrieve all USE'd module names
modules = cre.findall(node.get_text_contents())
diff --git a/src/engine/SCons/Tool/FortranCommonTests.py b/src/engine/SCons/Tool/FortranCommonTests.py
new file mode 100644
index 0000000..9cca9b0
--- /dev/null
+++ b/src/engine/SCons/Tool/FortranCommonTests.py
@@ -0,0 +1,125 @@
+#
+# Copyright (c) 2001 - 2019 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# from typing import Dict, Any
+
+__revision__ = "src/engine/SCons/Tool/FortranCommonTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import os.path
+import unittest
+
+import SCons.Node.FS
+import SCons.Warnings
+import SCons.Tool.FortranCommon
+
+import TestCmd
+
+original = os.getcwd()
+
+test = TestCmd.TestCmd(workdir='')
+
+os.chdir(test.workpath(''))
+
+
+class DummyEnvironment(object):
+ dictionary = None # type: Dict[Any, Any]
+
+ def __init__(self, list_cpp_path):
+ self.path = list_cpp_path
+ self.fs = SCons.Node.FS.FS(test.workpath(''))
+ self.dictionary = {}
+
+ def has_key(self, key):
+ return key in self.dictionary
+
+ def __getitem__(self, key):
+ return self.dictionary[key]
+
+ def __setitem__(self, key, value):
+ self.dictionary[key] = value
+
+ def __delitem__(self, key):
+ del self.dictionary[key]
+
+ def subst(self, arg, target=None, source=None, conv=None):
+ if arg[0] == '$':
+ return self[arg[1:]]
+ return arg
+
+ def subst_path(self, path, target=None, source=None, conv=None):
+ if not isinstance(path, list):
+ path = [path]
+ return list(map(self.subst, path))
+
+ def get_calculator(self):
+ return None
+
+ def get_factory(self, factory):
+ return factory or self.fs.File
+
+ def Dir(self, filename):
+ return self.fs.Dir(filename)
+
+ def File(self, filename):
+ return self.fs.File(filename)
+
+
+class FortranScannerSubmodulesTestCase(unittest.TestCase):
+ def runTest(self):
+ """
+ Check that test_1.f90 and test_2.f90 which have interface specifications
+ Don't generate targets for those modules listed in the interface section
+ """
+
+ test.dir_fixture('fortran_unittests')
+ env = DummyEnvironment([test.workpath('modules')])
+ env['FORTRANMODDIR'] = 'modules'
+ env['FORTRANMODSUFFIX'] = '.mod'
+ emitter = SCons.Tool.FortranCommon._fortranEmitter
+ # path = s.path(env)
+
+ for fort in ['test_1.f90', 'test_2.f90']:
+ file_base, _ = os.path.splitext(fort)
+ file_mod = '%s.mod' % file_base
+ f = env.File(fort)
+ (target, source) = emitter([], [f, ], env)
+
+ # print("Targets:%s\nSources:%s"%([str(a) for a in target], [str(a) for a in source]))
+
+ # should only be 1 target and 1 source
+ self.assertEqual(len(target), 1,
+ msg="More than 1 target: %d [%s]" % (len(target), [str(t) for t in target]))
+ self.assertEqual(len(source), 1,
+ msg="More than 1 source: %d [%s]" % (len(source), [str(t) for t in source]))
+
+ # target should be file_base.mod
+ self.assertEqual(str(target[0]).endswith(file_mod), True,
+ msg="Target[0]=%s doesn't end with '%s'" % (str(target[0]), file_mod))
+
+ # source should be file_base .f90
+ self.assertEqual(str(source[0]).endswith(fort), True,
+ msg="Source[0]=%s doesn't end with '%s'" % (str(source[0]), fort))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/src/engine/SCons/Tool/GettextCommon.py b/src/engine/SCons/Tool/GettextCommon.py
index 8c2163e..79912b6 100644
--- a/src/engine/SCons/Tool/GettextCommon.py
+++ b/src/engine/SCons/Tool/GettextCommon.py
@@ -4,7 +4,7 @@ Used by several tools of `gettext` toolset.
"""
# Copyright (c) 2001 - 2019 The SCons Foundation
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@@ -12,10 +12,10 @@ Used by several tools of `gettext` toolset.
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -24,7 +24,7 @@ Used by several tools of `gettext` toolset.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/GettextCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/GettextCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Warnings
import re
@@ -71,7 +71,7 @@ SCons.Warnings.enableWarningClass(MsgfmtNotFound)
#############################################################################
class _POTargetFactory(object):
""" A factory of `PO` target files.
-
+
Factory defaults differ from these of `SCons.Node.FS.FS`. We set `precious`
(this is required by builders and actions gettext) and `noclean` flags by
default for all produced nodes.
@@ -80,9 +80,9 @@ class _POTargetFactory(object):
def __init__(self, env, nodefault=True, alias=None, precious=True
, noclean=True):
""" Object constructor.
-
+
**Arguments**
-
+
- *env* (`SCons.Environment.Environment`)
- *nodefault* (`boolean`) - if `True`, produced nodes will be ignored
from default target `'.'`
@@ -160,13 +160,13 @@ from SCons.Builder import BuilderBase
#############################################################################
class _POFileBuilder(BuilderBase):
""" `PO` file builder.
-
+
This is multi-target single-source builder. In typical situation the source
is single `POT` file, e.g. `messages.pot`, and there are multiple `PO`
targets to be updated from this `POT`. We must run
`SCons.Builder.BuilderBase._execute()` separatelly for each target to track
dependencies separatelly for each target file.
-
+
**NOTE**: if we call `SCons.Builder.BuilderBase._execute(.., target, ...)`
with target being list of all targets, all targets would be rebuilt each time
one of the targets from this list is missing. This would happen, for example,
@@ -198,29 +198,29 @@ class _POFileBuilder(BuilderBase):
# After that it calls emitter (which is quite too late). The emitter is
# also called in each iteration, what makes things yet worse.
def __init__(self, env, **kw):
- if not 'suffix' in kw:
+ if 'suffix' not in kw:
kw['suffix'] = '$POSUFFIX'
- if not 'src_suffix' in kw:
+ if 'src_suffix' not in kw:
kw['src_suffix'] = '$POTSUFFIX'
- if not 'src_builder' in kw:
+ if 'src_builder' not in kw:
kw['src_builder'] = '_POTUpdateBuilder'
- if not 'single_source' in kw:
+ if 'single_source' not in kw:
kw['single_source'] = True
alias = None
if 'target_alias' in kw:
alias = kw['target_alias']
del kw['target_alias']
- if not 'target_factory' in kw:
+ if 'target_factory' not in kw:
kw['target_factory'] = _POTargetFactory(env, alias=alias).File
BuilderBase.__init__(self, **kw)
def _execute(self, env, target, source, *args, **kw):
""" Execute builder's actions.
-
- Here we append to `target` the languages read from `$LINGUAS_FILE` and
+
+ Here we append to `target` the languages read from `$LINGUAS_FILE` and
apply `SCons.Builder.BuilderBase._execute()` separatelly to each target.
The arguments and return value are same as for
- `SCons.Builder.BuilderBase._execute()`.
+ `SCons.Builder.BuilderBase._execute()`.
"""
import SCons.Util
import SCons.Node
@@ -272,7 +272,7 @@ def _translate(env, target=None, source=SCons.Environment._null, *args, **kw):
class RPaths(object):
""" Callable object, which returns pathnames relative to SCons current
working directory.
-
+
It seems like `SCons.Node.FS.Base.get_path()` returns absolute paths
for nodes that are outside of current working directory (`env.fs.getcwd()`).
Here, we often have `SConscript`, `POT` and `PO` files within `po/`
@@ -285,17 +285,17 @@ class RPaths(object):
the references would be correct only on the machine, where `POT` file was
recently re-created. For such reason, we need a function, which always
returns relative paths. This is the purpose of `RPaths` callable object.
-
+
The `__call__` method returns paths relative to current working directory, but
we assume, that *xgettext(1)* is run from the directory, where target file is
going to be created.
-
+
Note, that this may not work for files distributed over several hosts or
across different drives on windows. We assume here, that single local
filesystem holds both source files and target `POT` templates.
-
+
Intended use of `RPaths` - in `xgettext.py`::
-
+
def generate(env):
from GettextCommon import RPaths
...
@@ -318,9 +318,9 @@ class RPaths(object):
def __init__(self, env):
""" Initialize `RPaths` callable object.
-
+
**Arguments**:
-
+
- *env* - a `SCons.Environment.Environment` object, defines *current
working dir*.
"""
@@ -329,16 +329,16 @@ class RPaths(object):
# FIXME: I'm not sure, how it should be implemented (what the *args are in
# general, what is **kw).
def __call__(self, nodes, *args, **kw):
- """ Return nodes' paths (strings) relative to current working directory.
-
+ """ Return nodes' paths (strings) relative to current working directory.
+
**Arguments**:
-
+
- *nodes* ([`SCons.Node.FS.Base`]) - list of nodes.
- *args* - currently unused.
- *kw* - currently unused.
-
+
**Returns**:
-
+
- Tuple of strings, which represent paths relative to current working
directory (for given environment).
"""
diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py
index 2683f03..1e58af6 100644
--- a/src/engine/SCons/Tool/JavaCommon.py
+++ b/src/engine/SCons/Tool/JavaCommon.py
@@ -27,7 +27,7 @@ Stuff for processing Java.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/JavaCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/JavaCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -42,6 +42,33 @@ default_java_version = '1.4'
# anonymous inner class parsing.
scopeStateVersions = ('1.8')
+# Glob patterns for use in finding where the JDK is.
+# These are pairs, *dir_glob used in the general case,
+# *version_dir_glob if matching only a specific version.
+# For now only used for Windows.
+java_win32_dir_glob = 'C:/Program Files*/Java/jdk*/bin'
+# On windows, since Java 9, there is a dash between 'jdk' and the version
+# string that wasn't there before. this glob should catch either way.
+java_win32_version_dir_glob = 'C:/Program Files*/Java/jdk*%s*/bin'
+
+# Glob patterns for use in finding where the JDK headers are.
+# These are pairs, *dir_glob used in the general case,
+# *version_dir_glob if matching only a specific version.
+java_macos_include_dir_glob = '/System/Library/Frameworks/JavaVM.framework/Headers/'
+java_macos_version_include_dir_glob = '/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/'
+
+java_linux_include_dirs_glob = [
+ '/usr/lib/jvm/default-java/include',
+ '/usr/lib/jvm/java-*/include'
+]
+# Need to match path like below (from Centos 7)
+# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include/
+java_linux_version_include_dirs_glob = [
+ '/usr/lib/jvm/java-*-sun-%s*/include',
+ '/usr/lib/jvm/java-%s*-openjdk*/include',
+ '/usr/java/jdk%s*/include'
+]
+
if java_parsing:
# Parse Java files for class names.
#
@@ -64,14 +91,15 @@ if java_parsing:
r'\d*\.\d*|[A-Za-z_][\w\$\.]*|<[A-Za-z_]\w+>|' +
r'/\*|\*/|\[\])')
+
class OuterState(object):
"""The initial state for parsing a Java file for classes,
interfaces, and anonymous inner classes."""
- def __init__(self, version=default_java_version):
- if not version in ('1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7',
- '1.8', '5', '6', '9.0', '10.0', '11.0'):
+ def __init__(self, version=default_java_version):
+ if version not in ('1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7',
+ '1.8', '5', '6', '9.0', '10.0', '11.0', '12.0'):
msg = "Java version %s not supported" % version
raise NotImplementedError(msg)
@@ -131,15 +159,15 @@ if java_parsing:
def closeBracket(self):
self.brackets = self.brackets - 1
if len(self.stackBrackets) and \
- self.brackets == self.stackBrackets[-1]:
+ self.brackets == self.stackBrackets[-1]:
self.listOutputs.append('$'.join(self.listClasses))
self.localClasses.pop()
self.listClasses.pop()
self.anonStacksStack.pop()
self.stackBrackets.pop()
if len(self.stackAnonClassBrackets) and \
- self.brackets == self.stackAnonClassBrackets[-1] and \
- self.version not in scopeStateVersions:
+ self.brackets == self.stackAnonClassBrackets[-1] and \
+ self.version not in scopeStateVersions:
self._getAnonStack().pop()
self.stackAnonClassBrackets.pop()
@@ -152,13 +180,13 @@ if java_parsing:
self.openBracket()
elif token == '}':
self.closeBracket()
- elif token in [ '"', "'" ]:
+ elif token in ['"', "'"]:
return IgnoreState(token, self)
elif token == "new":
# anonymous inner class
if len(self.listClasses) > 0:
return self.__getAnonClassState()
- return self.__getSkipState() # Skip the class name
+ return self.__getSkipState() # Skip the class name
elif token in ['class', 'interface', 'enum']:
if len(self.listClasses) == 0:
self.nextAnon = 1
@@ -178,7 +206,7 @@ if java_parsing:
if self.version in ('1.1', '1.2', '1.3', '1.4'):
clazz = self.listClasses[0]
self.listOutputs.append('%s$%d' % (clazz, self.nextAnon))
- elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0', '11.0'):
+ elif self.version in ('1.5', '1.6', '1.7', '1.8', '5', '6', '9.0', '10.0', '11.0', '12.0'):
self.stackAnonClassBrackets.append(self.brackets)
className = []
className.extend(self.listClasses)
@@ -193,11 +221,13 @@ if java_parsing:
def setPackage(self, package):
self.package = package
+
class ScopeState(object):
"""
A state that parses code within a scope normally,
within the confines of a scope.
"""
+
def __init__(self, old_state):
self.outer_state = old_state.outer_state
self.old_state = old_state
@@ -259,13 +289,16 @@ if java_parsing:
return self.__getSkipState()
return self
+
class AnonClassState(object):
"""A state that looks for anonymous inner classes."""
+
def __init__(self, old_state):
# outer_state is always an instance of OuterState
self.outer_state = old_state.outer_state
self.old_state = old_state
self.brace_level = 0
+
def parseToken(self, token):
# This is an anonymous class if and only if the next
# non-whitespace token is a bracket. Everything between
@@ -293,26 +326,32 @@ if java_parsing:
if token == '{':
self.outer_state.addAnonClass()
if self.outer_state.version in scopeStateVersions:
- return ScopeState(old_state = self.old_state).parseToken(token)
+ return ScopeState(old_state=self.old_state).parseToken(token)
return self.old_state.parseToken(token)
+
class SkipState(object):
"""A state that will skip a specified number of tokens before
reverting to the previous state."""
+
def __init__(self, tokens_to_skip, old_state):
self.tokens_to_skip = tokens_to_skip
self.old_state = old_state
+
def parseToken(self, token):
self.tokens_to_skip = self.tokens_to_skip - 1
if self.tokens_to_skip < 1:
return self.old_state
return self
+
class ClassState(object):
"""A state we go into when we hit a class or interface keyword."""
+
def __init__(self, outer_state):
# outer_state is always an instance of OuterState
self.outer_state = outer_state
+
def parseToken(self, token):
# the next non-whitespace token should be the name of the class
if token == '\n':
@@ -322,12 +361,12 @@ if java_parsing:
# 'Foo$1Inner'
# https://github.com/SCons/scons/issues/2087
if self.outer_state.localClasses and \
- self.outer_state.stackBrackets[-1] > \
- self.outer_state.stackBrackets[-2]+1:
+ self.outer_state.stackBrackets[-1] > \
+ self.outer_state.stackBrackets[-2] + 1:
locals = self.outer_state.localClasses[-1]
try:
idx = locals[token]
- locals[token] = locals[token]+1
+ locals[token] = locals[token] + 1
except KeyError:
locals[token] = 1
token = str(locals[token]) + token
@@ -336,32 +375,40 @@ if java_parsing:
self.outer_state.anonStacksStack.append([0])
return self.outer_state
+
class IgnoreState(object):
"""A state that will ignore all tokens until it gets to a
specified token."""
+
def __init__(self, ignore_until, old_state):
self.ignore_until = ignore_until
self.old_state = old_state
+
def parseToken(self, token):
if self.ignore_until == token:
return self.old_state
return self
+
class PackageState(object):
"""The state we enter when we encounter the package keyword.
We assume the next token will be the package name."""
+
def __init__(self, outer_state):
# outer_state is always an instance of OuterState
self.outer_state = outer_state
+
def parseToken(self, token):
self.outer_state.setPackage(token)
return self.outer_state
+
def parse_java_file(fn, version=default_java_version):
with open(fn, 'r') as f:
data = f.read()
return parse_java(data, version)
+
def parse_java(contents, version=default_java_version, trace=None):
"""Parse a .java file and return a double of package directory,
plus a list of .class files that compiling that .java file will
@@ -395,81 +442,68 @@ else:
return os.path.split(fn)
-
-java_win32_version_dir_glob = 'C:/Program Files*/Java/jdk%s*/bin'
-java_win32_dir_glob = 'C:/Program Files*/Java/jdk*/bin'
-
-java_macos_include_dir = '/System/Library/Frameworks/JavaVM.framework/Headers/'
-java_macos_version_include_dir = '/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/'
-
-java_linux_include_dirs = ['/usr/lib/jvm/default-java/include',
- '/usr/lib/jvm/java-*/include']
-# Need to match path like below (from Centos 7)
-# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include/
-java_linux_version_include_dirs = ['/usr/lib/jvm/java-*-sun-%s*/include',
- '/usr/lib/jvm/java-%s*-openjdk*/include',
- '/usr/java/jdk%s*/include']
-
-
-
def get_java_install_dirs(platform, version=None):
"""
- Using patterns above find the java jdk install dir
- :param platform:
+ Find the java jdk installation directories.
+
+ This list is intended to supply as "default paths" for use when looking
+ up actual java binaries.
+
+ :param platform: selector for search algorithm.
:param version: If specified, only look for java sdk's of this version
:return: list of default paths for java.
"""
+
paths = []
if platform == 'win32':
if version:
- paths = glob.glob(java_win32_version_dir_glob%version)
+ paths = glob.glob(java_win32_version_dir_glob % version)
else:
paths = glob.glob(java_win32_dir_glob)
else:
- # do nothing for now
+ # other platforms, do nothing for now
pass
- paths=sorted(paths)
+ return sorted(paths)
- return paths
def get_java_include_paths(env, javac, version):
"""
- Return java include paths
- :param platform:
- :param javac:
- :return:
+ Find java include paths for JNI building.
+
+ :param env: construction environment, used to extract platform.
+ :param javac: path to detected javac.
+ :return: list of paths.
"""
+
paths = []
if not javac:
# there are no paths if we've not detected javac.
pass
elif env['PLATFORM'] == 'win32':
+ # on Windows, we have the right path to javac, so look locally
javac_bin_dir = os.path.dirname(javac)
java_inc_dir = os.path.normpath(os.path.join(javac_bin_dir, '..', 'include'))
paths = [java_inc_dir, os.path.join(java_inc_dir, 'win32')]
elif env['PLATFORM'] == 'darwin':
if not version:
- paths = [java_macos_include_dir]
+ paths = [java_macos_include_dir_glob]
else:
- paths = sorted(glob.glob(java_macos_version_include_dir%version))
+ paths = sorted(glob.glob(java_macos_version_include_dir_glob % version))
else:
- base_paths=[]
+ base_paths = []
if not version:
- for p in java_linux_include_dirs:
+ for p in java_linux_include_dirs_glob:
base_paths.extend(glob.glob(p))
else:
- for p in java_linux_version_include_dirs:
- base_paths.extend(glob.glob(p%version))
+ for p in java_linux_version_include_dirs_glob:
+ base_paths.extend(glob.glob(p % version))
for p in base_paths:
- paths.extend([p, os.path.join(p,'linux')])
-
- #print("PATHS:%s"%paths)
- return paths
-
-
+ paths.extend([p, os.path.join(p, 'linux')])
+ # print("PATHS:%s"%paths)
+ return paths
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py
index c70e445..45a8a0b 100644
--- a/src/engine/SCons/Tool/JavaCommonTests.py
+++ b/src/engine/SCons/Tool/JavaCommonTests.py
@@ -21,15 +21,17 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/JavaCommonTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
import unittest
+import fnmatch
import SCons.Scanner.IDL
import SCons.Tool.JavaCommon
+import TestSCons
# Adding trace=trace to any of the parse_jave() calls below will cause
# the parser to spit out trace messages of the tokens it sees and the
@@ -607,6 +609,76 @@ public class AnonDemo {
pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.8')
assert expect == classes, (expect, classes)
+ def test_jdk_globs(self):
+ """
+ Verify that the java path globs work with specific examples.
+ :return:
+ """
+ from SCons.Tool.JavaCommon import java_linux_include_dirs_glob, java_linux_version_include_dirs_glob, java_win32_dir_glob, java_win32_version_dir_glob, java_macos_include_dir_glob, java_macos_version_include_dir_glob
+
+ # Test windows globs
+ win_java_dirs = [
+ ('C:/Program Files/Java/jdk1.8.0_201/bin', '1.8.0'),
+ ('C:/Program Files/Java/jdk-11.0.2/bin', '11.0.2'),
+ ('C:/Program Files/Java/jdk1.7.0_80/bin', '1.7.0')
+ ]
+
+ for (wjd, version) in win_java_dirs:
+ if not fnmatch.fnmatch(wjd, java_win32_dir_glob):
+ self.fail("Didn't properly match %s with pattern %s" % (wjd, java_win32_dir_glob))
+ if not fnmatch.fnmatch(wjd, java_win32_version_dir_glob % version):
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, java_win32_version_dir_glob % version))
+
+ non_win_java_include_dirs = [
+ ('/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include', '1.8.0'),
+ ('/usr/lib/jvm/java-1.8.0-openjdk-amd64/include', '1.8.0'),
+ ('/usr/lib/jvm/java-8-openjdk-amd64/include', '8'),
+ ]
+
+ # Test non-windows/non-macos globs
+ for (wjd, version) in non_win_java_include_dirs:
+ match = False
+ globs_tried =[]
+ for jlig in java_linux_include_dirs_glob:
+ globs_tried.append(jlig)
+
+ if fnmatch.fnmatch(wjd, jlig):
+ match = True
+ break
+
+ if not match:
+ self.fail("Didn't properly match %s with pattern %s" % (wjd, globs_tried))
+
+ match = False
+ globs_tried = []
+ for jlvig in java_linux_version_include_dirs_glob:
+ globs_tried.append(jlvig%version)
+ if fnmatch.fnmatch(wjd, jlvig % version):
+ match = True
+ break
+
+ if not match:
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, globs_tried))
+
+ # Test macos globs
+ # Test windows globs
+ macos_java_dirs = [
+ # ('/System/Library/Frameworks/JavaVM.framework/Headers/', None),
+ ('/System/Library/Frameworks/JavaVM.framework/Versions/11.0.2/Headers/', '11.0.2'),
+ ]
+
+ if not fnmatch.fnmatch('/System/Library/Frameworks/JavaVM.framework/Headers/', java_macos_include_dir_glob):
+ self.fail("Didn't properly match %s with pattern %s" % ('/System/Library/Frameworks/JavaVM.framework/Headers/', java_macos_include_dir_glob))
+
+ for (wjd, version) in macos_java_dirs:
+ if not fnmatch.fnmatch(wjd, java_macos_version_include_dir_glob % version):
+ self.fail("Didn't properly match %s with version (%s) specific pattern %s" % (
+ wjd, version, java_macos_version_include_dir_glob % version))
+
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/src/engine/SCons/Tool/MSCommon/__init__.py b/src/engine/SCons/Tool/MSCommon/__init__.py
index 7faff33..e3c4471 100644
--- a/src/engine/SCons/Tool/MSCommon/__init__.py
+++ b/src/engine/SCons/Tool/MSCommon/__init__.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
Common functions for Microsoft Visual Studio and Visual C/C++.
diff --git a/src/engine/SCons/Tool/MSCommon/arch.py b/src/engine/SCons/Tool/MSCommon/arch.py
index 6965fbf..6312541 100644
--- a/src/engine/SCons/Tool/MSCommon/arch.py
+++ b/src/engine/SCons/Tool/MSCommon/arch.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/arch.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to define supported Windows chip architectures.
"""
diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py
index c8db141..8353944 100644
--- a/src/engine/SCons/Tool/MSCommon/common.py
+++ b/src/engine/SCons/Tool/MSCommon/common.py
@@ -25,7 +25,7 @@ Common helper functions for working with the Microsoft tool chain.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/MSCommon/common.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/common.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import copy
import os
@@ -34,7 +34,6 @@ import re
import SCons.Util
-
LOGFILE = os.environ.get('SCONS_MSCOMMON_DEBUG')
if LOGFILE == '-':
def debug(message):
@@ -117,7 +116,7 @@ def normalize_env(env, keys, force=False):
normenv[k] = copy.deepcopy(env[k])
for k in keys:
- if k in os.environ and (force or not k in normenv):
+ if k in os.environ and (force or k not in normenv):
normenv[k] = os.environ[k]
# This shouldn't be necessary, since the default environment should include system32,
diff --git a/src/engine/SCons/Tool/MSCommon/netframework.py b/src/engine/SCons/Tool/MSCommon/netframework.py
index 01bb5b7..edd9fd9 100644
--- a/src/engine/SCons/Tool/MSCommon/netframework.py
+++ b/src/engine/SCons/Tool/MSCommon/netframework.py
@@ -20,7 +20,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/netframework.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
"""
@@ -68,7 +68,7 @@ def query_versions():
# sequence comparison in python is lexicographical
# which is exactly what we want.
# Note we sort backwards so the highest version is first.
- return cmp(bbl,aal)
+ return (aal > bbl) - (aal < bbl)
versions.sort(versrt)
else:
diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py
index 2814d97..e664a30 100644
--- a/src/engine/SCons/Tool/MSCommon/sdk.py
+++ b/src/engine/SCons/Tool/MSCommon/sdk.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/sdk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to detect the Platform/Windows SDK
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 5de85d6..fa7be96 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -30,7 +30,7 @@
# * test on 64 bits XP + VS 2005 (and VS 6 if possible)
# * SDK
# * Assembly
-__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/vc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module for Visual C/C++ detection and configuration.
"""
@@ -60,7 +60,10 @@ class VisualCException(Exception):
class UnsupportedVersion(VisualCException):
pass
-class UnsupportedArch(VisualCException):
+class MSVCUnsupportedHostArch(VisualCException):
+ pass
+
+class MSVCUnsupportedTargetArch(VisualCException):
pass
class MissingConfiguration(VisualCException):
@@ -89,17 +92,15 @@ _ARCH_TO_CANONICAL = {
"aarch64" : "arm64",
}
-# get path to the cl.exe dir for newer VS versions
-# based off a tuple of (host, target) platforms
_HOST_TARGET_TO_CL_DIR_GREATER_THAN_14 = {
- ("amd64","amd64") : "Hostx64\\x64",
- ("amd64","x86") : "Hostx64\\x86",
- ("amd64","arm") : "Hostx64\\arm",
- ("amd64","arm64") : "Hostx64\\arm64",
- ("x86","amd64") : "Hostx86\\x64",
- ("x86","x86") : "Hostx86\\x86",
- ("x86","arm") : "Hostx86\\arm",
- ("x86","arm64") : "Hostx86\\arm64",
+ ("amd64","amd64") : ("Hostx64","x64"),
+ ("amd64","x86") : ("Hostx64","x86"),
+ ("amd64","arm") : ("Hostx64","arm"),
+ ("amd64","arm64") : ("Hostx64","arm64"),
+ ("x86","amd64") : ("Hostx86","x64"),
+ ("x86","x86") : ("Hostx86","x86"),
+ ("x86","arm") : ("Hostx86","arm"),
+ ("x86","arm64") : ("Hostx86","arm64"),
}
# get path to the cl.exe dir for older VS versions
@@ -174,25 +175,33 @@ def get_host_target(env):
try:
host = _ARCH_TO_CANONICAL[host_platform.lower()]
- except KeyError as e:
+ except KeyError:
msg = "Unrecognized host architecture %s"
- raise ValueError(msg % repr(host_platform))
+ raise MSVCUnsupportedHostArch(msg % repr(host_platform))
try:
target = _ARCH_TO_CANONICAL[target_platform.lower()]
- except KeyError as e:
+ except KeyError:
all_archs = str(list(_ARCH_TO_CANONICAL.keys()))
- raise ValueError("Unrecognized target architecture %s\n\tValid architectures: %s" % (target_platform, all_archs))
+ raise MSVCUnsupportedTargetArch("Unrecognized target architecture %s\n\tValid architectures: %s" % (target_platform, all_archs))
return (host, target,req_target_platform)
# If you update this, update SupportedVSList in Tool/MSCommon/vs.py, and the
# MSVC_VERSION documentation in Tool/msvc.xml.
-_VCVER = ["14.1", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"]
+_VCVER = ["14.2", "14.1", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"]
+
+# if using vswhere, a further mapping is needed
+_VCVER_TO_VSWHERE_VER = {
+ '14.2' : '[16.0, 17.0)',
+ '14.1' : '[15.0, 16.0)',
+}
_VCVER_TO_PRODUCT_DIR = {
+ '14.2' : [
+ (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # VS 2019 doesn't set this key
'14.1' : [
- (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # Visual Studio 2017 doesn't set this registry key anymore
+ (SCons.Util.HKEY_LOCAL_MACHINE, r'')], # VS 2017 doesn't set this key
'14.0' : [
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\14.0\Setup\VC\ProductDir')],
'14.0Exp' : [
@@ -253,42 +262,40 @@ def msvc_version_to_maj_min(msvc_version):
raise ValueError("Unrecognized version %s (%s)" % (msvc_version,msvc_version_numeric))
def is_host_target_supported(host_target, msvc_version):
- """Check if the given (host, target) tuple is supported for given version.
+ """Check if (host, target) pair is supported for a VC version.
- Args:
- host_target: tuple
- tuple of (canonalized) host-targets, e.g. ("x86", "amd64")
- for cross compilation from 32 bit Windows to 64 bits.
- msvc_version: str
- msvc version (major.minor, e.g. 10.0)
-
- Returns:
- bool:
-
- Note:
- This only checks whether a given version *may* support the given (host,
+ :note: only checks whether a given version *may* support the given (host,
target), not that the toolchain is actually present on the machine.
+ :param tuple host_target: canonalized host-targets pair, e.g.
+ ("x86", "amd64") for cross compilation from 32 bit Windows to 64 bits.
+ :param str msvc_version: Visual C++ version (major.minor), e.g. "10.0"
+ :returns: True or False
"""
# We assume that any Visual Studio version supports x86 as a target
if host_target[1] != "x86":
maj, min = msvc_version_to_maj_min(msvc_version)
if maj < 8:
return False
-
return True
def find_vc_pdir_vswhere(msvc_version):
"""
- Find the MSVC product directory using vswhere.exe.
+ Find the MSVC product directory using the vswhere program.
- Run it asking for specified version and get MSVS install location
- :param msvc_version:
+ :param msvc_version: MSVC version to search for
:return: MSVC install dir or None
+ :raises UnsupportedVersion: if the version is not known by this file
"""
+ try:
+ vswhere_version = _VCVER_TO_VSWHERE_VER[msvc_version]
+ except KeyError:
+ debug("Unknown version of MSVC: %s" % msvc_version)
+ raise UnsupportedVersion("Unknown version %s" % msvc_version)
+
# For bug 3333 - support default location of vswhere for both 64 and 32 bit windows
- # installs.
+ # installs.
for pf in ['Program Files (x86)', 'Program Files']:
vswhere_path = os.path.join(
'C:\\',
@@ -300,31 +307,36 @@ def find_vc_pdir_vswhere(msvc_version):
if os.path.exists(vswhere_path):
# If we found vswhere, then use it.
break
+ else:
+ # No vswhere on system, no install info available
+ return None
- vswhere_cmd = [vswhere_path, '-products', '*', '-version', msvc_version, '-property', 'installationPath']
-
- if os.path.exists(vswhere_path):
- #TODO PY27 cannot use Popen as context manager
- # try putting it back to the old way for now
- sp = subprocess.Popen(vswhere_cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- vsdir, err = sp.communicate()
- if vsdir:
- vsdir = vsdir.decode("mbcs").splitlines()
- # vswhere could easily return multiple lines
- # we could define a way to pick the one we prefer, but since
- # this data is currently only used to make a check for existence,
- # returning the first hit should be good enough for now.
- vc_pdir = os.path.join(vsdir[0], 'VC')
- return vc_pdir
+ vswhere_cmd = [vswhere_path,
+ '-products', '*',
+ '-version', vswhere_version,
+ '-property', 'installationPath']
+
+ #TODO PY27 cannot use Popen as context manager
+ # try putting it back to the old way for now
+ sp = subprocess.Popen(vswhere_cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ vsdir, err = sp.communicate()
+ if vsdir:
+ vsdir = vsdir.decode("mbcs").splitlines()
+ # vswhere could easily return multiple lines
+ # we could define a way to pick the one we prefer, but since
+ # this data is currently only used to make a check for existence,
+ # returning the first hit should be good enough for now.
+ vc_pdir = os.path.join(vsdir[0], 'VC')
+ return vc_pdir
else:
# No vswhere on system, no install info available
return None
def find_vc_pdir(msvc_version):
- """Find the product directory for the given version.
+ """Find the MSVC product directory for the given version.
Tries to look up the path using a registry key from the table
_VCVER_TO_PRODUCT_DIR; if there is no key, calls find_vc_pdir_wshere
@@ -425,6 +437,8 @@ def find_batch_file(env,msvc_version,host_arch,target_arch):
__INSTALLED_VCS_RUN = None
+_VC_TOOLS_VERSION_FILE_PATH = ['Auxiliary', 'Build', 'Microsoft.VCToolsVersion.default.txt']
+_VC_TOOLS_VERSION_FILE = os.sep.join(_VC_TOOLS_VERSION_FILE_PATH)
def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
"""Find the cl.exe on the filesystem in the vc_dir depending on
@@ -459,7 +473,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
host_platform = _ARCH_TO_CANONICAL[host_platform]
target_platform = _ARCH_TO_CANONICAL[target_platform]
- debug('_check_cl_exists_in_vc_dir(): host platform %s, target platform %s' % (host_platform, target_platform))
+ debug('_check_cl_exists_in_vc_dir(): host platform %s, target platform %s for version %s' % (host_platform, target_platform, msvc_version))
ver_num = float(get_msvc_version_numeric(msvc_version))
@@ -468,7 +482,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# 2017 and newer allowed multiple versions of the VC toolset to be installed at the same time.
# Just get the default tool version for now
#TODO: support setting a specific minor VC version
- default_toolset_file = os.path.join(vc_dir, r'Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')
+ default_toolset_file = os.path.join(vc_dir, _VC_TOOLS_VERSION_FILE)
try:
with open(default_toolset_file) as f:
vc_specific_version = f.readlines()[0].strip()
@@ -480,11 +494,11 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
return False
host_trgt_dir = _HOST_TARGET_TO_CL_DIR_GREATER_THAN_14.get((host_platform, target_platform), None)
- if not host_trgt_dir:
- debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo')
+ if host_trgt_dir is None:
+ debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo: (%s,%s)'%(host_platform, target_platform))
return False
- cl_path = os.path.join(vc_dir, r'Tools\MSVC', vc_specific_version, 'bin', host_trgt_dir, _CL_EXE_NAME)
+ cl_path = os.path.join(vc_dir, 'Tools','MSVC', vc_specific_version, 'bin', host_trgt_dir[0], host_trgt_dir[1], _CL_EXE_NAME)
debug('_check_cl_exists_in_vc_dir(): checking for ' + _CL_EXE_NAME + ' at ' + cl_path)
if os.path.exists(cl_path):
debug('_check_cl_exists_in_vc_dir(): found ' + _CL_EXE_NAME + '!')
@@ -492,8 +506,10 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
elif ver_num <= 14 and ver_num >= 8:
+ # Set default value to be -1 as "" which is the value for x86/x86 yields true when tested
+ # if not host_trgt_dir
host_trgt_dir = _HOST_TARGET_TO_CL_DIR.get((host_platform, target_platform), None)
- if not host_trgt_dir:
+ if host_trgt_dir is None:
debug('_check_cl_exists_in_vc_dir(): unsupported host/target platform combo')
return False
@@ -505,8 +521,11 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version):
# older versions of visual studio only had x86 binaries,
# so if the host platform is amd64, we need to check cross
# compile options (x86 binary compiles some other target on a 64 bit os)
+
+ # Set default value to be -1 as "" which is the value for x86/x86 yields true when tested
+ # if not host_trgt_dir
host_trgt_dir = _HOST_TARGET_TO_CL_DIR.get(('x86', target_platform), None)
- if not host_trgt_dir:
+ if host_trgt_dir is None:
return False
cl_path = os.path.join(vc_dir, 'bin', host_trgt_dir, _CL_EXE_NAME)
@@ -554,6 +573,10 @@ def get_installed_vcs(env=None):
debug('find_vc_pdir no compiler found %s' % ver)
else:
debug('find_vc_pdir return None for ver %s' % ver)
+ except (MSVCUnsupportedTargetArch, MSVCUnsupportedHostArch):
+ # Allow this exception to propagate further as it should cause
+ # SCons to exit with an error code
+ raise
except VisualCException as e:
debug('did not find VC %s: caught exception %s' % (ver, str(e)))
return installed_versions
diff --git a/src/engine/SCons/Tool/MSCommon/vcTests.py b/src/engine/SCons/Tool/MSCommon/vcTests.py
new file mode 100644
index 0000000..25537f3
--- /dev/null
+++ b/src/engine/SCons/Tool/MSCommon/vcTests.py
@@ -0,0 +1,180 @@
+#
+# Copyright (c) 2001 - 2019 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# from typing import Dict, Any
+
+__revision__ = "src/engine/SCons/Tool/MSCommon/vcTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import os.path
+import unittest
+
+import SCons.Node.FS
+import SCons.Warnings
+import SCons.Tool.MSCommon.vc
+
+import TestCmd
+
+original = os.getcwd()
+
+test = TestCmd.TestCmd(workdir='')
+
+os.chdir(test.workpath(''))
+
+MSVCUnsupportedHostArch = SCons.Tool.MSCommon.vc.MSVCUnsupportedHostArch
+MSVCUnsupportedTargetArch = SCons.Tool.MSCommon.vc.MSVCUnsupportedTargetArch
+
+MS_TOOLS_VERSION='1.1.1'
+
+class MSVcTestCase(unittest.TestCase):
+
+ @staticmethod
+ def _createDummyCl(path, add_bin=True):
+ """
+ Creates a dummy cl.ex in the correct directory.
+ It will create all missing parent directories as well
+
+ Args:
+ path: Relative path to cl.exe for the version about to be tested.
+ """
+
+ # print("PATH:%s"%path)
+
+ path = path.replace('\\', os.sep)
+ if add_bin:
+ create_path = os.path.join(path,'bin')
+ else:
+ create_path = path
+ if create_path and not os.path.isdir(create_path):
+ os.makedirs(create_path)
+
+ create_this = os.path.join(create_path,'cl.exe')
+
+ # print("Creating: %s"%create_this)
+ with open(create_this,'w') as ct:
+ ct.write('created')
+
+
+
+
+ def runTest(self):
+ """
+ Check that all proper HOST_PLATFORM and TARGET_PLATFORM are handled.
+ Verify that improper HOST_PLATFORM and/or TARGET_PLATFORM are properly handled.
+ by SCons.Tool.MSCommon.vc._check_cl_exists_in_vc_dir()
+ """
+
+ check = SCons.Tool.MSCommon.vc._check_cl_exists_in_vc_dir
+
+ env={'TARGET_ARCH':'x86'}
+ p = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR[('x86','x86')]
+ MSVcTestCase._createDummyCl(p)
+
+ # print("retval:%s"%check(env, '.', '8.0'))
+
+
+ # Setup for VC 14+ tests
+
+ # Create the VC minor/major version file
+ tools_version_file = SCons.Tool.MSCommon.vc._VC_TOOLS_VERSION_FILE
+ tools_dir = os.path.dirname(tools_version_file)
+ if not os.path.isdir(tools_dir):
+ os.makedirs(tools_dir)
+ try:
+ with open(tools_version_file, 'w') as tf:
+ tf.write(MS_TOOLS_VERSION)
+ except IOError as e:
+ print("Failed trying to write :%s :%s"%(tools_version_file, e))
+
+
+ # Now walk all the valid combinations of host/target for VC 14 +
+ vc_gt_14_map = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR_GREATER_THAN_14
+
+ for key, value in vc_gt_14_map.items():
+ # print("GT 14 Got: %s -> %s"%(key,value))
+
+ env={'TARGET_ARCH':key[1], 'HOST_ARCH':key[0]}
+ path = os.path.join('.','Tools','MSVC', MS_TOOLS_VERSION, 'bin', value[0], value[1])
+ MSVcTestCase._createDummyCl(path, add_bin=False)
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(key[1], result))
+ self.assertTrue(result, "Checking host: %s target: %s"%(value[0], value[1]))
+
+ # Now test bogus value for HOST_ARCH
+ env={'TARGET_ARCH':'x86', 'HOST_ARCH':'GARBAGE'}
+ try:
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus HOST_ARCH host: %s target: %s"%(value[0], value[1]))
+ except MSVCUnsupportedHostArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['HOST_ARCH'])
+
+ # Now test bogus value for TARGET_ARCH
+ env={'TARGET_ARCH':'GARBAGE', 'HOST_ARCH':'x86'}
+ try:
+ result=check(env, '.', '14.1')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus TARGET_ARCH host: %s target: %s"%(value[0], value[1]))
+ except MSVCUnsupportedTargetArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['TARGET_ARCH'])
+
+ # Test >8 < 14 VC versions
+ vc_map = SCons.Tool.MSCommon.vc._HOST_TARGET_TO_CL_DIR
+ for key,value in vc_map.items():
+ # print("LT 14 Got: %s -> %s"%(key,value))
+ env={'TARGET_ARCH':key[1], 'HOST_ARCH':key[0]}
+ path = os.path.join('.', 'bin', value )
+ MSVcTestCase._createDummyCl(path, add_bin=False)
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(key[1], result))
+ self.assertTrue(result, "Checking host: %s target: %s"%(key[0], key[1]))
+
+ # Now test bogus value for HOST_ARCH
+ env={'TARGET_ARCH':'x86', 'HOST_ARCH':'GARBAGE'}
+ try:
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus HOST_ARCH host: %s target: %s"%(env['HOST_ARCH'], env['TARGET_ARCH']))
+ except MSVCUnsupportedHostArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['HOST_ARCH'])
+
+ # Now test bogus value for TARGET_ARCH
+ env={'TARGET_ARCH':'GARBAGE', 'HOST_ARCH':'x86'}
+ try:
+ result=check(env, '.', '9.0')
+ # print("for:%s got :%s"%(env, result))
+ self.assertFalse(result, "Did not fail with bogus TARGET_ARCH host: %s target: %s"%(env['HOST_ARCH'], env['TARGET_ARCH']))
+ except MSVCUnsupportedTargetArch:
+ pass
+ else:
+ self.fail('Did not fail when HOST_ARCH specified as: %s'%env['TARGET_ARCH'])
+
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py
index 72d4421..731f328 100644
--- a/src/engine/SCons/Tool/MSCommon/vs.py
+++ b/src/engine/SCons/Tool/MSCommon/vs.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/MSCommon/vs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """Module to detect Visual Studio and/or Visual C/C++
"""
@@ -198,6 +198,17 @@ class VisualStudio(object):
# Tool/MSCommon/vc.py, and the MSVC_VERSION documentation in Tool/msvc.xml.
SupportedVSList = [
+ # Visual Studio 2019
+ VisualStudio('14.2',
+ vc_version='14.2',
+ sdk_version='10.0A',
+ hkeys=[],
+ common_tools_var='VS160COMNTOOLS',
+ executable_path=r'Common7\IDE\devenv.com',
+ batch_file_path=r'VC\Auxiliary\Build\vsvars32.bat',
+ supported_arch=['x86', 'amd64', "arm"],
+ ),
+
# Visual Studio 2017
VisualStudio('14.1',
vc_version='14.1',
@@ -520,7 +531,7 @@ def get_default_arch(env):
if not msvs:
arch = 'x86'
- elif not arch in msvs.get_supported_arch():
+ elif arch not in msvs.get_supported_arch():
fmt = "Visual Studio version %s does not support architecture %s"
raise SCons.Errors.UserError(fmt % (env['MSVS_VERSION'], arch))
diff --git a/src/engine/SCons/Tool/PharLapCommon.py b/src/engine/SCons/Tool/PharLapCommon.py
index 103e21c..623f2a8 100644
--- a/src/engine/SCons/Tool/PharLapCommon.py
+++ b/src/engine/SCons/Tool/PharLapCommon.py
@@ -29,7 +29,7 @@ Phar Lap ETS tool chain. Right now, this is linkloc and
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/PharLapCommon.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/PharLapCommon.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -79,7 +79,8 @@ def getPharLapVersion():
include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h"))
if not os.path.exists(include_path):
raise SCons.Errors.UserError("Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?")
- mo = REGEX_ETS_VER.search(open(include_path, 'r').read())
+ with open(include_path, 'r') as f:
+ mo = REGEX_ETS_VER.search(f.read())
if mo:
return int(mo.group(1))
# Default return for Phar Lap 9.1
diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py
index 81b6491..25e9b2d 100644
--- a/src/engine/SCons/Tool/ToolTests.py
+++ b/src/engine/SCons/Tool/ToolTests.py
@@ -21,8 +21,9 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ToolTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ToolTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+import os
import sys
import unittest
@@ -31,29 +32,49 @@ import TestUnit
import SCons.Errors
import SCons.Tool
+
+class DummyEnvironment(object):
+ def __init__(self):
+ self.dict = {}
+ def Detect(self, progs):
+ if not SCons.Util.is_List(progs):
+ progs = [ progs ]
+ return progs[0]
+ def Append(self, **kw):
+ self.dict.update(kw)
+ def __getitem__(self, key):
+ return self.dict[key]
+ def __setitem__(self, key, val):
+ self.dict[key] = val
+ def __contains__(self, key):
+ return self.dict.__contains__(key)
+ def has_key(self, key):
+ return key in self.dict
+ def subst(self, string, *args, **kwargs):
+ return string
+
+ PHONY_PATH = "/usr/phony/bin"
+ def WhereIs(self, key_program):
+ # for pathfind test for Issue #3336:
+ # need to fake the case where extra paths are searched, and
+ # if one has a "hit" after some fails, the fails are left in
+ # the environment's PATH. So construct a positive answer if
+ # we see a magic known path component in PATH; answer in
+ # the negative otherwise.
+ paths = self['ENV']['PATH']
+ if self.PHONY_PATH in paths:
+ return os.path.join(self.PHONY_PATH, key_program)
+ return None
+ def AppendENVPath(self, pathvar, path):
+ # signature matches how called from find_program_path()
+ self['ENV'][pathvar] = self['ENV'][pathvar] + os.pathsep + path
+
+
class ToolTestCase(unittest.TestCase):
def test_Tool(self):
"""Test the Tool() function"""
- class Environment(object):
- def __init__(self):
- self.dict = {}
- def Detect(self, progs):
- if not SCons.Util.is_List(progs):
- progs = [ progs ]
- return progs[0]
- def Append(self, **kw):
- self.dict.update(kw)
- def __getitem__(self, key):
- return self.dict[key]
- def __setitem__(self, key, val):
- self.dict[key] = val
- def __contains__(self, key):
- return self.dict.__contains__(key)
- def has_key(self, key):
- return key in self.dict
- def subst(self, string, *args, **kwargs):
- return string
- env = Environment()
+
+ env = DummyEnvironment()
env['BUILDERS'] = {}
env['ENV'] = {}
env['PLATFORM'] = 'test'
@@ -67,17 +88,34 @@ class ToolTestCase(unittest.TestCase):
SCons.Tool.Tool()
except TypeError:
pass
- else:
+ else: # TODO pylint E0704: bare raise not inside except
raise
try:
p = SCons.Tool.Tool('_does_not_exist_')
- except SCons.Errors.EnvironmentError:
+ except SCons.Errors.SConsEnvironmentError:
pass
- else:
+ else: # TODO pylint E0704: bare raise not inside except
raise
+ def test_pathfind(self):
+ """Test that find_program_path() does not alter PATH"""
+
+ env = DummyEnvironment()
+ PHONY_PATHS = [
+ r'C:\cygwin64\bin',
+ r'C:\cygwin\bin',
+ '/usr/local/dummy/bin',
+ env.PHONY_PATH, # will be recognized by dummy WhereIs
+ ]
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
+ pre_path = env['ENV']['PATH']
+ _ = SCons.Tool.find_program_path(env, 'no_tool', default_paths=PHONY_PATHS)
+ assert env['ENV']['PATH'] == pre_path, env['ENV']['PATH']
+
+
if __name__ == "__main__":
suite = unittest.makeSuite(ToolTestCase, 'test_')
TestUnit.run(suite)
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index b7d5dcc..271f214 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -35,10 +35,8 @@ tool definition.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-import imp
-import importlib
import sys
import re
import os
@@ -53,7 +51,12 @@ import SCons.Scanner.D
import SCons.Scanner.LaTeX
import SCons.Scanner.Prog
import SCons.Scanner.SWIG
-import collections
+try:
+ # Python 3
+ from collections.abc import Callable
+except ImportError:
+ # Python 2.7
+ from collections import Callable
DefaultToolpath = []
@@ -106,7 +109,9 @@ TOOL_ALIASES = {
class Tool(object):
- def __init__(self, name, toolpath=[], **kw):
+ def __init__(self, name, toolpath=None, **kw):
+ if toolpath is None:
+ toolpath = []
# Rename if there's a TOOL_ALIAS for this tool
self.name = TOOL_ALIASES.get(name, name)
@@ -121,6 +126,8 @@ class Tool(object):
self.options = module.options
def _load_dotted_module_py2(self, short_name, full_name, searchpaths=None):
+ import imp
+
splitname = short_name.split('.')
index = 0
srchpths = searchpaths
@@ -149,7 +156,7 @@ class Tool(object):
except ImportError as e:
splitname = self.name.split('.')
if str(e) != "No module named %s" % splitname[0]:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
except ImportError:
@@ -211,13 +218,13 @@ class Tool(object):
if spec is None:
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
module = importlib.util.module_from_spec(spec)
if module is None:
if debug: print("MODULE IS NONE:%s" % self.name)
error_string = "No module named %s" % self.name
- raise SCons.Errors.EnvironmentError(error_string)
+ raise SCons.Errors.SConsEnvironmentError(error_string)
# Don't reload a tool we already loaded.
sys_modules_value = sys.modules.get(found_name, False)
@@ -258,7 +265,7 @@ class Tool(object):
return module
except ImportError as e:
if str(e) != "No module named %s" % self.name:
- raise SCons.Errors.EnvironmentError(e)
+ raise SCons.Errors.SConsEnvironmentError(e)
try:
import zipimport
importer = zipimport.zipimporter(sys.modules['SCons.Tool'].__path__[0])
@@ -267,10 +274,10 @@ class Tool(object):
return module
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
except ImportError as e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError(m)
+ raise SCons.Errors.SConsEnvironmentError(m)
def __call__(self, env, *args, **kw):
if self.init_kw is not None:
@@ -376,7 +383,7 @@ def _call_linker_cb(env, callback, args, result=None):
if Verbose:
print('_call_linker_cb: env["LINKCALLBACKS"][%r] found' % callback)
print('_call_linker_cb: env["LINKCALLBACKS"][%r]=%r' % (callback, cbfun))
- if isinstance(cbfun, collections.Callable):
+ if isinstance(cbfun, Callable):
if Verbose:
print('_call_linker_cb: env["LINKCALLBACKS"][%r] is callable' % callback)
result = cbfun(env, *args)
@@ -394,7 +401,8 @@ def _call_env_subst(env, string, *args, **kw):
class _ShLibInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'ShLib'
def get_lib_prefix(self, env, *args, **kw):
@@ -411,7 +419,8 @@ class _ShLibInfoSupport(object):
class _LdModInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'LdMod'
def get_lib_prefix(self, env, *args, **kw):
@@ -428,7 +437,8 @@ class _LdModInfoSupport(object):
class _ImpLibInfoSupport(object):
- def get_libtype(self):
+ @property
+ def libtype(self):
return 'ImpLib'
def get_lib_prefix(self, env, *args, **kw):
@@ -480,25 +490,21 @@ class _LibInfoGeneratorBase(object):
'ImpLib': _ImpLibInfoSupport}
def __init__(self, libtype, infoname):
- self.set_libtype(libtype)
- self.set_infoname(infoname)
+ self.libtype = libtype
+ self.infoname = infoname
+
+ @property
+ def libtype(self):
+ return self._support.libtype
- def set_libtype(self, libtype):
+ @libtype.setter
+ def libtype(self, libtype):
try:
support_class = self._support_classes[libtype]
except KeyError:
raise ValueError('unsupported libtype %r' % libtype)
self._support = support_class()
- def get_libtype(self):
- return self._support.get_libtype()
-
- def set_infoname(self, infoname):
- self.infoname = infoname
-
- def get_infoname(self):
- return self.infoname
-
def get_lib_prefix(self, env, *args, **kw):
return self._support.get_lib_prefix(env, *args, **kw)
@@ -518,9 +524,8 @@ class _LibInfoGeneratorBase(object):
try:
libtype = kw['generator_libtype']
except KeyError:
- libtype = self.get_libtype()
- infoname = self.get_infoname()
- return 'Versioned%s%s' % (libtype, infoname)
+ libtype = self.libtype
+ return 'Versioned%s%s' % (libtype, self.infoname)
def generate_versioned_lib_info(self, env, args, result=None, **kw):
callback = self.get_versioned_lib_info_generator(**kw)
@@ -730,7 +735,7 @@ class _LibSonameGenerator(_LibInfoGeneratorBase):
if not soname:
# fallback to library name (as returned by appropriate _LibNameGenerator)
- soname = _LibNameGenerator(self.get_libtype())(env, libnode)
+ soname = _LibNameGenerator(self.libtype)(env, libnode)
if Verbose:
print("_LibSonameGenerator: FALLBACK: soname=%r" % soname)
@@ -1316,30 +1321,35 @@ def tool_list(platform, env):
return [x for x in tools if x]
-def find_program_path(env, key_program, default_paths=[]):
+def find_program_path(env, key_program, default_paths=None):
"""
- Find the location of key_program and then return the path it was located at.
- Checking the default install locations.
- Mainly for windows where tools aren't all installed in /usr/bin,etc
- :param env: Current Environment()
- :param key_program: Program we're using to locate the directory to add to PATH.
+ Find the location of a tool using various means.
+
+ Mainly for windows where tools aren't all installed in /usr/bin, etc.
+
+ :param env: Current Construction Environment.
+ :param key_program: Tool to locate.
+ :param default_paths: List of additional paths this tool might be found in.
"""
# First search in the SCons path
path = env.WhereIs(key_program)
- if (path):
+ if path:
return path
- # then the OS path:
+
+ # Then in the OS path
path = SCons.Util.WhereIs(key_program)
- if (path):
+ if path:
return path
- # If that doesn't work try default location for mingw
+ # Finally, add the defaults and check again. Do not change
+ # ['ENV']['PATH'] permananetly, the caller can do that if needed.
+ if default_paths is None:
+ return path
save_path = env['ENV']['PATH']
for p in default_paths:
env.AppendENVPath('PATH', p)
path = env.WhereIs(key_program)
- if not path:
- env['ENV']['PATH'] = save_path
+ env['ENV']['PATH'] = save_path
return path
# Local Variables:
diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py
index be14abc..bafaea4 100644
--- a/src/engine/SCons/Tool/aixc++.py
+++ b/src/engine/SCons/Tool/aixc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
from SCons.Tool.aixcxx import *
diff --git a/src/engine/SCons/Tool/aixcc.py b/src/engine/SCons/Tool/aixcc.py
index a1fe216..349a40a 100644
--- a/src/engine/SCons/Tool/aixcc.py
+++ b/src/engine/SCons/Tool/aixcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixcxx.py b/src/engine/SCons/Tool/aixcxx.py
index ec2af1a..0830e33 100644
--- a/src/engine/SCons/Tool/aixcxx.py
+++ b/src/engine/SCons/Tool/aixcxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixcxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixcxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixf77.py b/src/engine/SCons/Tool/aixf77.py
index 6281b13..d2c619a 100644
--- a/src/engine/SCons/Tool/aixf77.py
+++ b/src/engine/SCons/Tool/aixf77.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixf77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/aixlink.py b/src/engine/SCons/Tool/aixlink.py
index ddb4281..ea2949f 100644
--- a/src/engine/SCons/Tool/aixlink.py
+++ b/src/engine/SCons/Tool/aixlink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/aixlink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/aixlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/applelink.py b/src/engine/SCons/Tool/applelink.py
index 5981d19..011b29d 100644
--- a/src/engine/SCons/Tool/applelink.py
+++ b/src/engine/SCons/Tool/applelink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/applelink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/applelink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/ar.py b/src/engine/SCons/Tool/ar.py
index bef719f..459fb55 100644
--- a/src/engine/SCons/Tool/ar.py
+++ b/src/engine/SCons/Tool/ar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/as.py b/src/engine/SCons/Tool/as.py
index 8deea59..02139c5 100644
--- a/src/engine/SCons/Tool/as.py
+++ b/src/engine/SCons/Tool/as.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/as.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/as.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/bcc32.py b/src/engine/SCons/Tool/bcc32.py
index 1cb0a38..e8ffbbf 100644
--- a/src/engine/SCons/Tool/bcc32.py
+++ b/src/engine/SCons/Tool/bcc32.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/bcc32.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/bcc32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/c++.py b/src/engine/SCons/Tool/c++.py
index e670d0d..8819f82 100644
--- a/src/engine/SCons/Tool/c++.py
+++ b/src/engine/SCons/Tool/c++.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/c++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/c++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/cc.py b/src/engine/SCons/Tool/cc.py
index 9b604c4..698d725 100644
--- a/src/engine/SCons/Tool/cc.py
+++ b/src/engine/SCons/Tool/cc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/clang.py b/src/engine/SCons/Tool/clang.py
index 69cbbb6..f48afbf 100644
--- a/src/engine/SCons/Tool/clang.py
+++ b/src/engine/SCons/Tool/clang.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# __revision__ = "src/engine/SCons/Tool/clang.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+# __revision__ = "src/engine/SCons/Tool/clang.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Based on SCons/Tool/gcc.py by Paweł Tomulik 2014 as a separate tool.
# Brought into the SCons mainline by Russel Winder 2017.
@@ -77,7 +77,8 @@ def generate(env):
stdout=subprocess.PIPE)
if pipe.wait() != 0: return
# clang -dumpversion is of no use
- line = pipe.stdout.readline()
+ with pipe.stdout:
+ line = pipe.stdout.readline()
if sys.version_info[0] > 2:
line = line.decode()
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
diff --git a/src/engine/SCons/Tool/clangxx.py b/src/engine/SCons/Tool/clangxx.py
index 7899228..d88874e 100644
--- a/src/engine/SCons/Tool/clangxx.py
+++ b/src/engine/SCons/Tool/clangxx.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# __revision__ = "src/engine/SCons/Tool/clangxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+# __revision__ = "src/engine/SCons/Tool/clangxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Based on SCons/Tool/g++.py by Paweł Tomulik 2014 as a separate tool.
# Brought into the SCons mainline by Russel Winder 2017.
@@ -85,7 +85,8 @@ def generate(env):
return
# clang -dumpversion is of no use
- line = pipe.stdout.readline()
+ with pipe.stdout:
+ line = pipe.stdout.readline()
if sys.version_info[0] > 2:
line = line.decode()
match = re.search(r'clang +version +([0-9]+(?:\.[0-9]+)+)', line)
diff --git a/src/engine/SCons/Tool/cvf.py b/src/engine/SCons/Tool/cvf.py
index bc1e888..aa24d69 100644
--- a/src/engine/SCons/Tool/cvf.py
+++ b/src/engine/SCons/Tool/cvf.py
@@ -27,7 +27,7 @@ Tool-specific initialization for the Compaq Visual Fortran compiler.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cvf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cvf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import fortran
diff --git a/src/engine/SCons/Tool/cxx.py b/src/engine/SCons/Tool/cxx.py
index 81a67c7..2ac278e 100644
--- a/src/engine/SCons/Tool/cxx.py
+++ b/src/engine/SCons/Tool/cxx.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/cxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/cxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Tool/cyglink.py b/src/engine/SCons/Tool/cyglink.py
index f69b886..c3d78de 100644
--- a/src/engine/SCons/Tool/cyglink.py
+++ b/src/engine/SCons/Tool/cyglink.py
@@ -133,7 +133,7 @@ def _versioned_lib_suffix(env, suffix, version):
if Verbose:
print("_versioned_lib_suffix: suffix= ", suffix)
print("_versioned_lib_suffix: version= ", version)
- cygversion = re.sub('\.', '-', version)
+ cygversion = re.sub(r'\.', '-', version)
if not suffix.startswith('-' + cygversion):
suffix = '-' + cygversion + suffix
if Verbose:
diff --git a/src/engine/SCons/Tool/default.py b/src/engine/SCons/Tool/default.py
index e8aa11b..866b823 100644
--- a/src/engine/SCons/Tool/default.py
+++ b/src/engine/SCons/Tool/default.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/default.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/default.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py
index b281e1c..befcd22 100644
--- a/src/engine/SCons/Tool/dmd.py
+++ b/src/engine/SCons/Tool/dmd.py
@@ -53,7 +53,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dmd.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dmd.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import subprocess
diff --git a/src/engine/SCons/Tool/docbook/__init__.py b/src/engine/SCons/Tool/docbook/__init__.py
index d7d10c0..147556d 100644
--- a/src/engine/SCons/Tool/docbook/__init__.py
+++ b/src/engine/SCons/Tool/docbook/__init__.py
@@ -84,7 +84,7 @@ def __extend_targets_sources(target, source):
source = [source]
if len(target) < len(source):
target.extend(source[len(target):])
-
+
return target, source
def __init_xsl_stylesheet(kw, env, user_xsl_var, default_path):
@@ -94,12 +94,12 @@ def __init_xsl_stylesheet(kw, env, user_xsl_var, default_path):
path_args = [scriptpath, db_xsl_folder] + default_path
xsl_style = os.path.join(*path_args)
kw['DOCBOOK_XSL'] = xsl_style
-
+
def __select_builder(lxml_builder, libxml2_builder, cmdline_builder):
""" Selects a builder, based on which Python modules are present. """
if prefer_xsltproc:
return cmdline_builder
-
+
if not has_libxml2:
# At the moment we prefer libxml2 over lxml, the latter can lead
# to conflicts when installed together with libxml2.
@@ -115,7 +115,7 @@ def __ensure_suffix(t, suffix):
tpath = str(t)
if not tpath.endswith(suffix):
return tpath+suffix
-
+
return t
def __ensure_suffix_stem(t, suffix):
@@ -124,11 +124,11 @@ def __ensure_suffix_stem(t, suffix):
if not tpath.endswith(suffix):
stem = tpath
tpath += suffix
-
+
return tpath, stem
else:
stem, ext = os.path.splitext(tpath)
-
+
return t, stem
def __get_xml_text(root):
@@ -151,7 +151,7 @@ def __create_output_dir(base_dir):
else:
if base_dir.endswith('/'):
dir = base_dir
-
+
if dir and not os.path.isdir(dir):
os.makedirs(dir)
@@ -203,10 +203,10 @@ def _detect(env):
the requested output formats.
"""
global prefer_xsltproc
-
+
if env.get('DOCBOOK_PREFER_XSLTPROC',''):
prefer_xsltproc = True
-
+
if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc)):
# Try to find the XSLT processors
__detect_cl_tool(env, 'DOCBOOK_XSLTPROC', xsltproc_com, xsltproc_com_priority)
@@ -219,15 +219,15 @@ def _detect(env):
#
include_re = re.compile('fileref\\s*=\\s*["|\']([^\\n]*)["|\']')
sentity_re = re.compile('<!ENTITY\\s+%*\\s*[^\\s]+\\s+SYSTEM\\s+["|\']([^\\n]*)["|\']>')
-
+
def __xml_scan(node, env, path, arg):
""" Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. """
# Does the node exist yet?
if not os.path.isfile(str(node)):
return []
-
+
if env.get('DOCBOOK_SCANENT',''):
- # Use simple pattern matching for system entities..., no support
+ # Use simple pattern matching for system entities..., no support
# for recursion yet.
contents = node.get_text_contents()
return sentity_re.findall(contents)
@@ -235,9 +235,9 @@ def __xml_scan(node, env, path, arg):
xsl_file = os.path.join(scriptpath,'utils','xmldepend.xsl')
if not has_libxml2 or prefer_xsltproc:
if has_lxml and not prefer_xsltproc:
-
+
from lxml import etree
-
+
xsl_tree = etree.parse(xsl_file)
doc = etree.parse(str(node))
result = doc.xslt(xsl_tree)
@@ -266,7 +266,7 @@ def __xml_scan(node, env, path, arg):
for x in str(result).splitlines():
if x.strip() != "" and not x.startswith("<?xml "):
depfiles.extend(x.strip().split())
-
+
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
@@ -282,7 +282,7 @@ docbook_xml_scanner = SCons.Script.Scanner(function = __xml_scan,
# Action generators
#
def __generate_xsltproc_action(source, target, env, for_signature):
- cmd = env['DOCBOOK_XSLTPROCCOM']
+ cmd = env['DOCBOOK_XSLTPROCCOM']
# Does the environment have a base_dir defined?
base_dir = env.subst('$base_dir')
if base_dir:
@@ -300,7 +300,7 @@ def __emit_xsl_basedir(target, source, env):
if base_dir:
# Yes, so prepend it to each target
return [os.path.join(base_dir, str(t)) for t in target], source
-
+
# No, so simply pass target and source names through
return target, source
@@ -334,11 +334,11 @@ def __build_lxml(target, source, env):
General XSLT builder (HTML/FO), using the lxml module.
"""
from lxml import etree
-
- xslt_ac = etree.XSLTAccessControl(read_file=True,
- write_file=True,
- create_dir=True,
- read_network=False,
+
+ xslt_ac = etree.XSLTAccessControl(read_file=True,
+ write_file=True,
+ create_dir=True,
+ read_network=False,
write_network=False)
xsl_style = env.subst('$DOCBOOK_XSL')
xsl_tree = etree.parse(xsl_style)
@@ -350,11 +350,10 @@ def __build_lxml(target, source, env):
result = transform(doc, **parampass)
else:
result = transform(doc)
-
+
try:
- of = open(str(target[0]), "wb")
- of.write(of.write(etree.tostring(result, pretty_print=True)))
- of.close()
+ with open(str(target[0]), "wb") as of:
+ of.write(etree.tostring(result, pretty_print=True))
except:
pass
@@ -376,11 +375,11 @@ def __xinclude_lxml(target, source, env):
Resolving XIncludes, using the lxml module.
"""
from lxml import etree
-
+
doc = etree.parse(str(source[0]))
doc.xinclude()
try:
- doc.write(str(target[0]), xml_declaration=True,
+ doc.write(str(target[0]), xml_declaration=True,
encoding="UTF-8", pretty_print=True)
except:
pass
@@ -432,33 +431,31 @@ def DocbookEpub(env, target, source=None, *args, **kw):
"""
import zipfile
import shutil
-
+
def build_open_container(target, source, env):
"""Generate the *.epub file from intermediate outputs
- Constructs the epub file according to the Open Container Format. This
+ Constructs the epub file according to the Open Container Format. This
function could be replaced by a call to the SCons Zip builder if support
was added for different compression formats for separate source nodes.
"""
- zf = zipfile.ZipFile(str(target[0]), 'w')
- mime_file = open('mimetype', 'w')
- mime_file.write('application/epub+zip')
- mime_file.close()
- zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED)
- for s in source:
- if os.path.isfile(str(s)):
- head, tail = os.path.split(str(s))
- if not head:
- continue
- s = head
- 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', ''))),
- zipfile.ZIP_DEFLATED)
- zf.close()
-
+ with zipfile.ZipFile(str(target[0]), 'w') as zf:
+ with open('mimetype', 'w') as mime_file:
+ mime_file.write('application/epub+zip')
+ zf.write(mime_file.name, compress_type = zipfile.ZIP_STORED)
+ for s in source:
+ if os.path.isfile(str(s)):
+ head, tail = os.path.split(str(s))
+ if not head:
+ continue
+ s = head
+ 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', ''))),
+ zipfile.ZIP_DEFLATED)
+
def add_resources(target, source, env):
"""Add missing resources to the OEBPS directory
@@ -468,7 +465,7 @@ def DocbookEpub(env, target, source=None, *args, **kw):
content_file = os.path.join(source[0].get_abspath(), 'content.opf')
if not os.path.isfile(content_file):
return
-
+
hrefs = []
if has_libxml2:
nsmap = {'opf' : 'http://www.idpf.org/2007/opf'}
@@ -495,51 +492,51 @@ def DocbookEpub(env, target, source=None, *args, **kw):
hrefs.append(item.attrib['href'])
doc.freeDoc()
- xpath_context.xpathFreeContext()
+ xpath_context.xpathFreeContext()
elif has_lxml:
from lxml import etree
-
+
opf = etree.parse(content_file)
# All the opf:item elements are resources
- for item in opf.xpath('//opf:item',
+ for item in opf.xpath('//opf:item',
namespaces= { 'opf': 'http://www.idpf.org/2007/opf' }):
hrefs.append(item.attrib['href'])
-
+
for href in hrefs:
- # If the resource was not already created by DocBook XSL itself,
+ # If the resource was not already created by DocBook XSL itself,
# copy it into the OEBPS folder
referenced_file = os.path.join(source[0].get_abspath(), href)
if not os.path.exists(referenced_file):
shutil.copy(href, os.path.join(source[0].get_abspath(), href))
-
+
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_EPUB', ['epub','docbook.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
- if not env.GetOption('clean'):
+ if not env.GetOption('clean'):
# Ensure that the folders OEBPS and META-INF exist
__create_output_dir('OEBPS/')
__create_output_dir('META-INF/')
dirs = env.Dir(['OEBPS', 'META-INF'])
-
+
# Set the fixed base_dir
kw['base_dir'] = 'OEBPS/'
tocncx = __builder.__call__(env, 'toc.ncx', source[0], **kw)
cxml = env.File('META-INF/container.xml')
env.SideEffect(cxml, tocncx)
-
+
env.Depends(tocncx, kw['DOCBOOK_XSL'])
result.extend(tocncx+[cxml])
- container = env.Command(__ensure_suffix(str(target[0]), '.epub'),
- tocncx+[cxml], [add_resources, build_open_container])
+ container = env.Command(__ensure_suffix(str(target[0]), '.epub'),
+ tocncx+[cxml], [add_resources, build_open_container])
mimetype = env.File('mimetype')
env.SideEffect(mimetype, container)
@@ -555,13 +552,13 @@ def DocbookHtml(env, target, source=None, *args, **kw):
"""
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTML', ['html','docbook.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
@@ -583,18 +580,18 @@ def DocbookHtmlChunked(env, target, source=None, *args, **kw):
target = ['index.html']
elif not SCons.Util.is_List(source):
source = [source]
-
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLCHUNKED', ['html','chunkfast.xsl'])
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Detect base dir
base_dir = kw.get('base_dir', '')
if base_dir:
__create_output_dir(base_dir)
-
+
# Create targets
result = []
r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
@@ -617,8 +614,8 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw):
source = target
target = ['index.html']
elif not SCons.Util.is_List(source):
- source = [source]
-
+ source = [source]
+
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLHELP', ['htmlhelp','htmlhelp.xsl'])
@@ -629,7 +626,7 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw):
base_dir = kw.get('base_dir', '')
if base_dir:
__create_output_dir(base_dir)
-
+
# Create targets
result = []
r = __builder.__call__(env, __ensure_suffix(str(target[0]), '.html'), source[0], **kw)
@@ -687,30 +684,29 @@ def DocbookMan(env, target, source=None, *args, **kw):
if os.path.isfile(srcfile):
try:
import xml.dom.minidom
-
+
dom = xml.dom.minidom.parse(__ensure_suffix(str(s),'.xml'))
# Extract volume number, default is 1
for node in dom.getElementsByTagName('refmeta'):
for vol in node.getElementsByTagName('manvolnum'):
volnum = __get_xml_text(vol)
-
+
# Extract output filenames
for node in dom.getElementsByTagName('refnamediv'):
for ref in node.getElementsByTagName('refname'):
outfiles.append(__get_xml_text(ref)+'.'+volnum)
-
+
except:
- # Use simple regex parsing
- f = open(__ensure_suffix(str(s),'.xml'), 'r')
- content = f.read()
- f.close()
-
+ # Use simple regex parsing
+ with open(__ensure_suffix(str(s),'.xml'), 'r') as f:
+ content = f.read()
+
for m in re_manvolnum.finditer(content):
volnum = m.group(1)
-
+
for m in re_refname.finditer(content):
outfiles.append(m.group(1)+'.'+volnum)
-
+
if not outfiles:
# Use stem of the source file
spath = str(s)
@@ -722,14 +718,14 @@ def DocbookMan(env, target, source=None, *args, **kw):
else:
# We have to completely rely on the given target name
outfiles.append(t)
-
+
__builder.__call__(env, outfiles[0], s, **kw)
env.Depends(outfiles[0], kw['DOCBOOK_XSL'])
result.append(outfiles[0])
if len(outfiles) > 1:
env.Clean(outfiles[0], outfiles[1:])
-
+
return result
def DocbookSlidesPdf(env, target, source=None, *args, **kw):
@@ -750,7 +746,7 @@ def DocbookSlidesPdf(env, target, source=None, *args, **kw):
for t,s in zip(target,source):
t, stem = __ensure_suffix_stem(t, '.pdf')
xsl = __builder.__call__(env, stem+'.fo', s, **kw)
- env.Depends(xsl, kw['DOCBOOK_XSL'])
+ env.Depends(xsl, kw['DOCBOOK_XSL'])
result.extend(xsl)
result.extend(__fop_builder.__call__(env, t, xsl, **kw))
@@ -767,7 +763,7 @@ def DocbookSlidesHtml(env, target, source=None, *args, **kw):
source = target
target = ['index.html']
elif not SCons.Util.is_List(source):
- source = [source]
+ source = [source]
# Init XSL stylesheet
__init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','html','plain.xsl'])
@@ -800,12 +796,12 @@ def DocbookXInclude(env, target, source, *args, **kw):
# Setup builder
__builder = __select_builder(__xinclude_lxml_builder,__xinclude_libxml2_builder,__xmllint_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
result.extend(__builder.__call__(env, t, s, **kw))
-
+
return result
def DocbookXslt(env, target, source=None, *args, **kw):
@@ -814,13 +810,13 @@ def DocbookXslt(env, target, source=None, *args, **kw):
"""
# Init list of targets/sources
target, source = __extend_targets_sources(target, source)
-
+
# Init XSL stylesheet
kw['DOCBOOK_XSL'] = kw.get('xsl', 'transform.xsl')
# Setup builder
__builder = __select_builder(__lxml_builder, __libxml2_builder, __xsltproc_builder)
-
+
# Create targets
result = []
for t,s in zip(target,source):
@@ -844,18 +840,18 @@ def generate(env):
DOCBOOK_DEFAULT_XSL_MAN = '',
DOCBOOK_DEFAULT_XSL_SLIDESPDF = '',
DOCBOOK_DEFAULT_XSL_SLIDESHTML = '',
-
+
# Paths to the detected executables
DOCBOOK_XSLTPROC = '',
DOCBOOK_XMLLINT = '',
DOCBOOK_FOP = '',
-
+
# Additional flags for the text processors
DOCBOOK_XSLTPROCFLAGS = SCons.Util.CLVar(''),
DOCBOOK_XMLLINTFLAGS = SCons.Util.CLVar(''),
DOCBOOK_FOPFLAGS = SCons.Util.CLVar(''),
DOCBOOK_XSLTPROCPARAMS = SCons.Util.CLVar(''),
-
+
# Default command lines for the detected executables
DOCBOOK_XSLTPROCCOM = xsltproc_com['xsltproc'],
DOCBOOK_XMLLINTCOM = xmllint_com['xmllint'],
@@ -865,7 +861,7 @@ def generate(env):
DOCBOOK_XSLTPROCCOMSTR = None,
DOCBOOK_XMLLINTCOMSTR = None,
DOCBOOK_FOPCOMSTR = None,
-
+
)
_detect(env)
diff --git a/src/engine/SCons/Tool/dvi.py b/src/engine/SCons/Tool/dvi.py
index 9844e37..5cd85ed 100644
--- a/src/engine/SCons/Tool/dvi.py
+++ b/src/engine/SCons/Tool/dvi.py
@@ -27,7 +27,7 @@ Common DVI Builder definition for various other Tool modules that use it.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dvi.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvi.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Tool
diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py
index a4d7d93..32f57e6 100644
--- a/src/engine/SCons/Tool/dvipdf.py
+++ b/src/engine/SCons/Tool/dvipdf.py
@@ -30,7 +30,7 @@ selection method.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/dvipdf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvipdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py
index 30a79ba..988ecd3 100644
--- a/src/engine/SCons/Tool/dvips.py
+++ b/src/engine/SCons/Tool/dvips.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/dvips.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/dvips.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/f03.py b/src/engine/SCons/Tool/f03.py
index 64b67bf..541ec88 100644
--- a/src/engine/SCons/Tool/f03.py
+++ b/src/engine/SCons/Tool/f03.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f03.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f03.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/f08.py b/src/engine/SCons/Tool/f08.py
index 3c317f5..5dc49da 100644
--- a/src/engine/SCons/Tool/f08.py
+++ b/src/engine/SCons/Tool/f08.py
@@ -33,7 +33,7 @@ from __future__ import absolute_import
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f08.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f08.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/f77.py b/src/engine/SCons/Tool/f77.py
index 8ff5f5c..6d60edf 100644
--- a/src/engine/SCons/Tool/f77.py
+++ b/src/engine/SCons/Tool/f77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Scanner.Fortran
diff --git a/src/engine/SCons/Tool/f90.py b/src/engine/SCons/Tool/f90.py
index 6f80821..e0b5fae 100644
--- a/src/engine/SCons/Tool/f90.py
+++ b/src/engine/SCons/Tool/f90.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f90.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f90.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Scanner.Fortran
diff --git a/src/engine/SCons/Tool/f95.py b/src/engine/SCons/Tool/f95.py
index 363245c..9a1afdf 100644
--- a/src/engine/SCons/Tool/f95.py
+++ b/src/engine/SCons/Tool/f95.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/f95.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/f95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/filesystem.py b/src/engine/SCons/Tool/filesystem.py
index c3c79ce..a625714 100644
--- a/src/engine/SCons/Tool/filesystem.py
+++ b/src/engine/SCons/Tool/filesystem.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/filesystem.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/filesystem.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
from SCons.Tool.install import copyFunc
diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py
index c090b00..1b09880 100644
--- a/src/engine/SCons/Tool/fortran.py
+++ b/src/engine/SCons/Tool/fortran.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/fortran.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/fortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import re
diff --git a/src/engine/SCons/Tool/g++.py b/src/engine/SCons/Tool/g++.py
index 7b3bc50..8cf881f 100644
--- a/src/engine/SCons/Tool/g++.py
+++ b/src/engine/SCons/Tool/g++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/g++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/g++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/g77.py b/src/engine/SCons/Tool/g77.py
index fac9794..fc0bcba 100644
--- a/src/engine/SCons/Tool/g77.py
+++ b/src/engine/SCons/Tool/g77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/g77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/g77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env
diff --git a/src/engine/SCons/Tool/gas.py b/src/engine/SCons/Tool/gas.py
index d6b3886..c104e34 100644
--- a/src/engine/SCons/Tool/gas.py
+++ b/src/engine/SCons/Tool/gas.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gas.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gas.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
try:
as_module = __import__('as', globals(), locals(), [])
diff --git a/src/engine/SCons/Tool/gcc.py b/src/engine/SCons/Tool/gcc.py
index 3b4be6d..2532427 100644
--- a/src/engine/SCons/Tool/gcc.py
+++ b/src/engine/SCons/Tool/gcc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
import os
diff --git a/src/engine/SCons/Tool/gdc.py b/src/engine/SCons/Tool/gdc.py
index d12a7cf..46a910c 100644
--- a/src/engine/SCons/Tool/gdc.py
+++ b/src/engine/SCons/Tool/gdc.py
@@ -48,7 +48,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gdc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gdc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/gettext_tool.py b/src/engine/SCons/Tool/gettext_tool.py
index c33de28..5fc0158 100644
--- a/src/engine/SCons/Tool/gettext_tool.py
+++ b/src/engine/SCons/Tool/gettext_tool.py
@@ -23,7 +23,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/gettext_tool.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gettext_tool.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#############################################################################
def generate(env,**kw):
diff --git a/src/engine/SCons/Tool/gfortran.py b/src/engine/SCons/Tool/gfortran.py
index 37a697e..8d02daa 100644
--- a/src/engine/SCons/Tool/gfortran.py
+++ b/src/engine/SCons/Tool/gfortran.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gfortran.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gfortran.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/gnulink.py b/src/engine/SCons/Tool/gnulink.py
index 7634772..53f5081 100644
--- a/src/engine/SCons/Tool/gnulink.py
+++ b/src/engine/SCons/Tool/gnulink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gnulink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gnulink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
import SCons.Tool
diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py
index 8ff9065..371b810 100644
--- a/src/engine/SCons/Tool/gs.py
+++ b/src/engine/SCons/Tool/gs.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/gxx.py b/src/engine/SCons/Tool/gxx.py
index 20445ba..d956c9f 100644
--- a/src/engine/SCons/Tool/gxx.py
+++ b/src/engine/SCons/Tool/gxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/gxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/gxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
diff --git a/src/engine/SCons/Tool/hpc++.py b/src/engine/SCons/Tool/hpc++.py
index 1528066..4ec2fe3 100644
--- a/src/engine/SCons/Tool/hpc++.py
+++ b/src/engine/SCons/Tool/hpc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/hpcc.py b/src/engine/SCons/Tool/hpcc.py
index 2734006..6a564b9 100644
--- a/src/engine/SCons/Tool/hpcc.py
+++ b/src/engine/SCons/Tool/hpcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/hpcxx.py b/src/engine/SCons/Tool/hpcxx.py
index 196777a..8ee888f 100644
--- a/src/engine/SCons/Tool/hpcxx.py
+++ b/src/engine/SCons/Tool/hpcxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hpcxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hpcxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -68,7 +68,8 @@ def generate(env):
env['CXX'] = acc or 'aCC'
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS +Z')
# determine version of aCC
- line = os.popen(acc + ' -V 2>&1').readline().rstrip()
+ with os.popen(acc + ' -V 2>&1') as p:
+ line = p.readline().rstrip()
if line.find('aCC: HP ANSI C++') == 0:
env['CXXVERSION'] = line.split()[-1]
diff --git a/src/engine/SCons/Tool/hplink.py b/src/engine/SCons/Tool/hplink.py
index 9f38a3b..1afa95e 100644
--- a/src/engine/SCons/Tool/hplink.py
+++ b/src/engine/SCons/Tool/hplink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/hplink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/hplink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/icc.py b/src/engine/SCons/Tool/icc.py
index 1923c60..8110a60 100644
--- a/src/engine/SCons/Tool/icc.py
+++ b/src/engine/SCons/Tool/icc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/icc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/icc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
diff --git a/src/engine/SCons/Tool/icl.py b/src/engine/SCons/Tool/icl.py
index 26490f0..29d5862 100644
--- a/src/engine/SCons/Tool/icl.py
+++ b/src/engine/SCons/Tool/icl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/icl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/icl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool.intelc
diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py
index e438c44..0eb7cda 100644
--- a/src/engine/SCons/Tool/ifl.py
+++ b/src/engine/SCons/Tool/ifl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ifl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ifl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
from SCons.Scanner.Fortran import FortranScan
diff --git a/src/engine/SCons/Tool/ifort.py b/src/engine/SCons/Tool/ifort.py
index d69bd14..730e778 100644
--- a/src/engine/SCons/Tool/ifort.py
+++ b/src/engine/SCons/Tool/ifort.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ifort.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ifort.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
from SCons.Scanner.Fortran import FortranScan
diff --git a/src/engine/SCons/Tool/ilink.py b/src/engine/SCons/Tool/ilink.py
index 6c3a072..7c69e72 100644
--- a/src/engine/SCons/Tool/ilink.py
+++ b/src/engine/SCons/Tool/ilink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ilink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/ilink32.py b/src/engine/SCons/Tool/ilink32.py
index 7c7e983..a1e12a6 100644
--- a/src/engine/SCons/Tool/ilink32.py
+++ b/src/engine/SCons/Tool/ilink32.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ilink32.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ilink32.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Tool.bcc32
diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py
index 6b5a741..c0a8917 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -31,7 +31,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/install.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/install.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import re
diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py
index 3429145..fdd9730 100644
--- a/src/engine/SCons/Tool/intelc.py
+++ b/src/engine/SCons/Tool/intelc.py
@@ -32,12 +32,12 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import division, print_function
-__revision__ = "src/engine/SCons/Tool/intelc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/intelc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import math, sys, os.path, glob, string, re
is_windows = sys.platform == 'win32'
-is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
+is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
('PROCESSOR_ARCHITEW6432' in os.environ and
os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64'))
is_linux = sys.platform.startswith('linux')
@@ -113,11 +113,6 @@ def check_abi(abi):
(abi, list(valid_abis.keys())))
return abi
-def vercmp(a, b):
- """Compare strings as floats,
- but Intel changed Linux naming convention at 9.0"""
- return cmp(linux_ver_normalize(b), linux_ver_normalize(a))
-
def get_version_from_list(v, vlist):
"""See if we can match v (string) in vlist (list of strings)
Linux has to match in a fuzzy way."""
@@ -221,7 +216,7 @@ def get_all_compiler_versions():
versions = []
try:
while i < 100:
- subkey = SCons.Util.RegEnumKey(k, i) # raises EnvironmentError
+ subkey = SCons.Util.RegEnumKey(k, i) # raises SConsEnvironmentError
# Check that this refers to an existing dir.
# This is not 100% perfect but should catch common
# installation issues like when the compiler was installed
@@ -293,7 +288,7 @@ def get_all_compiler_versions():
m = re.search(r'([0-9]{0,4})(?:_sp\d*)?\.([0-9][0-9.]*)$', d)
if m:
versions.append("%s.%s"%(m.group(1), m.group(2)))
-
+
def keyfunc(str):
"""Given a dot-separated version string, return a tuple of ints representing it."""
return [int(x) for x in str.split('.')]
@@ -383,7 +378,7 @@ def get_intel_compiler_top(version, abi):
top = d
break
return top
-
+
top = find_in_2016style_dir(version) or find_in_2011style_dir(version) or find_in_2010style_dir(version) or find_in_2008style_dir(version)
# print "INTELC: top=",top
if not top:
diff --git a/src/engine/SCons/Tool/ipkg.py b/src/engine/SCons/Tool/ipkg.py
index 5685abb..664c3a6 100644
--- a/src/engine/SCons/Tool/ipkg.py
+++ b/src/engine/SCons/Tool/ipkg.py
@@ -33,7 +33,7 @@ packages fake_root.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ipkg.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ipkg.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -55,8 +55,10 @@ def generate(env):
env['IPKGCOM'] = '$IPKG $IPKGFLAGS ${SOURCE}'
if env.WhereIs('id'):
- env['IPKGUSER'] = os.popen('id -un').read().strip()
- env['IPKGGROUP'] = os.popen('id -gn').read().strip()
+ with os.popen('id -un') as p:
+ env['IPKGUSER'] = p.read().strip()
+ with os.popen('id -gn') as p:
+ env['IPKGGROUP'] = p.read().strip()
env['IPKGFLAGS'] = SCons.Util.CLVar('-o $IPKGUSER -g $IPKGGROUP')
env['IPKGSUFFIX'] = '.ipk'
diff --git a/src/engine/SCons/Tool/jar.py b/src/engine/SCons/Tool/jar.py
index 5858b2c..98be08f 100644
--- a/src/engine/SCons/Tool/jar.py
+++ b/src/engine/SCons/Tool/jar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/jar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/jar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons.Subst
@@ -86,7 +86,7 @@ def jarFlags(target, source, env, for_signature):
for src in source:
contents = src.get_text_contents()
if contents.startswith("Manifest-Version"):
- if not 'm' in jarflags:
+ if 'm' not in jarflags:
return jarflags + 'm'
break
return jarflags
@@ -106,7 +106,7 @@ def Jar(env, target = None, source = [], *args, **kw):
source = target
target = None
- # mutiple targets pass so build each target the same from the
+ # mutiple targets pass so build each target the same from the
# same source
#TODO Maybe this should only be done once, and the result copied
# for each target since it should result in the same?
@@ -184,7 +184,7 @@ def Jar(env, target = None, source = [], *args, **kw):
continue
except:
pass
-
+
try:
# source is string try to covnert it to dir
target_nodes.extend(dir_to_class(env.fs.Dir(s)))
@@ -193,7 +193,7 @@ def Jar(env, target = None, source = [], *args, **kw):
pass
SCons.Warnings.Warning("File: " + str(s) + " could not be identified as File or Directory, skipping.")
-
+
# at this point all our sources have been converted to classes or directories of class
# so pass it to the Jar builder
return env.JarFile(target = target, source = target_nodes, *args, **kw)
@@ -209,9 +209,9 @@ def generate(env):
env.AddMethod(Jar)
if env['PLATFORM'] == 'win32':
- # Ensure that we have a proper path for clang
- jar = SCons.Tool.find_program_path(env, 'jar',
- default_paths=get_java_install_dirs(env['PLATFORM']))
+ # Ensure that we have a proper path for jar
+ paths = get_java_install_dirs('win32')
+ jar = SCons.Tool.find_program_path(env, 'jar', default_paths=paths)
if jar:
jar_bin_dir = os.path.dirname(jar)
env.AppendENVPath('PATH', jar_bin_dir)
diff --git a/src/engine/SCons/Tool/javac.py b/src/engine/SCons/Tool/javac.py
index b5e4aaa..387afdb 100644
--- a/src/engine/SCons/Tool/javac.py
+++ b/src/engine/SCons/Tool/javac.py
@@ -30,7 +30,7 @@ selection method.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/javac.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/javac.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -210,15 +210,15 @@ def generate(env):
version = env.get('JAVAVERSION', None)
- javac = SCons.Tool.find_program_path(env, 'javac')
if env['PLATFORM'] == 'win32':
# Ensure that we have a proper path for javac
- paths=get_java_install_dirs(env['PLATFORM'], version=version)
- javac = SCons.Tool.find_program_path(env, 'javac',
- default_paths=paths)
+ paths = get_java_install_dirs('win32', version=version)
+ javac = SCons.Tool.find_program_path(env, 'javac', default_paths=paths)
if javac:
javac_bin_dir = os.path.dirname(javac)
env.AppendENVPath('PATH', javac_bin_dir)
+ else:
+ javac = SCons.Tool.find_program_path(env, 'javac')
env['JAVAINCLUDES'] = get_java_include_paths(env, javac, version)
diff --git a/src/engine/SCons/Tool/javah.py b/src/engine/SCons/Tool/javah.py
index 84183cb..251778d 100644
--- a/src/engine/SCons/Tool/javah.py
+++ b/src/engine/SCons/Tool/javah.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/javah.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/javah.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -123,9 +123,9 @@ def generate(env):
java_javah.emitter = emit_java_headers
if env['PLATFORM'] == 'win32':
- # Ensure that we have a proper path for clang
- javah = SCons.Tool.find_program_path(env, 'javah',
- default_paths=get_java_install_dirs(env['PLATFORM']))
+ # Ensure that we have a proper path for javah
+ paths = get_java_install_dirs('win32')
+ javah = SCons.Tool.find_program_path(env, 'javah', default_paths=paths)
if javah:
javah_bin_dir = os.path.dirname(javah)
env.AppendENVPath('PATH', javah_bin_dir)
diff --git a/src/engine/SCons/Tool/latex.py b/src/engine/SCons/Tool/latex.py
index 9626693..3f1af08 100644
--- a/src/engine/SCons/Tool/latex.py
+++ b/src/engine/SCons/Tool/latex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/latex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/latex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Defaults
diff --git a/src/engine/SCons/Tool/ldc.py b/src/engine/SCons/Tool/ldc.py
index fe3df1f..dda1a5e 100644
--- a/src/engine/SCons/Tool/ldc.py
+++ b/src/engine/SCons/Tool/ldc.py
@@ -48,7 +48,7 @@ Lib tool variables:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/ldc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/ldc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import subprocess
diff --git a/src/engine/SCons/Tool/lex.py b/src/engine/SCons/Tool/lex.py
index affb52c..4831776 100644
--- a/src/engine/SCons/Tool/lex.py
+++ b/src/engine/SCons/Tool/lex.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/lex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/lex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
LexAction = SCons.Action.Action("$LEXCOM", "$LEXCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['flex', 'lex', 'win_flex']
+else:
+ BINS = ["flex", "lex"]
+
def lexEmitter(target, source, env):
sourceBase, sourceExt = os.path.splitext(SCons.Util.to_String(source[0]))
@@ -70,22 +75,22 @@ def lexEmitter(target, source, env):
def get_lex_path(env, append_paths=False):
"""
- Find the a path containing the lex or flex binaries. If a construction
- environment is passed in then append the path to the ENV PATH.
- """
- # save existing path to reset if we don't want to append any paths
- envPath = env['ENV']['PATH']
- bins = ['flex', 'lex', 'win_flex']
+ Find the path to the lex tool, searching several possible names
- for prog in bins:
+ Only called in the Windows case, so the default_path
+ can be Windows-specific
+
+ :param env: current construction environment
+ :param append_paths: if set, add the path to the tool to PATH
+ :return: path to lex tool, if found
+ """
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
- if not append_paths:
- env['ENV']['PATH'] = envPath
- else:
+ if append_paths:
env.AppendENVPath('PATH', os.path.dirname(bin_path))
return bin_path
SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
@@ -113,20 +118,21 @@ def generate(env):
env["LEXFLAGS"] = SCons.Util.CLVar("")
if sys.platform == 'win32':
- get_lex_path(env, append_paths=True)
- env["LEX"] = env.Detect(['flex', 'lex', 'win_flex'])
+ # ignore the return - we do not need the full path here
+ _ = get_lex_path(env, append_paths=True)
+ env["LEX"] = env.Detect(BINS)
if not env.get("LEXUNISTD"):
env["LEXUNISTD"] = SCons.Util.CLVar("")
env["LEXCOM"] = "$LEX $LEXUNISTD $LEXFLAGS -t $SOURCES > $TARGET"
else:
- env["LEX"] = env.Detect(["flex", "lex"])
+ env["LEX"] = env.Detect(BINS)
env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET"
def exists(env):
if sys.platform == 'win32':
return get_lex_path(env)
else:
- return env.Detect(["flex", "lex"])
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/link.py b/src/engine/SCons/Tool/link.py
index 65fe013..dcaf91f 100644
--- a/src/engine/SCons/Tool/link.py
+++ b/src/engine/SCons/Tool/link.py
@@ -32,7 +32,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/link.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/link.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import re
diff --git a/src/engine/SCons/Tool/linkloc.py b/src/engine/SCons/Tool/linkloc.py
index cdcf25a..42d010d 100644
--- a/src/engine/SCons/Tool/linkloc.py
+++ b/src/engine/SCons/Tool/linkloc.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/linkloc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/linkloc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
diff --git a/src/engine/SCons/Tool/m4.py b/src/engine/SCons/Tool/m4.py
index 30dc4c9..0ecc82a 100644
--- a/src/engine/SCons/Tool/m4.py
+++ b/src/engine/SCons/Tool/m4.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/m4.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/m4.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/masm.py b/src/engine/SCons/Tool/masm.py
index 77e32c2..cf147a7 100644
--- a/src/engine/SCons/Tool/masm.py
+++ b/src/engine/SCons/Tool/masm.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/masm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/masm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/midl.py b/src/engine/SCons/Tool/midl.py
index 6879da1..f75204a 100644
--- a/src/engine/SCons/Tool/midl.py
+++ b/src/engine/SCons/Tool/midl.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/midl.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/midl.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index ed3f1a3..8410d2f 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mingw.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mingw.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -65,7 +65,7 @@ def shlib_generator(target, source, env, for_signature):
def_target = env.FindIxes(target, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
insert_def = env.subst("$WINDOWS_INSERT_DEF")
- if not insert_def in ['', '0', 0] and def_target: \
+ if insert_def not in ['', '0', 0] and def_target: \
cmd.append('-Wl,--output-def,' + def_target.get_string(for_signature))
return [cmd]
@@ -123,7 +123,7 @@ key_program = 'mingw32-make'
def find_version_specific_mingw_paths():
- """
+ r"""
One example of default mingw install paths is:
C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev2\mingw64\bin
diff --git a/src/engine/SCons/Tool/msgfmt.py b/src/engine/SCons/Tool/msgfmt.py
index 87589ce..c8141a0 100644
--- a/src/engine/SCons/Tool/msgfmt.py
+++ b/src/engine/SCons/Tool/msgfmt.py
@@ -21,7 +21,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/msgfmt.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msgfmt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Builder import BuilderBase
#############################################################################
diff --git a/src/engine/SCons/Tool/msginit.py b/src/engine/SCons/Tool/msginit.py
index e52c1b5..69e803a 100644
--- a/src/engine/SCons/Tool/msginit.py
+++ b/src/engine/SCons/Tool/msginit.py
@@ -24,7 +24,7 @@ Tool specific initialization of msginit tool.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/msginit.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msginit.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Warnings
import SCons.Builder
diff --git a/src/engine/SCons/Tool/msgmerge.py b/src/engine/SCons/Tool/msgmerge.py
index 849fe32..4254fa6 100644
--- a/src/engine/SCons/Tool/msgmerge.py
+++ b/src/engine/SCons/Tool/msgmerge.py
@@ -24,7 +24,7 @@ Tool specific initialization for `msgmerge` tool.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/msgmerge.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msgmerge.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#############################################################################
def _update_or_init_po_files(target, source, env):
diff --git a/src/engine/SCons/Tool/mslib.py b/src/engine/SCons/Tool/mslib.py
index 00a17d7..cecdbdc 100644
--- a/src/engine/SCons/Tool/mslib.py
+++ b/src/engine/SCons/Tool/mslib.py
@@ -31,7 +31,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mslib.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mslib.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
import SCons.Defaults
import SCons.Tool
@@ -54,6 +56,13 @@ def generate(env):
env['LIBPREFIX'] = ''
env['LIBSUFFIX'] = '.lib'
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
+
def exists(env):
return msvc_exists(env)
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py
index 9df531b..9fbce4b 100644
--- a/src/engine/SCons/Tool/mslink.py
+++ b/src/engine/SCons/Tool/mslink.py
@@ -32,8 +32,9 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/mslink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mslink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+import os
import os.path
import SCons.Action
@@ -107,7 +108,7 @@ def _dllEmitter(target, source, env, paramtp):
raise SCons.Errors.UserError('A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp))
insert_def = env.subst("$WINDOWS_INSERT_DEF")
- if not insert_def in ['', '0', 0] and \
+ if insert_def not in ['', '0', 0] and \
not env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"):
# append a def file to the list of sources
@@ -158,7 +159,7 @@ def windowsLibEmitter(target, source, env):
def ldmodEmitter(target, source, env):
"""Emitter for loadable modules.
-
+
Loadable modules are identical to shared libraries on Windows, but building
them is subject to different parameters (LDMODULE*).
"""
@@ -219,7 +220,7 @@ def embedManifestDllCheck(target, source, env):
if env.get('WINDOWS_EMBED_MANIFEST', 0):
manifestSrc = target[0].get_abspath() + '.manifest'
if os.path.exists(manifestSrc):
- ret = (embedManifestDllAction) ([target[0]],None,env)
+ ret = (embedManifestDllAction) ([target[0]],None,env)
if ret:
raise SCons.Errors.UserError("Unable to embed manifest into %s" % (target[0]))
return ret
@@ -327,6 +328,12 @@ def generate(env):
env['LDMODULEEMITTER'] = [ldmodEmitter]
env['LDMODULECOM'] = compositeLdmodAction
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
def exists(env):
return msvc_exists(env)
diff --git a/src/engine/SCons/Tool/mssdk.py b/src/engine/SCons/Tool/mssdk.py
index d66c7fc..7a38c6a 100644
--- a/src/engine/SCons/Tool/mssdk.py
+++ b/src/engine/SCons/Tool/mssdk.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mssdk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mssdk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""engine.SCons.Tool.mssdk
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index a611f8e..052a0b0 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -31,9 +31,10 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/msvc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
+import os
import re
import sys
@@ -161,7 +162,7 @@ def msvc_batch_key(action, env, target, source):
# Note we need to do the env.subst so $MSVC_BATCH can be a reference to
# another construction variable, which is why we test for False and 0
# as strings.
- if not 'MSVC_BATCH' in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
+ if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
# We're not using batching; return no key.
return None
t = target[0]
@@ -187,7 +188,7 @@ def msvc_output_flag(target, source, env, for_signature):
# len(source)==1 as batch mode can compile only one file
# (and it also fixed problem with compiling only one changed file
# with batch mode enabled)
- if not 'MSVC_BATCH' in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
+ if 'MSVC_BATCH' not in env or env.subst('$MSVC_BATCH') in ('0', 'False', '', None):
return '/Fo$TARGET'
else:
# The Visual C/C++ compiler requires a \ at the end of the /Fo
@@ -283,6 +284,12 @@ def generate(env):
msvc_set_PCHPDBFLAGS(env)
+ # Issue #3350
+ # Change tempfile argument joining character from a space to a newline
+ # mslink will fail if any single line is too long, but is fine with many lines
+ # in a tempfile
+ env['TEMPFILEARGJOIN'] = os.linesep
+
env['PCHCOM'] = '$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
env['BUILDERS']['PCH'] = pch_builder
diff --git a/src/engine/SCons/Tool/msvc.xml b/src/engine/SCons/Tool/msvc.xml
index 03d8ce3..b8b4f6d 100644
--- a/src/engine/SCons/Tool/msvc.xml
+++ b/src/engine/SCons/Tool/msvc.xml
@@ -353,6 +353,7 @@ constructor; setting it later has no effect.
<para>
Valid values for Windows are
+<literal>14.2</literal>,
<literal>14.1</literal>,
<literal>14.0</literal>,
<literal>14.0Exp</literal>,
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index ddf8608..38965e3 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -32,7 +32,7 @@ selection method.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/msvs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -70,10 +70,14 @@ def xmlify(s):
s = s.replace('\n', '&#x0A;')
return s
-# Process a CPPPATH list in includes, given the env, target and source.
-# Returns a tuple of nodes.
def processIncludes(includes, env, target, source):
- return SCons.PathList.PathList(includes).subst_path(env, target, source)
+ """
+ Process a CPPPATH list in includes, given the env, target and source.
+ Returns a list of directory paths. These paths are absolute so we avoid
+ putting pound-prefixed paths in a Visual Studio project file.
+ """
+ return [env.Dir(i).abspath for i in
+ SCons.PathList.PathList(includes).subst_path(env, target, source)]
external_makefile_guid = '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}'
@@ -348,10 +352,20 @@ V10DebugSettings = {
}
class _GenerateV10User(_UserGenerator):
- """Generates a Project'user file for MSVS 2010"""
+ """Generates a Project'user file for MSVS 2010 or later"""
def __init__(self, dspfile, source, env):
- self.versionstr = '4.0'
+ version_num, suite = msvs_parse_version(env['MSVS_VERSION'])
+ if version_num >= 14.2:
+ # Visual Studio 2019 is considered to be version 16.
+ self.versionstr = '16.0'
+ elif version_num >= 14.1:
+ # Visual Studio 2017 is considered to be version 15.
+ self.versionstr = '15.0'
+ elif version_num == 14.0:
+ self.versionstr = '14.0'
+ else:
+ self.versionstr = '4.0'
self.usrhead = V10UserHeader
self.usrconf = V10UserConfiguration
self.usrdebg = V10DebugSettings
@@ -397,7 +411,7 @@ class _DSPGenerator(object):
elif SCons.Util.is_List(env['variant']):
variants = env['variant']
- if 'buildtarget' not in env or env['buildtarget'] == None:
+ if 'buildtarget' not in env or env['buildtarget'] is None:
buildtarget = ['']
elif SCons.Util.is_String(env['buildtarget']):
buildtarget = [env['buildtarget']]
@@ -418,7 +432,7 @@ class _DSPGenerator(object):
for _ in variants:
buildtarget.append(bt)
- if 'outdir' not in env or env['outdir'] == None:
+ if 'outdir' not in env or env['outdir'] is None:
outdir = ['']
elif SCons.Util.is_String(env['outdir']):
outdir = [env['outdir']]
@@ -439,7 +453,7 @@ class _DSPGenerator(object):
for v in variants:
outdir.append(s)
- if 'runfile' not in env or env['runfile'] == None:
+ if 'runfile' not in env or env['runfile'] is None:
runfile = buildtarget[-1:]
elif SCons.Util.is_String(env['runfile']):
runfile = [env['runfile']]
@@ -462,15 +476,41 @@ class _DSPGenerator(object):
self.sconscript = env['MSVSSCONSCRIPT']
- if 'cmdargs' not in env or env['cmdargs'] == None:
- cmdargs = [''] * len(variants)
- elif SCons.Util.is_String(env['cmdargs']):
- cmdargs = [env['cmdargs']] * len(variants)
- elif SCons.Util.is_List(env['cmdargs']):
- if len(env['cmdargs']) != len(variants):
- raise SCons.Errors.InternalError("Sizes of 'cmdargs' and 'variant' lists must be the same.")
+ def GetKeyFromEnv(env, key, variants):
+ """
+ Retrieves a specific key from the environment. If the key is
+ present, it is expected to either be a string or a list with length
+ equal to the number of variants. The function returns a list of
+ the desired value (e.g. cpp include paths) guaranteed to be of
+ length equal to the length of the variants list.
+ """
+ if key not in env or env[key] is None:
+ return [''] * len(variants)
+ elif SCons.Util.is_String(env[key]):
+ return [env[key]] * len(variants)
+ elif SCons.Util.is_List(env[key]):
+ if len(env[key]) != len(variants):
+ raise SCons.Errors.InternalError("Sizes of '%s' and 'variant' lists must be the same." % key)
+ else:
+ return env[key]
else:
- cmdargs = env['cmdargs']
+ raise SCons.Errors.InternalError("Unsupported type for key '%s' in environment: %s" %
+ (key, type(env[key])))
+
+ cmdargs = GetKeyFromEnv(env, 'cmdargs', variants)
+
+ # The caller is allowed to put 'cppdefines' and/or 'cpppaths' in the
+ # environment, which is useful if they want to provide per-variant
+ # values for these. Otherwise, we fall back to using the global
+ # 'CPPDEFINES' and 'CPPPATH' functions.
+ if 'cppdefines' in env:
+ cppdefines = GetKeyFromEnv(env, 'cppdefines', variants)
+ else:
+ cppdefines = [env.get('CPPDEFINES', [])] * len(variants)
+ if 'cpppaths' in env:
+ cpppaths = GetKeyFromEnv(env, 'cpppaths', variants)
+ else:
+ cpppaths = [env.get('CPPPATH', [])] * len(variants)
self.env = env
@@ -513,13 +553,17 @@ class _DSPGenerator(object):
for n in sourcenames:
self.sources[n].sort(key=lambda a: a.lower())
- def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile):
+ def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, cppdefines, cpppaths, dspfile=dspfile, env=env):
config = Config()
config.buildtarget = buildtarget
config.outdir = outdir
config.cmdargs = cmdargs
+ config.cppdefines = cppdefines
config.runfile = runfile
+ # Dir objects can't be pickled, so we need an absolute path here.
+ config.cpppaths = processIncludes(cpppaths, env, None, None)
+
match = re.match(r'(.*)\|(.*)', variant)
if match:
config.variant = match.group(1)
@@ -532,12 +576,12 @@ class _DSPGenerator(object):
print("Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dspfile) + "'")
for i in range(len(variants)):
- AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i])
+ AddConfig(self, variants[i], buildtarget[i], outdir[i], runfile[i], cmdargs[i], cppdefines[i], cpppaths[i])
self.platforms = []
for key in list(self.configs.keys()):
platform = self.configs[key].platform
- if not platform in self.platforms:
+ if platform not in self.platforms:
self.platforms.append(platform)
def Build(self):
@@ -553,16 +597,16 @@ V6DSPHeader = """\
CFG=%(name)s - Win32 %(confkey)s
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "%(name)s.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "%(name)s.mak" CFG="%(name)s - Win32 %(confkey)s"
-!MESSAGE
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
+!MESSAGE
"""
class _GenerateV6DSP(_DSPGenerator):
@@ -580,7 +624,7 @@ class _GenerateV6DSP(_DSPGenerator):
for kind in confkeys:
self.file.write('!MESSAGE "%s - Win32 %s" (based on "Win32 (x86) External Target")\n' % (name, kind))
- self.file.write('!MESSAGE \n\n')
+ self.file.write('!MESSAGE\n\n')
def PrintProject(self):
name = self.name
@@ -637,7 +681,7 @@ class _GenerateV6DSP(_DSPGenerator):
first = 1
else:
self.file.write('!ELSEIF "$(CFG)" == "%s - Win32 %s"\n\n' % (name,kind))
- self.file.write('!ENDIF \n\n')
+ self.file.write('!ENDIF\n\n')
self.PrintSourceFiles()
self.file.write('# End Target\n'
'# End Project\n')
@@ -645,10 +689,10 @@ class _GenerateV6DSP(_DSPGenerator):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '\n')
def PrintSourceFiles(self):
@@ -685,11 +729,13 @@ class _GenerateV6DSP(_DSPGenerator):
return # doesn't exist yet, so can't add anything to configs.
line = dspfile.readline()
+ # skip until marker
while line:
if line.find("# End Project") > -1:
break
line = dspfile.readline()
+ # read to get configs
line = dspfile.readline()
datas = line
while line and line != '\n':
@@ -707,12 +753,14 @@ class _GenerateV6DSP(_DSPGenerator):
self.configs.update(data)
+ # keep reading to get sources
data = None
line = dspfile.readline()
datas = line
while line and line != '\n':
line = dspfile.readline()
datas = datas + line
+ dspfile.close()
# OK, we've found our little pickled cache of data.
# it has a "# " in front of it, so we strip that.
@@ -878,6 +926,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
buildtarget = self.configs[kind].buildtarget
runfile = self.configs[kind].runfile
cmdargs = self.configs[kind].cmdargs
+ cpppaths = self.configs[kind].cpppaths
+ cppdefines = self.configs[kind].cppdefines
env_has_buildtarget = 'MSVSBUILDTARGET' in self.env
if not env_has_buildtarget:
@@ -895,9 +945,8 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
# This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
# so they could vary depending on the command being generated. This code
# assumes they don't.
- preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ preprocdefs = xmlify(';'.join(processDefines(cppdefines)))
+ includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None)))
if not env_has_buildtarget:
del self.env['MSVSBUILDTARGET']
@@ -917,10 +966,10 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write('<!-- SCons Data:\n' + pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '-->\n')
def printSources(self, hierarchy, commonprefix):
@@ -998,11 +1047,13 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
return # doesn't exist yet, so can't add anything to configs.
line = dspfile.readline()
+ # skip until marker
while line:
if line.find('<!-- SCons Data:') > -1:
break
line = dspfile.readline()
+ # read to get configs
line = dspfile.readline()
datas = line
while line and line != '\n':
@@ -1020,12 +1071,14 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
self.configs.update(data)
+ # keep reading to get sources
data = None
line = dspfile.readline()
datas = line
while line and line != '\n':
line = dspfile.readline()
datas = datas + line
+ dspfile.close()
# OK, we've found our little pickled cache of data.
try:
@@ -1052,7 +1105,7 @@ class _GenerateV7DSP(_DSPGenerator, _GenerateV7User):
V10DSPHeader = """\
<?xml version="1.0" encoding="%(encoding)s"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="%(versionstr)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
"""
V10DSPProjectConfiguration = """\
@@ -1067,6 +1120,7 @@ V10DSPGlobals = """\
\t\t<ProjectGuid>%(project_guid)s</ProjectGuid>
%(scc_attrs)s\t\t<RootNamespace>%(name)s</RootNamespace>
\t\t<Keyword>MakeFileProj</Keyword>
+\t\t<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
\t</PropertyGroup>
"""
@@ -1080,7 +1134,7 @@ V10DSPPropertyGroupCondition = """\
V10DSPImportGroupCondition = """\
\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'" Label="PropertySheets">
-\t\t<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
\t</ImportGroup>
"""
@@ -1104,9 +1158,9 @@ V15DSPHeader = """\
class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
"""Generates a Project file for MSVS 2010"""
- def __init__(self, dspfile, header, source, env):
+ def __init__(self, dspfile, source, env):
_DSPGenerator.__init__(self, dspfile, source, env)
- self.dspheader = header
+ self.dspheader = V10DSPHeader
self.dspconfiguration = V10DSPProjectConfiguration
self.dspglobals = V10DSPGlobals
@@ -1115,6 +1169,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
def PrintHeader(self):
env = self.env
name = self.name
+ versionstr = self.versionstr
encoding = env.subst('$MSVSENCODING')
project_guid = env.get('MSVS_PROJECT_GUID', '')
scc_provider = env.get('MSVS_SCC_PROVIDER', '')
@@ -1159,7 +1214,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
name = self.name
confkeys = sorted(self.configs.keys())
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\n')
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />\n')
toolset = ''
if 'MSVC_VERSION' in self.env:
@@ -1170,7 +1225,7 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
platform = self.configs[kind].platform
self.file.write(V10DSPPropertyGroupCondition % locals())
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\n')
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />\n')
self.file.write('\t<ImportGroup Label="ExtensionSettings">\n')
self.file.write('\t</ImportGroup>\n')
@@ -1190,6 +1245,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
buildtarget = self.configs[kind].buildtarget
runfile = self.configs[kind].runfile
cmdargs = self.configs[kind].cmdargs
+ cpppaths = self.configs[kind].cpppaths
+ cppdefines = self.configs[kind].cppdefines
env_has_buildtarget = 'MSVSBUILDTARGET' in self.env
if not env_has_buildtarget:
@@ -1207,9 +1264,8 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
# This isn't perfect; CPPDEFINES and CPPPATH can contain $TARGET and $SOURCE,
# so they could vary depending on the command being generated. This code
# assumes they don't.
- preprocdefs = xmlify(';'.join(processDefines(self.env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(self.env.get('CPPPATH', []), self.env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ preprocdefs = xmlify(';'.join(processDefines(cppdefines)))
+ includepath = xmlify(';'.join(processIncludes(cpppaths, self.env, None, None)))
if not env_has_buildtarget:
del self.env['MSVSBUILDTARGET']
@@ -1226,14 +1282,15 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
raise SCons.Errors.InternalError('Unable to open "' + self.filtersabs + '" for writing:' + str(detail))
self.filters_file.write('<?xml version="1.0" encoding="utf-8"?>\n'
- '<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n')
+ '<Project ToolsVersion="%s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\n' %
+ self.versionstr)
self.PrintSourceFiles()
self.filters_file.write('</Project>')
self.filters_file.close()
- self.file.write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\n'
+ self.file.write('\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />\n'
'\t<ImportGroup Label="ExtensionTargets">\n'
'\t</ImportGroup>\n'
'</Project>\n')
@@ -1241,10 +1298,10 @@ class _GenerateV10DSP(_DSPGenerator, _GenerateV10User):
if self.nokeep == 0:
# now we pickle some data and add it to the file -- MSDEV will ignore it.
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write('<!-- SCons Data:\n' + pdata + '\n')
pdata = pickle.dumps(self.sources,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata + '-->\n')
def printFilters(self, hierarchy, name):
@@ -1451,13 +1508,16 @@ class _GenerateV7DSW(_DSWGenerator):
self.platforms = []
for key in list(self.configs.keys()):
platform = self.configs[key].platform
- if not platform in self.platforms:
+ if platform not in self.platforms:
self.platforms.append(platform)
def GenerateProjectFilesInfo(self):
for dspfile in self.dspfiles:
dsp_folder_path, name = os.path.split(dspfile)
dsp_folder_path = os.path.abspath(dsp_folder_path)
+ if SCons.Util.splitext(name)[1] == '.filters':
+ # Ignore .filters project files
+ continue
dsp_relative_folder_path = os.path.relpath(dsp_folder_path, self.dsw_folder_path)
if dsp_relative_folder_path == os.curdir:
dsp_relative_file_path = name
@@ -1491,6 +1551,7 @@ class _GenerateV7DSW(_DSWGenerator):
while line:
line = dswfile.readline()
datas = datas + line
+ dswfile.close()
# OK, we've found our little pickled cache of data.
try:
@@ -1506,7 +1567,11 @@ class _GenerateV7DSW(_DSWGenerator):
def PrintSolution(self):
"""Writes a solution file"""
self.file.write('Microsoft Visual Studio Solution File, Format Version %s\n' % self.versionstr)
- if self.version_num > 14.0:
+ if self.version_num >= 14.2:
+ # Visual Studio 2019 is considered to be version 16.
+ self.file.write('# Visual Studio 16\n')
+ elif self.version_num > 14.0:
+ # Visual Studio 2015 and 2017 are both considered to be version 15.
self.file.write('# Visual Studio 15\n')
elif self.version_num >= 12.0:
self.file.write('# Visual Studio 14\n')
@@ -1617,7 +1682,7 @@ class _GenerateV7DSW(_DSWGenerator):
self.file.write('EndGlobal\n')
if self.nokeep == 0:
pdata = pickle.dumps(self.configs,PICKLE_PROTOCOL)
- pdata = base64.encodestring(pdata).decode()
+ pdata = base64.b64encode(pdata).decode()
self.file.write(pdata)
self.file.write('\n')
@@ -1686,11 +1751,8 @@ def GenerateDSP(dspfile, source, env):
version_num = 6.0
if 'MSVS_VERSION' in env:
version_num, suite = msvs_parse_version(env['MSVS_VERSION'])
- if version_num > 14.0:
- g = _GenerateV10DSP(dspfile, V15DSPHeader, source, env)
- g.Build()
- elif version_num >= 10.0:
- g = _GenerateV10DSP(dspfile, V10DSPHeader, source, env)
+ if version_num >= 10.0:
+ g = _GenerateV10DSP(dspfile, source, env)
g.Build()
elif version_num >= 7.0:
g = _GenerateV7DSP(dspfile, source, env)
@@ -1730,7 +1792,7 @@ def GenerateProject(target, source, env):
dspfile = builddspfile.srcnode()
# this detects whether or not we're using a VariantDir
- if not dspfile is builddspfile:
+ if dspfile is not builddspfile:
try:
bdsp = open(str(builddspfile), "w+")
except IOError as detail:
@@ -1738,6 +1800,7 @@ def GenerateProject(target, source, env):
raise
bdsp.write("This is just a placeholder file.\nThe real project file is here:\n%s\n" % dspfile.get_abspath())
+ bdsp.close()
GenerateDSP(dspfile, source, env)
@@ -1745,7 +1808,7 @@ def GenerateProject(target, source, env):
builddswfile = target[1]
dswfile = builddswfile.srcnode()
- if not dswfile is builddswfile:
+ if dswfile is not builddswfile:
try:
bdsw = open(str(builddswfile), "w+")
@@ -1754,6 +1817,7 @@ def GenerateProject(target, source, env):
raise
bdsw.write("This is just a placeholder file.\nThe real workspace file is here:\n%s\n" % dswfile.get_abspath())
+ bdsw.close()
GenerateDSW(dswfile, source, env)
@@ -1781,11 +1845,10 @@ def projectEmitter(target, source, env):
# Project file depends on CPPDEFINES and CPPPATH
preprocdefs = xmlify(';'.join(processDefines(env.get('CPPDEFINES', []))))
- includepath_Dirs = processIncludes(env.get('CPPPATH', []), env, None, None)
- includepath = xmlify(';'.join([str(x) for x in includepath_Dirs]))
+ includepath = xmlify(';'.join(processIncludes(env.get('CPPPATH', []), env, None, None)))
source = source + "; ppdefs:%s incpath:%s"%(preprocdefs, includepath)
- if 'buildtarget' in env and env['buildtarget'] != None:
+ if 'buildtarget' in env and env['buildtarget'] is not None:
if SCons.Util.is_String(env['buildtarget']):
source = source + ' "%s"' % env['buildtarget']
elif SCons.Util.is_List(env['buildtarget']):
@@ -1799,7 +1862,7 @@ def projectEmitter(target, source, env):
try: source = source + ' "%s"' % env['buildtarget'].get_abspath()
except AttributeError: raise SCons.Errors.InternalError("buildtarget can be a string, a node, a list of strings or nodes, or None")
- if 'outdir' in env and env['outdir'] != None:
+ if 'outdir' in env and env['outdir'] is not None:
if SCons.Util.is_String(env['outdir']):
source = source + ' "%s"' % env['outdir']
elif SCons.Util.is_List(env['outdir']):
@@ -1962,8 +2025,14 @@ def generate(env):
default_MSVS_SConscript = env.File('SConstruct')
env['MSVSSCONSCRIPT'] = default_MSVS_SConscript
- env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env))
- env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'
+ # Allow consumers to provide their own versions of MSVSSCONS and
+ # MSVSSCONSFLAGS. This helps support consumers who use wrapper scripts to
+ # invoke scons.
+ if 'MSVSSCONS' not in env:
+ env['MSVSSCONS'] = '"%s" -c "%s"' % (python_executable, getExecScriptMain(env))
+ if 'MSVSSCONSFLAGS' not in env:
+ env['MSVSSCONSFLAGS'] = '-C "${MSVSSCONSCRIPT.dir.get_abspath()}" -f ${MSVSSCONSCRIPT.name}'
+
env['MSVSSCONSCOM'] = '$MSVSSCONS $MSVSSCONSFLAGS'
env['MSVSBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"'
env['MSVSREBUILDCOM'] = '$MSVSSCONSCOM "$MSVSBUILDTARGET"'
diff --git a/src/engine/SCons/Tool/msvs.xml b/src/engine/SCons/Tool/msvs.xml
index 7943f22..9f2353a 100644
--- a/src/engine/SCons/Tool/msvs.xml
+++ b/src/engine/SCons/Tool/msvs.xml
@@ -48,14 +48,16 @@ See its __doc__ string for a discussion of the format.
latest installed version, or the version specified by
&cv-link-MSVS_VERSION; in the Environment constructor). For
Visual Studio 6, it will generate a <filename>.dsp</filename>
- file. For Visual Studio 7 (.NET) and later versions, it will
- generate a <filename>.vcproj</filename> file.
+ file. For Visual Studio 7, 8, and 9, it will
+ generate a <filename>.vcproj</filename> file. For Visual
+ Studio 10 and later, it will generate a
+ <filename>.vcxproj</filename> file.
</para>
<para>
By default, this also generates a solution file for the
specified project, a <filename>.dsw</filename> file for
Visual Studio 6 or a <filename>.sln</filename> file for
- Visual Studio 7 (.NET). This behavior may be disabled by
+ Visual Studio 7 and later. This behavior may be disabled by
specifying <literal>auto_build_solution=0</literal> when you
call &b-MSVSProject;, in which case you presumably want to
build the solution file(s) by calling the &b-MSVSSolution;
@@ -128,6 +130,36 @@ See its __doc__ string for a discussion of the format.
</listitem>
</varlistentry>
<varlistentry>
+ <term>cppdefines</term>
+ <listitem>
+ <para>
+ Preprocessor definitions for the different variants.
+ The number of <literal>cppdefines</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPDEFINES</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>cpppaths</term>
+ <listitem>
+ <para>
+ Compiler include paths for the different variants.
+ The number of <literal>cpppaths</literal> entries
+ must match the number of <literal>variant</literal>
+ entries, or be empty (not specified). If you give
+ only one, it will automatically be propagated to all
+ variants. If you don't give this parameter, SCons
+ will use the invoking environment's
+ <literal>CPPPATH</literal> entry for all variants.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>buildtarget</term>
<listitem>
<para>
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index fd5e343..e0b5ced 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/msvsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
@@ -34,6 +34,7 @@ import TestUnit
from SCons.Tool.msvs import *
from SCons.Tool.MSCommon.vs import SupportedVSList
+import SCons.Node.FS
import SCons.Util
import SCons.Warnings
@@ -352,6 +353,36 @@ regdata_80 = r'''
"VCXDCMakeTool"="*.xdc"
'''.split('\n')
+regdata_140 = r'''
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
+"MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+"VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
+"VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
+"VS7CommonBinDir"=""
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
+"1033"="14.0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
+"IsInstallInProgress"="0"
+"CurrentOperation"="install"
+"SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
+"SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
+"InstallResult"="0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
+"Version"="7.0.20620.1"
+'''.split('\n')
+
regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"ProgramFilesDir"="C:\Program Files"
"CommonFilesDir"="C:\Program Files\Common Files"
@@ -363,6 +394,7 @@ regdata_none = []
class DummyEnv(object):
def __init__(self, dict=None):
+ self.fs = SCons.Node.FS.FS()
if dict:
self.dict = dict
else:
@@ -385,6 +417,16 @@ class DummyEnv(object):
def has_key(self,name):
return name in self.dict
+ def get(self, name, value=None):
+ if self.has_key(name):
+ return self.dict[name]
+ else:
+ return value
+
+ def Dir(self, name):
+ return self.fs.Dir(name)
+
+
class RegKey(object):
"""key class for storing an 'open' registry key"""
def __init__(self,key):
@@ -554,6 +596,11 @@ class msvsTestCase(unittest.TestCase):
from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
reset_installed_visual_studios()
+ self.test = TestCmd.TestCmd(workdir='')
+ # FS doesn't like the cwd to be something other than its root.
+ os.chdir(self.test.workpath(""))
+ self.fs = SCons.Node.FS.FS()
+
def test_get_default_version(self):
"""Test retrieval of the default visual studio version"""
@@ -607,13 +654,19 @@ class msvsTestCase(unittest.TestCase):
version_num, suite = msvs_parse_version(self.highest_version)
if version_num >= 10.0:
function_test = _GenerateV10DSP
+ suffix = '.vcxproj'
elif version_num >= 7.0:
function_test = _GenerateV7DSP
+ suffix = '.dsp'
else:
function_test = _GenerateV6DSP
+ suffix = '.dsp'
+
+ # Avoid any race conditions between the test cases when we test
+ # actually writing the files.
+ dspfile = 'test%s%s' % (hash(self), suffix)
str_function_test = str(function_test.__init__)
- dspfile = 'test.dsp'
source = 'test.cpp'
# Create the cmdargs test list
@@ -623,50 +676,95 @@ class msvsTestCase(unittest.TestCase):
'debug=False target_arch=32',
'debug=True target_arch=x64',
'debug=False target_arch=x64']
-
- # Tuple list : (parameter, dictionary of expected result per variant)
- tests_cmdargs = [(None, dict.fromkeys(list_variant, '')),
- ('', dict.fromkeys(list_variant, '')),
- (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])),
- (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))]
-
+ list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
+ list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
+ [self.fs.Dir('subdir')], []]
+
+ def TestParamsFromList(test_variant, test_list):
+ """
+ Generates test data based on the parameters passed in.
+
+ Returns tuple list:
+ 1. Parameter.
+ 2. Dictionary of expected result per variant.
+ """
+ def normalizeParam(param):
+ """
+ Converts the raw data based into the AddConfig function of
+ msvs.py to the expected result.
+
+ Expects the following behavior:
+ 1. A value of None will be converted to an empty list.
+ 2. A File or Directory object will be converted to an
+ absolute path (because those objects can't be pickled).
+ 3. Otherwise, the parameter will be used.
+ """
+ if param is None:
+ return []
+ elif isinstance(param, list):
+ return [normalizeParam(p) for p in param]
+ elif hasattr(param, 'abspath'):
+ return param.abspath
+ else:
+ return param
+
+ return [
+ (None, dict.fromkeys(test_variant, '')),
+ ('', dict.fromkeys(test_variant, '')),
+ (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
+ (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
+ ]
+
+ tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
+ tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
+ tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
+
# Run the test for each test case
for param_cmdargs, expected_cmdargs in tests_cmdargs:
- debug('Testing %s. with :\n variant = %s \n cmdargs = "%s"' % \
- (str_function_test, list_variant, param_cmdargs))
- param_configs = []
- expected_configs = {}
- for platform in ['Win32', 'x64']:
- for variant in ['Debug', 'Release']:
- variant_platform = '%s|%s' % (variant, platform)
- runfile = '%s\\%s\\test.exe' % (platform, variant)
- buildtarget = '%s\\%s\\test.exe' % (platform, variant)
- outdir = '%s\\%s' % (platform, variant)
+ for param_cppdefines, expected_cppdefines in tests_cppdefines:
+ for param_cpppaths, expected_cpppaths in tests_cpppaths:
+ debug('Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s"' % \
+ (str_function_test, list_variant, param_cmdargs, param_cppdefines, param_cpppaths))
+ param_configs = []
+ expected_configs = {}
+ for platform in ['Win32', 'x64']:
+ for variant in ['Debug', 'Release']:
+ variant_platform = '%s|%s' % (variant, platform)
+ runfile = '%s\\%s\\test.exe' % (platform, variant)
+ buildtarget = '%s\\%s\\test.exe' % (platform, variant)
+ outdir = '%s\\%s' % (platform, variant)
- # Create parameter list for this variant_platform
- param_configs.append([variant_platform, runfile, buildtarget, outdir])
-
- # Create expected dictionary result for this variant_platform
- expected_configs[variant_platform] = \
- {'variant': variant, 'platform': platform,
- 'runfile': runfile,
- 'buildtarget': buildtarget,
- 'outdir': outdir,
- 'cmdargs': expected_cmdargs[variant_platform]}
+ # Create parameter list for this variant_platform
+ param_configs.append([variant_platform, runfile, buildtarget, outdir])
+ # Create expected dictionary result for this variant_platform
+ expected_configs[variant_platform] = {
+ 'variant': variant,
+ 'platform': platform,
+ 'runfile': runfile,
+ 'buildtarget': buildtarget,
+ 'outdir': outdir,
+ 'cmdargs': expected_cmdargs[variant_platform],
+ 'cppdefines': expected_cppdefines[variant_platform],
+ 'cpppaths': expected_cpppaths[variant_platform],
+ }
+
# Create parameter environment with final parameter dictionary
param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
[list(l) for l in zip(*param_configs)])))
param_dict['cmdargs'] = param_cmdargs
+ param_dict['cppdefines'] = param_cppdefines
+ param_dict['cpppaths'] = param_cpppaths
# Hack to be able to run the test with a 'DummyEnv'
class _DummyEnv(DummyEnv):
- def subst(self, string) :
+ def subst(self, string, *args, **kwargs):
return string
env = _DummyEnv(param_dict)
env['MSVSSCONSCRIPT'] = ''
env['MSVS_VERSION'] = self.highest_version
+ env['MSVSBUILDTARGET'] = 'target'
# Call function to test
genDSP = function_test(dspfile, source, env)
@@ -676,6 +774,16 @@ class msvsTestCase(unittest.TestCase):
for key in list(genDSP.configs.keys()):
self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key])
+ genDSP.Build()
+
+ # Delete the resulting file so we don't leave anything behind.
+ for file in [dspfile, dspfile + '.filters']:
+ path = os.path.realpath(file)
+ try:
+ os.remove(path)
+ except OSError:
+ pass
+
class msvs6aTestCase(msvsTestCase):
"""Test MSVS 6 Registry"""
registry = DummyRegistry(regdata_6a + regdata_cv)
@@ -787,6 +895,18 @@ class msvs80TestCase(msvsTestCase):
}
default_install_loc = install_locs['8.0']
+class msvs140TestCase(msvsTestCase):
+ """Test MSVS 140 Registry"""
+ registry = DummyRegistry(regdata_140 + regdata_cv)
+ default_version = '14.0'
+ highest_version = '14.0'
+ number_of_versions = 2
+ install_locs = {
+ '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
+ 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
+ }
+ default_install_loc = install_locs['14.0']
+
class msvsEmptyTestCase(msvsTestCase):
"""Test Empty Registry"""
registry = DummyRegistry(regdata_none)
@@ -829,6 +949,7 @@ if __name__ == "__main__":
msvs71TestCase,
msvs8ExpTestCase,
msvs80TestCase,
+ msvs140TestCase,
msvsEmptyTestCase,
]
diff --git a/src/engine/SCons/Tool/mwcc.py b/src/engine/SCons/Tool/mwcc.py
index 5cad127..b2b2f5b 100644
--- a/src/engine/SCons/Tool/mwcc.py
+++ b/src/engine/SCons/Tool/mwcc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mwcc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mwcc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/mwld.py b/src/engine/SCons/Tool/mwld.py
index 7d7341a..5049c55 100644
--- a/src/engine/SCons/Tool/mwld.py
+++ b/src/engine/SCons/Tool/mwld.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/mwld.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/mwld.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
diff --git a/src/engine/SCons/Tool/nasm.py b/src/engine/SCons/Tool/nasm.py
index 8871ab6..d4d0a1b 100644
--- a/src/engine/SCons/Tool/nasm.py
+++ b/src/engine/SCons/Tool/nasm.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/nasm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/nasm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index 513e672..72b9eef 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -25,7 +25,7 @@ SCons Packaging Tool.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/packaging/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Environment
@@ -35,11 +35,11 @@ from SCons.Util import is_List, make_path_relative
from SCons.Warnings import warn, Warning
import os
-import imp
+import importlib
__all__ = [
- 'src_targz', 'src_tarbz2', 'src_xz', 'src_zip',
- 'targz', 'tarbz2', 'xz', 'zip',
+ 'src_targz', 'src_tarbz2', 'src_tarxz', 'src_zip',
+ 'targz', 'tarbz2', 'tarxz', 'zip',
'rpm', 'msi', 'ipk',
]
@@ -122,12 +122,12 @@ def Package(env, target=None, source=None, **kw):
# load the needed packagers.
def load_packager(type):
try:
- file,path,desc=imp.find_module(type, __path__)
- return imp.load_module(type, file, path, desc)
+ # the specific packager is a relative import
+ return importlib.import_module("." + type, __name__)
except ImportError as e:
- raise EnvironmentError("packager %s not available: %s"%(type,str(e)))
+ raise SConsEnvironmentError("packager %s not available: %s" % (type, str(e)))
- packagers=list(map(load_packager, PACKAGETYPE))
+ packagers = list(map(load_packager, PACKAGETYPE))
# set up targets and the PACKAGEROOT
try:
diff --git a/src/engine/SCons/Tool/packaging/ipk.py b/src/engine/SCons/Tool/packaging/ipk.py
index 60cd3cb..dbf5be8 100644
--- a/src/engine/SCons/Tool/packaging/ipk.py
+++ b/src/engine/SCons/Tool/packaging/ipk.py
@@ -3,7 +3,7 @@
#
# Copyright (c) 2001 - 2019 The SCons Foundation
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
@@ -24,7 +24,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/ipk.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/ipk.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -117,17 +117,17 @@ def build_specfiles(source, target, env):
#
#
opened_files={}
- def open_file(needle, haystack):
+ def open_file(needle, haystack=None):
try:
return opened_files[needle]
except KeyError:
files = filter(lambda x: x.get_path().rfind(needle) != -1, haystack)
# Py3: filter returns an iterable, not a list
file = list(files)[0]
- opened_files[needle]=open(file.get_abspath(), 'w')
+ opened_files[needle] = open(file.get_abspath(), 'w')
return opened_files[needle]
- control_file=open_file('control', target)
+ control_file = open_file('control', target)
if 'X_IPK_DESCRIPTION' not in env:
env['X_IPK_DESCRIPTION']="%s\n %s"%(env['SUMMARY'],
@@ -149,7 +149,7 @@ Description: $X_IPK_DESCRIPTION
control_file.write(env.subst(content))
#
- # now handle the various other files, which purpose it is to set post-,
+ # now handle the various other files, which purpose it is to set post-,
# pre-scripts and mark files as config files.
#
# We do so by filtering the source files for files which are marked with
@@ -161,14 +161,14 @@ Description: $X_IPK_DESCRIPTION
# into the same named file.
#
for f in [x for x in source if 'PACKAGING_CONFIG' in dir(x)]:
- config=open_file('conffiles')
+ config = open_file('conffiles')
config.write(f.PACKAGING_INSTALL_LOCATION)
config.write('\n')
for str in 'POSTRM PRERM POSTINST PREINST'.split():
name="PACKAGING_X_IPK_%s"%str
for f in [x for x in source if name in dir(x)]:
- file=open_file(name)
+ file = open_file(name)
file.write(env[str])
#
diff --git a/src/engine/SCons/Tool/packaging/msi.py b/src/engine/SCons/Tool/packaging/msi.py
index 4e8724b..4a48b47 100644
--- a/src/engine/SCons/Tool/packaging/msi.py
+++ b/src/engine/SCons/Tool/packaging/msi.py
@@ -25,7 +25,7 @@ The msi packager.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/packaging/msi.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/msi.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons
@@ -188,7 +188,7 @@ def build_wxsfile(target, source, env):
""" Compiles a .wxs file from the keywords given in env['msi_spec'] and
by analyzing the tree of source nodes and their tags.
"""
- file = open(target[0].get_abspath(), 'w')
+ f = open(target[0].get_abspath(), 'w')
try:
# Create a document with the Wix root tag
@@ -209,7 +209,7 @@ def build_wxsfile(target, source, env):
build_license_file(target[0].get_dir(), env)
# write the xml to a file
- file.write( doc.toprettyxml() )
+ f.write( doc.toprettyxml() )
# call a user specified function
if 'CHANGE_SPECFILE' in env:
@@ -217,6 +217,8 @@ def build_wxsfile(target, source, env):
except KeyError as e:
raise SCons.Errors.UserError( '"%s" package field for MSI is missing.' % e.args[0] )
+ finally:
+ f.close()
#
# setup function
@@ -440,14 +442,13 @@ def build_license_file(directory, spec):
pass # ignore this as X_MSI_LICENSE_TEXT is optional
if name!='' or text!='':
- file = open( os.path.join(directory.get_path(), 'License.rtf'), 'w' )
- file.write('{\\rtf')
- if text!='':
- file.write(text.replace('\n', '\\par '))
- else:
- file.write(name+'\\par\\par')
- file.write('}')
- file.close()
+ with open(os.path.join(directory.get_path(), 'License.rtf'), 'w') as f:
+ f.write('{\\rtf')
+ if text!='':
+ f.write(text.replace('\n', '\\par '))
+ else:
+ f.write(name+'\\par\\par')
+ f.write('}')
#
# mandatory and optional package tags
diff --git a/src/engine/SCons/Tool/packaging/rpm.py b/src/engine/SCons/Tool/packaging/rpm.py
index 48b9aab..a948e29 100644
--- a/src/engine/SCons/Tool/packaging/rpm.py
+++ b/src/engine/SCons/Tool/packaging/rpm.py
@@ -25,7 +25,7 @@ The rpm packager.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/packaging/rpm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/rpm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
@@ -125,11 +125,11 @@ def build_specfile(target, source, env):
""" Builds a RPM specfile from a dictionary with string metadata and
by analyzing a tree of nodes.
"""
- with open(target[0].get_abspath(), 'w') as file:
+ with open(target[0].get_abspath(), 'w') as ofp:
try:
- file.write(build_specfile_header(env))
- file.write(build_specfile_sections(env))
- file.write(build_specfile_filesection(env, source))
+ ofp.write(build_specfile_header(env))
+ ofp.write(build_specfile_sections(env))
+ ofp.write(build_specfile_filesection(env, source))
# call a user specified function
if 'CHANGE_SPECFILE' in env:
diff --git a/src/engine/SCons/Tool/packaging/src_tarbz2.py b/src/engine/SCons/Tool/packaging/src_tarbz2.py
index 473ce75..b628ccd 100644
--- a/src/engine/SCons/Tool/packaging/src_tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/src_tarbz2.py
@@ -26,7 +26,7 @@ The tarbz2 SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_tarbz2.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_tarbz2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_targz.py b/src/engine/SCons/Tool/packaging/src_targz.py
index 865b8dd..4c7469c 100644
--- a/src/engine/SCons/Tool/packaging/src_targz.py
+++ b/src/engine/SCons/Tool/packaging/src_targz.py
@@ -26,7 +26,7 @@ The targz SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_targz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_targz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_tarxz.py b/src/engine/SCons/Tool/packaging/src_tarxz.py
index 07ffdb0..6688c46 100644
--- a/src/engine/SCons/Tool/packaging/src_tarxz.py
+++ b/src/engine/SCons/Tool/packaging/src_tarxz.py
@@ -26,7 +26,7 @@ The tarxz SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_tarxz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_tarxz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/src_zip.py b/src/engine/SCons/Tool/packaging/src_zip.py
index 819e52a..d56f3aa 100644
--- a/src/engine/SCons/Tool/packaging/src_zip.py
+++ b/src/engine/SCons/Tool/packaging/src_zip.py
@@ -26,7 +26,7 @@ The zip SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/src_zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/src_zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/tarbz2.py b/src/engine/SCons/Tool/packaging/tarbz2.py
index 5658de3..e371f1b 100644
--- a/src/engine/SCons/Tool/packaging/tarbz2.py
+++ b/src/engine/SCons/Tool/packaging/tarbz2.py
@@ -26,7 +26,7 @@ The tarbz2 packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/tarbz2.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/tarbz2.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/targz.py b/src/engine/SCons/Tool/packaging/targz.py
index f515f1e..121e4a4 100644
--- a/src/engine/SCons/Tool/packaging/targz.py
+++ b/src/engine/SCons/Tool/packaging/targz.py
@@ -26,7 +26,7 @@ The targz packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/targz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/targz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/tarxz.py b/src/engine/SCons/Tool/packaging/tarxz.py
index 5f7a8d8..3ec9822 100644
--- a/src/engine/SCons/Tool/packaging/tarxz.py
+++ b/src/engine/SCons/Tool/packaging/tarxz.py
@@ -26,7 +26,7 @@ The tarxz packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/tarxz.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/tarxz.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/packaging/zip.py b/src/engine/SCons/Tool/packaging/zip.py
index 2ae496e..11ab3b5 100644
--- a/src/engine/SCons/Tool/packaging/zip.py
+++ b/src/engine/SCons/Tool/packaging/zip.py
@@ -26,7 +26,7 @@ The zip SRC packager.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/packaging/zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/packaging/zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Tool.packaging import stripinstallbuilder, putintopackageroot
diff --git a/src/engine/SCons/Tool/pdf.py b/src/engine/SCons/Tool/pdf.py
index da970ff..50988b6 100644
--- a/src/engine/SCons/Tool/pdf.py
+++ b/src/engine/SCons/Tool/pdf.py
@@ -28,7 +28,7 @@ Add an explicit action to run epstopdf to convert .eps files to .pdf
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdf.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdf.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Tool
diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py
index 2a97d0f..2c559f7 100644
--- a/src/engine/SCons/Tool/pdflatex.py
+++ b/src/engine/SCons/Tool/pdflatex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdflatex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdflatex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Util
diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py
index 80913ae..c658aa0 100644
--- a/src/engine/SCons/Tool/pdftex.py
+++ b/src/engine/SCons/Tool/pdftex.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/pdftex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/pdftex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import SCons.Action
diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py
index e8b0325..a582e6f 100644
--- a/src/engine/SCons/Tool/qt.py
+++ b/src/engine/SCons/Tool/qt.py
@@ -33,7 +33,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/qt.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/qt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
@@ -66,11 +66,17 @@ if SCons.Util.case_sensitive_suffixes('.h', '.H'):
cxx_suffixes = cplusplus.CXXSuffixes
-#
def find_platform_specific_qt_paths():
"""
- If the platform has non-standard paths which it installs QT in,return the likely default path
- :return:
+ find non-standard QT paths
+
+ If the platform does not put QT tools in standard search paths,
+ the path is expected to be set using QTDIR. SCons violates
+ the normal rule of not pulling from the user's environment
+ in this case. However, some test cases try to validate what
+ happens when QTDIR is unset, so we need to try to make a guess.
+
+ :return: a guess at a path
"""
# qt_bin_dirs = []
@@ -83,6 +89,7 @@ def find_platform_specific_qt_paths():
# Centos installs QT under /usr/{lib,lib64}/qt{4,5,-3.3}/bin
# so we need to handle this differently
# qt_bin_dirs = glob.glob('/usr/lib64/qt*/bin')
+ # TODO: all current Fedoras do the same, need to look deeper here.
qt_bin_dir = '/usr/lib64/qt-3.3/bin'
return qt_bin_dir
@@ -97,7 +104,7 @@ def checkMocIncluded(target, source, env):
# not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
path = SCons.Defaults.CScan.path(env, moc.cwd)
includes = SCons.Defaults.CScan(cpp, env, path)
- if not moc in includes:
+ if moc not in includes:
SCons.Warnings.warn(
GeneratedMocFileNotIncluded,
"Generated moc file '%s' is not included by '%s'" %
@@ -118,7 +125,7 @@ class _Automoc(object):
def __init__(self, objBuilderName):
self.objBuilderName = objBuilderName
-
+
def __call__(self, target, source, env):
"""
Smart autoscan function. Gets the list of objects for the Program
@@ -133,25 +140,25 @@ class _Automoc(object):
debug = int(env.subst('$QT_DEBUG'))
except ValueError:
debug = 0
-
+
# some shortcuts used in the scanner
splitext = SCons.Util.splitext
objBuilder = getattr(env, self.objBuilderName)
-
+
# some regular expressions:
# Q_OBJECT detection
- q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
# cxx and c comment 'eater'
#comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
# CW: something must be wrong with the regexp. See also bug #998222
# CURRENTLY THERE IS NO TEST CASE FOR THAT
-
+
# The following is kind of hacky to get builders working properly (FIXME)
objBuilderEnv = objBuilder.env
objBuilder.env = env
mocBuilderEnv = env.Moc.env
env.Moc.env = env
-
+
# make a deep copy for the result; MocH objects will be appended
out_sources = source[:]
@@ -164,7 +171,7 @@ class _Automoc(object):
cpp = obj.sources[0]
if not splitext(str(cpp))[1] in cxx_suffixes:
if debug:
- print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
+ print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
# c or fortran source
continue
#cpp_contents = comment.sub('', cpp.get_text_contents())
@@ -260,7 +267,7 @@ def uicScannerFunc(node, env, path):
return result
uicScanner = SCons.Scanner.Base(uicScannerFunc,
- name = "UicScanner",
+ name = "UicScanner",
node_class = SCons.Node.FS.File,
node_factory = SCons.Node.FS.File,
recursive = 0)
@@ -336,7 +343,7 @@ def generate(env):
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
- # register the builders
+ # register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
diff --git a/src/engine/SCons/Tool/rmic.py b/src/engine/SCons/Tool/rmic.py
index 1d401fd..d6f7b2b 100644
--- a/src/engine/SCons/Tool/rmic.py
+++ b/src/engine/SCons/Tool/rmic.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rmic.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rmic.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
@@ -110,11 +110,9 @@ def generate(env):
if env['PLATFORM'] == 'win32':
version = env.get('JAVAVERSION', None)
- default_paths=get_java_install_dirs(env['PLATFORM'], version=version)
-
# Ensure that we have a proper path for rmic
- rmic = SCons.Tool.find_program_path(env, 'rmic', default_paths=default_paths)
-
+ paths = get_java_install_dirs('win32', version=version)
+ rmic = SCons.Tool.find_program_path(env, 'rmic', default_paths=paths)
# print("RMIC: %s"%rmic)
if rmic:
rmic_bin_dir = os.path.dirname(rmic)
diff --git a/src/engine/SCons/Tool/rpcgen.py b/src/engine/SCons/Tool/rpcgen.py
index 349af6a..b9f8ca6 100644
--- a/src/engine/SCons/Tool/rpcgen.py
+++ b/src/engine/SCons/Tool/rpcgen.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rpcgen.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpcgen.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from SCons.Builder import Builder
import SCons.Util
diff --git a/src/engine/SCons/Tool/rpm.py b/src/engine/SCons/Tool/rpm.py
index 61e4185..0253365 100644
--- a/src/engine/SCons/Tool/rpm.py
+++ b/src/engine/SCons/Tool/rpm.py
@@ -33,7 +33,7 @@ tar.gz consisting of the source file and a specfile.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/rpm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import re
@@ -51,43 +51,44 @@ def get_cmd(source, env):
if SCons.Util.is_List(source):
tar_file_with_included_specfile = source[0]
return "%s %s %s"%(env['RPM'], env['RPMFLAGS'],
- tar_file_with_included_specfile.get_abspath() )
+ tar_file_with_included_specfile.get_abspath())
def build_rpm(target, source, env):
# create a temporary rpm build root.
- tmpdir = os.path.join( os.path.dirname( target[0].get_abspath() ), 'rpmtemp' )
+ tmpdir = os.path.join(os.path.dirname(target[0].get_abspath()), 'rpmtemp')
if os.path.exists(tmpdir):
shutil.rmtree(tmpdir)
# now create the mandatory rpm directory structure.
for d in ['RPMS', 'SRPMS', 'SPECS', 'BUILD']:
- os.makedirs( os.path.join( tmpdir, d ) )
+ os.makedirs(os.path.join(tmpdir, d))
# set the topdir as an rpmflag.
- env.Prepend( RPMFLAGS = '--define \'_topdir %s\'' % tmpdir )
+ env.Prepend(RPMFLAGS = '--define \'_topdir %s\'' % tmpdir)
# now call rpmbuild to create the rpm package.
handle = subprocess.Popen(get_cmd(source, env),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True)
- output = SCons.Util.to_str(handle.stdout.read())
+ with handle.stdout:
+ output = SCons.Util.to_str(handle.stdout.read())
status = handle.wait()
if status:
- raise SCons.Errors.BuildError( node=target[0],
- errstr=output,
- filename=str(target[0]) )
+ raise SCons.Errors.BuildError(node=target[0],
+ errstr=output,
+ filename=str(target[0]))
else:
# XXX: assume that LC_ALL=C is set while running rpmbuild
- output_files = re.compile( 'Wrote: (.*)' ).findall( output )
+ output_files = re.compile('Wrote: (.*)').findall(output)
- for output, input in zip( output_files, target ):
+ for output, input in zip(output_files, target):
rpm_output = os.path.basename(output)
expected = os.path.basename(input.get_path())
assert expected == rpm_output, "got %s but expected %s" % (rpm_output, expected)
- shutil.copy( output, input.get_abspath() )
+ shutil.copy(output, input.get_abspath())
# cleanup before leaving.
diff --git a/src/engine/SCons/Tool/rpmutils.py b/src/engine/SCons/Tool/rpmutils.py
index 10bb28d..a2400ff 100644
--- a/src/engine/SCons/Tool/rpmutils.py
+++ b/src/engine/SCons/Tool/rpmutils.py
@@ -36,7 +36,7 @@ exact syntax.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/rpmutils.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/rpmutils.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import platform
@@ -482,9 +482,11 @@ def updateRpmDicts(rpmrc, pyfile):
"""
try:
# Read old rpmutils.py file
- oldpy = open(pyfile,"r").readlines()
+ with open(pyfile,"r") as f:
+ oldpy = f.readlines()
# Read current rpmrc.in file
- rpm = open(rpmrc,"r").readlines()
+ with open(rpmrc,"r") as f:
+ rpm = f.readlines()
# Parse for data
data = {}
# Allowed section names that get parsed
@@ -511,24 +513,23 @@ def updateRpmDicts(rpmrc, pyfile):
# Insert data
data[key][tokens[1]] = tokens[2:]
# Write new rpmutils.py file
- out = open(pyfile,"w")
- pm = 0
- for l in oldpy:
- if pm:
- if l.startswith('# End of rpmrc dictionaries'):
- pm = 0
+ with open(pyfile,"w") as out:
+ pm = 0
+ for l in oldpy:
+ if pm:
+ if l.startswith('# End of rpmrc dictionaries'):
+ pm = 0
+ out.write(l)
+ else:
out.write(l)
- else:
- out.write(l)
- if l.startswith('# Start of rpmrc dictionaries'):
- pm = 1
- # Write data sections to single dictionaries
- for key, entries in data.items():
- out.write("%s = {\n" % key)
- for arch in sorted(entries.keys()):
- out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
- out.write("}\n\n")
- out.close()
+ if l.startswith('# Start of rpmrc dictionaries'):
+ pm = 1
+ # Write data sections to single dictionaries
+ for key, entries in data.items():
+ out.write("%s = {\n" % key)
+ for arch in sorted(entries.keys()):
+ out.write(" '%s' : ['%s'],\n" % (arch, "','".join(entries[arch])))
+ out.write("}\n\n")
except:
pass
diff --git a/src/engine/SCons/Tool/sgiar.py b/src/engine/SCons/Tool/sgiar.py
index 152afd4..d82ec89 100644
--- a/src/engine/SCons/Tool/sgiar.py
+++ b/src/engine/SCons/Tool/sgiar.py
@@ -33,7 +33,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgiar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgiar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/sgic++.py b/src/engine/SCons/Tool/sgic++.py
index 35f913f..84d775a 100644
--- a/src/engine/SCons/Tool/sgic++.py
+++ b/src/engine/SCons/Tool/sgic++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgic++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgic++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
from SCons.Tool.sgicxx import *
diff --git a/src/engine/SCons/Tool/sgicc.py b/src/engine/SCons/Tool/sgicc.py
index c5461e3..537f1a3 100644
--- a/src/engine/SCons/Tool/sgicc.py
+++ b/src/engine/SCons/Tool/sgicc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgicc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgicc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
from . import cc
diff --git a/src/engine/SCons/Tool/sgicxx.py b/src/engine/SCons/Tool/sgicxx.py
index 7656939..d44ec26 100644
--- a/src/engine/SCons/Tool/sgicxx.py
+++ b/src/engine/SCons/Tool/sgicxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgicxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgicxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sgilink.py b/src/engine/SCons/Tool/sgilink.py
index 366b227..ca9e69c 100644
--- a/src/engine/SCons/Tool/sgilink.py
+++ b/src/engine/SCons/Tool/sgilink.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sgilink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sgilink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunar.py b/src/engine/SCons/Tool/sunar.py
index 6745511..07d45b2 100644
--- a/src/engine/SCons/Tool/sunar.py
+++ b/src/engine/SCons/Tool/sunar.py
@@ -32,7 +32,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Defaults
import SCons.Tool
diff --git a/src/engine/SCons/Tool/sunc++.py b/src/engine/SCons/Tool/sunc++.py
index f1bbf14..1611fe9 100644
--- a/src/engine/SCons/Tool/sunc++.py
+++ b/src/engine/SCons/Tool/sunc++.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunc++.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunc++.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
#forward proxy to the preffered cxx version
diff --git a/src/engine/SCons/Tool/suncc.py b/src/engine/SCons/Tool/suncc.py
index 49cfa70..da6ca6e 100644
--- a/src/engine/SCons/Tool/suncc.py
+++ b/src/engine/SCons/Tool/suncc.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/suncc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/suncc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/suncxx.py b/src/engine/SCons/Tool/suncxx.py
index 1fa5331..1ee1c6a 100644
--- a/src/engine/SCons/Tool/suncxx.py
+++ b/src/engine/SCons/Tool/suncxx.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/suncxx.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/suncxx.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
@@ -52,11 +52,17 @@ def get_package_info(package_name, pkginfo, pkgchk):
version = None
pathname = None
try:
- sadm_contents = open('/var/sadm/install/contents', 'r').read()
+ from subprocess import DEVNULL # py3k
+ except ImportError:
+ DEVNULL = open(os.devnull, 'wb')
+
+ try:
+ with open('/var/sadm/install/contents', 'r') as f:
+ sadm_contents = f.read()
except EnvironmentError:
pass
else:
- sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M)
+ sadm_re = re.compile(r'^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M)
sadm_match = sadm_re.search(sadm_contents)
if sadm_match:
pathname = os.path.dirname(sadm_match.group(1))
@@ -64,12 +70,12 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
p = subprocess.Popen([pkginfo, '-l', package_name],
stdout=subprocess.PIPE,
- stderr=open('/dev/null', 'w'))
+ stderr=DEVNULL)
except EnvironmentError:
pass
else:
pkginfo_contents = p.communicate()[0]
- version_re = re.compile('^ *VERSION:\s*(.*)$', re.M)
+ version_re = re.compile(r'^ *VERSION:\s*(.*)$', re.M)
version_match = version_re.search(pkginfo_contents)
if version_match:
version = version_match.group(1)
@@ -78,7 +84,7 @@ def get_package_info(package_name, pkginfo, pkgchk):
try:
p = subprocess.Popen([pkgchk, '-l', package_name],
stdout=subprocess.PIPE,
- stderr=open('/dev/null', 'w'))
+ stderr=DEVNULL)
except EnvironmentError:
pass
else:
diff --git a/src/engine/SCons/Tool/sunf77.py b/src/engine/SCons/Tool/sunf77.py
index 1d9487d..c1c216f 100644
--- a/src/engine/SCons/Tool/sunf77.py
+++ b/src/engine/SCons/Tool/sunf77.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf77.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf77.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunf90.py b/src/engine/SCons/Tool/sunf90.py
index 4de62c3..4cabee8 100644
--- a/src/engine/SCons/Tool/sunf90.py
+++ b/src/engine/SCons/Tool/sunf90.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf90.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf90.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunf95.py b/src/engine/SCons/Tool/sunf95.py
index 6d1ccf6..077b1bc 100644
--- a/src/engine/SCons/Tool/sunf95.py
+++ b/src/engine/SCons/Tool/sunf95.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunf95.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunf95.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Util
diff --git a/src/engine/SCons/Tool/sunlink.py b/src/engine/SCons/Tool/sunlink.py
index 1eca1b2..8d965fa 100644
--- a/src/engine/SCons/Tool/sunlink.py
+++ b/src/engine/SCons/Tool/sunlink.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/sunlink.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/sunlink.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index a207a89..2e61b91 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -32,7 +32,7 @@ from __future__ import print_function
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/swig.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/swig.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -184,9 +184,10 @@ def generate(env):
from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
if sys.platform == 'win32':
- swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + [r'C:\ProgramData\chocolatey\bin'] )
+ swig = SCons.Tool.find_program_path(env, 'swig', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS + CHOCO_DEFAULT_PATH)
if swig:
swig_bin_dir = os.path.dirname(swig)
env.AppendENVPath('PATH', swig_bin_dir)
diff --git a/src/engine/SCons/Tool/tar.py b/src/engine/SCons/Tool/tar.py
index ac4f7f7..08c80f2 100644
--- a/src/engine/SCons/Tool/tar.py
+++ b/src/engine/SCons/Tool/tar.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/tar.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tar.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Action
import SCons.Builder
diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py
index 2fecd1d..9beb557 100644
--- a/src/engine/SCons/Tool/tex.py
+++ b/src/engine/SCons/Tool/tex.py
@@ -33,7 +33,7 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/tex.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tex.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
@@ -781,7 +781,7 @@ def tex_emitter_core(target, source, env, graphics_extensions):
# add side effects if feature is present.If file is to be generated,add all side effects
if Verbose and theSearch:
print("check side effects for ",suffix_list[-1])
- if (theSearch != None) or (not source[0].exists() ):
+ if theSearch is not None or not source[0].exists():
file_list = [targetbase,]
# for bibunit we need a list of files
if suffix_list[-1] == 'bibunit':
diff --git a/src/engine/SCons/Tool/textfile.py b/src/engine/SCons/Tool/textfile.py
index bbbde9f..58a5007 100644
--- a/src/engine/SCons/Tool/textfile.py
+++ b/src/engine/SCons/Tool/textfile.py
@@ -44,7 +44,7 @@ Textfile/Substfile builder for SCons.
is unpredictable whether the expansion will occur.
"""
-__revision__ = "src/engine/SCons/Tool/textfile.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/textfile.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons
diff --git a/src/engine/SCons/Tool/tlib.py b/src/engine/SCons/Tool/tlib.py
index e1483a2..4d8101b 100644
--- a/src/engine/SCons/Tool/tlib.py
+++ b/src/engine/SCons/Tool/tlib.py
@@ -27,7 +27,7 @@ XXX
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/tlib.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/tlib.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Tool
import SCons.Tool.bcc32
diff --git a/src/engine/SCons/Tool/wix.py b/src/engine/SCons/Tool/wix.py
index bba033e..e79e4a1 100644
--- a/src/engine/SCons/Tool/wix.py
+++ b/src/engine/SCons/Tool/wix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/wix.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/wix.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.Builder
import SCons.Action
diff --git a/src/engine/SCons/Tool/wixTests.py b/src/engine/SCons/Tool/wixTests.py
index c1812a2..f2649a3 100644
--- a/src/engine/SCons/Tool/wixTests.py
+++ b/src/engine/SCons/Tool/wixTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/wixTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/wixTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import unittest
import os.path
diff --git a/src/engine/SCons/Tool/xgettext.py b/src/engine/SCons/Tool/xgettext.py
index 3f11357..185558e 100644
--- a/src/engine/SCons/Tool/xgettext.py
+++ b/src/engine/SCons/Tool/xgettext.py
@@ -24,7 +24,24 @@ Tool specific initialization of `xgettext` tool.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Tool/xgettext.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/xgettext.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
+
+import os
+import re
+import subprocess
+import sys
+
+import SCons.Action
+import SCons.Node.FS
+import SCons.Tool
+import SCons.Util
+from SCons.Builder import BuilderBase
+from SCons.Environment import _null
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Tool.GettextCommon import _POTargetFactory
+from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
+from SCons.Tool.GettextCommon import _xgettext_exists
#############################################################################
@@ -41,10 +58,6 @@ class _CmdRunner(object):
self.commandstr = commandstr
def __call__(self, target, source, env):
- import SCons.Action
- import subprocess
- import os
- import sys
kw = {
'stdin': 'devnull',
'stdout': subprocess.PIPE,
@@ -57,11 +70,10 @@ class _CmdRunner(object):
self.out, self.err = proc.communicate()
self.status = proc.wait()
if self.err:
- sys.stderr.write(unicode(self.err))
+ sys.stderr.write(SCons.Util.UnicodeType(self.err))
return self.status
def strfunction(self, target, source, env):
- import os
comstr = self.commandstr
if env.subst(comstr, target=target, source=source) == "":
comstr = self.command
@@ -74,9 +86,6 @@ class _CmdRunner(object):
#############################################################################
def _update_pot_file(target, source, env):
""" Action function for `POTUpdate` builder """
- import re
- import os
- import SCons.Action
nop = lambda target, source, env: 0
# Save scons cwd and os cwd (NOTE: they may be different. After the job, we
@@ -154,10 +163,6 @@ def _update_pot_file(target, source, env):
#############################################################################
#############################################################################
-from SCons.Builder import BuilderBase
-
-
-#############################################################################
class _POTBuilder(BuilderBase):
def _execute(self, env, target, source, *args):
if not target:
@@ -175,10 +180,6 @@ class _POTBuilder(BuilderBase):
def _scan_xgettext_from_files(target, source, env, files=None, path=None):
""" Parses `POTFILES.in`-like file and returns list of extracted file names.
"""
- import re
- import SCons.Util
- import SCons.Node.FS
-
if files is None:
return 0
if not SCons.Util.is_List(files):
@@ -230,10 +231,6 @@ def _scan_xgettext_from_files(target, source, env, files=None, path=None):
#############################################################################
def _pot_update_emitter(target, source, env):
""" Emitter function for `POTUpdate` builder """
- from SCons.Tool.GettextCommon import _POTargetFactory
- import SCons.Util
- import SCons.Node.FS
-
if 'XGETTEXTFROM' in env:
xfrom = env['XGETTEXTFROM']
else:
@@ -261,10 +258,6 @@ def _pot_update_emitter(target, source, env):
#############################################################################
#############################################################################
-from SCons.Environment import _null
-
-
-#############################################################################
def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
return env._POTUpdateBuilder(target, source, **kw)
@@ -274,8 +267,6 @@ def _POTUpdateBuilderWrapper(env, target=None, source=_null, **kw):
#############################################################################
def _POTUpdateBuilder(env, **kw):
""" Creates `POTUpdate` builder object """
- import SCons.Action
- from SCons.Tool.GettextCommon import _POTargetFactory
kw['action'] = SCons.Action.Action(_update_pot_file, None)
kw['suffix'] = '$POTSUFFIX'
kw['target_factory'] = _POTargetFactory(env, alias='$POTUPDATE_ALIAS').File
@@ -288,13 +279,6 @@ def _POTUpdateBuilder(env, **kw):
#############################################################################
def generate(env, **kw):
""" Generate `xgettext` tool """
- import sys
- import os
- import SCons.Util
- import SCons.Tool
- from SCons.Tool.GettextCommon import RPaths, _detect_xgettext
- from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
- from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
if sys.platform == 'win32':
xgettext = SCons.Tool.find_program_path(env, 'xgettext', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
@@ -359,7 +343,6 @@ def generate(env, **kw):
#############################################################################
def exists(env):
""" Check, whether the tool exists """
- from SCons.Tool.GettextCommon import _xgettext_exists
try:
return _xgettext_exists(env)
except:
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index d397de1..6857574 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/yacc.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/yacc.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -45,6 +45,11 @@ from SCons.Platform.win32 import CHOCO_DEFAULT_PATH
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
+if sys.platform == 'win32':
+ BINS = ['bison', 'yacc', 'win_bison']
+else:
+ BINS = ["bison", "yacc"]
+
def _yaccEmitter(target, source, env, ysuf, hsuf):
yaccflags = env.subst("$YACCFLAGS", target=target, source=source)
flags = SCons.Util.CLVar(yaccflags)
@@ -100,25 +105,26 @@ def yyEmitter(target, source, env):
def get_yacc_path(env, append_paths=False):
"""
- Find the a path containing the lex or flex binaries. If a construction
- environment is passed in then append the path to the ENV PATH.
- """
- # save existing path to reset if we don't want to append any paths
- envPath = env['ENV']['PATH']
- bins = ['bison', 'yacc', 'win_bison']
+ Find the path to the yacc tool, searching several possible names
+
+ Only called in the Windows case, so the default_path
+ can be Windows-specific
- for prog in bins:
+ :param env: current construction environment
+ :param append_paths: if set, add the path to the tool to PATH
+ :return: path to yacc tool, if found
+ """
+ for prog in BINS:
bin_path = SCons.Tool.find_program_path(
- env,
- prog,
+ env,
+ prog,
default_paths=CHOCO_DEFAULT_PATH + MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
if bin_path:
- if not append_paths:
- env['ENV']['PATH'] = envPath
- else:
+ if append_paths:
env.AppendENVPath('PATH', os.path.dirname(bin_path))
return bin_path
- SCons.Warnings.Warning('lex tool requested, but lex or flex binary not found in ENV PATH')
+ SCons.Warnings.Warning('yacc tool requested, but yacc or bison binary not found in ENV PATH')
+
def generate(env):
"""Add Builders and construction variables for yacc to an Environment."""
@@ -140,29 +146,21 @@ def generate(env):
cxx_file.add_emitter('.yy', yyEmitter)
if sys.platform == 'win32':
- bison = SCons.Tool.find_program_path(env, 'bison', default_paths=MINGW_DEFAULT_PATHS + CYGWIN_DEFAULT_PATHS )
- if bison:
- bison_bin_dir = os.path.dirname(bison)
- env.AppendENVPath('PATH', bison_bin_dir)
- else:
- SCons.Warnings.Warning('yacc tool requested, but bison binary not found in ENV PATH')
+ # ignore the return, all we need is for the path to be added
+ _ = get_yacc_path(env, append_paths=True)
- if sys.platform == 'win32':
- get_yacc_path(env, append_paths=True)
- env["YACC"] = env.Detect(['bison', 'yacc', 'win_bison'])
- else:
- env["YACC"] = env.Detect(["bison", "yacc"])
-
+ env["YACC"] = env.Detect(BINS)
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
env['YACCHFILESUFFIX'] = '.h'
-
env['YACCHXXFILESUFFIX'] = '.hpp'
-
env['YACCVCGFILESUFFIX'] = '.vcg'
def exists(env):
- return env.Detect(['bison', 'yacc'])
+ if sys.platform == 'win32':
+ return get_yacc_path(env)
+ else:
+ return env.Detect(BINS)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/Tool/zip.py b/src/engine/SCons/Tool/zip.py
index 55792c2..b7efdc7 100644
--- a/src/engine/SCons/Tool/zip.py
+++ b/src/engine/SCons/Tool/zip.py
@@ -31,7 +31,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Tool/zip.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/zip.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index f2498e9..5b4c225 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -24,7 +24,7 @@ Various utility functions go here.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Util.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Util.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
@@ -33,6 +33,7 @@ import re
import types
import codecs
import pprint
+import hashlib
PY3 = sys.version_info[0] == 3
@@ -656,13 +657,15 @@ except ImportError:
pass
RegError = _NoError
-WinError = None
+
# Make sure we have a definition of WindowsError so we can
# run platform-independent tests of Windows functionality on
# platforms other than Windows. (WindowsError is, in fact, an
# OSError subclass on Windows.)
+
class PlainWindowsError(OSError):
pass
+
try:
WinError = WindowsError
except NameError:
@@ -676,7 +679,7 @@ if can_read_reg:
HKEY_USERS = hkey_mod.HKEY_USERS
def RegGetValue(root, key):
- """This utility function returns a value in the registry
+ r"""This utility function returns a value in the registry
without having to open the key first. Only available on
Windows platforms with a version of Python that can read the
registry. Returns the same thing as
@@ -883,7 +886,7 @@ def PrependPath(oldpath, newpath, sep = os.pathsep,
# now we add them only if they are unique
for path in newpaths:
normpath = os.path.normpath(os.path.normcase(path))
- if path and not normpath in normpaths:
+ if path and normpath not in normpaths:
paths.append(path)
normpaths.append(normpath)
@@ -963,7 +966,7 @@ def AppendPath(oldpath, newpath, sep = os.pathsep,
# now we add them only if they are unique
for path in newpaths:
normpath = os.path.normpath(os.path.normcase(path))
- if path and not normpath in normpaths:
+ if path and normpath not in normpaths:
paths.append(path)
normpaths.append(normpath)
paths.reverse()
@@ -999,7 +1002,9 @@ if sys.platform == 'cygwin':
def get_native_path(path):
"""Transforms an absolute path into a native path for the system. In
Cygwin, this converts from a Cygwin path to a Windows one."""
- return os.popen('cygpath -w ' + path).read().replace('\n', '')
+ with os.popen('cygpath -w ' + path) as p:
+ npath = p.read().replace('\n', '')
+ return npath
else:
def get_native_path(path):
"""Transforms an absolute path into a native path for the system.
@@ -1176,10 +1181,13 @@ def unique(s):
# ASPN: Python Cookbook: Remove duplicates from a sequence
# First comment, dated 2001/10/13.
# (Also in the printed Python Cookbook.)
+# This not currently used, in favor of the next function...
def uniquer(seq, idfun=None):
- if idfun is None:
- def idfun(x): return x
+ def default_idfun(x):
+ return x
+ if not idfun:
+ idfun = default_idfun
seen = {}
result = []
for item in seq:
@@ -1444,56 +1452,53 @@ def RenameFunction(function, name):
function.__defaults__)
-md5 = False
-
+if hasattr(hashlib, 'md5'):
+ md5 = True
-def MD5signature(s):
- return str(s)
+ def MD5signature(s):
+ """
+ Generate md5 signature of a string
+ :param s: either string or bytes. Normally should be bytes
+ :return: String of hex digits representing the signature
+ """
+ m = hashlib.md5()
-def MD5filesignature(fname, chunksize=65536):
- with open(fname, "rb") as f:
- result = f.read()
- return result
+ try:
+ m.update(to_bytes(s))
+ except TypeError as e:
+ m.update(to_bytes(str(s)))
-try:
- import hashlib
-except ImportError:
- pass
-else:
- if hasattr(hashlib, 'md5'):
- md5 = True
+ return m.hexdigest()
- def MD5signature(s):
- """
- Generate a String of Hex digits representing the md5 signature of the string
- :param s: either string or bytes. Normally should be bytes
- :return: String of hex digits
- """
- m = hashlib.md5()
+ def MD5filesignature(fname, chunksize=65536):
+ """
+ Generate the md5 signature of a file
- try:
- m.update(to_bytes(s))
- except TypeError as e:
- m.update(to_bytes(str(s)))
-
- return m.hexdigest()
-
- def MD5filesignature(fname, chunksize=65536):
- """
- :param fname:
- :param chunksize:
- :return: String of Hex digits
- """
- m = hashlib.md5()
- f = open(fname, "rb")
+ :param fname: file to hash
+ :param chunksize: chunk size to read
+ :return: String of Hex digits representing the signature
+ """
+ m = hashlib.md5()
+ with open(fname, "rb") as f:
while True:
blck = f.read(chunksize)
if not blck:
break
m.update(to_bytes(blck))
- f.close()
- return m.hexdigest()
+ return m.hexdigest()
+else:
+ # if md5 algorithm not available, just return data unmodified
+ # could add alternative signature scheme here
+ md5 = False
+
+ def MD5signature(s):
+ return str(s)
+
+ def MD5filesignature(fname, chunksize=65536):
+ with open(fname, "rb") as f:
+ result = f.read()
+ return result
def MD5collect(signatures):
@@ -1509,7 +1514,6 @@ def MD5collect(signatures):
return MD5signature(', '.join(signatures))
-
def silent_intern(x):
"""
Perform sys.intern() on the passed argument and return the result.
@@ -1533,7 +1537,7 @@ def silent_intern(x):
class Null(object):
""" Null objects always and reliably "do nothing." """
def __new__(cls, *args, **kwargs):
- if not '_instance' in vars(cls):
+ if '_instance' not in vars(cls):
cls._instance = super(Null, cls).__new__(cls, *args, **kwargs)
return cls._instance
def __init__(self, *args, **kwargs):
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index c33a1fe..41a1647 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/UtilTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/UtilTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import SCons.compat
@@ -275,7 +275,7 @@ class UtilTestCase(unittest.TestCase):
assert not is_Dict(())
assert not is_Dict("")
if HasUnicode:
- exec("assert not is_Dict(u'')")
+ exec ("assert not is_Dict(u'')")
def test_is_List(self):
assert is_List([])
@@ -291,12 +291,12 @@ class UtilTestCase(unittest.TestCase):
assert not is_List({})
assert not is_List("")
if HasUnicode:
- exec("assert not is_List(u'')")
+ exec ("assert not is_List(u'')")
def test_is_String(self):
assert is_String("")
if HasUnicode:
- exec("assert is_String(u'')")
+ exec ("assert is_String(u'')")
assert is_String(UserString(''))
try:
class mystr(str):
@@ -322,7 +322,7 @@ class UtilTestCase(unittest.TestCase):
assert not is_Tuple({})
assert not is_Tuple("")
if HasUnicode:
- exec("assert not is_Tuple(u'')")
+ exec ("assert not is_Tuple(u'')")
def test_to_Bytes(self):
""" Test the to_Bytes method"""
@@ -768,12 +768,12 @@ class UtilTestCase(unittest.TestCase):
def test_LogicalLines(self):
"""Test the LogicalLines class"""
content = u"""
-foo \
-bar \
+foo \\
+bar \\
baz
foo
-bling \
-bling \ bling
+bling \\
+bling \\ bling
bling
"""
fobj = io.StringIO(content)
@@ -875,17 +875,18 @@ class flattenTestCase(unittest.TestCase):
def test_scalar(self):
"""Test flattening a scalar"""
result = flatten('xyz')
- self.assertEqual(result,['xyz'], result)
+ self.assertEqual(result, ['xyz'], result)
def test_dictionary_values(self):
"""Test flattening the dictionary values"""
items = {"a": 1, "b": 2, "c": 3}
result = flatten(items.values())
- self.assertEqual(sorted(result),[1,2,3])
+ self.assertEqual(sorted(result), [1, 2, 3])
class OsEnviron(object):
"""Used to temporarily mock os.environ"""
+
def __init__(self, environ):
self._environ = environ
@@ -915,21 +916,21 @@ class get_env_boolTestCase(unittest.TestCase):
assert var is False, "var should be False, not %s" % repr(var)
def test_true(self):
- for foo in [ 'TRUE', 'True', 'true',
- 'YES', 'Yes', 'yes',
- 'Y', 'y',
- 'ON', 'On', 'on',
- '1', '20', '-1']:
+ for foo in ['TRUE', 'True', 'true',
+ 'YES', 'Yes', 'yes',
+ 'Y', 'y',
+ 'ON', 'On', 'on',
+ '1', '20', '-1']:
env = {'FOO': foo}
var = get_env_bool(env, 'FOO')
assert var is True, 'var should be True, not %s' % repr(var)
def test_false(self):
- for foo in [ 'FALSE', 'False', 'false',
- 'NO', 'No', 'no',
- 'N', 'n',
- 'OFF', 'Off', 'off',
- '0']:
+ for foo in ['FALSE', 'False', 'false',
+ 'NO', 'No', 'no',
+ 'N', 'n',
+ 'OFF', 'Off', 'off',
+ '0']:
env = {'FOO': foo}
var = get_env_bool(env, 'FOO', True)
assert var is False, 'var should be True, not %s' % repr(var)
@@ -952,21 +953,21 @@ class get_os_env_boolTestCase(unittest.TestCase):
assert var is False, "var should be False, not %s" % repr(var)
def test_true(self):
- for foo in [ 'TRUE', 'True', 'true',
- 'YES', 'Yes', 'yes',
- 'Y', 'y',
- 'ON', 'On', 'on',
- '1', '20', '-1']:
+ for foo in ['TRUE', 'True', 'true',
+ 'YES', 'Yes', 'yes',
+ 'Y', 'y',
+ 'ON', 'On', 'on',
+ '1', '20', '-1']:
with OsEnviron({'FOO': foo}):
var = get_os_env_bool('FOO')
assert var is True, 'var should be True, not %s' % repr(var)
def test_false(self):
- for foo in [ 'FALSE', 'False', 'false',
- 'NO', 'No', 'no',
- 'N', 'n',
- 'OFF', 'Off', 'off',
- '0']:
+ for foo in ['FALSE', 'False', 'false',
+ 'NO', 'No', 'no',
+ 'N', 'n',
+ 'OFF', 'Off', 'off',
+ '0']:
with OsEnviron({'FOO': foo}):
var = get_os_env_bool('FOO', True)
assert var is False, 'var should be True, not %s' % repr(var)
diff --git a/src/engine/SCons/Variables/BoolVariable.py b/src/engine/SCons/Variables/BoolVariable.py
index 5af3a5f..4cb9f35 100644
--- a/src/engine/SCons/Variables/BoolVariable.py
+++ b/src/engine/SCons/Variables/BoolVariable.py
@@ -34,7 +34,7 @@ Usage example::
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/BoolVariable.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/BoolVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__all__ = ['BoolVariable',]
diff --git a/src/engine/SCons/Variables/BoolVariableTests.py b/src/engine/SCons/Variables/BoolVariableTests.py
index 62519bc..a184378 100644
--- a/src/engine/SCons/Variables/BoolVariableTests.py
+++ b/src/engine/SCons/Variables/BoolVariableTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/BoolVariableTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/BoolVariableTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Variables/EnumVariable.py b/src/engine/SCons/Variables/EnumVariable.py
index 1a5f40c..ba9f972 100644
--- a/src/engine/SCons/Variables/EnumVariable.py
+++ b/src/engine/SCons/Variables/EnumVariable.py
@@ -37,7 +37,7 @@ Usage example::
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/EnumVariable.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/EnumVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__all__ = ['EnumVariable',]
@@ -45,7 +45,7 @@ __all__ = ['EnumVariable',]
import SCons.Errors
def _validator(key, val, env, vals):
- if not val in vals:
+ if val not in vals:
raise SCons.Errors.UserError(
'Invalid value for option %s: %s. Valid values are: %s' % (key, val, vals))
diff --git a/src/engine/SCons/Variables/EnumVariableTests.py b/src/engine/SCons/Variables/EnumVariableTests.py
index d6e4761..28b9d68 100644
--- a/src/engine/SCons/Variables/EnumVariableTests.py
+++ b/src/engine/SCons/Variables/EnumVariableTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/EnumVariableTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/EnumVariableTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Variables/ListVariable.py b/src/engine/SCons/Variables/ListVariable.py
index d0f99f5..a30f265 100644
--- a/src/engine/SCons/Variables/ListVariable.py
+++ b/src/engine/SCons/Variables/ListVariable.py
@@ -46,7 +46,7 @@ Usage example::
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Variables/ListVariable.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/ListVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
# Known Bug: This should behave like a Set-Type, but does not really,
# since elements can occur twice.
@@ -96,7 +96,7 @@ def _converter(val, allowedElems, mapdict):
else:
val = [_f for _f in val.split(',') if _f]
val = [mapdict.get(v, v) for v in val]
- notAllowed = [v for v in val if not v in allowedElems]
+ notAllowed = [v for v in val if v not in allowedElems]
if notAllowed:
raise ValueError("Invalid value(s) for option: %s" %
','.join(notAllowed))
diff --git a/src/engine/SCons/Variables/ListVariableTests.py b/src/engine/SCons/Variables/ListVariableTests.py
index ff933d0..86e2c9e 100644
--- a/src/engine/SCons/Variables/ListVariableTests.py
+++ b/src/engine/SCons/Variables/ListVariableTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/ListVariableTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/ListVariableTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import copy
import sys
diff --git a/src/engine/SCons/Variables/PackageVariable.py b/src/engine/SCons/Variables/PackageVariable.py
index e2b3394..7c23cca 100644
--- a/src/engine/SCons/Variables/PackageVariable.py
+++ b/src/engine/SCons/Variables/PackageVariable.py
@@ -50,7 +50,7 @@ Usage example:
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/PackageVariable.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/PackageVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__all__ = ['PackageVariable',]
diff --git a/src/engine/SCons/Variables/PackageVariableTests.py b/src/engine/SCons/Variables/PackageVariableTests.py
index 636e2c1..2e48536 100644
--- a/src/engine/SCons/Variables/PackageVariableTests.py
+++ b/src/engine/SCons/Variables/PackageVariableTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/PackageVariableTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/PackageVariableTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Variables/PathVariable.py b/src/engine/SCons/Variables/PathVariable.py
index 52df0af..bf123fb 100644
--- a/src/engine/SCons/Variables/PathVariable.py
+++ b/src/engine/SCons/Variables/PathVariable.py
@@ -67,7 +67,7 @@ Usage example::
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/PathVariable.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/PathVariable.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__all__ = ['PathVariable',]
diff --git a/src/engine/SCons/Variables/PathVariableTests.py b/src/engine/SCons/Variables/PathVariableTests.py
index 1cd35f6..d862887 100644
--- a/src/engine/SCons/Variables/PathVariableTests.py
+++ b/src/engine/SCons/Variables/PathVariableTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/PathVariableTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/PathVariableTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py
index 7712bb4..ed2edab 100644
--- a/src/engine/SCons/Variables/VariablesTests.py
+++ b/src/engine/SCons/Variables/VariablesTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Variables/VariablesTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/VariablesTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py
index bde5b88..5b4b3af 100644
--- a/src/engine/SCons/Variables/__init__.py
+++ b/src/engine/SCons/Variables/__init__.py
@@ -26,7 +26,7 @@ customizable variables to an SCons build.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-__revision__ = "src/engine/SCons/Variables/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Variables/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import sys
@@ -99,7 +99,7 @@ class Variables(object):
option.converter = converter
self.options.append(option)
-
+
# options might be added after the 'unknown' dict has been set up,
# so we remove the key and all its aliases from that dict
for alias in list(option.aliases) + [ option.key ]:
@@ -168,7 +168,7 @@ class Variables(object):
# first set the defaults:
for option in self.options:
- if not option.default is None:
+ if option.default is not None:
values[option.key] = option.default
# next set the value specified in the options file
@@ -288,7 +288,7 @@ class Variables(object):
env - an environment that is used to get the current values
of the options.
- cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1
+ cmp - Either a function as follows: The specific sort function should take two arguments and return -1, 0 or 1
or a boolean to indicate if it should be sorted.
"""
diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py
index 4c6031a..1c84d57 100644
--- a/src/engine/SCons/Warnings.py
+++ b/src/engine/SCons/Warnings.py
@@ -27,7 +27,7 @@ This file implements the warnings framework for SCons.
"""
-__revision__ = "src/engine/SCons/Warnings.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Warnings.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
@@ -193,9 +193,10 @@ def warn(clazz, *args):
break
def process_warn_strings(arguments):
- """Process string specifications of enabling/disabling warnings,
- as passed to the --warn option or the SetOption('warn') function.
-
+ """Process requests to enable/disable warnings.
+
+ The requests are strings passed to the --warn option or the
+ SetOption('warn') function.
An argument to this option should be of the form <warning-class>
or no-<warning-class>. The warning class is munged in order
@@ -210,7 +211,6 @@ def process_warn_strings(arguments):
As a special case, --warn=all and --warn=no-all will enable or
disable (respectively) the base Warning class of all warnings.
-
"""
def _capitalize(s):
diff --git a/src/engine/SCons/WarningsTests.py b/src/engine/SCons/WarningsTests.py
index 5257050..2b36eb2 100644
--- a/src/engine/SCons/WarningsTests.py
+++ b/src/engine/SCons/WarningsTests.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/WarningsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/WarningsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import sys
import unittest
diff --git a/src/engine/SCons/__init__.py b/src/engine/SCons/__init__.py
index 6b22009..c915441 100644
--- a/src/engine/SCons/__init__.py
+++ b/src/engine/SCons/__init__.py
@@ -27,17 +27,17 @@ The main package for the SCons software construction utility.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-__version__ = "3.0.5"
+__version__ = "3.1.0"
-__build__ = "103260fce95bf5db1c35fb2371983087d85dd611"
+__build__ = "e724ae812eb96f4858a132f5b8c769724744faf6"
-__buildsys__ = "Williams-MBP-2"
+__buildsys__ = "kufra"
-__date__ = "2019-07-13 18:25:30"
+__date__ = "2019-07-21 00:04:47"
-__developer__ = "bdbaddog"
+__developer__ = "bdeegan"
# make sure compatibility is always in place
import SCons.compat
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py
index 1e744e4..dcbd8e8 100644
--- a/src/engine/SCons/compat/__init__.py
+++ b/src/engine/SCons/compat/__init__.py
@@ -57,31 +57,22 @@ function defined below loads the module as the "real" name (without the
rest of our code will find our pre-loaded compatibility module.
"""
-__revision__ = "src/engine/SCons/compat/__init__.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/compat/__init__.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
-import imp # Use the "imp" module to protect imports from fixers.
+import importlib
PYPY = hasattr(sys, 'pypy_translation_info')
-def import_as(module, name):
- """
- Imports the specified module (from our local directory) as the
- specified name, returning the loaded module object.
- """
- dir = os.path.split(__file__)[0]
- return imp.load_module(name, *imp.find_module(module, [dir]))
-
-
def rename_module(new, old):
"""
- Attempts to import the old module and load it under the new name.
+ Attempt to import the old module and load it under the new name.
Used for purely cosmetic name changes in Python 3.x.
"""
try:
- sys.modules[new] = imp.load_module(old, *imp.find_module(old))
+ sys.modules[new] = importlib.import_module(old)
return True
except ImportError:
return False
@@ -122,28 +113,28 @@ except AttributeError:
# intern into the sys package
sys.intern = intern
-# Preparing for 3.x. UserDict, UserList, UserString are in
-# collections for 3.x, but standalone in 2.7.x
+# UserDict, UserList, UserString are in # collections for 3.x,
+# but standalone in 2.7.x. Monkey-patch into collections for 2.7.
import collections
try:
collections.UserDict
except AttributeError:
- exec ('from UserDict import UserDict as _UserDict')
+ from UserDict import UserDict as _UserDict
collections.UserDict = _UserDict
del _UserDict
try:
collections.UserList
except AttributeError:
- exec ('from UserList import UserList as _UserList')
+ from UserList import UserList as _UserList
collections.UserList = _UserList
del _UserList
try:
collections.UserString
except AttributeError:
- exec ('from UserString import UserString as _UserString')
+ from UserString import UserString as _UserString
collections.UserString = _UserString
del _UserString
diff --git a/src/engine/SCons/compat/_scons_dbm.py b/src/engine/SCons/compat/_scons_dbm.py
index 31d6803..ec5e261 100644
--- a/src/engine/SCons/compat/_scons_dbm.py
+++ b/src/engine/SCons/compat/_scons_dbm.py
@@ -30,7 +30,7 @@ that the whichdb.whichdb() implementstation in the various 2.X versions of
Python won't blow up even if dbm wasn't compiled in.
"""
-__revision__ = "src/engine/SCons/compat/_scons_dbm.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/compat/_scons_dbm.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
class error(Exception):
pass
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index e500711..7c4ac92 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/cpp.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/cpp.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
SCons C Pre-Processor module
@@ -165,7 +165,7 @@ def CPP_to_Python(s):
"""
s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s)
for expr, repl in CPP_to_Python_Eval_List:
- s = expr.sub(repl, s)
+ s = re.sub(expr, repl, s)
return s
@@ -210,7 +210,7 @@ class FunctionEvaluator(object):
parts = []
for s in self.expansion:
- if not s in self.args:
+ if s not in self.args:
s = repr(s)
parts.append(s)
statement = ' + '.join(parts)
diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py
index 7ebdf99..6d41ab0 100644
--- a/src/engine/SCons/cppTests.py
+++ b/src/engine/SCons/cppTests.py
@@ -23,7 +23,7 @@
from __future__ import absolute_import
-__revision__ = "src/engine/SCons/cppTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/cppTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import atexit
import sys
diff --git a/src/engine/SCons/exitfuncs.py b/src/engine/SCons/exitfuncs.py
index 3f4c1ac..c5414a2 100644
--- a/src/engine/SCons/exitfuncs.py
+++ b/src/engine/SCons/exitfuncs.py
@@ -27,7 +27,7 @@ Register functions which are executed when SCons exits for any reason.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/exitfuncs.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/exitfuncs.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import atexit
diff --git a/src/script/scons-configure-cache.py b/src/script/scons-configure-cache.py
index 7c5d3b6..757a79f 100644
--- a/src/script/scons-configure-cache.py
+++ b/src/script/scons-configure-cache.py
@@ -37,17 +37,17 @@ import glob
import json
import os
-__revision__ = "src/script/scons-configure-cache.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/script/scons-configure-cache.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-__version__ = "3.0.5"
+__version__ = "3.1.0"
-__build__ = "103260fce95bf5db1c35fb2371983087d85dd611"
+__build__ = "e724ae812eb96f4858a132f5b8c769724744faf6"
-__buildsys__ = "Williams-MBP-2"
+__buildsys__ = "kufra"
-__date__ = "2019-07-13 18:25:30"
+__date__ = "2019-07-21 00:04:47"
-__developer__ = "bdbaddog"
+__developer__ = "bdeegan"
def rearrange_cache_entries(current_prefix_len, new_prefix_len):
diff --git a/src/script/scons-time.py b/src/script/scons-time.py
index b2ae22b..975ff64 100644
--- a/src/script/scons-time.py
+++ b/src/script/scons-time.py
@@ -31,7 +31,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import division, print_function
-__revision__ = "src/script/scons-time.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/script/scons-time.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import getopt
import glob
@@ -41,21 +41,7 @@ import shutil
import sys
import tempfile
import time
-
-def make_temp_file(**kw):
- try:
- result = tempfile.mktemp(**kw)
- result = os.path.realpath(result)
- except TypeError:
- try:
- save_template = tempfile.template
- prefix = kw['prefix']
- del kw['prefix']
- tempfile.template = prefix
- result = tempfile.mktemp(**kw)
- finally:
- tempfile.template = save_template
- return result
+import subprocess
def HACK_for_exec(cmd, *args):
"""
@@ -121,7 +107,7 @@ class Line(object):
# in the line's index number. We might want to represent
# this some way rather than just drawing the line straight
# between the two points on either side.
- if not y is None:
+ if y is not None:
print(fmt % (x, y))
print('e')
@@ -155,13 +141,13 @@ class Gnuplotter(Plotter):
result = []
for line in self.lines:
result.extend(line.get_x_values())
- return [r for r in result if not r is None]
+ return [r for r in result if r is not None]
def get_all_y_values(self):
result = []
for line in self.lines:
result.extend(line.get_y_values())
- return [r for r in result if not r is None]
+ return [r for r in result if r is not None]
def get_min_x(self):
try:
@@ -248,14 +234,16 @@ def unzip(fname):
os.makedirs(dir)
except:
pass
- open(name, 'wb').write(zf.read(name))
+ with open(name, 'wb') as f:
+ f.write(zf.read(name))
def read_tree(dir):
for dirpath, dirnames, filenames in os.walk(dir):
for fn in filenames:
fn = os.path.join(dirpath, fn)
if os.path.isfile(fn):
- open(fn, 'rb').read()
+ with open(fn, 'rb') as f:
+ f.read()
def redirect_to_file(command, log):
return '%s > %s 2>&1' % (command, log)
@@ -264,7 +252,7 @@ def tee_to_file(command, log):
return '%s 2>&1 | tee %s' % (command, log)
-
+
class SConsTimer(object):
"""
Usage: scons-time SUBCOMMAND [ARGUMENTS]
@@ -360,7 +348,7 @@ class SConsTimer(object):
'SCons' : 'Total SCons execution time',
'commands' : 'Total command execution time',
}
-
+
time_string_all = 'Total .* time'
#
@@ -456,14 +444,20 @@ class SConsTimer(object):
def log_execute(self, command, log):
command = self.subst(command, self.__dict__)
- output = os.popen(command).read()
+ p = os.popen(command)
+ output = p.read()
+ p.close()
+ #TODO: convert to subrocess, os.popen is obsolete. This didn't work:
+ #process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
+ #output = process.stdout.read()
+ #process.stdout.close()
+ #process.wait()
if self.verbose:
sys.stdout.write(output)
# TODO: Figure out
# Not sure we need to write binary here
- open(log, 'w').write(output)
-
- #
+ with open(log, 'w') as f:
+ f.write(str(output))
def archive_splitext(self, path):
"""
@@ -628,13 +622,14 @@ class SConsTimer(object):
search_string = self.time_string_all
else:
search_string = time_string
- contents = open(file).read()
+ with open(file) as f:
+ contents = f.read()
if not contents:
sys.stderr.write('file %s has no contents!\n' % repr(file))
return None
result = re.findall(r'%s: ([\d\.]*)' % search_string, contents)[-4:]
result = [ float(r) for r in result ]
- if not time_string is None:
+ if time_string is not None:
try:
result = result[0]
except IndexError:
@@ -673,7 +668,8 @@ class SConsTimer(object):
search_string = self.memory_string_all
else:
search_string = memory_string
- lines = open(file).readlines()
+ with open(file) as f:
+ lines = f.readlines()
lines = [ l for l in lines if l.startswith(search_string) ][-4:]
result = [ int(l.split()[-1]) for l in lines[-4:] ]
if len(result) == 1:
@@ -685,14 +681,14 @@ class SConsTimer(object):
Returns the counts of the specified object_name.
"""
object_string = ' ' + object_name + '\n'
- lines = open(file).readlines()
+ with open(file) as f:
+ lines = f.readlines()
line = [ l for l in lines if l.endswith(object_string) ][0]
result = [ int(field) for field in line.split()[:4] ]
if index is not None:
result = result[index]
return result
- #
command_alias = {}
@@ -925,7 +921,7 @@ class SConsTimer(object):
elif o in ('-p', '--prefix'):
self.prefix = a
elif o in ('--stage',):
- if not a in self.stages:
+ if a not in self.stages:
sys.stderr.write('%s: mem: Unrecognized stage "%s".\n' % (self.name, a))
sys.exit(1)
stage = a
@@ -1039,7 +1035,7 @@ class SConsTimer(object):
elif o in ('-p', '--prefix'):
self.prefix = a
elif o in ('--stage',):
- if not a in self.stages:
+ if a not in self.stages:
sys.stderr.write('%s: obj: Unrecognized stage "%s".\n' % (self.name, a))
sys.stderr.write('%s Type "%s help obj" for help.\n' % (self.name_spaces, self.name))
sys.exit(1)
@@ -1239,7 +1235,7 @@ class SConsTimer(object):
return os.path.join(dir, 'src', 'engine')
def prep_aegis_run(self, commands, removals):
- self.aegis_tmpdir = make_temp_file(prefix = self.name + '-aegis-')
+ self.aegis_tmpdir = tempfile.mkdtemp(prefix=self.name + '-aegis-')
removals.append((shutil.rmtree, 'rm -rf %%s', self.aegis_tmpdir))
self.aegis_parent_project = os.path.splitext(self.aegis_project)[0]
@@ -1247,21 +1243,19 @@ class SConsTimer(object):
self.scons_lib_dir = self.scons_lib_dir_path(self.aegis_tmpdir)
commands.extend([
- 'mkdir %(aegis_tmpdir)s',
(lambda: os.chdir(self.aegis_tmpdir), 'cd %(aegis_tmpdir)s'),
'%(aegis)s -cp -ind -p %(aegis_parent_project)s .',
'%(aegis)s -cp -ind -p %(aegis_project)s -delta %(run_number)s .',
])
def prep_subversion_run(self, commands, removals):
- self.svn_tmpdir = make_temp_file(prefix = self.name + '-svn-')
+ self.svn_tmpdir = tempfile.mkdtemp(prefix=self.name + '-svn-')
removals.append((shutil.rmtree, 'rm -rf %%s', self.svn_tmpdir))
self.scons = self.scons_path(self.svn_tmpdir)
self.scons_lib_dir = self.scons_lib_dir_path(self.svn_tmpdir)
commands.extend([
- 'mkdir %(svn_tmpdir)s',
'%(svn)s co %(svn_co_flag)s -r %(run_number)s %(subversion_url)s %(svn_tmpdir)s',
])
@@ -1308,11 +1302,9 @@ class SConsTimer(object):
if self.targets2 is None:
self.targets2 = self.targets
- self.tmpdir = make_temp_file(prefix = self.name + '-')
+ self.tmpdir = tempfile.mkdtemp(prefix=self.name + '-')
commands.extend([
- 'mkdir %(tmpdir)s',
-
(os.chdir, 'cd %%s', self.tmpdir),
])
@@ -1365,7 +1357,6 @@ class SConsTimer(object):
if not os.environ.get('PRESERVE'):
commands.extend(removals)
-
commands.append((shutil.rmtree, 'rm -rf %%s', self.tmpdir))
self.run_command_list(commands, self.__dict__)
@@ -1432,14 +1423,16 @@ class SConsTimer(object):
elif o in ('--title',):
self.title = a
elif o in ('--which',):
- if not a in list(self.time_strings.keys()):
+ if a not in list(self.time_strings.keys()):
sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a))
sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name))
sys.exit(1)
which = a
if self.config_file:
- HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
+ with open(self.config_file, 'r') as f:
+ config = f.read()
+ HACK_for_exec(config, self.__dict__)
if self.chdir:
os.chdir(self.chdir)
diff --git a/src/script/scons.bat b/src/script/scons.bat
index 156aa9c..75e2a49 100644
--- a/src/script/scons.bat
+++ b/src/script/scons.bat
@@ -1,11 +1,11 @@
@REM Copyright (c) 2001 - 2019 The SCons Foundation
-@REM src/script/scons.bat 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog
+@REM src/script/scons.bat e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan
@echo off
set SCONS_ERRORLEVEL=
if "%OS%" == "Windows_NT" goto WinNT
@REM for 9x/Me you better not have more than 9 args
-python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.0.5'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.0.5'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
+python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.1.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.1.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
@REM no way to set exit status of this script for 9x/Me
goto endscons
diff --git a/src/script/scons.py b/src/script/scons.py
index e58d8e2..b3172b1 100755
--- a/src/script/scons.py
+++ b/src/script/scons.py
@@ -25,17 +25,17 @@
from __future__ import print_function
-__revision__ = "src/script/scons.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/script/scons.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-__version__ = "3.0.5"
+__version__ = "3.1.0"
-__build__ = "103260fce95bf5db1c35fb2371983087d85dd611"
+__build__ = "e724ae812eb96f4858a132f5b8c769724744faf6"
-__buildsys__ = "Williams-MBP-2"
+__buildsys__ = "kufra"
-__date__ = "2019-07-13 18:25:30"
+__date__ = "2019-07-21 00:04:47"
-__developer__ = "bdbaddog"
+__developer__ = "bdeegan"
# This is the entry point to the SCons program.
# The only job of this script is to work out where the guts of the program
diff --git a/src/script/sconsign.py b/src/script/sconsign.py
index 217193a..a0d7b7e 100644
--- a/src/script/sconsign.py
+++ b/src/script/sconsign.py
@@ -25,17 +25,17 @@
from __future__ import print_function
-__revision__ = "src/script/sconsign.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/script/sconsign.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
-__version__ = "3.0.5"
+__version__ = "3.1.0"
-__build__ = "103260fce95bf5db1c35fb2371983087d85dd611"
+__build__ = "e724ae812eb96f4858a132f5b8c769724744faf6"
-__buildsys__ = "Williams-MBP-2"
+__buildsys__ = "kufra"
-__date__ = "2019-07-13 18:25:30"
+__date__ = "2019-07-21 00:04:47"
-__developer__ = "bdbaddog"
+__developer__ = "bdeegan"
import os
import sys
@@ -117,7 +117,7 @@ else:
# check `pwd`/lib/scons*.
temp.append(os.getcwd())
else:
- if script_dir == '.' or script_dir == '':
+ if script_dir in ('.', ''):
script_dir = os.getcwd()
head, tail = os.path.split(script_dir)
if tail == "bin":
@@ -185,13 +185,13 @@ import SCons.compat
try:
import whichdb
+
whichdb = whichdb.whichdb
except ImportError as e:
from dbm import whichdb
import time
import pickle
-import imp
import SCons.SConsign
@@ -200,9 +200,8 @@ def my_whichdb(filename):
if filename[-7:] == ".dblite":
return "SCons.dblite"
try:
- f = open(filename + ".dblite", "rb")
- f.close()
- return "SCons.dblite"
+ with open(filename + ".dblite", "rb"):
+ return "SCons.dblite"
except IOError:
pass
return _orig_whichdb(filename)
@@ -217,6 +216,8 @@ whichdb = my_whichdb
#dbm.whichdb = my_whichdb
def my_import(mname):
+ import imp
+
if '.' in mname:
i = mname.rfind('.')
parent = my_import(mname[:i])
@@ -247,9 +248,8 @@ Readable = 0
Warns = 0
-
def default_mapper(entry, name):
- '''
+ """
Stringify an entry that doesn't have an explicit mapping.
Args:
@@ -258,10 +258,10 @@ def default_mapper(entry, name):
Returns: str
- '''
+ """
try:
val = eval("entry." + name)
- except:
+ except AttributeError:
val = None
if sys.version_info.major >= 3 and isinstance(val, bytes):
# This is a dirty hack for py 2/3 compatibility. csig is a bytes object
@@ -272,7 +272,7 @@ def default_mapper(entry, name):
def map_action(entry, _):
- '''
+ """
Stringify an action entry and signature.
Args:
@@ -281,7 +281,7 @@ def map_action(entry, _):
Returns: str
- '''
+ """
try:
bact = entry.bact
bactsig = entry.bactsig
@@ -289,8 +289,9 @@ def map_action(entry, _):
return None
return '%s [%s]' % (bactsig, bact)
+
def map_timestamp(entry, _):
- '''
+ """
Stringify a timestamp entry.
Args:
@@ -299,7 +300,7 @@ def map_timestamp(entry, _):
Returns: str
- '''
+ """
try:
timestamp = entry.timestamp
except AttributeError:
@@ -309,8 +310,9 @@ def map_timestamp(entry, _):
else:
return str(timestamp)
+
def map_bkids(entry, _):
- '''
+ """
Stringify an implicit entry.
Args:
@@ -319,7 +321,7 @@ def map_bkids(entry, _):
Returns: str
- '''
+ """
try:
bkids = entry.bsources + entry.bdepends + entry.bimplicit
bkidsigs = entry.bsourcesigs + entry.bdependsigs + entry.bimplicitsigs
@@ -448,8 +450,8 @@ class Do_SConsignDB(object):
def __call__(self, fname):
# The *dbm modules stick their own file suffixes on the names
- # that are passed in. This is causes us to jump through some
- # hoops here to be able to allow the user
+ # that are passed in. This causes us to jump through some
+ # hoops here.
try:
# Try opening the specified file name. Example:
# SPECIFIED OPENED BY self.dbm.open()
@@ -461,16 +463,17 @@ class Do_SConsignDB(object):
print_e = e
try:
# That didn't work, so try opening the base name,
- # so that if the actually passed in 'sconsign.dblite'
+ # so that if they actually passed in 'sconsign.dblite'
# (for example), the dbm module will put the suffix back
# on for us and open it anyway.
db = self.dbm.open(os.path.splitext(fname)[0], "r")
except (IOError, OSError):
# That didn't work either. See if the file name
- # they specified just exists (independent of the dbm
+ # they specified even exists (independent of the dbm
# suffix-mangling).
try:
- open(fname, "r")
+ with open(fname, "rb"):
+ pass # this is a touch only, we don't use it here.
except (IOError, OSError) as e:
# Nope, that file doesn't even exist, so report that
# fact back.
@@ -486,6 +489,9 @@ class Do_SConsignDB(object):
except Exception as e:
sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n"
% (self.dbm_name, fname, e))
+ exc_type, _, _ = sys.exc_info()
+ if exc_type.__name__ == "ValueError" and sys.version_info < (3,0,0):
+ sys.stderr.write("Python 2 only supports pickle protocols 0-2.\n")
return
if Print_Directories:
@@ -512,23 +518,23 @@ class Do_SConsignDB(object):
def Do_SConsignDir(name):
try:
- fp = open(name, 'rb')
+ with open(name, 'rb') as fp:
+ try:
+ sconsign = SCons.SConsign.Dir(fp)
+ except KeyboardInterrupt:
+ raise
+ except pickle.UnpicklingError:
+ err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name)
+ sys.stderr.write(err)
+ return
+ except Exception as e:
+ err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)
+ sys.stderr.write(err)
+ return
+ printentries(sconsign.entries, args[0])
except (IOError, OSError) as e:
sys.stderr.write("sconsign: %s\n" % e)
return
- try:
- sconsign = SCons.SConsign.Dir(fp)
- except KeyboardInterrupt:
- raise
- except pickle.UnpicklingError:
- err = "sconsign: ignoring invalid .sconsign file `%s'\n" % (name)
- sys.stderr.write(err)
- return
- except Exception as e:
- err = "sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e)
- sys.stderr.write(err)
- return
- printentries(sconsign.entries, args[0])
##############################################################################
@@ -536,7 +542,7 @@ def Do_SConsignDir(name):
import getopt
helpstr = """\
-Usage: sconsign [OPTIONS] FILE [...]
+Usage: sconsign [OPTIONS] [FILE ...]
Options:
-a, --act, --action Print build action information.
-c, --csig Print content signature information.
@@ -552,13 +558,17 @@ Options:
-v, --verbose Verbose, describe each field.
"""
-opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv",
- ['act', 'action',
- 'csig', 'dir=', 'entry=',
- 'format=', 'help', 'implicit',
- 'raw', 'readable',
- 'size', 'timestamp', 'verbose'])
-
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "acd:e:f:hirstv",
+ ['act', 'action',
+ 'csig', 'dir=', 'entry=',
+ 'format=', 'help', 'implicit',
+ 'raw', 'readable',
+ 'size', 'timestamp', 'verbose'])
+except getopt.GetoptError as err:
+ sys.stderr.write(str(err) + '\n')
+ print(helpstr)
+ sys.exit(2)
for o, a in opts:
if o in ('-a', '--act', '--action'):
@@ -586,7 +596,7 @@ for o, a in opts:
# this was handled by calling my_import('SCons.dblite')
# again in earlier versions...
SCons.dblite.ignore_corrupt_dbfiles = 0
- except:
+ except ImportError:
sys.stderr.write("sconsign: illegal file format `%s'\n" % a)
print(helpstr)
sys.exit(2)
@@ -613,6 +623,8 @@ if Do_Call:
for a in args:
Do_Call(a)
else:
+ if not args:
+ args = [".sconsign.dblite"]
for a in args:
dbm_name = whichdb(a)
if dbm_name:
diff --git a/src/setup.py b/src/setup.py
index 2d021c2..790b1ea 100755
--- a/src/setup.py
+++ b/src/setup.py
@@ -44,13 +44,13 @@ NOTE: Installed SCons is not importable like usual Python packages. It is
"""
-__revision__ = "src/setup.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/setup.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import stat
import sys
-Version = "3.0.5"
+Version = "3.1.0"
man_pages = [
'scons.1',
diff --git a/src/test_files.py b/src/test_files.py
index cab1045..42fb397 100644
--- a/src/test_files.py
+++ b/src/test_files.py
@@ -23,7 +23,7 @@
#
from __future__ import print_function
-__revision__ = "src/test_files.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/test_files.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""
Verify that we have certain important files in our distribution
diff --git a/src/test_interrupts.py b/src/test_interrupts.py
index 6b8c7c3..4ae0969 100644
--- a/src/test_interrupts.py
+++ b/src/test_interrupts.py
@@ -23,7 +23,7 @@
from __future__ import print_function
-__revision__ = "src/test_interrupts.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/test_interrupts.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""
Verify that the SCons source code contains only correct handling of
@@ -87,7 +87,8 @@ exceptall_pat = re.compile(r' *except(?: *| +Exception *, *[^: ]+):[^\n]*')
uncaughtKeyboardInterrupt = 0
for f in files:
- contents = open(os.path.join(scons_lib_dir, f)).read()
+ with open(os.path.join(scons_lib_dir, f)) as ifp:
+ contents = ifp.read()
try_except_lines = {}
lastend = 0
while True:
diff --git a/src/test_pychecker.py b/src/test_pychecker.py
index 058189e..a93033d 100644
--- a/src/test_pychecker.py
+++ b/src/test_pychecker.py
@@ -22,7 +22,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import print_function
-__revision__ = "src/test_pychecker.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/test_pychecker.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""
Use pychecker to catch various Python coding errors.
@@ -63,7 +63,8 @@ else:
src_engine_ = os.path.join(src_engine, '')
MANIFEST = os.path.join(src_engine, 'MANIFEST.in')
-files = open(MANIFEST).read().split()
+with open(MANIFEST) as f:
+ files = f.read().split()
files = [f for f in files if f[-3:] == '.py']
diff --git a/src/test_setup.py b/src/test_setup.py
index 2726465..b540ab2 100644
--- a/src/test_setup.py
+++ b/src/test_setup.py
@@ -23,7 +23,7 @@
#
from __future__ import print_function
-__revision__ = "src/test_setup.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/test_setup.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""
Test how the setup.py script installs SCons.
@@ -176,21 +176,26 @@ tar_gz = os.path.join(cwd, 'build', 'dist', '%s.tar.gz' % scons_version)
zip = os.path.join(cwd, 'build', 'dist', '%s.zip' % scons_version)
if os.path.isfile(zip):
- try: import zipfile
- except ImportError: pass
+ try:
+ import zipfile
+ except ImportError:
+ pass
else:
- zf = zipfile.ZipFile(zip, 'r')
-
- for name in zf.namelist():
- dir = os.path.dirname(name)
- try: os.makedirs(dir)
- except: pass
- # if the file exists, then delete it before writing
- # to it so that we don't end up trying to write to a symlink:
- if os.path.isfile(name) or os.path.islink(name):
- os.unlink(name)
- if not os.path.isdir(name):
- open(name, 'w').write(zf.read(name))
+ with zipfile.ZipFile(zip, 'r') as zf:
+
+ for name in zf.namelist():
+ dname = os.path.dirname(name)
+ try:
+ os.makedirs(dname)
+ except FileExistsError:
+ pass
+ # if the file exists, then delete it before writing
+ # to it so that we don't end up trying to write to a symlink:
+ if os.path.isfile(name) or os.path.islink(name):
+ os.unlink(name)
+ if not os.path.isdir(name):
+ with open(name, 'w') as ofp:
+ ofp.write(zf.read(name))
if not os.path.isdir(scons_version) and os.path.isfile(tar_gz):
# Unpack the .tar.gz file. This should create the scons_version/
diff --git a/src/test_strings.py b/src/test_strings.py
index 59ac613..ad2c755 100644
--- a/src/test_strings.py
+++ b/src/test_strings.py
@@ -23,7 +23,7 @@
#
from __future__ import print_function
-__revision__ = "src/test_strings.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/test_strings.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
"""
Verify that we have proper strings like Copyright notices on all the
@@ -98,7 +98,8 @@ class Checker(object):
for fname in filenames:
fpath = os.path.join(dirpath, fname)
if self.search_this(fpath) and not self.remove_this(fname, fpath):
- body = open(fpath, 'r').read()
+ with open(fpath, 'r') as f:
+ body = f.read()
for expr in self.expressions:
if not expr.search(body):
msg = '%s: missing %s' % (fpath, repr(expr.pattern))
@@ -108,7 +109,7 @@ class Checker(object):
class CheckUnexpandedStrings(Checker):
expressions = [
re.compile('Copyright (c) 2001 - 2019 The SCons Foundation'),
- re.compile('src/test_strings.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog'),
+ re.compile('src/test_strings.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan'),
]
def must_be_built(self):
return None
diff --git a/testing/framework/README.txt b/testing/framework/README.txt
index 0e0f2bb..817cb3f 100644
--- a/testing/framework/README.txt
+++ b/testing/framework/README.txt
@@ -47,4 +47,4 @@ the pieces here are local to SCons.
Test infrastructure for the sconsign.py script.
Copyright (c) 2001 - 2019 The SCons Foundation
-testing/framework/README.txt 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog
+testing/framework/README.txt e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan
diff --git a/testing/framework/SConscript b/testing/framework/SConscript
index 535f187..f79a254 100644
--- a/testing/framework/SConscript
+++ b/testing/framework/SConscript
@@ -41,12 +41,13 @@ files = [
def copy(target, source, env):
t = str(target[0])
s = str(source[0])
- c = open(s, 'r').read()
- # Note: We construct the __ VERSION __ substitution string at
- # run-time so it doesn't get replaced when this file gets copied
- # into the tree for packaging.
- c = c.replace('__' + 'VERSION' + '__', env['VERSION'])
- open(t, 'w').write(c)
+ with open(s, 'r') as i, open(t, 'w') as o:
+ c = i.read()
+ # Note: We construct the __ VERSION __ substitution string at
+ # run-time so it doesn't get replaced when this file gets copied
+ # into the tree for packaging.
+ c = c.replace('__' + 'VERSION' + '__', env['VERSION'])
+ o.write(c)
for file in files:
# Guarantee that real copies of these files always exist in
diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py
index a6a8045..81e03f3 100644
--- a/testing/framework/TestCmd.py
+++ b/testing/framework/TestCmd.py
@@ -366,13 +366,11 @@ else:
def is_String(e):
return isinstance(e, (str, unicode, UserString))
-tempfile.template = 'testcmd.'
+testprefix = 'testcmd.'
if os.name in ('posix', 'nt'):
- tempfile.template = 'testcmd.' + str(os.getpid()) + '.'
-else:
- tempfile.template = 'testcmd.'
+ testprefix += "%s." % str(os.getpid())
-re_space = re.compile('\s')
+re_space = re.compile(r'\s')
def _caller(tblist, skip):
@@ -470,6 +468,14 @@ def pass_test(self=None, condition=1, function=None):
def match_exact(lines=None, matches=None, newline=os.sep):
"""
+ Match function using exact match.
+
+ :param lines: data lines
+ :type lines: str or list[str]
+ :param matches: expected lines to match
+ :type matches: str or list[str]
+ :param newline: line separator
+ :returns: an object (1) on match, else None, like re.match
"""
if isinstance(lines, bytes) or bytes is str:
@@ -480,30 +486,51 @@ def match_exact(lines=None, matches=None, newline=os.sep):
if not is_List(matches):
matches = matches.split(newline)
if len(lines) != len(matches):
- return
- for i in range(len(lines)):
- if lines[i] != matches[i]:
- return
+ return None
+ for line, match in zip(lines, matches):
+ if line != match:
+ return None
return 1
def match_caseinsensitive(lines=None, matches=None):
"""
+ Match function using case-insensitive matching.
+
+ Only a simplistic comparison is done, based on lowercasing the
+ strings. This has plenty of holes for unicode data using
+ non-English languages.
+
+ TODO: casefold() is better than lower() if we don't need Py2 support.
+
+ :param lines: data lines
+ :type lines: str or list[str]
+ :param matches: expected lines to match
+ :type matches: str or list[str]
+ :returns: True or False
+ :returns: an object (1) on match, else None, like re.match
"""
if not is_List(lines):
lines = lines.split("\n")
if not is_List(matches):
matches = matches.split("\n")
if len(lines) != len(matches):
- return
- for i in range(len(lines)):
- if lines[i].lower() != matches[i].lower():
- return
+ return None
+ for line, match in zip(lines, matches):
+ if line.lower() != match.lower():
+ return None
return 1
def match_re(lines=None, res=None):
"""
+ Match function using line-by-line regular expression match.
+
+ :param lines: data lines
+ :type lines: str or list[str]
+ :param res: regular expression(s) for matching
+ :type res: str or list[str]
+ :returns: an object (1) on match, else None, like re.match
"""
if not is_List(lines):
# CRs mess up matching (Windows) so split carefully
@@ -512,29 +539,39 @@ def match_re(lines=None, res=None):
res = res.split("\n")
if len(lines) != len(res):
print("match_re: expected %d lines, found %d" % (len(res), len(lines)))
- return
- for i in range(len(lines)):
- s = "^" + res[i] + "$"
+ return None
+ for i, (line, regex) in enumerate(zip(lines, res)):
+ s = r"^{}$".format(regex)
try:
expr = re.compile(s)
except re.error as e:
msg = "Regular expression error in %s: %s"
raise re.error(msg % (repr(s), e.args[0]))
- if not expr.search(lines[i]):
- print("match_re: mismatch at line %d:\n search re='%s'\n line='%s'" % (
- i, s, lines[i]))
- return
+ if not expr.search(line):
+ miss_tmpl = "match_re: mismatch at line {}:\n search re='{}'\n line='{}'"
+ print(miss_tmpl.format(i, s, line))
+ return None
return 1
def match_re_dotall(lines=None, res=None):
"""
+ Match function using regular expression match.
+
+ Unlike match_re, the arguments are converted to strings (if necessary)
+ and must match exactly.
+
+ :param lines: data lines
+ :type lines: str or list[str]
+ :param res: regular expression(s) for matching
+ :type res: str or list[str]
+ :returns: a match object, or None as for re.match
"""
if not isinstance(lines, str):
lines = "\n".join(lines)
if not isinstance(res, str):
res = "\n".join(res)
- s = "^" + res + "$"
+ s = r"^{}$".format(res)
try:
expr = re.compile(s, re.DOTALL)
except re.error as e:
@@ -544,11 +581,32 @@ def match_re_dotall(lines=None, res=None):
def simple_diff(a, b, fromfile='', tofile='',
- fromfiledate='', tofiledate='', n=3, lineterm='\n'):
- """
- A function with the same calling signature as difflib.context_diff
- (diff -c) and difflib.unified_diff (diff -u) but which prints
- output like the simple, unadorned 'diff" command.
+ fromfiledate='', tofiledate='', n=0, lineterm=''):
+ r"""
+ Compare two sequences of lines; generate the delta as a simple diff.
+
+ Similar to difflib.context_diff and difflib.unified_diff but
+ output is like from the 'diff" command without arguments. The function
+ keeps the same signature as the difflib ones so they will be
+ interchangeable, but except for lineterm, the arguments beyond the
+ two sequences are ignored in this version. By default, the
+ diff is not created with trailing newlines, set the lineterm
+ argument to '\n' to do so.
+
+ :raises re.error: if a regex fails to compile
+
+ Example:
+
+ >>> print(''.join(simple_diff('one\ntwo\nthree\nfour\n'.splitlines(True),
+ ... 'zero\none\ntree\nfour\n'.splitlines(True), lineterm='\n')))
+ 0a1
+ > zero
+ 2,3c3
+ < two
+ < three
+ ---
+ > tree
+
"""
a = [to_str(q) for q in a]
b = [to_str(q) for q in b]
@@ -556,25 +614,30 @@ def simple_diff(a, b, fromfile='', tofile='',
def comma(x1, x2):
return x1 + 1 == x2 and str(x2) or '%s,%s' % (x1 + 1, x2)
- result = []
+
for op, a1, a2, b1, b2 in sm.get_opcodes():
if op == 'delete':
- result.append("%sd%d" % (comma(a1, a2), b1))
- result.extend(['< ' + l for l in a[a1:a2]])
+ yield "{}d{}{}".format(comma(a1, a2), b1, lineterm)
+ for l in a[a1:a2]:
+ yield '< ' + l
elif op == 'insert':
- result.append("%da%s" % (a1, comma(b1, b2)))
- result.extend(['> ' + l for l in b[b1:b2]])
+ yield "{}a{}{}".format(a1, comma(b1, b2), lineterm)
+ for l in b[b1:b2]:
+ yield '> ' + l
elif op == 'replace':
- result.append("%sc%s" % (comma(a1, a2), comma(b1, b2)))
- result.extend(['< ' + l for l in a[a1:a2]])
- result.append('---')
- result.extend(['> ' + l for l in b[b1:b2]])
- return result
+ yield "{}c{}{}".format(comma(a1, a2), comma(b1, b2), lineterm)
+ for l in a[a1:a2]:
+ yield '< ' + l
+ yield '---{}'.format(lineterm)
+ for l in b[b1:b2]:
+ yield '> ' + l
def diff_re(a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n'):
"""
+ Compare a and b (lists of strings) where a are regexes.
+
A simple "diff" of two sets of lines when the expected lines
are regular expressions. This is a really dumb thing that
just compares each line in turn, so it doesn't look for
@@ -587,9 +650,8 @@ def diff_re(a, b, fromfile='', tofile='',
a = a + [''] * (-diff)
elif diff > 0:
b = b + [''] * diff
- i = 0
- for aline, bline in zip(a, b):
- s = "^" + aline + "$"
+ for i, (aline, bline) in enumerate(zip(a, b)):
+ s = r"^{}$".format(aline)
try:
expr = re.compile(s)
except re.error as e:
@@ -600,7 +662,6 @@ def diff_re(a, b, fromfile='', tofile='',
result.append('< ' + repr(a[i]))
result.append('---')
result.append('> ' + repr(b[i]))
- i = i + 1
return result
@@ -974,6 +1035,12 @@ class TestCmd(object):
self.subdir(subdir)
self.fixture_dirs = []
+ try:
+ self.fixture_dirs = (os.environ['FIXTURE_DIRS']).split(os.pathsep)
+ except KeyError:
+ pass
+
+
def __del__(self):
self.cleanup()
@@ -1026,7 +1093,7 @@ class TestCmd(object):
condition = self.condition
if self._preserve[condition]:
for dir in self._dirlist:
- print(u"Preserved directory " + dir + "\n")
+ print(u"Preserved directory " + dir)
else:
list = self._dirlist[:]
list.reverse()
@@ -1242,6 +1309,7 @@ class TestCmd(object):
def read(self, file, mode='rb', newline=None):
"""Reads and returns the contents of the specified file name.
+
The file name may be a list, in which case the elements are
concatenated with the os.path.join() method. The file is
assumed to be under the temporary working directory unless it
@@ -1261,6 +1329,7 @@ class TestCmd(object):
def rmdir(self, dir):
"""Removes the specified dir name.
+
The dir name may be a list, in which case the elements are
concatenated with the os.path.join() method. The dir is
assumed to be under the temporary working directory unless it
@@ -1302,6 +1371,7 @@ class TestCmd(object):
"""Copies the contents of the specified folder srcdir from
the directory of the called script, to the current
working directory.
+
The srcdir name may be a list, in which case the elements are
concatenated with the os.path.join() method. The dstdir is
assumed to be under the temporary working directory, it gets
@@ -1343,6 +1413,7 @@ class TestCmd(object):
def file_fixture(self, srcfile, dstfile=None):
"""Copies the file srcfile from the directory of
the called script, to the current working directory.
+
The dstfile is assumed to be under the temporary working
directory unless it is an absolute path name.
If dstfile is specified its target directory gets created
@@ -1439,6 +1510,7 @@ class TestCmd(object):
def fix_binary_stream(stream):
"""
Handle stdout/stderr from popen when we specify universal_newlines = False.
+
This will read from the pipes in binary mode, not decode the output,
and not convert line endings to \n.
We do this because in py3 (3.5) with universal_newlines=True, it will
@@ -1455,7 +1527,7 @@ class TestCmd(object):
return stream
# TODO: Run full tests on both platforms and see if this fixes failures
# It seems that py3.6 still sets text mode if you set encoding.
- elif sys.version_info[0] == 3:# TODO and sys.version_info[1] < 6:
+ elif sys.version_info[0] == 3: # TODO and sys.version_info[1] < 6:
stream = stream.decode('utf-8')
stream = stream.replace('\r\n', '\n')
elif sys.version_info[0] == 2:
@@ -1629,7 +1701,7 @@ class TestCmd(object):
try:
os.mkdir(new)
except OSError as e:
- print("Got error :%s"%e)
+ print("Got error creating dir: %s :%s" % (sub, e))
pass
else:
count = count + 1
@@ -1662,10 +1734,11 @@ class TestCmd(object):
"""
if path is None:
try:
- path = tempfile.mktemp(prefix=tempfile.template)
+ path = tempfile.mkdtemp(prefix=testprefix)
except TypeError:
- path = tempfile.mktemp()
- os.mkdir(path)
+ path = tempfile.mkdtemp()
+ else:
+ os.mkdir(path)
# Symlinks in the path will report things
# differently from os.getcwd(), so chdir there
diff --git a/testing/framework/TestCmdTests.py b/testing/framework/TestCmdTests.py
index b9226fd..ef76228 100644
--- a/testing/framework/TestCmdTests.py
+++ b/testing/framework/TestCmdTests.py
@@ -26,13 +26,22 @@ import os
import shutil
import signal
import stat
-from StringIO import StringIO
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from io import StringIO
+from contextlib import closing
import sys
import tempfile
import time
import types
import unittest
-from UserList import UserList
+try:
+ from collections import UserList
+except ImportError:
+ from UserList import UserList
+
+from SCons.Util import to_bytes, to_str
# Strip the current directory so we get the right TestCmd.py module.
@@ -55,7 +64,7 @@ def _is_executable(path):
def _clear_dict(dict, *keys):
for key in keys:
try:
- dict[key] = '' # del dict[key]
+ del dict[key]
except KeyError:
pass
@@ -156,9 +165,9 @@ class TestCmdTestCase(unittest.TestCase):
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
- stdout, stderr = p.communicate(input)
- stdout = self.translate_newlines(stdout)
- stderr = self.translate_newlines(stderr)
+ stdout, stderr = p.communicate(to_bytes(input))
+ stdout = self.translate_newlines(to_str(stdout))
+ stderr = self.translate_newlines(to_str(stderr))
return stdout, stderr, p.returncode
def popen_python(self, input, status=0, stdout="", stderr="", python=None):
@@ -181,7 +190,7 @@ class TestCmdTestCase(unittest.TestCase):
def run_match(self, content, *args):
expect = "%s: %s: %s: %s\n" % args
- content = self.translate_newlines(content)
+ content = self.translate_newlines(to_str(content))
assert content == expect, \
"Expected %s ==========\n" % args[1] + expect + \
"Actual %s ============\n" % args[1] + content
@@ -257,6 +266,7 @@ result = TestCmd.TestCmd(workdir = '')
sys.exit(0)
""" % self.orig_cwd, stdout='my_exitfunc()\n')
+ @unittest.skipIf(TestCmd.IS_PY3, "No sys.exitfunc in Python 3")
def test_exitfunc(self):
"""Test cleanup() when sys.exitfunc is set"""
self.popen_python("""from __future__ import print_function
@@ -271,7 +281,6 @@ sys.exit(0)
""" % self.orig_cwd, stdout='my_exitfunc()\n')
-
class chmod_TestCase(TestCmdTestCase):
def test_chmod(self):
"""Test chmod()"""
@@ -280,8 +289,10 @@ class chmod_TestCase(TestCmdTestCase):
wdir_file1 = os.path.join(test.workdir, 'file1')
wdir_sub_file2 = os.path.join(test.workdir, 'sub', 'file2')
- open(wdir_file1, 'w').write("")
- open(wdir_sub_file2, 'w').write("")
+ with open(wdir_file1, 'w') as f:
+ f.write("")
+ with open(wdir_sub_file2, 'w') as f:
+ f.write("")
if sys.platform == 'win32':
@@ -349,11 +360,8 @@ sys.stderr.write("run2 STDERR third line\\n")
test = TestCmd.TestCmd(interpreter = 'python',
workdir = '',
combine = 1)
- try:
- output = test.stdout()
- except IndexError:
- pass
- else:
+ output = test.stdout()
+ if output is not None:
raise IndexError("got unexpected output:\n\t`%s'\n" % output)
# The underlying system subprocess implementations can combine
@@ -422,10 +430,13 @@ class diff_TestCase(TestCmdTestCase):
def test_diff_re(self):
"""Test diff_re()"""
result = TestCmd.diff_re(["abcde"], ["abcde"])
+ result = list(result)
assert result == [], result
result = TestCmd.diff_re(["a.*e"], ["abcde"])
+ result = list(result)
assert result == [], result
result = TestCmd.diff_re(["a.*e"], ["xxx"])
+ result = list(result)
assert result == ['1c1', "< 'a.*e'", '---', "> 'xxx'"], result
def test_diff_custom_function(self):
@@ -475,13 +486,13 @@ STDOUT==========================================================================
script_input = """import sys
sys.path = ['%s'] + sys.path
import TestCmd
-assert TestCmd.diff_re(["a.*(e"], ["abcde"])
+assert TestCmd.diff_re([r"a.*(e"], ["abcde"])
sys.exit(0)
""" % self.orig_cwd
stdout, stderr, status = self.call_python(script_input)
assert status == 1, status
- expect1 = "Regular expression error in '^a.*(e$': missing )\n"
- expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis\n"
+ expect1 = "Regular expression error in '^a.*(e$': missing )"
+ expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis"
assert (stderr.find(expect1) != -1 or
stderr.find(expect2) != -1), repr(stderr)
@@ -492,6 +503,7 @@ sys.path = ['%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.simple_diff(['a', 'b', 'c', 'e', 'f1'],
['a', 'c', 'd', 'e', 'f2'])
+result = list(result)
expect = ['2d1', '< b', '3a3', '> d', '5c5', '< f1', '---', '> f2']
assert result == expect, result
sys.exit(0)
@@ -557,6 +569,7 @@ sys.path = ['%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.diff_re(['a', 'b', 'c', '.', 'f1'],
['a', 'c', 'd', 'e', 'f2'])
+result = list(result)
expect = [
'2c2',
"< 'b'",
@@ -844,22 +857,22 @@ test.%s()
_test_it(cwd, 'dir04', 'pass_test', 1)
_test_it(cwd, 'dir05', 'fail_test', 1)
_test_it(cwd, 'dir06', 'no_result', 1)
- os.environ['PRESERVE'] = '' # del os.environ['PRESERVE']
+ del os.environ['PRESERVE']
os.environ['PRESERVE_PASS'] = '1'
_test_it(cwd, 'dir07', 'pass_test', 1)
_test_it(cwd, 'dir08', 'fail_test', 0)
_test_it(cwd, 'dir09', 'no_result', 0)
- os.environ['PRESERVE_PASS'] = '' # del os.environ['PRESERVE_PASS']
+ del os.environ['PRESERVE_PASS']
os.environ['PRESERVE_FAIL'] = '1'
_test_it(cwd, 'dir10', 'pass_test', 0)
_test_it(cwd, 'dir11', 'fail_test', 1)
_test_it(cwd, 'dir12', 'no_result', 0)
- os.environ['PRESERVE_FAIL'] = '' # del os.environ['PRESERVE_FAIL']
+ del os.environ['PRESERVE_FAIL']
os.environ['PRESERVE_NO_RESULT'] = '1'
_test_it(cwd, 'dir13', 'pass_test', 0)
_test_it(cwd, 'dir14', 'fail_test', 0)
_test_it(cwd, 'dir15', 'no_result', 1)
- os.environ['PRESERVE_NO_RESULT'] = '' # del os.environ['PRESERVE_NO_RESULT']
+ del os.environ['PRESERVE_NO_RESULT']
finally:
_clear_dict(os.environ, 'PRESERVE', 'PRESERVE_PASS', 'PRESERVE_FAIL', 'PRESERVE_NO_RESULT')
@@ -980,10 +993,10 @@ class match_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match = TestCmd.match_exact)
assert not test.match("abcde\n", "a.*e\n")
assert test.match("abcde\n", "abcde\n")
- assert not test.match("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match(lines, regexes)
assert test.match(lines, lines)
@@ -992,10 +1005,10 @@ class match_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match=TestCmd.TestCmd.match_exact)
assert not test.match("abcde\n", "a.*e\n")
assert test.match("abcde\n", "abcde\n")
- assert not test.match("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match(lines, regexes)
assert test.match(lines, lines)
@@ -1004,10 +1017,10 @@ class match_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match='match_exact')
assert not test.match("abcde\n", "a.*e\n")
assert test.match("abcde\n", "abcde\n")
- assert not test.match("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match(lines, regexes)
assert test.match(lines, lines)
@@ -1057,16 +1070,16 @@ class match_exact_TestCase(TestCmdTestCase):
class match_re_dotall_TestCase(TestCmdTestCase):
def test_match_re_dotall_function(self):
"""Test calling the TestCmd.match_re_dotall() function"""
- assert TestCmd.match_re_dotall("abcde\nfghij\n", "a.*j\n")
+ assert TestCmd.match_re_dotall("abcde\nfghij\n", r"a.*j\n")
def test_match_re_dotall_instance_method(self):
"""Test calling the TestCmd.TestCmd().match_re_dotall() instance method"""
test = TestCmd.TestCmd()
- test.match_re_dotall("abcde\\nfghij\\n", "a.*j\\n")
+ test.match_re_dotall("abcde\\nfghij\\n", r"a.*j\\n")
def test_match_re_dotall_static_method(self):
"""Test calling the TestCmd.TestCmd.match_re_dotall() static method"""
- assert TestCmd.TestCmd.match_re_dotall("abcde\nfghij\n", "a.*j\n")
+ assert TestCmd.TestCmd.match_re_dotall("abcde\nfghij\n", r"a.*j\n")
def test_error(self):
"""Test handling a compilation error in TestCmd.match_re_dotall()"""
@@ -1079,13 +1092,13 @@ class match_re_dotall_TestCase(TestCmdTestCase):
script_input = """import sys
sys.path = ['%s'] + sys.path
import TestCmd
-assert TestCmd.match_re_dotall("abcde", "a.*(e")
+assert TestCmd.match_re_dotall("abcde", r"a.*(e")
sys.exit(0)
""" % cwd
stdout, stderr, status = self.call_python(script_input)
assert status == 1, status
- expect1 = "Regular expression error in '^a.*(e$': missing )\n"
- expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis\n"
+ expect1 = "Regular expression error in '^a.*(e$': missing )"
+ expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis"
assert (stderr.find(expect1) != -1 or
stderr.find(expect2) != -1), repr(stderr)
finally:
@@ -1094,44 +1107,34 @@ sys.exit(0)
def test_evaluation(self):
"""Test match_re_dotall() evaluation"""
test = TestCmd.TestCmd()
- assert test.match_re_dotall("abcde\nfghij\n", "a.*e\nf.*j\n")
- assert test.match_re_dotall("abcde\nfghij\n", "a[^j]*j\n")
- assert test.match_re_dotall("abcde\nfghij\n", "abcde\nfghij\n")
+ assert test.match_re_dotall("abcde\nfghij\n", r"a.*e\nf.*j\n")
+ assert test.match_re_dotall("abcde\nfghij\n", r"a[^j]*j\n")
+ assert test.match_re_dotall("abcde\nfghij\n", r"abcde\nfghij\n")
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- ["1[0-9]*5\n", "a.*e\n", "f.*j\n"])
+ [r"1[0-9]*5\n", r"a.*e\n", r"f.*j\n"])
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- ["1.*j\n"])
+ [r"1.*j\n"])
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- ["12345\n", "abcde\n", "fghij\n"])
- assert test.match_re_dotall(UserList(["12345\n",
- "abcde\n",
- "fghij\n"]),
- ["1[0-9]*5\n", "a.*e\n", "f.*j\n"])
- assert test.match_re_dotall(UserList(["12345\n",
- "abcde\n",
- "fghij\n"]),
- ["1.*j\n"])
- assert test.match_re_dotall(UserList(["12345\n",
- "abcde\n",
- "fghij\n"]),
- ["12345\n", "abcde\n", "fghij\n"])
+ [r"12345\n", r"abcde\n", r"fghij\n"])
+ assert test.match_re_dotall(UserList(["12345\n", "abcde\n", "fghij\n"]),
+ [r"1[0-9]*5\n", r"a.*e\n", r"f.*j\n"])
+ assert test.match_re_dotall(UserList(["12345\n", "abcde\n", "fghij\n"]),
+ [r"1.*j\n"])
+ assert test.match_re_dotall(UserList(["12345\n", "abcde\n", "fghij\n"]),
+ [r"12345\n", r"abcde\n", r"fghij\n"])
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- UserList(["1[0-9]*5\n",
- "a.*e\n",
- "f.*j\n"]))
+ UserList([r"1[0-9]*5\n", r"a.*e\n", r"f.*j\n"]))
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- UserList(["1.*j\n"]))
+ UserList([r"1.*j\n"]))
assert test.match_re_dotall(["12345\n", "abcde\n", "fghij\n"],
- UserList(["12345\n",
- "abcde\n",
- "fghij\n"]))
+ UserList([r"12345\n", r"abcde\n", r"fghij\n"]))
assert test.match_re_dotall("12345\nabcde\nfghij\n",
- "1[0-9]*5\na.*e\nf.*j\n")
- assert test.match_re_dotall("12345\nabcde\nfghij\n", "1.*j\n")
+ r"1[0-9]*5\na.*e\nf.*j\n")
+ assert test.match_re_dotall("12345\nabcde\nfghij\n", r"1.*j\n")
assert test.match_re_dotall("12345\nabcde\nfghij\n",
- "12345\nabcde\nfghij\n")
+ r"12345\nabcde\nfghij\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_re_dotall(lines, regexes)
assert test.match_re_dotall(lines, lines)
@@ -1167,8 +1170,8 @@ sys.exit(0)
""" % cwd
stdout, stderr, status = self.call_python(script_input)
assert status == 1, status
- expect1 = "Regular expression error in '^a.*(e$': missing )\n"
- expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis\n"
+ expect1 = "Regular expression error in '^a.*(e$': missing )"
+ expect2 = "Regular expression error in '^a.*(e$': unbalanced parenthesis"
assert (stderr.find(expect1) != -1 or
stderr.find(expect2) != -1), repr(stderr)
finally:
@@ -1192,7 +1195,7 @@ sys.exit(0)
assert test.match_re("12345\nabcde\n", "1[0-9]*5\na.*e\n")
assert test.match_re("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_re(lines, regexes)
assert test.match_re(lines, lines)
@@ -1205,7 +1208,7 @@ class match_stderr_TestCase(TestCmdTestCase):
assert test.match_stderr("abcde\n", "a.*e\n")
assert test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_stderr(lines, regexes)
def test_match_stderr_not_affecting_match_stdout(self):
@@ -1217,14 +1220,14 @@ class match_stderr_TestCase(TestCmdTestCase):
assert not test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stderr("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stderr(lines, regexes)
assert test.match_stderr(lines, lines)
assert test.match_stdout("abcde\n", "a.*e\n")
assert test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_stdout(lines, regexes)
def test_match_stderr_custom_function(self):
@@ -1237,7 +1240,7 @@ class match_stderr_TestCase(TestCmdTestCase):
assert not test.match_stderr("123\n123\n", "1\n1\n")
assert test.match_stderr("123\n123\n", "111\n111\n")
lines = ["123\n", "123\n"]
- regexes = ["1\n", "1\n"]
+ regexes = [r"1\n", r"1\n"]
assert test.match_stderr(lines, regexes) # equal numbers of lines
def test_match_stderr_TestCmd_function(self):
@@ -1245,10 +1248,10 @@ class match_stderr_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stderr = TestCmd.match_exact)
assert not test.match_stderr("abcde\n", "a.*e\n")
assert test.match_stderr("abcde\n", "abcde\n")
- assert not test.match_stderr("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stderr("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stderr(lines, regexes)
assert test.match_stderr(lines, lines)
@@ -1257,10 +1260,10 @@ class match_stderr_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stderr=TestCmd.TestCmd.match_exact)
assert not test.match_stderr("abcde\n", "a.*e\n")
assert test.match_stderr("abcde\n", "abcde\n")
- assert not test.match_stderr("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stderr("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stderr(lines, regexes)
assert test.match_stderr(lines, lines)
@@ -1269,10 +1272,10 @@ class match_stderr_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stderr='match_exact')
assert not test.match_stderr("abcde\n", "a.*e\n")
assert test.match_stderr("abcde\n", "abcde\n")
- assert not test.match_stderr("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stderr("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stderr(lines, regexes)
assert test.match_stderr(lines, lines)
@@ -1285,7 +1288,7 @@ class match_stdout_TestCase(TestCmdTestCase):
assert test.match_stdout("abcde\n", "a.*e\n")
assert test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_stdout(lines, regexes)
def test_match_stdout_not_affecting_match_stderr(self):
@@ -1297,14 +1300,14 @@ class match_stdout_TestCase(TestCmdTestCase):
assert not test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stdout("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stdout(lines, regexes)
assert test.match_stdout(lines, lines)
assert test.match_stderr("abcde\n", "a.*e\n")
assert test.match_stderr("12345\nabcde\n", "1\\d+5\na.*e\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert test.match_stderr(lines, regexes)
def test_match_stdout_custom_function(self):
@@ -1317,7 +1320,7 @@ class match_stdout_TestCase(TestCmdTestCase):
assert not test.match_stdout("123\n123\n", "1\n1\n")
assert test.match_stdout("123\n123\n", "111\n111\n")
lines = ["123\n", "123\n"]
- regexes = ["1\n", "1\n"]
+ regexes = [r"1\n", r"1\n"]
assert test.match_stdout(lines, regexes) # equal numbers of lines
def test_match_stdout_TestCmd_function(self):
@@ -1325,10 +1328,10 @@ class match_stdout_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stdout = TestCmd.match_exact)
assert not test.match_stdout("abcde\n", "a.*e\n")
assert test.match_stdout("abcde\n", "abcde\n")
- assert not test.match_stdout("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stdout("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stdout(lines, regexes)
assert test.match_stdout(lines, lines)
@@ -1337,10 +1340,10 @@ class match_stdout_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stdout=TestCmd.TestCmd.match_exact)
assert not test.match_stdout("abcde\n", "a.*e\n")
assert test.match_stdout("abcde\n", "abcde\n")
- assert not test.match_stdout("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stdout("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stdout(lines, regexes)
assert test.match_stdout(lines, lines)
@@ -1349,10 +1352,10 @@ class match_stdout_TestCase(TestCmdTestCase):
test = TestCmd.TestCmd(match_stdout='match_exact')
assert not test.match_stdout("abcde\n", "a.*e\n")
assert test.match_stdout("abcde\n", "abcde\n")
- assert not test.match_stdout("12345\nabcde\n", "1\d+5\na.*e\n")
+ assert not test.match_stdout("12345\nabcde\n", "1\\d+5\na.*e\n")
assert test.match_stdout("12345\nabcde\n", "12345\nabcde\n")
lines = ["vwxyz\n", "67890\n"]
- regexes = ["v[^a-u]*z\n", "6[^ ]+0\n"]
+ regexes = [r"v[^a-u]*z\n", r"6[^ ]+0\n"]
assert not test.match_stdout(lines, regexes)
assert test.match_stdout(lines, lines)
@@ -1468,20 +1471,20 @@ class preserve_TestCase(TestCmdTestCase):
def test_preserve(self):
"""Test preserve()"""
def cleanup_test(test, cond=None, stdout=""):
- io = StringIO()
save = sys.stdout
- sys.stdout = io
- try:
- if cond:
- test.cleanup(cond)
- else:
- test.cleanup()
- o = io.getvalue()
- assert o == stdout, "o = `%s', stdout = `%s'" % (o, stdout)
- finally:
- sys.stdout = save
-
- test = TestCmd.TestCmd(workdir = '')
+ with closing(StringIO()) as io:
+ sys.stdout = io
+ try:
+ if cond:
+ test.cleanup(cond)
+ else:
+ test.cleanup()
+ o = io.getvalue()
+ assert o == stdout, "o = `%s', stdout = `%s'" % (o, stdout)
+ finally:
+ sys.stdout = save
+
+ test = TestCmd.TestCmd(workdir='')
wdir = test.workdir
try:
test.write('file1', "Test file #1\n")
@@ -1490,10 +1493,10 @@ class preserve_TestCase(TestCmdTestCase):
assert not os.path.exists(wdir)
finally:
if os.path.exists(wdir):
- shutil.rmtree(wdir, ignore_errors = 1)
+ shutil.rmtree(wdir, ignore_errors=1)
test._dirlist.remove(wdir)
- test = TestCmd.TestCmd(workdir = '')
+ test = TestCmd.TestCmd(workdir='')
wdir = test.workdir
try:
test.write('file2', "Test file #2\n")
@@ -1576,11 +1579,16 @@ class read_TestCase(TestCmdTestCase):
wdir_file4 = os.path.join(test.workdir, 'file4')
wdir_file5 = os.path.join(test.workdir, 'file5')
- open(wdir_file1, 'wb').write("")
- open(wdir_file2, 'wb').write("Test\nfile\n#2.\n")
- open(wdir_foo_file3, 'wb').write("Test\nfile\n#3.\n")
- open(wdir_file4, 'wb').write("Test\nfile\n#4.\n")
- open(wdir_file5, 'wb').write("Test\r\nfile\r\n#5.\r\n")
+ with open(wdir_file1, 'wb') as f:
+ f.write(to_bytes(""))
+ with open(wdir_file2, 'wb') as f:
+ f.write(to_bytes("Test\nfile\n#2.\n"))
+ with open(wdir_foo_file3, 'wb') as f:
+ f.write(to_bytes("Test\nfile\n#3.\n"))
+ with open(wdir_file4, 'wb') as f:
+ f.write(to_bytes("Test\nfile\n#4.\n"))
+ with open(wdir_file5, 'wb') as f:
+ f.write(to_bytes("Test\r\nfile\r\n#5.\r\n"))
try:
contents = test.read('no_file')
@@ -1597,6 +1605,7 @@ class read_TestCase(TestCmdTestCase):
raise
def _file_matches(file, contents, expected):
+ contents = to_str(contents)
assert contents == expected, \
"Expected contents of " + str(file) + "==========\n" + \
expected + \
@@ -1627,7 +1636,7 @@ class rmdir_TestCase(TestCmdTestCase):
except EnvironmentError:
pass
else:
- raise Exception("did not catch expected EnvironmentError")
+ raise Exception("did not catch expected SConsEnvironmentError")
test.subdir(['sub'],
['sub', 'dir'],
@@ -1642,7 +1651,7 @@ class rmdir_TestCase(TestCmdTestCase):
except EnvironmentError:
pass
else:
- raise Exception("did not catch expected EnvironmentError")
+ raise Exception("did not catch expected SConsEnvironmentError")
assert os.path.isdir(s_d_o), "%s is gone?" % s_d_o
@@ -1651,7 +1660,7 @@ class rmdir_TestCase(TestCmdTestCase):
except EnvironmentError:
pass
else:
- raise Exception("did not catch expected EnvironmentError")
+ raise Exception("did not catch expected SConsEnvironmentError")
assert os.path.isdir(s_d_o), "%s is gone?" % s_d_o
@@ -1867,29 +1876,25 @@ class run_verbose_TestCase(TestCmdTestCase):
workdir = '',
verbose = 1)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- test.run(arguments = ['arg1 arg2'])
- o = sys.stdout.getvalue()
- assert o == '', o
- e = sys.stderr.getvalue()
- expect = 'python "%s" "arg1 arg2"\n' % t.script_path
- assert expect == e, (expect, e)
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
+ o = sys.stdout.getvalue()
+ assert o == '', o
+ e = sys.stderr.getvalue()
+ expect = 'python "%s" "arg1 arg2"\n' % t.script_path
+ assert expect == e, (expect, e)
testx = TestCmd.TestCmd(program = t.scriptx,
workdir = '',
verbose = 1)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- testx.run(arguments = ['arg1 arg2'])
- expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
- o = sys.stdout.getvalue()
- assert o == '', o
- e = sys.stderr.getvalue()
- assert expect == e, (expect, e)
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ testx.run(arguments = ['arg1 arg2'])
+ expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
+ o = sys.stdout.getvalue()
+ assert o == '', o
+ e = sys.stderr.getvalue()
+ assert expect == e, (expect, e)
# Test calling TestCmd() with an explicit verbose = 2.
@@ -1918,43 +1923,39 @@ class run_verbose_TestCase(TestCmdTestCase):
workdir = '',
verbose = 2)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
- test.run(arguments = ['arg1 arg2'])
+ line_fmt = "script: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ stderr_line = line_fmt % ('STDERR', t.sub_dir)
+ expect = outerr_fmt % (len(stdout_line), stdout_line,
+ len(stderr_line), stderr_line)
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- line_fmt = "script: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- stderr_line = line_fmt % ('STDERR', t.sub_dir)
- expect = outerr_fmt % (len(stdout_line), stdout_line,
- len(stderr_line), stderr_line)
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
-
- expect = 'python "%s" "arg1 arg2"\n' % t.script_path
- e = sys.stderr.getvalue()
- assert e == expect, (e, expect)
+ expect = 'python "%s" "arg1 arg2"\n' % t.script_path
+ e = sys.stderr.getvalue()
+ assert e == expect, (e, expect)
testx = TestCmd.TestCmd(program = t.scriptx,
workdir = '',
verbose = 2)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- testx.run(arguments = ['arg1 arg2'])
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ testx.run(arguments = ['arg1 arg2'])
- line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- stderr_line = line_fmt % ('STDERR', t.sub_dir)
- expect = outerr_fmt % (len(stdout_line), stdout_line,
- len(stderr_line), stderr_line)
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
+ line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ stderr_line = line_fmt % ('STDERR', t.sub_dir)
+ expect = outerr_fmt % (len(stdout_line), stdout_line,
+ len(stderr_line), stderr_line)
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
- e = sys.stderr.getvalue()
- assert e == expect, (e, expect)
+ expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
+ e = sys.stderr.getvalue()
+ assert e == expect, (e, expect)
# Test calling TestCmd() with an explicit verbose = 3.
@@ -1963,41 +1964,37 @@ class run_verbose_TestCase(TestCmdTestCase):
workdir = '',
verbose = 2)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
- test.run(arguments = ['arg1 arg2'])
+ line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ expect = out_fmt % (len(stdout_line), stdout_line)
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- expect = out_fmt % (len(stdout_line), stdout_line)
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
-
- e = sys.stderr.getvalue()
- expect = 'python "%s" "arg1 arg2"\n' % (t.scriptout_path)
- assert e == expect, (e, expect)
+ e = sys.stderr.getvalue()
+ expect = 'python "%s" "arg1 arg2"\n' % (t.scriptout_path)
+ assert e == expect, (e, expect)
test = TestCmd.TestCmd(program = t.scriptout,
interpreter = 'python',
workdir = '',
verbose = 3)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- test.run(arguments = ['arg1 arg2'])
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
- line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- expect = outerr_fmt % (len(stdout_line), stdout_line,
- '0', '')
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
+ line_fmt = "scriptout: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ expect = outerr_fmt % (len(stdout_line), stdout_line,
+ '0', '')
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- e = sys.stderr.getvalue()
- expect = 'python "%s" "arg1 arg2"\n' % (t.scriptout_path)
- assert e == expect, (e, expect)
+ e = sys.stderr.getvalue()
+ expect = 'python "%s" "arg1 arg2"\n' % (t.scriptout_path)
+ assert e == expect, (e, expect)
# Test letting TestCmd() pick up verbose = 2 from the environment.
@@ -2007,42 +2004,38 @@ class run_verbose_TestCase(TestCmdTestCase):
interpreter = 'python',
workdir = '')
- sys.stdout = StringIO()
- sys.stderr = StringIO()
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
- test.run(arguments = ['arg1 arg2'])
+ line_fmt = "script: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ stderr_line = line_fmt % ('STDERR', t.sub_dir)
+ expect = outerr_fmt % (len(stdout_line), stdout_line,
+ len(stderr_line), stderr_line)
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- line_fmt = "script: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- stderr_line = line_fmt % ('STDERR', t.sub_dir)
- expect = outerr_fmt % (len(stdout_line), stdout_line,
- len(stderr_line), stderr_line)
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
-
- expect = 'python "%s" "arg1 arg2"\n' % t.script_path
- e = sys.stderr.getvalue()
- assert e == expect, (e, expect)
+ expect = 'python "%s" "arg1 arg2"\n' % t.script_path
+ e = sys.stderr.getvalue()
+ assert e == expect, (e, expect)
testx = TestCmd.TestCmd(program = t.scriptx,
workdir = '')
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- testx.run(arguments = ['arg1 arg2'])
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ testx.run(arguments = ['arg1 arg2'])
- line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n"
- stdout_line = line_fmt % ('STDOUT', t.sub_dir)
- stderr_line = line_fmt % ('STDERR', t.sub_dir)
- expect = outerr_fmt % (len(stdout_line), stdout_line,
- len(stderr_line), stderr_line)
- o = sys.stdout.getvalue()
- assert expect == o, (expect, o)
+ line_fmt = "scriptx.bat: %s: %s: ['arg1 arg2']\n"
+ stdout_line = line_fmt % ('STDOUT', t.sub_dir)
+ stderr_line = line_fmt % ('STDERR', t.sub_dir)
+ expect = outerr_fmt % (len(stdout_line), stdout_line,
+ len(stderr_line), stderr_line)
+ o = sys.stdout.getvalue()
+ assert expect == o, (expect, o)
- expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
- e = sys.stderr.getvalue()
- assert e == expect, (e, expect)
+ expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
+ e = sys.stderr.getvalue()
+ assert e == expect, (e, expect)
# Test letting TestCmd() pick up verbose = 1 from the environment.
@@ -2053,29 +2046,25 @@ class run_verbose_TestCase(TestCmdTestCase):
workdir = '',
verbose = 1)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- test.run(arguments = ['arg1 arg2'])
- o = sys.stdout.getvalue()
- assert o == '', o
- e = sys.stderr.getvalue()
- expect = 'python "%s" "arg1 arg2"\n' % t.script_path
- assert expect == e, (expect, e)
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ test.run(arguments = ['arg1 arg2'])
+ o = sys.stdout.getvalue()
+ assert o == '', o
+ e = sys.stderr.getvalue()
+ expect = 'python "%s" "arg1 arg2"\n' % t.script_path
+ assert expect == e, (expect, e)
testx = TestCmd.TestCmd(program = t.scriptx,
workdir = '',
verbose = 1)
- sys.stdout = StringIO()
- sys.stderr = StringIO()
-
- testx.run(arguments = ['arg1 arg2'])
- expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
- o = sys.stdout.getvalue()
- assert o == '', o
- e = sys.stderr.getvalue()
- assert expect == e, (expect, e)
+ with closing(StringIO()) as sys.stdout, closing(StringIO()) as sys.stderr:
+ testx.run(arguments = ['arg1 arg2'])
+ expect = '"%s" "arg1 arg2"\n' % t.scriptx_path
+ o = sys.stdout.getvalue()
+ assert o == '', o
+ e = sys.stderr.getvalue()
+ assert expect == e, (expect, e)
finally:
sys.stdout = save_stdout
@@ -2343,16 +2332,15 @@ sys.stderr = Unbuffered(sys.stderr)
sys.stdout.write('script_recv: STDOUT\\n')
sys.stderr.write('script_recv: STDERR\\n')
-logfp = open(r'%s', 'wb')
-while 1:
- line = sys.stdin.readline()
- if not line:
- break
- logfp.write('script_recv: ' + line)
- sys.stdout.write('script_recv: STDOUT: ' + line)
- sys.stderr.write('script_recv: STDERR: ' + line)
-logfp.close()
- """ % t.recv_out_path
+with open(r'%s', 'wb') as logfp:
+ while 1:
+ line = sys.stdin.readline()
+ if not line:
+ break
+ logfp.write('script_recv: ' + line)
+ sys.stdout.write('script_recv: STDOUT: ' + line)
+ sys.stderr.write('script_recv: STDERR: ' + line)
+""" % t.recv_out_path
t.run_env.write(t.recv_script_path, text)
os.chmod(t.recv_script_path, 0o644) # XXX UNIX-specific
return t
@@ -2618,10 +2606,11 @@ script_recv: STDERR: input
p = test.start(stdin=1)
input = 'stdin.write() input to the receive script\n'
- p.stdin.write(input)
+ p.stdin.write(to_bytes(input))
p.stdin.close()
p.wait()
- result = open(t.recv_out_path, 'rb').read()
+ with open(t.recv_out_path, 'rb') as f:
+ result = to_str(f.read())
expect = 'script_recv: ' + input
assert result == expect, repr(result)
@@ -2630,7 +2619,8 @@ script_recv: STDERR: input
p.send(input)
p.stdin.close()
p.wait()
- result = open(t.recv_out_path, 'rb').read()
+ with open(t.recv_out_path, 'rb') as f:
+ result = to_str(f.read())
expect = 'script_recv: ' + input
assert result == expect, repr(result)
@@ -2689,7 +2679,8 @@ script_recv: STDERR: input to the receive script
"""
assert stdout == expect_stdout, stdout
assert stderr == expect_stderr, stderr
- result = open(t.recv_out_path, 'rb').read()
+ with open(t.recv_out_path, 'rb') as f:
+ result = f.read()
expect = ('script_recv: ' + input) * 2
assert result == expect, (result, stdout, stderr)
@@ -2745,11 +2736,8 @@ sys.stderr.write("run2 STDERR second line\\n")
# Everything before this prepared our "source directory."
# Now do the real test.
test = TestCmd.TestCmd(interpreter = 'python', workdir = '')
- try:
- output = test.stdout()
- except IndexError:
- pass
- else:
+ output = test.stdout()
+ if output is not None:
raise IndexError("got unexpected output:\n\t`%s'\n" % output)
test.program_set('run1')
test.run(arguments = 'foo bar')
@@ -2807,15 +2795,18 @@ class symlink_TestCase(TestCmdTestCase):
test.symlink('target1', 'file1')
assert os.path.islink(wdir_file1)
assert not os.path.exists(wdir_file1)
- open(wdir_target1, 'w').write("")
+ with open(wdir_target1, 'w') as f:
+ f.write("")
assert os.path.exists(wdir_file1)
test.symlink('target2', ['foo', 'file2'])
assert os.path.islink(wdir_foo_file2)
assert not os.path.exists(wdir_foo_file2)
- open(wdir_target2, 'w').write("")
+ with open(wdir_target2, 'w') as f:
+ f.write("")
assert not os.path.exists(wdir_foo_file2)
- open(wdir_foo_target2, 'w').write("")
+ with open(wdir_foo_target2, 'w') as f:
+ f.write("")
assert os.path.exists(wdir_foo_file2)
@@ -2947,12 +2938,18 @@ class unlink_TestCase(TestCmdTestCase):
wdir_foo_file4 = os.path.join(test.workdir, 'foo', 'file4')
wdir_file5 = os.path.join(test.workdir, 'file5')
- open(wdir_file1, 'w').write("")
- open(wdir_file2, 'w').write("")
- open(wdir_foo_file3a, 'w').write("")
- open(wdir_foo_file3b, 'w').write("")
- open(wdir_foo_file4, 'w').write("")
- open(wdir_file5, 'w').write("")
+ with open(wdir_file1, 'w') as f:
+ f.write("")
+ with open(wdir_file2, 'w') as f:
+ f.write("")
+ with open(wdir_foo_file3a, 'w') as f:
+ f.write("")
+ with open(wdir_foo_file3b, 'w') as f:
+ f.write("")
+ with open(wdir_foo_file4, 'w') as f:
+ f.write("")
+ with open(wdir_file5, 'w') as f:
+ f.write("")
try:
contents = test.unlink('no_file')
@@ -2981,20 +2978,17 @@ class unlink_TestCase(TestCmdTestCase):
# For Windows, open the file.
os.chmod(test.workdir, 0o500)
os.chmod(wdir_file5, 0o400)
- f = open(wdir_file5, 'r')
-
- try:
+ with open(wdir_file5, 'r'):
try:
- test.unlink('file5')
- except OSError: # expect "Permission denied"
- pass
- except:
- raise
- finally:
- os.chmod(test.workdir, 0o700)
- os.chmod(wdir_file5, 0o600)
- f.close()
-
+ try:
+ test.unlink('file5')
+ except OSError: # expect "Permission denied"
+ pass
+ except:
+ raise
+ finally:
+ os.chmod(test.workdir, 0o700)
+ os.chmod(wdir_file5, 0o600)
class touch_TestCase(TestCmdTestCase):
@@ -3005,8 +2999,10 @@ class touch_TestCase(TestCmdTestCase):
wdir_file1 = os.path.join(test.workdir, 'file1')
wdir_sub_file2 = os.path.join(test.workdir, 'sub', 'file2')
- open(wdir_file1, 'w').write("")
- open(wdir_sub_file2, 'w').write("")
+ with open(wdir_file1, 'w') as f:
+ f.write("")
+ with open(wdir_sub_file2, 'w') as f:
+ f.write("")
file1_old_time = os.path.getmtime(wdir_file1)
file2_old_time = os.path.getmtime(wdir_sub_file2)
@@ -3312,9 +3308,12 @@ class write_TestCase(TestCmdTestCase):
if os.name != "nt":
assert not os.path.exists(test.workpath('file10'))
- assert open(test.workpath('file8'), 'r').read() == "Test file #8.\n"
- assert open(test.workpath('file9'), 'rb').read() == "Test file #9.\r\n"
-
+ with open(test.workpath('file8'), 'r') as f:
+ res = f.read()
+ assert res == "Test file #8.\n", res
+ with open(test.workpath('file9'), 'rb') as f:
+ res = to_str(f.read())
+ assert res == "Test file #9.\r\n", res
class variables_TestCase(TestCmdTestCase):
diff --git a/testing/framework/TestRuntest.py b/testing/framework/TestRuntest.py
index 64dcf17..e9ca524 100644
--- a/testing/framework/TestRuntest.py
+++ b/testing/framework/TestRuntest.py
@@ -14,7 +14,7 @@ attributes defined in this subclass.
# Copyright (c) 2001 - 2019 The SCons Foundation
-__revision__ = "testing/framework/TestRuntest.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "testing/framework/TestRuntest.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -30,7 +30,7 @@ __all__.extend([ 'TestRuntest',
'pythonflags',
])
-if re.search('\s', python):
+if re.search(r'\s', python):
pythonstring = _python_
else:
pythonstring = python
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))
diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py
index 09cb5ee..86935fd 100644
--- a/testing/framework/TestSConsMSVS.py
+++ b/testing/framework/TestSConsMSVS.py
@@ -15,7 +15,7 @@ in this subclass.
# Copyright (c) 2001 - 2019 The SCons Foundation
-__revision__ = "testing/framework/TestSConsMSVS.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "testing/framework/TestSConsMSVS.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
@@ -23,6 +23,7 @@ import platform
import traceback
from xml.etree import ElementTree
+import SCons.Errors
from TestSCons import *
from TestSCons import __all__
@@ -38,18 +39,18 @@ expected_dspfile_6_0 = '''\
CFG=Test - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "Test.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Release"
-!MESSAGE
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
+!MESSAGE
!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) External Target")
-!MESSAGE
+!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
@@ -85,7 +86,7 @@ CFG=Test - Win32 Release
!IF "$(CFG)" == "Test - Win32 Release"
-!ENDIF
+!ENDIF
# Begin Group "Header Files"
@@ -435,31 +436,10 @@ env.MSVSProject(target = 'Test.vcproj',
"""
-
-expected_slnfile_8_0 = """\
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "<PROJECT_GUID>"
-EndProject
-Global
-<SCC_SLN_INFO>
-\tGlobalSection(SolutionConfigurationPlatforms) = preSolution
-\t\tRelease|Win32 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(ProjectConfigurationPlatforms) = postSolution
-\t\t<PROJECT_GUID>.Release|Win32.ActiveCfg = Release|Win32
-\t\t<PROJECT_GUID>.Release|Win32.Build.0 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(SolutionProperties) = preSolution
-\t\tHideSolutionNode = FALSE
-\tEndGlobalSection
-EndGlobal
-"""
-
-expected_slnfile_9_0 = """\
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "<PROJECT_GUID>"
+expected_slnfile_fmt = """\
+Microsoft Visual Studio Solution File, Format Version %(FORMAT_VERSION)s
+# Visual Studio %(VS_NUMBER)s
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "%(PROJECT_NAME)s", "%(PROJECT_FILE)s", "<PROJECT_GUID>"
EndProject
Global
<SCC_SLN_INFO>
@@ -476,91 +456,11 @@ Global
EndGlobal
"""
-expected_slnfile_10_0 = """\
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}"
-EndProject
-Global
-<SCC_SLN_INFO>
-\tGlobalSection(SolutionConfigurationPlatforms) = preSolution
-\t\tRelease|Win32 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(ProjectConfigurationPlatforms) = postSolution
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(SolutionProperties) = preSolution
-\t\tHideSolutionNode = FALSE
-\tEndGlobalSection
-EndGlobal
-"""
-
-expected_slnfile_11_0 = """\
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 11
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}"
-EndProject
-Global
-<SCC_SLN_INFO>
-\tGlobalSection(SolutionConfigurationPlatforms) = preSolution
-\t\tRelease|Win32 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(ProjectConfigurationPlatforms) = postSolution
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(SolutionProperties) = preSolution
-\t\tHideSolutionNode = FALSE
-\tEndGlobalSection
-EndGlobal
-"""
-
-expected_slnfile_14_0 = """\
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}"
-EndProject
-Global
-<SCC_SLN_INFO>
-\tGlobalSection(SolutionConfigurationPlatforms) = preSolution
-\t\tRelease|Win32 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(ProjectConfigurationPlatforms) = postSolution
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(SolutionProperties) = preSolution
-\t\tHideSolutionNode = FALSE
-\tEndGlobalSection
-EndGlobal
-"""
-
-expected_slnfile_14_1 = """\
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}"
-EndProject
-Global
-<SCC_SLN_INFO>
-\tGlobalSection(SolutionConfigurationPlatforms) = preSolution
-\t\tRelease|Win32 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(ProjectConfigurationPlatforms) = postSolution
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32
-\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32
-\tEndGlobalSection
-\tGlobalSection(SolutionProperties) = preSolution
-\t\tHideSolutionNode = FALSE
-\tEndGlobalSection
-EndGlobal
-"""
-
-expected_vcprojfile_8_0 = """\
+expected_vcprojfile_fmt = """\
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
\tProjectType="Visual C++"
-\tVersion="8.00"
+\tVersion="%(TOOLS_VERSION)s"
\tName="Test"
\tProjectGUID="<PROJECT_GUID>"
\tRootNamespace="Test"
@@ -586,7 +486,7 @@ expected_vcprojfile_8_0 = """\
\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
\t\t\t\tOutput="Test.exe"
\t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234"
-\t\t\t\tIncludeSearchPath="inc1;inc2"
+\t\t\t\tIncludeSearchPath="%(INCLUDE_DIRS)s"
\t\t\t\tForcedIncludes=""
\t\t\t\tAssemblySearchPath=""
\t\t\t\tForcedUsingAssemblies=""
@@ -601,7 +501,7 @@ expected_vcprojfile_8_0 = """\
\t\t\tName="Header Files"
\t\t\tFilter="h;hpp;hxx;hm;inl">
\t\t\t<File
-\t\t\t\tRelativePath="sdk.h">
+\t\t\t\tRelativePath="sdk_dir\\sdk.h">
\t\t\t</File>
\t\t</Filter>
\t\t<Filter
@@ -644,97 +544,9 @@ expected_vcprojfile_8_0 = """\
</VisualStudioProject>
"""
-expected_vcprojfile_9_0 = """\
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-\tProjectType="Visual C++"
-\tVersion="9.00"
-\tName="Test"
-\tProjectGUID="<PROJECT_GUID>"
-\tRootNamespace="Test"
-<SCC_VCPROJ_INFO>
-\tKeyword="MakeFileProj">
-\t<Platforms>
-\t\t<Platform
-\t\t\tName="Win32"/>
-\t</Platforms>
-\t<ToolFiles>
-\t</ToolFiles>
-\t<Configurations>
-\t\t<Configuration
-\t\t\tName="Release|Win32"
-\t\t\tConfigurationType="0"
-\t\t\tUseOfMFC="0"
-\t\t\tATLMinimizesCRunTimeLibraryUsage="false"
-\t\t\t>
-\t\t\t<Tool
-\t\t\t\tName="VCNMakeTool"
-\t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
-\t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
-\t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
-\t\t\t\tOutput="Test.exe"
-\t\t\t\tPreprocessorDefinitions="DEF1;DEF2;DEF3=1234"
-\t\t\t\tIncludeSearchPath="inc1;inc2"
-\t\t\t\tForcedIncludes=""
-\t\t\t\tAssemblySearchPath=""
-\t\t\t\tForcedUsingAssemblies=""
-\t\t\t\tCompileAsManaged=""
-\t\t\t/>
-\t\t</Configuration>
-\t</Configurations>
-\t<References>
-\t</References>
-\t<Files>
-\t\t<Filter
-\t\t\tName="Header Files"
-\t\t\tFilter="h;hpp;hxx;hm;inl">
-\t\t\t<File
-\t\t\t\tRelativePath="sdk.h">
-\t\t\t</File>
-\t\t</Filter>
-\t\t<Filter
-\t\t\tName="Local Headers"
-\t\t\tFilter="h;hpp;hxx;hm;inl">
-\t\t\t<File
-\t\t\t\tRelativePath="test.h">
-\t\t\t</File>
-\t\t</Filter>
-\t\t<Filter
-\t\t\tName="Other Files"
-\t\t\tFilter="">
-\t\t\t<File
-\t\t\t\tRelativePath="readme.txt">
-\t\t\t</File>
-\t\t</Filter>
-\t\t<Filter
-\t\t\tName="Resource Files"
-\t\t\tFilter="r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
-\t\t\t<File
-\t\t\t\tRelativePath="test.rc">
-\t\t\t</File>
-\t\t</Filter>
-\t\t<Filter
-\t\t\tName="Source Files"
-\t\t\tFilter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat">
-\t\t\t<File
-\t\t\t\tRelativePath="test1.cpp">
-\t\t\t</File>
-\t\t\t<File
-\t\t\t\tRelativePath="test2.cpp">
-\t\t\t</File>
-\t\t</Filter>
-\t\t<File
-\t\t\tRelativePath="<SCONSCRIPT>">
-\t\t</File>
-\t</Files>
-\t<Globals>
-\t</Globals>
-</VisualStudioProject>
-"""
-
-expected_vcprojfile_10_0 = """\
+expected_vcxprojfile_fmt = """\
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="%(TOOLS_VERSION)s" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
\t<ItemGroup Label="ProjectConfigurations">
\t\t<ProjectConfiguration Include="Release|Win32">
\t\t\t<Configuration>Release</Configuration>
@@ -746,6 +558,7 @@ expected_vcprojfile_10_0 = """\
<SCC_VCPROJ_INFO>
\t\t<RootNamespace>Test</RootNamespace>
\t\t<Keyword>MakeFileProj</Keyword>
+\t\t<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
\t</PropertyGroup>
\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@@ -767,13 +580,13 @@ expected_vcprojfile_10_0 = """\
\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;</NMakeCleanCommandLine>
\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput>
\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions>
-\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath>
+\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(INCLUDE_DIRS)s</NMakeIncludeSearchPath>
\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
\t</PropertyGroup>
\t<ItemGroup>
-\t\t<ClInclude Include="sdk_dir\sdk.h" />
+\t\t<ClInclude Include="sdk_dir\\sdk.h" />
\t</ItemGroup>
\t<ItemGroup>
\t\t<ClInclude Include="test.h" />
@@ -797,237 +610,19 @@ expected_vcprojfile_10_0 = """\
</Project>
"""
-expected_vcprojfile_11_0 = """\
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-\t<ItemGroup Label="ProjectConfigurations">
-\t\t<ProjectConfiguration Include="Release|Win32">
-\t\t\t<Configuration>Release</Configuration>
-\t\t\t<Platform>Win32</Platform>
-\t\t</ProjectConfiguration>
-\t</ItemGroup>
-\t<PropertyGroup Label="Globals">
-\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid>
-<SCC_VCPROJ_INFO>
-\t\t<RootNamespace>Test</RootNamespace>
-\t\t<Keyword>MakeFileProj</Keyword>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
-\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-\t\t<ConfigurationType>Makefile</ConfigurationType>
-\t\t<UseOfMfc>false</UseOfMfc>
-\t\t<PlatformToolset>v110</PlatformToolset>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />
-\t<ImportGroup Label="ExtensionSettings">
-\t</ImportGroup>
-\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
-\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-\t</ImportGroup>
-\t<PropertyGroup Label="UserMacros" />
-\t<PropertyGroup>
-\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
-\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeBuildCommandLine>
-\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeReBuildCommandLine>
-\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;</NMakeCleanCommandLine>
-\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput>
-\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions>
-\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath>
-\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
-\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
-\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
-\t</PropertyGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="sdk_dir\sdk.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="test.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="readme.txt" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="test.rc" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClCompile Include="test1.cpp" />
-\t\t<ClCompile Include="test2.cpp" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="SConstruct" />
-\t</ItemGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />
-\t<ImportGroup Label="ExtensionTargets">
-\t</ImportGroup>
-</Project>
-"""
-
-expected_vcprojfile_14_0 = """\
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-\t<ItemGroup Label="ProjectConfigurations">
-\t\t<ProjectConfiguration Include="Release|Win32">
-\t\t\t<Configuration>Release</Configuration>
-\t\t\t<Platform>Win32</Platform>
-\t\t</ProjectConfiguration>
-\t</ItemGroup>
-\t<PropertyGroup Label="Globals">
-\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid>
-<SCC_VCPROJ_INFO>
-\t\t<RootNamespace>Test</RootNamespace>
-\t\t<Keyword>MakeFileProj</Keyword>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
-\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-\t\t<ConfigurationType>Makefile</ConfigurationType>
-\t\t<UseOfMfc>false</UseOfMfc>
-\t\t<PlatformToolset>v140</PlatformToolset>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />
-\t<ImportGroup Label="ExtensionSettings">
-\t</ImportGroup>
-\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
-\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-\t</ImportGroup>
-\t<PropertyGroup Label="UserMacros" />
-\t<PropertyGroup>
-\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
-\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeBuildCommandLine>
-\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeReBuildCommandLine>
-\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;</NMakeCleanCommandLine>
-\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput>
-\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions>
-\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath>
-\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
-\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
-\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
-\t</PropertyGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="sdk_dir\sdk.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="test.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="readme.txt" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="test.rc" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClCompile Include="test1.cpp" />
-\t\t<ClCompile Include="test2.cpp" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="SConstruct" />
-\t</ItemGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />
-\t<ImportGroup Label="ExtensionTargets">
-\t</ImportGroup>
-</Project>
-"""
-
-expected_vcprojfile_14_1 = """\
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-\t<ItemGroup Label="ProjectConfigurations">
-\t\t<ProjectConfiguration Include="Release|Win32">
-\t\t\t<Configuration>Release</Configuration>
-\t\t\t<Platform>Win32</Platform>
-\t\t</ProjectConfiguration>
-\t</ItemGroup>
-\t<PropertyGroup Label="Globals">
-\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid>
-<SCC_VCPROJ_INFO>
-\t\t<RootNamespace>Test</RootNamespace>
-\t\t<Keyword>MakeFileProj</Keyword>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
-\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-\t\t<ConfigurationType>Makefile</ConfigurationType>
-\t\t<UseOfMfc>false</UseOfMfc>
-\t\t<PlatformToolset>v141</PlatformToolset>
-\t</PropertyGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />
-\t<ImportGroup Label="ExtensionSettings">
-\t</ImportGroup>
-\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
-\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-\t</ImportGroup>
-\t<PropertyGroup Label="UserMacros" />
-\t<PropertyGroup>
-\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
-\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeBuildCommandLine>
-\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;</NMakeReBuildCommandLine>
-\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;</NMakeCleanCommandLine>
-\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput>
-\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions>
-\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath>
-\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
-\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
-\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
-\t</PropertyGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="sdk_dir\sdk.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClInclude Include="test.h" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="readme.txt" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="test.rc" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<ClCompile Include="test1.cpp" />
-\t\t<ClCompile Include="test2.cpp" />
-\t</ItemGroup>
-\t<ItemGroup>
-\t\t<None Include="SConstruct" />
-\t</ItemGroup>
-\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />
-\t<ImportGroup Label="ExtensionTargets">
-\t</ImportGroup>
-</Project>
-"""
-
-SConscript_contents_8_0 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0',
- CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
- CPPPATH=['inc1', 'inc2'],
- HOST_ARCH='%(HOST_ARCH)s')
-
-testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk.h']
-testlocalincs = ['test.h']
-testresources = ['test.rc']
-testmisc = ['readme.txt']
-
-env.MSVSProject(target = 'Test.vcproj',
- slnguid = '{SLNGUID}',
- srcs = testsrc,
- incs = testincs,
- localincs = testlocalincs,
- resources = testresources,
- misc = testmisc,
- buildtarget = 'Test.exe',
- variant = 'Release')
-"""
-
-SConscript_contents_9_0 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='9.0',
+SConscript_contents_fmt = """\
+env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='%(MSVS_VERSION)s',
CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
CPPPATH=['inc1', 'inc2'],
HOST_ARCH='%(HOST_ARCH)s')
testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk.h']
+testincs = [r'sdk_dir\\sdk.h']
testlocalincs = ['test.h']
testresources = ['test.rc']
testmisc = ['readme.txt']
-env.MSVSProject(target = 'Test.vcproj',
+env.MSVSProject(target = '%(PROJECT_FILE)s',
slnguid = '{SLNGUID}',
srcs = testsrc,
incs = testincs,
@@ -1038,97 +633,13 @@ env.MSVSProject(target = 'Test.vcproj',
variant = 'Release')
"""
-SConscript_contents_10_0 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='10.0',
- CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
- CPPPATH=['inc1', 'inc2'],
- HOST_ARCH='%(HOST_ARCH)s')
-testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk_dir\sdk.h']
-testlocalincs = ['test.h']
-testresources = ['test.rc']
-testmisc = ['readme.txt']
+def get_tested_proj_file_vc_versions():
+ """
+ Returns all MSVC versions that we want to test project file creation for.
+ """
+ return ['8.0', '9.0', '10.0', '11.0', '12.0', '14.0', '14.1', '14.2']
-env.MSVSProject(target = 'Test.vcxproj',
- slnguid = '{SLNGUID}',
- srcs = testsrc,
- incs = testincs,
- localincs = testlocalincs,
- resources = testresources,
- misc = testmisc,
- buildtarget = 'Test.exe',
- variant = 'Release')
-"""
-
-SConscript_contents_11_0 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='11.0',
- CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
- CPPPATH=['inc1', 'inc2'],
- HOST_ARCH='%(HOST_ARCH)s')
-
-testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk_dir\sdk.h']
-testlocalincs = ['test.h']
-testresources = ['test.rc']
-testmisc = ['readme.txt']
-
-env.MSVSProject(target = 'Test.vcxproj',
- slnguid = '{SLNGUID}',
- srcs = testsrc,
- incs = testincs,
- localincs = testlocalincs,
- resources = testresources,
- misc = testmisc,
- buildtarget = 'Test.exe',
- variant = 'Release')
-"""
-
-SConscript_contents_14_0 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0',
- CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
- CPPPATH=['inc1', 'inc2'],
- HOST_ARCH='%(HOST_ARCH)s')
-
-testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk_dir\sdk.h']
-testlocalincs = ['test.h']
-testresources = ['test.rc']
-testmisc = ['readme.txt']
-
-env.MSVSProject(target = 'Test.vcxproj',
- slnguid = '{SLNGUID}',
- srcs = testsrc,
- incs = testincs,
- localincs = testlocalincs,
- resources = testresources,
- misc = testmisc,
- buildtarget = 'Test.exe',
- variant = 'Release')
-"""
-
-SConscript_contents_14_1 = """\
-env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.1',
- CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
- CPPPATH=['inc1', 'inc2'],
- HOST_ARCH='%(HOST_ARCH)s')
-
-testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk_dir\sdk.h']
-testlocalincs = ['test.h']
-testresources = ['test.rc']
-testmisc = ['readme.txt']
-
-env.MSVSProject(target = 'Test.vcxproj',
- slnguid = '{SLNGUID}',
- srcs = testsrc,
- incs = testincs,
- localincs = testlocalincs,
- resources = testresources,
- misc = testmisc,
- buildtarget = 'Test.exe',
- variant = 'Release')
-"""
class TestSConsMSVS(TestSCons):
"""Subclass for testing MSVS-specific portions of SCons."""
@@ -1150,7 +661,7 @@ import SCons.Tool.MSCommon
print("self.scons_version =%%s"%%repr(SCons.__%s__))
print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions()))
""" % 'version'
-
+
self.run(arguments = '-n -q -Q -f -', stdin = input)
exec(self.stdout())
@@ -1233,11 +744,11 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions()))
finally:
os.environ['SCONSFLAGS'] = save_sconsflags or ''
return result
-
+
def get_vs_host_arch(self):
""" Get an MSVS, SDK , and/or MSVS acceptable platform arch
"""
-
+
# Dict to 'canonalize' the arch
_ARCH_TO_CANONICAL = {
"x86": "x86",
@@ -1255,21 +766,19 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions()))
# PROCESSOR_ARCHITECTURE.
if not host_platform:
host_platform = os.environ.get('PROCESSOR_ARCHITECTURE', '')
-
-
+
try:
host = _ARCH_TO_CANONICAL[host_platform]
except KeyError as e:
# Default to x86 for all other platforms
host = 'x86'
-
-
+
return host
def validate_msvs_file(self, file):
try:
x = ElementTree.parse(file)
- except:
+ except:
print("--------------------------------------------------------------")
print("--------------------------------------------------------------")
print(traceback.format_exc())
@@ -1278,6 +787,119 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions()))
print("--------------------------------------------------------------")
print("--------------------------------------------------------------")
self.fail_test()
+
+ def parse_vc_version(self, vc_version):
+ """
+ Parses the string vc_version to determine the major and minor version
+ included.
+ """
+ components = vc_version.split('.')
+ major = int(components[0])
+ minor = 0 if len(components) < 2 else int(components[1])
+ return major, minor
+
+ def _get_solution_file_format_version(self, vc_version):
+ """
+ Returns the Visual Studio format version expected in the .sln file.
+ """
+ major, _ = self.parse_vc_version(vc_version)
+ if major == 8:
+ return '9.00'
+ elif major == 9:
+ return '10.00'
+ elif major == 10:
+ return '11.00'
+ elif major > 10:
+ return '12.00'
+ else:
+ raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version)
+
+ def _get_solution_file_vs_number(self, vc_version):
+ """
+ Returns the Visual Studio number expected in the .sln file.
+ """
+ major, minor = self.parse_vc_version(vc_version)
+ if major == 8:
+ return '2005'
+ elif major == 9:
+ return '2008'
+ if major == 10:
+ return '2010'
+ elif major == 11:
+ return '11'
+ elif major == 12:
+ return '14'
+ elif major == 14 and (minor == 0 or minor == 1):
+ # Visual Studio 2015 and 2017 both use 15 in this entry.
+ return '15'
+ elif major == 14 and minor == 2:
+ return '16'
+ else:
+ raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version)
+
+ def _get_vcxproj_file_tools_version(self, vc_version):
+ """
+ Returns the version entry expected in the project file.
+ For .vcxproj files, this goes is ToolsVersion.
+ For .vcproj files, this goes in Version.
+ """
+ major, minor = self.parse_vc_version(vc_version)
+ if major == 8:
+ # Version="8.00"
+ return '8.00'
+ elif major == 9:
+ # Version="9.00"
+ return '9.00'
+ elif major < 14:
+ # ToolsVersion='4.0'
+ return '4.0'
+ elif major == 14 and minor == 0:
+ # ToolsVersion='14.0'
+ return '14.0'
+ elif major == 14 and minor == 1:
+ # ToolsVersion='15.0'
+ return '15.0'
+ elif vc_version == '14.2':
+ # ToolsVersion='16'
+ return '16.0'
+ else:
+ raise SCons.Errors.UserError('Received unexpected VC version %s' % vc_version)
+
+ def _get_vcxproj_file_cpp_path(self, dirs):
+ """Returns the include paths expected in the .vcxproj file"""
+ return ';'.join([self.workpath(dir) for dir in dirs])
+
+ def get_expected_sln_file_contents(self, vc_version, project_file):
+ """
+ Returns the expected .sln file contents.
+ Currently this function only supports the newer VC versions that use
+ the .vcxproj file format.
+ """
+ return expected_slnfile_fmt % {
+ 'FORMAT_VERSION': self._get_solution_file_format_version(vc_version),
+ 'VS_NUMBER': self._get_solution_file_vs_number(vc_version),
+ 'PROJECT_NAME': project_file.split('.')[0],
+ 'PROJECT_FILE': project_file,
+ }
+
+ def get_expected_proj_file_contents(self, vc_version, dirs, project_file):
+ """Returns the expected .vcxproj file contents"""
+ if project_file.endswith('.vcxproj'):
+ fmt = expected_vcxprojfile_fmt
+ else:
+ fmt = expected_vcprojfile_fmt
+ return fmt % {
+ 'TOOLS_VERSION': self._get_vcxproj_file_tools_version(vc_version),
+ 'INCLUDE_DIRS': self._get_vcxproj_file_cpp_path(dirs),
+ }
+
+ def get_expected_sconscript_file_contents(self, vc_version, project_file):
+ return SConscript_contents_fmt % {
+ 'HOST_ARCH': self.get_vs_host_arch(),
+ 'MSVS_VERSION': vc_version,
+ 'PROJECT_FILE': project_file,
+ }
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/testing/framework/TestSCons_time.py b/testing/framework/TestSCons_time.py
index 624eb4c..547e264 100644
--- a/testing/framework/TestSCons_time.py
+++ b/testing/framework/TestSCons_time.py
@@ -13,7 +13,7 @@ attributes defined in this subclass.
# Copyright (c) 2001 - 2019 The SCons Foundation
-__revision__ = "testing/framework/TestSCons_time.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "testing/framework/TestSCons_time.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import os.path
@@ -272,7 +272,8 @@ class TestSCons_time(TestCommon):
d, f = os.path.split(path)
if not os.path.isdir(d):
os.makedirs(d)
- open(path, 'w').write(content)
+ with open(path, 'w') as f:
+ f.write(content)
return dir
def write_sample_tarfile(self, archive, dir, files):
diff --git a/testing/framework/TestSConsign.py b/testing/framework/TestSConsign.py
index fc72aa4..8f992ef 100644
--- a/testing/framework/TestSConsign.py
+++ b/testing/framework/TestSConsign.py
@@ -1,7 +1,7 @@
# Copyright (c) 2001 - 2019 The SCons Foundation
from __future__ import print_function
-__revision__ = "testing/framework/TestSConsign.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "testing/framework/TestSConsign.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
__doc__ = """
TestSConsign.py: a testing framework for the "sconsign" script