From 5c5bdcd84110d1e26cd118cbbc449be5e86f59ba Mon Sep 17 00:00:00 2001 From: Bob Burger Date: Thu, 10 Aug 2017 17:44:34 -0400 Subject: [PATCH] added support for Microsoft Visual Studio 2017 on Windows updated ez-grammar-test to write temp files to current directory and delete them when finished original commit: 89885b73d679759de9c62bab0b407318df123d6f --- BUILDING | 21 +++++++-------- LOG | 5 ++++ c/Mf-a6nt | 2 +- c/Mf-ta6nt | 2 +- c/vs.bat | 51 ++++++++++++++++-------------------- examples/ez-grammar-test.ss | 52 +++++++++++++++++++++---------------- mats/Mf-a6nt | 4 +-- mats/Mf-ta6nt | 4 +-- mats/ftype.ms | 2 +- 9 files changed, 74 insertions(+), 69 deletions(-) diff --git a/BUILDING b/BUILDING index 59f9f18265..6f32a132ab 100644 --- a/BUILDING +++ b/BUILDING @@ -167,11 +167,11 @@ The make file supports several targets: WINDOWS -Building Chez Scheme under Windows with Cygwin or Bash/WSL follows the -instructions above, except that 'make install' is not supported, and -the 'OS' environment variable must be set to 'Windows_NT' on Bash/WSL -(to indicate a build for Windows, as opposed to a build for Linux on -Windows): +Building Chez Scheme under 64-bit Windows with Cygwin or Bash/WSL +follows the instructions above, except that 'make install' is not +supported, and the 'OS' environment variable must be set to +'Windows_NT' on Bash/WSL (to indicate a build for Windows, as opposed +to a build for Linux on Windows): env OS=Windows_NT ./configure env OS=Windows_NT make @@ -179,7 +179,7 @@ env OS=Windows_NT make Prerequisites: * Cygwin or Bash/WSL with bash, grep, make, sed, etc. -* Microsoft Visual Studio 2015 +* Microsoft Visual Studio 2017 or 2015 * WiX Toolset (for making an install) To run Chez Scheme or Petite Chez Scheme from a Windows command prompt, @@ -191,10 +191,10 @@ again with $W and $M replaced with the workarea name and machine type, and start Chez Scheme with the command "scheme" or Petite Chez with the command "petite". -The executables are linked against the Microsoft Visual C++ run-time -library vcruntime140.dll. If you distribute the executables to a -different system, be sure to include the redistributable run-time -library. +The executables are dynamically linked against the Microsoft Visual +C++ run-time library vcruntime140.dll. If you distribute the +executables to a different system, be sure to include the +redistributable run-time library. Making an Install for Windows @@ -229,4 +229,3 @@ the Cygwin values are incompatible with the Microsoft C Runtime Library. Use 'make test' described above to run the tests. - diff --git a/LOG b/LOG index e6306febbb..939e4ab361 100644 --- a/LOG +++ b/LOG @@ -559,3 +559,8 @@ - added "ez-grammar" example program examples/ez-grammar.ss, examples/ez-grammar-test.ss, examples/Makefile, examples.ms +- updated ez-grammar-test to write temp files to current directory and delete them when finished + examples/ez-grammar-test.ss +- added support for Microsoft Visual Studio 2017 on Windows + BUILDING, c/Mf-a6nt, c/Mf-ta6nt, c/vs.bat, + mats/Mf-a6nt, mats/Mf-ta6nt, mats/ftype.ms diff --git a/c/Mf-a6nt b/c/Mf-a6nt index 8b51ff88d9..71898b46e2 100644 --- a/c/Mf-a6nt +++ b/c/Mf-a6nt @@ -31,5 +31,5 @@ ${Scheme}: make.bat make.bat: vs.bat echo '@echo off' > $@ echo 'set MAKEFLAGS=' >> $@ - echo 'vs.bat x86_amd64 amd64 && nmake /f Makefile.$m /nologo %*' >> $@ + echo 'vs.bat amd64 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ diff --git a/c/Mf-ta6nt b/c/Mf-ta6nt index 35638cb319..a6e0d94369 100644 --- a/c/Mf-ta6nt +++ b/c/Mf-ta6nt @@ -31,5 +31,5 @@ ${Scheme}: make.bat make.bat: vs.bat echo '@echo off' > $@ echo 'set MAKEFLAGS=' >> $@ - echo 'vs.bat x86_amd64 amd64 && nmake /f Makefile.$m /nologo %*' >> $@ + echo 'vs.bat amd64 && nmake /f Makefile.$m /nologo %*' >> $@ chmod +x $@ diff --git a/c/vs.bat b/c/vs.bat index 103db58cd6..700ab7e5f9 100644 --- a/c/vs.bat +++ b/c/vs.bat @@ -1,39 +1,32 @@ @echo off :: Set up Visual Studio command line environment variables given a -:: sequence of machine types to try ("x86", "x86_amd64", and "amd64"). +:: machine type, e.g., amd64 or x86. -:: Note: VS 11.0 (2012) and earlier won't work, because they -:: don't support C99 mid-block declarations. Also, there's no -:: such thing as VS 13.0. +:: Visual Studio 2017 Enterprise +set BATDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build +if exist "%BATDIR%\vcvarsall.bat" goto found + +:: Visual Studio 2017 Professional +set BATDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build +if exist "%BATDIR%\vcvarsall.bat" goto found + +:: Visual Studio 2017 Community +set BATDIR=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build +if exist "%BATDIR%\vcvarsall.bat" goto found + +:: Visual Studio 2015 +set BATDIR=%VS140COMNTOOLS%..\..\VC +if exist "%BATDIR%\vcvarsall.bat" goto found + +echo Visual Studio 2017 or 2015 must be installed. +exit 1 + +:found :: Clear environment variables that we might otherwise inherit set INCLUDE= set LIB= set LIBPATH= -:: Find visual studio -set VCDIR=%VS140COMNTOOLS%\..\..\vc -if not exist "%VCDIR%\vcvarsall.bat" set VCDIR=%VS120COMNTOOLS%\..\..\vc - -:: Loop to find a requested machine type -if exist "%VCDIR%\vcvarsall.bat" goto :VCDIR -echo Could not find Visual Studio installed. -exit 1 - -:VCDIR - -set MACHINETYPE=%1 -if "%MACHINETYPE%" neq "" goto :MACHINE -echo Could not find working machine type. -exit 1 - -:MACHINE -if "%MACHINETYPE%" == "x86" goto :VS -if exist "%VCDIR%\bin\%MACHINETYPE%\vcvars%MACHINETYPE%.bat" goto :VS -shift -goto :VCDIR - -:: Set environment variables -:VS -"%VCDIR%\vcvarsall.bat" %MACHINETYPE% +"%BATDIR%\vcvarsall.bat" %1 diff --git a/examples/ez-grammar-test.ss b/examples/ez-grammar-test.ss index 112b357c7f..d56390634d 100644 --- a/examples/ez-grammar-test.ss +++ b/examples/ez-grammar-test.ss @@ -348,25 +348,29 @@ (define parse (lambda (fn) (let ([ip (open-input-file fn)]) - (let ([token-stream (lexer fn ip)]) - (define (oops) - (let ([last-token (stream-last-forced token-stream)]) - (if last-token - (errorf 'parse "parse error at or before character ~s of ~a" (token-bfp last-token) fn) - (errorf 'parse "no expressions found in ~a" fn)))) - ;;; return the first result, if any, for which the input stream was entirely consumed. - (let loop ([res* (expr token-stream)]) - (if (null? res*) - (oops) - (let ([res (car res*)]) - (if (parse-consumed-all? res) - (parse-result-value res) - (loop (cdr res*)))))))))) + (dynamic-wind + void + (lambda () + (let ([token-stream (lexer fn ip)]) + (define (oops) + (let ([last-token (stream-last-forced token-stream)]) + (if last-token + (errorf 'parse "parse error at or before character ~s of ~a" (token-bfp last-token) fn) + (errorf 'parse "no expressions found in ~a" fn)))) +;;; return the first result, if any, for which the input stream was entirely consumed. + (let loop ([res* (expr token-stream)]) + (if (null? res*) + (oops) + (let ([res (car res*)]) + (if (parse-consumed-all? res) + (parse-result-value res) + (loop (cdr res*)))))))) + (lambda () (close-input-port ip)))))) ) (define (ez-grammar-test) (import (parser)) - (with-output-to-file "/tmp/t1" + (with-output-to-file "ez-grammar-test1" (lambda () (for-each display '( @@ -374,7 +378,7 @@ ))) 'replace) - (with-output-to-file "/tmp/t2" + (with-output-to-file "ez-grammar-test2" (lambda () (for-each display '( @@ -386,7 +390,7 @@ ))) 'replace) - (with-output-to-file "/tmp/t3err" + (with-output-to-file "ez-grammar-test3err" (lambda () (for-each display '( @@ -398,7 +402,7 @@ ))) 'replace) - (with-output-to-file "/tmp/t4err" + (with-output-to-file "ez-grammar-test4err" (lambda () (for-each display '( @@ -406,14 +410,18 @@ ))) 'replace) - (unless (guard (c [else #f]) (equal? (parse "/tmp/t1") (quote (int (0 . 3) 1347)))) + (unless (guard (c [else #f]) (equal? (parse "ez-grammar-test1") (quote (int (0 . 3) 1347)))) (printf "test 1 failed\n")) - (unless (guard (c [else #f]) (equal? (parse "/tmp/t2") (quote (=> (13 . 25) (group (16 . 25) (=> (18 . 24) (int (21 . 24) 1253))))))) + (delete-file "ez-grammar-test1") + (unless (guard (c [else #f]) (equal? (parse "ez-grammar-test2") (quote (=> (13 . 25) (group (16 . 25) (=> (18 . 24) (int (21 . 24) 1253))))))) (printf "test 2 failed\n")) - (unless (guard (c [else (and (equal? (condition-message c) "parse error at or before character ~s of ~a") (equal? (condition-irritants c) (quote (25 "/tmp/t3err"))))]) (parse "/tmp/t3err") #f) + (delete-file "ez-grammar-test2") + (unless (guard (c [else (and (equal? (condition-message c) "parse error at or before character ~s of ~a") (equal? (condition-irritants c) (quote (25 "ez-grammar-test3err"))))]) (parse "ez-grammar-test3err") #f) (printf "test 3 failed\n")) - (unless (guard (c [else (and (equal? (condition-message c) "unexpected ~a at character ~s of ~a") (equal? (condition-irritants c) (quote ("eof" 6 "/tmp/t4err"))))]) (parse "/tmp/t4err") #f) + (delete-file "ez-grammar-test3err") + (unless (guard (c [else (and (equal? (condition-message c) "unexpected ~a at character ~s of ~a") (equal? (condition-irritants c) (quote ("eof" 6 "ez-grammar-test4err"))))]) (parse "ez-grammar-test4err") #f) (printf "test 4 failed\n")) + (delete-file "ez-grammar-test4err") (printf "end of tests\n")) #!eof diff --git a/mats/Mf-a6nt b/mats/Mf-a6nt index 6fec7b426e..094b6187cb 100644 --- a/mats/Mf-a6nt +++ b/mats/Mf-a6nt @@ -22,7 +22,7 @@ mdclean = cat_flush.exe cat_flush.obj foreign1.exp foreign1.lib foreign1.obj for include Mf-base foreign1.so: $(fsrc) - cmd.exe /c "vs.bat x86_amd64 amd64 && cl /DWIN32 /DX86_64 /Fe$@ /I${Include} /LD /MD /nologo ../bin/$m/csv941.lib $(fsrc)" + cmd.exe /c "vs.bat amd64 && cl /DWIN32 /DX86_64 /Fe$@ /I${Include} /LD /MD /nologo ../bin/$m/csv941.lib $(fsrc)" cat_flush: cat_flush.c - cmd.exe /c "vs.bat x86_amd64 amd64 && cl /DWIN32 /DX86_64 /MD /nologo $<" + cmd.exe /c "vs.bat amd64 && cl /DWIN32 /DX86_64 /MD /nologo $<" diff --git a/mats/Mf-ta6nt b/mats/Mf-ta6nt index 51f63e744d..c7fb204e58 100644 --- a/mats/Mf-ta6nt +++ b/mats/Mf-ta6nt @@ -22,7 +22,7 @@ mdclean = cat_flush.exe cat_flush.obj foreign1.exp foreign1.lib foreign1.obj for include Mf-base foreign1.so: $(fsrc) - cmd.exe /c "vs.bat x86_amd64 amd64 && cl /DWIN32 /DX86_64 /Fe$@ /I${Include} /LD /MD /nologo ../bin/$m/csv941.lib $(fsrc)" + cmd.exe /c "vs.bat amd64 && cl /DWIN32 /DX86_64 /Fe$@ /I${Include} /LD /MD /nologo ../bin/$m/csv941.lib $(fsrc)" cat_flush: cat_flush.c - cmd.exe /c "vs.bat x86_amd64 amd64 && cl /DWIN32 /DX86_64 /MD /nologo $<" + cmd.exe /c "vs.bat amd64 && cl /DWIN32 /DX86_64 /MD /nologo $<" diff --git a/mats/ftype.ms b/mats/ftype.ms index 1971d13513..3e147cd1cf 100644 --- a/mats/ftype.ms +++ b/mats/ftype.ms @@ -557,7 +557,7 @@ [(a6osx a6osx) (system (format "cc -m64 -dynamiclib -o ~a ~a" testfile.so testfile.c))] [(a6nt ta6nt) - (system (format "..\\c\\vs.bat x86_amd64 amd64 && cl /DWIN32 /Fe~a /LD /MD /nologo ~a" testfile.so testfile.c))] + (system (format "..\\c\\vs.bat amd64 && cl /DWIN32 /Fe~a /LD /MD /nologo ~a" testfile.so testfile.c))] [(i3nt ti3nt) (system (format "..\\c\\vs.bat x86 && cl /DWIN32 /Fe~a /LD /MD /nologo ~a" testfile.so testfile.c))] [(arm32le tarm32le)