1@rem build_w32vc.bat
2@echo off
3
4rem This file builds and tests CCCC under Microsoft Visual C++ Toolkit 2003
5rem (distributed freely by Microsoft).
6rem This platform is distributed freely by Microsoft, but does not contain
7rem an implementation of 'make', hence all of the build logic is contained
8rem within this script.
9
10rem Path to Microsoft Visual Studio Toolkit 2003
11set VCTDIR=c:\Program Files\Microsoft Visual C++ Toolkit 2003
12if not exist "%VCTDIR%\bin\cl.exe" goto no_vc
13
14set CL_EXE="%VCTDIR%\bin\cl.exe"
15set CL_ARGS=-nologo -c -I "%VCTDIR%\include" -EHsc
16set LINK_EXE="%VCTDIR%\bin\link.exe"
17set LINK_ARGS=-libpath:"%VCTDIR%\lib" -subsystem:console
18
19set arg1=%1
20
21if "%arg1%"=="--version" (
22   echo // This version built on %HOSTNAME% at %DATE% > cccc\cccc_ver.h
23   echo #define CCCC_VERSION %2 >> cccc\cccc_ver.h
24   echo #define CCCC_VERSION_STRING "%2" >> cccc\cccc_ver.h
25   set arg1=--clean
26)
27if "%arg1%"=="--installer" (
28   goto :buildInstaller
29)
30
31
32if "%arg1%"=="--clean" (
33   for %%d in ( pccts\dlg pccts\antlr cccc ) do (
34      if exist %%d\*.obj del %%d\*.obj
35      if exist %%d\*.exe del %%d\*.exe
36   )
37   if exist pccts\bin rmdir /s /q pccts\bin
38   mkdir pccts\bin
39) else (
40   if not exist pccts\bin\dlg.exe goto :noPCCTS
41   if not exist pccts\bin\antlr.exe goto :noPCCTS
42   goto :buildCCCC
43)
44
45
46setlocal
47cd pccts\dlg
48
49set C_SOURCES=automata.c dlg_a.c dlg_p.c err.c main.c output.c relabel.c support.c
50set C_SOURCES=%C_SOURCES% ..\support\set\set.c
51set CL_ARGS=%CL_ARGS% -I ..\h -I ..\support\set  -D "USER_ZZSYN" -D "PC" -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /W3
52for %%f in ( %C_SOURCES% ) do (
53   %CL_EXE% %CL_ARGS% %%f
54)
55%LINK_EXE% %LINK_ARGS% *.obj -out:dlg.exe
56if exist dlg.exe copy dlg.exe ..\bin
57
58cd ..\..
59endlocal
60
61setlocal
62cd pccts\antlr
63
64set C_SOURCES=antlr.c bits.c build.c dumpcycles.c dumpnode.c egman.c err.c
65set C_SOURCES=%C_SOURCES% fcache.c fset.c fset2.c gen.c globals.c hash.c
66set C_SOURCES=%C_SOURCES% lex.c main.c misc.c mrhoist.c pred.c scan.c
67set C_SOURCES=%C_SOURCES% ..\support\set\set.c
68set CL_ARGS=%CL_ARGS% -I ..\h -I ..\support\set  -D "USER_ZZSYN" -D "PC" -D "ZZLEXBUFSIZE=65536"  /D "LONGFILENAMES" /W3
69for %%f in ( %C_SOURCES% ) do (
70   %CL_EXE% %CL_ARGS% %%f
71)
72%LINK_EXE% %LINK_ARGS% *.obj -out:antlr.exe
73if exist antlr.exe copy antlr.exe ..\bin
74
75cd ..\..
76endlocal
77
78:buildCCCC
79setlocal
80cd cccc
81if exist *.cpp del *.cpp
82set AFLAGS=-CC -k 2 -gd -ge -rl 5000 -w1 -e3
83set DFLAGS=-C2 -CC
84..\pccts\bin\antlr.exe %AFLAGS% -ft Ctokens.h cccc.g
85..\pccts\bin\dlg.exe %DFLAGS% -cl CLexer parser.dlg
86..\pccts\bin\antlr.exe %AFLAGS% -ft Jtokens.h java.g
87..\pccts\bin\dlg.exe %DFLAGS% -cl JLexer parser.dlg
88
89set CC_SOURCES=ccccmain cccc_db cccc_ext cccc_htm
90set CC_SOURCES=%CC_SOURCES% cccc_itm cccc_mem cccc_met cccc_mod
91set CC_SOURCES=%CC_SOURCES% cccc_new cccc_opt cccc_prj cccc_rec
92set CC_SOURCES=%CC_SOURCES% cccc_tbl cccc_tok cccc_tpl cccc_use
93set CC_SOURCES=%CC_SOURCES% cccc_utl cccc_xml
94set CPP_SOURCES=cccc CLexer CParser java JLexer JParser
95set A_SOURCES=..\pccts\h\AParser ..\pccts\h\DLexerBase ..\pccts\h\ATokenBuffer
96set CL_ARGS=-nologo -I ..\pccts\h -D CC_INCLUDED -D JAVA_INCLUDED -D CCCC_CONF_W32VC %CL_ARGS%
97for %%f in ( %CC_SOURCES% ) do (
98   if not exist %%f.obj (
99      %CL_EXE% %CL_ARGS% %%f.cc
100   )
101)
102for %%f in ( %CPP_SOURCES% ) do (
103   rem Only compile .obj files from .cpp files when they don't exist.
104   if not exist %%f.obj (
105      %CL_EXE% %CL_ARGS% %%f.cpp
106   )
107)
108for %%f in ( %A_SOURCES% ) do (
109   rem The ANLTR source files do not change => if an .obj file exists we can preserve
110   rem it.
111   if not exist %%f.obj (
112      %CL_EXE% %CL_ARGS% %%f.cpp
113   )
114)
115
116%LINK_EXE% %LINK_ARGS% *.obj -out:cccc.exe
117cd ..
118endlocal
119
120if not exist cccc\cccc.exe (
121   echo Failed to build cccc.exe
122   goto :end
123)
124
125setlocal
126cd test
127call run_test cc    test1
128call run_test cc    test2
129call run_test cc    test3
130call run_test test4 test4
131call run_test cc    prn1
132call run_test cc    prn2
133call run_test cc    prn3
134call run_test cc    prn4
135call run_test cc    prn5
136call run_test cc    prn6
137call run_test c     prn7
138call run_test java  prn8
139call run_test cc    prn9
140call run_test cc    prn10
141call run_test cc    prn11
142call run_test cc    prn12
143call run_test java  prn13
144call run_test java  prn14
145call run_test java  prn15
146call run_test java  prn16
147cd ..
148endlocal
149
150rem The visual C++ addin can't be built using MS Visual C++ Toolkit 2003
151rem because it doesn't provide MFC header files and libraries
152goto :afterAddIn
153setlocal
154cd vcaddin
155set CPP_SOURCES=CcccDevStudioAddIn CommandForm Commands DSAddIn
156set CPP_SOURCES=%CPP_SOURCES% FileList StdAfx WorkspaceInfo
157for %%f in ( %CPP_SOURCES% ) do (
158   if not exist %%f.obj (
159      %CL_EXE% %CL_ARGS% %%f.cpp
160   )
161)
162cd ..
163endlocal
164:afterAddIn
165
166:buildInstaller
167setlocal
168cd w32installer
169set CL_CPP_ARGS=/FI ..\cccc\cccc_ver.h /EP
170%CL_EXE% %CL_CPP_ARGS% cccc.iss.nover > cccc.iss
171"c:\Program Files\My Inno Setup Extensions\iscc.exe" cccc.iss
172copy output\CCCC_SETUP.exe ..
173goto :end
174
175
176:no_vc
177echo This script expects MS Visual C++ Toolkit 2003 to be in %VCTDIR%
178echo Please modify the script if the location is different.
179goto :end
180
181:noPCCTS
182echo There does not appear to be a valid set of PCCTS binaries in pccts\bin.
183echo Please rerun the script with the argument --clean to build these binaries.
184goto :end
185
186
187
188:end
189
190
191
192
193
194