summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2018-04-10 21:15:17 (GMT)
committerGitHub <noreply@github.com>2018-04-10 21:15:17 (GMT)
commitbb90373027f3da405f5c5bde4094565dd8c5de06 (patch)
tree6e61d482825addac3929d6604f29b9ae38e8318d
parent23f357c1addfe7edbccbf0b804b7b29c12b5049c (diff)
parentf8b479702bb0b5c81c147438f9ce91b5b6b460f2 (diff)
downloadSCons-bb90373027f3da405f5c5bde4094565dd8c5de06.zip
SCons-bb90373027f3da405f5c5bde4094565dd8c5de06.tar.gz
SCons-bb90373027f3da405f5c5bde4094565dd8c5de06.tar.bz2
Merge pull request #2 from dmoody256/bdbadog_windows_tools_yacc
Yacc Windows fixes
-rw-r--r--.appveyor.yml2
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Platform/cygwin.py9
-rw-r--r--src/engine/SCons/Platform/mingw.py39
-rw-r--r--src/engine/SCons/Tool/yacc.py11
-rw-r--r--test/YACC/YACC-fixture/myyacc.py6
-rw-r--r--test/YACC/YACC.py8
-rw-r--r--test/YACC/live-check-output-cleaned.py2
-rw-r--r--test/YACC/live.py12
9 files changed, 79 insertions, 12 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index a9d2dfc..a735070 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -2,7 +2,7 @@ image: Visual Studio 2017
shallow_clone: true
install:
- - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
+ - "set PATH=%PYTHON%;%PYTHON%\\Scripts;C:\\cygwin64\\bin;C:\\msys64;%PATH%"
- python --version
- pip install lxml
- pip install pypiwin32
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 43efa9e..76487f6 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -8,6 +8,8 @@
RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
From Daniel Moody:
+ - Add common location for default paths for cygwin and mingw in Platform modules
+ - Updated YACC tool to work on windows with Cygwin/MinGW setups
- Set the pickling protocal back to highest which was causing issues
with variant dir tests. This will cause issues if reading sconsigns
pickled with the previous lower protocal.
diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py
index 8b4669c..f6c5086 100644
--- a/src/engine/SCons/Platform/cygwin.py
+++ b/src/engine/SCons/Platform/cygwin.py
@@ -32,9 +32,18 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import sys
+
from . import posix
from SCons.Platform import TempFileMunge
+CYGWIN_DEFAULT_PATHS = []
+if sys.platform == 'win32':
+ CYGWIN_DEFAULT_PATHS = [
+ r'C:\cygwin64\bin',
+ r'C:\cygwin\bin'
+ ]
+
def generate(env):
posix.generate(env)
diff --git a/src/engine/SCons/Platform/mingw.py b/src/engine/SCons/Platform/mingw.py
new file mode 100644
index 0000000..73633d7
--- /dev/null
+++ b/src/engine/SCons/Platform/mingw.py
@@ -0,0 +1,39 @@
+"""SCons.Platform.mingw
+
+Platform-specific initialization for the MinGW system.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# 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.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import sys
+
+MINGW_DEFAULT_PATHS = []
+if sys.platform == 'win32':
+ MINGW_DEFAULT_PATHS = [
+ r'C:\msys64',
+ r'C:\msys'
+ ] \ No newline at end of file
diff --git a/src/engine/SCons/Tool/yacc.py b/src/engine/SCons/Tool/yacc.py
index 648433b..cd9b9a8 100644
--- a/src/engine/SCons/Tool/yacc.py
+++ b/src/engine/SCons/Tool/yacc.py
@@ -34,10 +34,13 @@ selection method.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os.path
+import sys
import SCons.Defaults
import SCons.Tool
import SCons.Util
+from SCons.Platform.mingw import MINGW_DEFAULT_PATHS
+from SCons.Platform.cygwin import CYGWIN_DEFAULT_PATHS
YaccAction = SCons.Action.Action("$YACCCOM", "$YACCCOMSTR")
@@ -113,6 +116,14 @@ def generate(env):
cxx_file.add_action('.yy', YaccAction)
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')
+
env['YACC'] = env.Detect('bison') or 'yacc'
env['YACCFLAGS'] = SCons.Util.CLVar('')
env['YACCCOM'] = '$YACC $YACCFLAGS -o $TARGET $SOURCES'
diff --git a/test/YACC/YACC-fixture/myyacc.py b/test/YACC/YACC-fixture/myyacc.py
index c2e1abf..756c98f 100644
--- a/test/YACC/YACC-fixture/myyacc.py
+++ b/test/YACC/YACC-fixture/myyacc.py
@@ -4,10 +4,10 @@ cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:', [])
output = None
opt_string = ''
for opt, arg in cmd_opts:
- if opt == '-o': output = open(arg, 'wb')
+ if opt == '-o': output = open(arg, 'w')
else: opt_string = opt_string + ' ' + opt
for a in args:
- contents = open(a, 'rb').read()
- output.write(contents.replace(b'YACC', b'myyacc.py'))
+ contents = open(a, 'r').read()
+ output.write(contents.replace('YACC', 'myyacc.py'))
output.close()
sys.exit(0)
diff --git a/test/YACC/YACC.py b/test/YACC/YACC.py
index 3fc1f7c..b27c2a7 100644
--- a/test/YACC/YACC.py
+++ b/test/YACC/YACC.py
@@ -53,10 +53,10 @@ env.CFile(target = 'ddd', source = 'ddd.ym')
test.run(arguments = '.', stderr = None)
-test.must_match('aaa.c', "aaa.y\nmyyacc.py\n")
-test.must_match('bbb.c', "bbb.yacc\nmyyacc.py\n")
-test.must_match('ccc.cc', "ccc.yacc\nmyyacc.py\n")
-test.must_match('ddd.m', "ddd.yacc\nmyyacc.py\n")
+test.must_match('aaa.c', "aaa.y" + os.linesep + "myyacc.py" + os.linesep)
+test.must_match('bbb.c', "bbb.yacc" + os.linesep + "myyacc.py" + os.linesep)
+test.must_match('ccc.cc', "ccc.yacc" + os.linesep + "myyacc.py" + os.linesep)
+test.must_match('ddd.m', "ddd.yacc" + os.linesep + "myyacc.py" + os.linesep)
diff --git a/test/YACC/live-check-output-cleaned.py b/test/YACC/live-check-output-cleaned.py
index a6240c9..8329b94 100644
--- a/test/YACC/live-check-output-cleaned.py
+++ b/test/YACC/live-check-output-cleaned.py
@@ -40,7 +40,7 @@ if not yacc:
test.skip_test('No yacc or bison found; skipping test.\n')
test.write('SConstruct', """
-foo = Environment(YACCFLAGS='-v -d')
+foo = Environment(YACCFLAGS='-v -d', tools = ['default', 'yacc'])
foo.CFile(source = 'foo.y')
""" % locals())
diff --git a/test/YACC/live.py b/test/YACC/live.py
index 6dd08f7..35f6c37 100644
--- a/test/YACC/live.py
+++ b/test/YACC/live.py
@@ -29,6 +29,8 @@ Test YACC and YACCFLAGS with a live yacc compiler.
"""
import TestSCons
+import sys
+import os
_exe = TestSCons._exe
_python_ = TestSCons._python_
@@ -40,12 +42,16 @@ yacc = test.where_is('yacc') or test.where_is('bison')
if not yacc:
test.skip_test('No yacc or bison found; skipping test.\n')
+if sys.platform == 'win32':
+ if not test.where_is('gcc'):
+ test.skip_test('No gcc found on windows; skipping test.\n')
+
test.file_fixture('wrapper.py')
test.write('SConstruct', """
-foo = Environment(YACCFLAGS='-d')
+foo = Environment(YACCFLAGS='-d', tools = ['default', 'yacc'])
yacc = foo.Dictionary('YACC')
-bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc)
+bar = Environment(YACC = r'%(_python_)s wrapper.py ' + yacc, tools = ['default', 'yacc'])
foo.Program(target = 'foo', source = 'foo.y')
bar.Program(target = 'bar', source = 'bar.y')
foo.Program(target = 'hello', source = ['hello.cpp'])
@@ -152,7 +158,7 @@ test.run(arguments = 'bar' + _exe)
test.up_to_date(arguments = 'bar' + _exe)
-test.must_match(test.workpath('wrapper.out'), "wrapper.py\n")
+test.must_match(test.workpath('wrapper.out'), "wrapper.py" + os.linesep)
test.run(program = test.workpath('bar'), stdin = "b\n", stdout = "bar.y\n")