From b4e55f50eb1105b83b893b46e86486e557120801 Mon Sep 17 00:00:00 2001 From: Pavel P Date: Fri, 11 Apr 2025 12:10:55 +0200 Subject: [PATCH 1/2] 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 --- build_w32vc.bat | 31 ++++++++++++++++++++----------- cccc/w32vc.mak | 2 +- pccts/antlr/AntlrMS.mak | 4 ++-- pccts/dlg/DlgMS.mak | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/build_w32vc.bat b/build_w32vc.bat index d9f03d6..e10abc9 100755 --- a/build_w32vc.bat +++ b/build_w32vc.bat @@ -1,38 +1,51 @@ @rem build_w32vc.bat @echo off +setlocal enabledelayedexpansion +if not exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto no_vswhere +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 ( + set InstallDir=%%i +) +if not exist "%InstallDir%\Common7\Tools\vsdevcmd.bat" goto no_vswhere +call "%InstallDir%\Common7\Tools\vsdevcmd.bat" %* +goto have_vc + +:no_vswhere rem This file builds and tests CCCC under Microsoft Visual Studio. rem Path to Microsoft Visual Studio standard edition release 6.0 set VCDIR=c:\Program Files\Microsoft Visual Studio\vc98 if not exist "%VCDIR%\bin\vcvars32.bat" goto no_vc call "%VCDIR%\bin\vcvars32.bat" +:have_vc if not exist pccts\bin mkdir pccts\bin cd pccts\dlg if exist *.obj del *.obj -nmake -f DlgMS.mak +nmake -nologo -f DlgMS.mak copy dlg.exe ..\bin cd ..\.. cd pccts\antlr if exist *.obj del *.obj -nmake -f AntlrMS.mak +nmake -nologo -f AntlrMS.mak copy antlr.exe ..\bin cd ..\.. cd cccc if exist *.obj del *.obj if exist *.cpp del *.cpp -nmake -f w32vc.mak +nmake -nologo -f w32vc.mak cd .. cd test -nmake -f w32vc.mak +nmake -nologo -f w32vc.mak cd .. +rem vswhere is a vs2017+ thing, ancient vcaddin won't compile. +if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" goto end cd vcaddin -nmake -f CcccDevStudioAddIn.mak CFG="CcccDevStudioAddIn - Win32 Release" +nmake -nologo -f CcccDevStudioAddIn.mak CFG="CcccDevStudioAddIn - Win32 Release" cd .. @@ -45,9 +58,5 @@ echo Please modify the script if the location is different. :end - - - - - - +rem show "Press any key to continue" if build_w32vc.bat was run from exlorer +IF %0 == "%~0" pause diff --git a/cccc/w32vc.mak b/cccc/w32vc.mak index f05f2fa..95408a1 100644 --- a/cccc/w32vc.mak +++ b/cccc/w32vc.mak @@ -14,7 +14,7 @@ LDFLAGS_DEBUG=-Zi PATHSEP=\\ CCC=cl.exe -nologo LD=cl.exe -nologo -CFLAGS=-c -I$(PCCTS_H) $(CFLAGS_DEBUG) -GX -TP -DCCCC_CONF_W32VC +CCC_OPTS=-c -I$(PCCTS_H) $(CFLAGS_DEBUG) -GX -TP -D_CRT_SECURE_NO_WARNINGS -DCCCC_CONF_W32VC C_OFLAG=-Fo LDFLAGS=$(LDFLAGS_DEBUG) LD_OFLAG=-Fe diff --git a/pccts/antlr/AntlrMS.mak b/pccts/antlr/AntlrMS.mak index 1f54b18..ef79525 100644 --- a/pccts/antlr/AntlrMS.mak +++ b/pccts/antlr/AntlrMS.mak @@ -10,9 +10,9 @@ SET=$(PCCTS_HOME)\support\set # Compiler stuff -CC = cl +CC = cl -nologo CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \ - -D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /W3 + -D "ZZLEXBUFSIZE=65536" -D_CRT_SECURE_NO_WARNINGS /D "LONGFILENAMES" /W3 ANTLR_OBJS = antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \ fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \ diff --git a/pccts/dlg/DlgMS.mak b/pccts/dlg/DlgMS.mak index d5aab8a..a604962 100644 --- a/pccts/dlg/DlgMS.mak +++ b/pccts/dlg/DlgMS.mak @@ -9,9 +9,9 @@ SET=$(PCCTS_HOME)\support\set # Compiler stuff -CC = cl +CC = cl -nologo CFLAGS = -I "." -I "$(PCCTS_H)" -I "$(SET)" -D "USER_ZZSYN" -D "PC" \ - -D "ZZLEXBUFSIZE=65536" /D "LONGFILENAMES" /W3 + -D "ZZLEXBUFSIZE=65536" -D_CRT_SECURE_NO_WARNINGS /D "LONGFILENAMES" /W3 DLG_OBJS = dlg_p.obj dlg_a.obj main.obj err.obj support.obj \ output.obj relabel.obj automata.obj From 94a67a54d006d9bb254375730479c69b02b69e3a Mon Sep 17 00:00:00 2001 From: Pavel P Date: Fri, 11 Apr 2025 12:21:22 +0200 Subject: [PATCH 2/2] Update build instructions for Windows --- README.md | 5 +++-- README_install.rst | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 05ffed9..847aa39 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,9 @@ Current versions should be installed via ebuild or built using the makefile, however, in earlier versions (3.pre-*) the recommended way of building the software was by using the BAT and SH scripts in the top directory of the distribution as appropriate for your platform. On Win32, the script -build_w32vc.bat builds the software with Microsoft Visual C++ version -5 or 6 (locations within the script may need to be modified according +build_w32vc.bat builds the software with Microsoft Visual C++. Newer versions +(vs2017 and newer) should work automatically. Older versions like 5 or 6: +locations within the script may need to be modified according to which you have and whether it is installed at the default position in the filesystem). On Linux and similar platforms the shell script build_posixgcc.sh should still work. diff --git a/README_install.rst b/README_install.rst index 8488021..2927869 100644 --- a/README_install.rst +++ b/README_install.rst @@ -50,7 +50,7 @@ For MSVC on windows you can follow the same basic procedure, but use the $ git clone https://github.com/sarnold/cccc $ cd cccc - $ ./build_msvc.bat --clean + $ ./build_w32vc.bat .. note:: On windows the executable name is ``cccc.exe``.