Skip to content

Commit 8734477

Browse files
committedFeb 29, 2020
Move buildlocaltools :Build function to a separate file
The `:Build` function, which is used to automate the SDK tool build process, was moved to a separate batch file, in order to support building on NT 5.1. For more details, refer to the issue #13.
1 parent b160fd1 commit 8734477

File tree

2 files changed

+81
-74
lines changed

2 files changed

+81
-74
lines changed
 

‎buildlocaltool.cmd

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@echo off
2+
3+
REM //
4+
REM // ** Build Local Tool Function **
5+
REM //
6+
REM // %~1 = Tool name
7+
REM // %~2 = Relative source directory path under %NTROOT%
8+
REM // %~3 = Relative binary path under %NTTREE%
9+
REM // %~4 = Relative binary path under %BETOOLS%
10+
REM //
11+
12+
REM //
13+
REM // Validate function arguments.
14+
REM //
15+
16+
if [%~1] equ [] exit /b 1
17+
if [%~2] equ [] exit /b 2
18+
19+
echo.
20+
echo [%~1]
21+
22+
REM //
23+
REM // Verify that the source directory for the specified tool exists.
24+
REM //
25+
26+
if not exist "%NTROOT%\%~2" (
27+
echo %~1 does not exist in the local source tree. Skipping %~1 build.
28+
exit /b
29+
)
30+
31+
cd "%NTROOT%\%~2"
32+
33+
REM //
34+
REM // Perform build.
35+
REM //
36+
37+
build -c
38+
if errorlevel 1 (
39+
echo Build command failed for %~1.
40+
exit /b 1
41+
)
42+
43+
REM //
44+
REM // Copy the built tool to the tools directory.
45+
REM //
46+
47+
if not [%~3] equ [] (
48+
copy /y "%NTTREE%\%~3" "%BETOOLS%\%~4"
49+
if errorlevel 1 (
50+
echo Failed to copy %~1 to tools directory.
51+
exit /b 2
52+
)
53+
)
54+
55+
exit /b 0

‎buildlocaltools.cmd

+26-74
Original file line numberDiff line numberDiff line change
@@ -54,82 +54,82 @@ REM //
5454
echo.
5555
echo == Building local tools ... ==
5656

57-
call :Build mkmsg sdktools\mkmsg bldtools\mkmsg.exe idw\mkmsg.exe
57+
call buildlocaltool.cmd mkmsg sdktools\mkmsg bldtools\mkmsg.exe idw\mkmsg.exe
5858
if errorlevel 1 goto Error
5959

60-
call :Build nmake sdktools\nmake bldtools\nmake.exe mstools\nmake.exe
60+
call buildlocaltool.cmd nmake sdktools\nmake bldtools\nmake.exe mstools\nmake.exe
6161
if errorlevel 1 goto Error
6262

63-
call :Build build sdktools\build idw\build.exe idw\build.exe
63+
call buildlocaltool.cmd build sdktools\build idw\build.exe idw\build.exe
6464
if errorlevel 1 goto Error
6565

66-
call :Build debuggers#dbg-common sdktools\debuggers\dbg-common
66+
call buildlocaltool.cmd debuggers#dbg-common sdktools\debuggers\dbg-common
6767
if errorlevel 1 goto Error
6868

69-
call :Build debuggers#minidump sdktools\debuggers\minidump
69+
call buildlocaltool.cmd debuggers#minidump sdktools\debuggers\minidump
7070
if errorlevel 1 goto Error
7171

72-
call :Build debuggers#imagehlp#tools sdktools\debuggers\imagehlp\tools
72+
call buildlocaltool.cmd debuggers#imagehlp#tools sdktools\debuggers\imagehlp\tools
7373
if errorlevel 1 goto Error
7474

75-
call :Build debuggers#imagehlp#dbghelp sdktools\debuggers\imagehlp\dbghelp
75+
call buildlocaltool.cmd debuggers#imagehlp#dbghelp sdktools\debuggers\imagehlp\dbghelp
7676
if errorlevel 1 goto Error
7777

78-
call :Build debuggers#imagehlp#imagehlp sdktools\debuggers\imagehlp\imagehlp
78+
call buildlocaltool.cmd debuggers#imagehlp#imagehlp sdktools\debuggers\imagehlp\imagehlp
7979
if errorlevel 1 goto Error
8080

81-
call :Build debuggers#imagehlp#binplace sdktools\debuggers\imagehlp\binplace idw\binplace.exe idw\binplace.exe
81+
call buildlocaltool.cmd debuggers#imagehlp#binplace sdktools\debuggers\imagehlp\binplace idw\binplace.exe idw\binplace.exe
8282
if errorlevel 1 goto Error
8383

84-
call :Build debuggers#symchk#symcommon sdktools\debuggers\symchk\symcommon
84+
call buildlocaltool.cmd debuggers#symchk#symcommon sdktools\debuggers\symchk\symcommon
8585
if errorlevel 1 goto Error
8686

87-
call :Build debuggers#symchk#symchk#dll sdktools\debuggers\symchk\symchk\dll dbg\files\bin\symbolcheck.dll idw\symbolcheck.dll
87+
call buildlocaltool.cmd debuggers#symchk#symchk#dll sdktools\debuggers\symchk\symchk\dll dbg\files\bin\symbolcheck.dll idw\symbolcheck.dll
8888
if errorlevel 1 goto Error
8989

90-
call :Build debuggers#symchk#symchk#exe sdktools\debuggers\symchk\symchk\exe dbg\files\bin\symchk.exe idw\symchk.exe
90+
call buildlocaltool.cmd debuggers#symchk#symchk#exe sdktools\debuggers\symchk\symchk\exe dbg\files\bin\symchk.exe idw\symchk.exe
9191
if errorlevel 1 goto Error
9292

93-
call :Build ztools sdktools\ztools
93+
call buildlocaltool.cmd ztools sdktools\ztools
9494
if errorlevel 1 goto Error
9595

96-
call :Build alias sdktools\alias bldtools\alias.exe idw\alias.exe
96+
call buildlocaltool.cmd alias sdktools\alias bldtools\alias.exe idw\alias.exe
9797
if errorlevel 1 goto Error
9898

99-
call :Build pcopy sdktools\pcopy bldtools\pcopy.exe idw\pcopy.exe
99+
call buildlocaltool.cmd pcopy sdktools\pcopy bldtools\pcopy.exe idw\pcopy.exe
100100
if errorlevel 1 goto Error
101101

102-
call :Build rcdll sdktools\rcdll bldtools\rcdll.dll mstools\rcdll.dll
102+
call buildlocaltool.cmd rcdll sdktools\rcdll bldtools\rcdll.dll mstools\rcdll.dll
103103
if errorlevel 1 goto Error
104104

105-
call :Build rc sdktools\rc bldtools\rc.exe mstools\rc.exe
105+
call buildlocaltool.cmd rc sdktools\rc bldtools\rc.exe mstools\rc.exe
106106
if errorlevel 1 goto Error
107107

108-
call :Build mc sdktools\mc bldtools\mc.exe mstools\mc.exe
108+
call buildlocaltool.cmd mc sdktools\mc bldtools\mc.exe mstools\mc.exe
109109
if errorlevel 1 goto Error
110110

111-
call :Build touch sdktools\touch bldtools\touch.exe idw\touch.exe
111+
call buildlocaltool.cmd touch sdktools\touch bldtools\touch.exe idw\touch.exe
112112
if errorlevel 1 goto Error
113113

114-
call :Build m4 sdktools\m4 bldtools\m4.exe idw\m4.exe
114+
call buildlocaltool.cmd m4 sdktools\m4 bldtools\m4.exe idw\m4.exe
115115
if errorlevel 1 goto Error
116116

117-
call :Build tracewpp sdktools\trace\tracewpp bldtools\tracewpp.exe idw\tracewpp.exe
117+
call buildlocaltool.cmd tracewpp sdktools\trace\tracewpp bldtools\tracewpp.exe idw\tracewpp.exe
118118
if errorlevel 1 goto Error
119119

120-
call :Build hextract sdktools\hextract idw\hextract.exe idw\hextract.exe
120+
call buildlocaltool.cmd hextract sdktools\hextract idw\hextract.exe idw\hextract.exe
121121
if errorlevel 1 goto Error
122122

123-
call :Build hsplit sdktools\hsplit idw\hsplit.exe idw\hsplit.exe
123+
call buildlocaltool.cmd hsplit sdktools\hsplit idw\hsplit.exe idw\hsplit.exe
124124
if errorlevel 1 goto Error
125125

126-
call :Build wcshdr sdktools\wcshdr idw\wcshdr.exe idw\wcshdr.exe
126+
call buildlocaltool.cmd wcshdr sdktools\wcshdr idw\wcshdr.exe idw\wcshdr.exe
127127
if errorlevel 1 goto Error
128128

129-
call :Build reloc sdktools\reloc bldtools\reloc.exe tools16\reloc.exe
129+
call buildlocaltool.cmd reloc sdktools\reloc bldtools\reloc.exe tools16\reloc.exe
130130
if errorlevel 1 goto Error
131131

132-
call :Build nosrvbld sdktools\nosrvbld bldtools\nosrvbld.exe tools16\nosrvbld.exe
132+
call buildlocaltool.cmd nosrvbld sdktools\nosrvbld bldtools\nosrvbld.exe tools16\nosrvbld.exe
133133
if errorlevel 1 goto Error
134134

135135
REM //
@@ -168,51 +168,3 @@ endlocal
168168
popd
169169

170170
exit /b 0
171-
172-
REM //
173-
REM // ** Build Function **
174-
REM //
175-
REM // %~1 = Tool name
176-
REM // %~2 = Relative source directory path under %NTROOT%
177-
REM // %~3 = Relative binary path under %NTTREE%
178-
REM // %~4 = Relative binary path under %BETOOLS%
179-
REM //
180-
181-
:Build
182-
echo.
183-
echo [%~1]
184-
185-
REM //
186-
REM // Verify that the source directory for the specified tool exists.
187-
REM //
188-
189-
if not exist "%NTROOT%\%~2" (
190-
echo %~1 does not exist in the local source tree. Skipping %~1 build.
191-
exit /b
192-
)
193-
194-
cd "%NTROOT%\%~2"
195-
196-
REM //
197-
REM // Perform build.
198-
REM //
199-
200-
build -c
201-
if errorlevel 1 (
202-
echo Build command failed for %~1.
203-
exit /b 1
204-
)
205-
206-
REM //
207-
REM // Copy the built tool to the tools directory.
208-
REM //
209-
210-
if not [%~3] equ [] (
211-
copy /y "%NTTREE%\%~3" "%BETOOLS%\%~4"
212-
if errorlevel 1 (
213-
echo Failed to copy %~1 to tools directory.
214-
exit /b 2
215-
)
216-
)
217-
218-
exit /b 0

0 commit comments

Comments
 (0)
Please sign in to comment.