Skip to content

Commit b4e55f5

Browse files
committed
Fix build with ms VS2017+
Use [vswhere](https://github.com/microsoft/vswhere) that comes with Visual Studio 2017 version 15.2 and later to detect location of VS to be used for building cccc
1 parent f3b6427 commit b4e55f5

4 files changed

Lines changed: 25 additions & 16 deletions

File tree

build_w32vc.bat

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
11
@rem build_w32vc.bat
22
@echo off
3+
setlocal enabledelayedexpansion
34

5+
if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto no_vswhere
6+
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
7+
set InstallDir=%%i
8+
)
9+
if not exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" goto no_vswhere
10+
call "%InstallDir%\Common7\Tools\vsdevcmd.bat" %*
11+
goto have_vc
12+
13+
:no_vswhere
414
rem This file builds and tests CCCC under Microsoft Visual Studio.
515
rem Path to Microsoft Visual Studio standard edition release 6.0
616
set VCDIR=c:\Program Files\Microsoft Visual Studio\vc98
717
if not exist "%VCDIR%\bin\vcvars32.bat" goto no_vc
818

919
call "%VCDIR%\bin\vcvars32.bat"
20+
:have_vc
1021
if not exist pccts\bin mkdir pccts\bin
1122

1223
cd pccts\dlg
1324
if exist *.obj del *.obj
14-
nmake -f DlgMS.mak
25+
nmake -nologo -f DlgMS.mak
1526
copy dlg.exe ..\bin
1627
cd ..\..
1728

1829
cd pccts\antlr
1930
if exist *.obj del *.obj
20-
nmake -f AntlrMS.mak
31+
nmake -nologo -f AntlrMS.mak
2132
copy antlr.exe ..\bin
2233
cd ..\..
2334

2435
cd cccc
2536
if exist *.obj del *.obj
2637
if exist *.cpp del *.cpp
27-
nmake -f w32vc.mak
38+
nmake -nologo -f w32vc.mak
2839
cd ..
2940

3041
cd test
31-
nmake -f w32vc.mak
42+
nmake -nologo -f w32vc.mak
3243
cd ..
3344

45+
rem vswhere is a vs2017+ thing, ancient vcaddin won't compile.
46+
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto end
3447
cd vcaddin
35-
nmake -f CcccDevStudioAddIn.mak CFG="CcccDevStudioAddIn - Win32 Release"
48+
nmake -nologo -f CcccDevStudioAddIn.mak CFG="CcccDevStudioAddIn - Win32 Release"
3649
cd ..
3750

3851

@@ -45,9 +58,5 @@ echo Please modify the script if the location is different.
4558

4659

4760
:end
48-
49-
50-
51-
52-
53-
61+
rem show "Press any key to continue" if build_w32vc.bat was run from exlorer
62+
IF %0 == "%~0" pause

cccc/w32vc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LDFLAGS_DEBUG=-Zi
1414
PATHSEP=\\
1515
CCC=cl.exe -nologo
1616
LD=cl.exe -nologo
17-
CFLAGS=-c -I$(PCCTS_H) $(CFLAGS_DEBUG) -GX -TP -DCCCC_CONF_W32VC
17+
CCC_OPTS=-c -I$(PCCTS_H) $(CFLAGS_DEBUG) -GX -TP -D_CRT_SECURE_NO_WARNINGS -DCCCC_CONF_W32VC
1818
C_OFLAG=-Fo
1919
LDFLAGS=$(LDFLAGS_DEBUG)
2020
LD_OFLAG=-Fe

pccts/antlr/AntlrMS.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ SET=$(PCCTS_HOME)\support\set
1010

1111

1212
# Compiler stuff
13-
CC = cl
13+
CC = cl -nologo
1414
CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \
15-
-D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /W3
15+
-D "ZZLEXBUFSIZE=65536" -D_CRT_SECURE_NO_WARNINGS /D "LONGFILENAMES" /W3
1616

1717
ANTLR_OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \
1818
fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \

pccts/dlg/DlgMS.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ SET=$(PCCTS_HOME)\support\set
99

1010

1111
# Compiler stuff
12-
CC = cl
12+
CC = cl -nologo
1313
CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \
14-
-D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /W3
14+
-D "ZZLEXBUFSIZE=65536" -D_CRT_SECURE_NO_WARNINGS /D "LONGFILENAMES" /W3
1515

1616
DLG_OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \
1717
output.obj relabel.obj automata.obj

0 commit comments

Comments
 (0)