5 ' This file is part of OpenTTD.
6 ' OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
7 ' OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 ' See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
11 Set FSO
= CreateObject("Scripting.FileSystemObject")
13 ' openttd_vs141.sln is for MSVC 2017
14 ' openttd_vs141.vcxproj is for MSVC 2017
15 ' openttd_vs141.vcxproj.filters is for MSVC 2017
16 ' langs_vs141.vcxproj is for MSVC 2017
17 ' strgen_vs141.vcxproj is for MSVC 2017
18 ' strgen_vs141.vcxproj.filters is for MSVC 2017
19 ' generate_vs141.vcxproj is for MSVC 2017
20 ' version_vs141.vcxproj is for MSVC 2017
22 ' openttd_vs140.sln is for MSVC 2015
23 ' openttd_vs140.vcxproj is for MSVC 2015
24 ' openttd_vs140.vcxproj.filters is for MSVC 2015
25 ' langs_vs140.vcxproj is for MSVC 2015
26 ' strgen_vs140.vcxproj is for MSVC 2015
27 ' strgen_vs140.vcxproj.filters is for MSVC 2015
28 ' generate_vs140.vcxproj is for MSVC 2015
29 ' version_vs140.vcxproj is for MSVC 2015
31 ' openttd_vs100.sln is for MSVC 2010
32 ' openttd_vs100.vcxproj is for MSVC 2010
33 ' openttd_vs100.vcxproj.filters is for MSVC 2010
34 ' langs_vs100.vcxproj is for MSVC 2010
35 ' strgen_vs100.vcxproj is for MSVC 2010
36 ' strgen_vs100.vcxproj.filters is for MSVC 2010
37 ' generate_vs100.vcxproj is for MSVC 2010
38 ' version_vs100.vcxproj is for MSVC 2010
40 ' openttd_vs90.sln is for MSVC 2008
41 ' openttd_vs90.vcproj is for MSVC 2008
42 ' langs_vs90.vcproj is for MSVC 2008
43 ' strgen_vs90.vcproj is for MSVC 2008
44 ' generate_vs90.vcproj is for MSVC 2008
45 ' version_vs90.vcproj is for MSVC 2008
47 ' openttd_vs80.sln is for MSVC 2005
48 ' openttd_vs80.vcproj is for MSVC 2005
49 ' langs_vs80.vcproj is for MSVC 2005
50 ' strgen_vs80.vcproj is for MSVC 2005
51 ' generate_vs80.vcproj is for MSVC 2005
52 ' version_vs80.vcproj is for MSVC 2005
54 Sub get_files(srcdir
, dir
, list
)
58 ' pattern for files to keep
59 Set rekeep
= New RegExp
60 rekeep
.Pattern
= "\.h(pp)?$"
63 ' pattern for files to exclude
64 Set reskip = New RegExp
65 reskip.Pattern = "\
.svn
"
68 For Each file in dir.Files
69 filename = Replace(file.path, srcdir, "") ' Remove */src/
70 filename = Replace(filename, "\
", "/") ' Replace separators
71 If rekeep.Test(filename) And Not reskip.Test(filename) Then
72 list.Add filename, filename
77 Sub get_dir_files(srcdir, dir, list)
80 get_files srcdir, dir, list
82 ' Recurse in subfolders
83 For Each folder in dir.SubFolders
84 get_dir_files srcdir, folder, list
88 Sub headers_check(filename, dir)
89 Dim source_list_headers, src_dir_headers, regexp, line, file, str
91 ' Define regexp for source.list parsing
92 Set regexp = New RegExp
93 regexp.Pattern = "\
.h
"
96 ' Parse source.list and store headers in a dictionary
97 Set source_list_headers = CreateObject("Scripting
.Dictionary
")
98 Set file = FSO.OpenTextFile(filename, 1, 0, 0)
99 While Not file.AtEndOfStream
100 line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
101 If Len(line) > 0 And regexp.Test(line) And line <> "../objs
/langs
/table
/strings
.h
" And line <> "../objs
/settings
/table
/settings
.h
" Then
102 source_list_headers.Add line, line
107 ' Get header files in /src/
108 Set src_dir_headers = CreateObject("Scripting
.Dictionary
")
109 get_dir_files dir, FSO.GetFolder(dir), src_dir_headers
111 ' Finding files in source.list but not in /src/
112 For Each line In source_list_headers
113 If Not src_dir_headers.Exists(line) Then
114 str = str & "< " & line & vbCrLf
118 ' Finding files in /src/ but not in source.list
119 For Each line In src_dir_headers
120 If Not source_list_headers.Exists(line) Then
121 str = str & "> " & line & vbCrLf
125 ' Display the missing files if any
127 str = "The following headers are missing
in source
.list
and not in /src
/ or vice versa
." _
133 Function load_main_data(filename, ByRef vcxproj, ByRef filters, ByRef files)
134 Dim res, file, line, deep, skip, first_filter, first_file, filter, cltype, index, ext, pathelems, outdir, config
136 configs(0) = "Release|Win32
"
137 configs(1) = "Debug|Win32
"
138 configs(2) = "Release|x64
"
139 configs(3) = "Debug|x64
"
142 ' Read the source.list and process it
143 Set file = FSO.OpenTextFile(filename, 1, 0, 0)
144 While Not file.AtEndOfStream
145 line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
146 If Len(line) > 0 Then
147 Select Case Split(line, " ")(0)
149 If deep = skip Then skip = skip - 1
154 ElseIf deep - 1 = skip Then
158 line = Replace(line, "#
if ", "")
159 If deep = skip And ( _
164 line = "DIRECTMUSIC
" Or _
167 line = "HAVE_THREAD
" _
168 ) Then skip = skip + 1
172 line = Replace(line, "#
", "")
173 if first_filter <> 0 Then
174 res = res & " </Filter
>" & vbCrLf
175 filters = filters & vbCrLf
181 " <Filter
" & vbCrLf & _
182 " Name
=" & Chr(34) & filter & Chr(34) & vbCrLf & _
184 filters = filters & _
185 " <Filter Include
="& Chr(34) & filter & Chr(34) & ">" & vbCrLf & _
186 " <UniqueIdentifier
>{c76ff9f1
-1e62
-46d8
-8d55
-" & String(12 - Len(CStr(index)), "0") & index & "}</UniqueIdentifier
>" & vbCrLf & _
192 line = Replace(line, "/" ,"\
")
193 if first_file <> 0 Then
194 vcxproj = vcxproj & vbCrLf
195 files = files & vbCrLf
199 ext = Split(Line, ".")(1)
200 pathelems = Split(Line, "\
")
201 If UBound(pathelems) > 0 Then
202 ReDim Preserve pathelems(UBound(pathelems) - 1)
203 outdir = "$(IntDir)\" & Join(pathelems
, "\") & "\"
208 " <File" & vbCrLf
& _
209 " RelativePath=" & Chr(34) & ".\..\src\" & line
& Chr(34) & vbCrLf
& _
211 If ext
= "cpp" And outdir
<> "" Then
212 For Each config
In configs
214 " <FileConfiguration" & vbCrLf
& _
215 " Name=" & Chr(34) & config
& Chr(34) & vbCrLf
& _
217 " <Tool" & vbCrLf
& _
218 " Name=" & Chr(34) & "VCCLCompilerTool" & Chr(34) & vbCrLf
& _
219 " AssemblerListingLocation=" & Chr(34) & outdir
& Chr(34) & vbCrLf
& _
220 " ObjectFile=" & Chr(34) & outdir
& Chr(34) & vbCrLf
& _
221 " XMLDocumentationFileName=" & Chr(34) & outdir
& Chr(34) & vbCrLf
& _
223 " </FileConfiguration>" & vbCrLf
232 cltype
= "ResourceCompile"
236 If ext
= "cpp" And outdir
<> "" Then
237 vcxproj
= vcxproj
& _
238 " <ClCompile Include=" & Chr(34) & "..\src\" & line
& Chr(34) & ">" & vbCrLf
& _
239 " <AssemblerListingLocation>" & outdir
& "</AssemblerListingLocation>" & vbCrLf
& _
240 " <ObjectFileName>" & outdir
& "</ObjectFileName>" & vbCrLf
& _
241 " <XMLDocumentationFileName>" & outdir
& "</XMLDocumentationFileName>" & vbCrLf
& _
244 vcxproj
= vcxproj
& " <" & cltype
& " Include="& Chr(34) & "..\src\" & line
& Chr(34) & " />"
247 " <" & cltype
& " Include="& Chr(34) & "..\src\" & line
& Chr(34) & ">" & vbCrLf
& _
248 " <Filter>" & filter
& "</Filter>" & vbCrLf
& _
254 res
= res
& " </Filter>"
259 Function load_lang_data(dir
, ByRef vcxproj
, ByRef files
)
260 Dim res
, folder
, file
, first_time
262 Set folder
= FSO
.GetFolder(dir
)
263 For Each file
In folder
.Files
264 file
= FSO
.GetFileName(file
)
265 If file
<> "english.txt" And FSO
.GetExtensionName(file
) = "txt" Then
266 file
= Left(file
, Len(file
) - 4)
267 If first_time
<> 0 Then
269 vcxproj
= vcxproj
& vbCrLf
270 files
= files
& vbCrLf
275 " <File" & vbCrLf
& _
276 " RelativePath=" & Chr(34) & "..\src\lang\" & file
& ".txt" & Chr(34) & vbCrLf
& _
278 " <FileConfiguration" & vbCrLf
& _
279 " Name=" & Chr(34) & "Debug|Win32" & Chr(34) & vbCrLf
& _
281 " <Tool" & vbCrLf
& _
282 " Name=" & Chr(34) & "VCCustomBuildTool" & Chr(34) & vbCrLf
& _
283 " Description=" & Chr(34) & "Generating " & file
& " language file" & Chr(34) & vbCrLf
& _
284 " CommandLine=" & Chr(34) & "..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
exit 0
" & Chr(34) & vbCrLf
& _
285 " AdditionalDependencies=" & Chr(34) & "..\src\lang\english.txt;..\objs\strgen\strgen.exe" & Chr(34) & vbCrLf
& _
286 " Outputs=" & Chr(34) & "..\bin\lang\" & file
& ".lng" & Chr(34) & vbCrLf
& _
288 " </FileConfiguration>" & vbCrLf
& _
290 vcxproj
= vcxproj
& _
291 " <CustomBuild Include=" & Chr(34) & "..\src\lang\" & file
& ".txt" & Chr(34) & ">" & vbCrLf
& _
292 " <Message Condition=" & Chr(34) & "'$(Configuration)|$(Platform)'=='Debug|Win32'" & Chr(34) & ">Generating
" & file & " language file
</Message
>" & vbCrLf & _
293 " <Command Condition
=" & Chr(34) & "'$(Configuration)|$(Platform)'=='Debug|Win32'" & Chr(34) & ">..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang " & Chr(34) & "%(FullPath)" & Chr(34) & "</Command>" & vbCrLf & _
294 " <AdditionalInputs Condition=" & Chr(34) & "'$(Configuration)|$(Platform)'=='Debug|Win32'" & Chr(34) & ">..\src\lang\english
.txt
;..\objs\strgen\strgen
.exe
;%(AdditionalInputs
)</AdditionalInputs
>" & vbCrLf & _
295 " <Outputs Condition
=" & Chr(34) & "'$(Configuration)|$(Platform)'=='Debug|Win32'" & Chr(34) & ">..\bin\lang\" & file & ".lng;%(Outputs)</Outputs>" & vbCrLf & _
298 " <CustomBuild Include=" & Chr(34) & "..\src\lang\" & file
& ".txt" & Chr(34) & ">" & vbCrLf
& _
299 " <Filter>Translations</Filter>" & vbCrLf
& _
306 Function load_settings_data(dir
, ByRef vcxproj
, ByRef command
, ByRef files
)
307 Dim res
, folder
, file
, first_time
309 command
= "..\objs\settings\settings_gen.exe -o ..\objs\settings\table\settings.h -b ..\src\table\settings.h.preamble -a ..\src\table\settings.h.postamble"
310 Set folder
= FSO
.GetFolder(dir
)
311 For Each file
In folder
.Files
312 file
= FSO
.GetFileName(file
)
313 If FSO
.GetExtensionName(file
) = "ini" Then
314 if first_time
<> 0 Then
316 vcxproj
= vcxproj
& vbCrLf
317 files
= files
& vbCrLf
322 " <File" & vbCrLf
& _
323 " RelativePath=" & Chr(34) & "..\src\table\" & file
& Chr(34) & vbCrLf
& _
326 vcxproj
= vcxproj
& _
327 " <None Include=" & Chr(34) & "..\src\table\" & file
& Chr(34) & " />"
328 command
= command
& " ..\src\table\" & file
330 " <None Include=" & Chr(34) & "..\src\table\" & file
& Chr(34) & ">" & vbCrLf
& _
331 " <Filter>INI</Filter>" & vbCrLf
& _
335 load_settings_data
= res
338 Sub generate(data
, dest
, data2
)
339 Dim srcfile
, destfile
, line
340 WScript
.Echo
"Generating " & FSO
.GetFileName(dest
) & "..."
341 Set srcfile
= FSO
.OpenTextFile(dest
& ".in", 1, 0, 0)
342 Set destfile
= FSO
.CreateTextFile(dest
, -1, 0)
344 If Not IsNull(data2
) Then
345 ' Everything above the !!FILTERS!! marker
346 line
= srcfile
.ReadLine()
347 While line
<> "!!FILTERS!!"
348 If len(line
) > 0 Then destfile
.WriteLine(line
)
349 line
= srcfile
.ReadLine()
352 ' Our generated content
353 destfile
.WriteLine(data2
)
356 ' Everything above the !!FILES!! marker
357 line
= srcfile
.ReadLine()
358 While line
<> "!!FILES!!"
359 If len(line
) > 0 Then destfile
.WriteLine(line
)
360 line
= srcfile
.ReadLine()
363 ' Our generated content
364 destfile
.WriteLine(data
)
366 ' Everything below the !!FILES!! marker
367 While Not srcfile
.AtEndOfStream
368 line
= srcfile
.ReadLine()
369 If len(line
) > 0 Then destfile
.WriteLine(line
)
376 ROOT_DIR
= FSO
.GetFolder("..").Path
377 If Not FSO
.FileExists(ROOT_DIR
& "/source.list") Then
378 ROOT_DIR
= FSO
.GetFolder(".").Path
380 If Not FSO
.FileExists(ROOT_DIR
& "/source.list") Then
381 WScript
.Echo
"Can't find source.list, needed in order to make this run." _
382 & vbCrLf
& "Please go to either the project dir, or the root dir of a clean SVN checkout."
386 headers_check ROOT_DIR
& "/source.list", ROOT_DIR
& "\src\" ' Backslashes needed for DoFiles
388 Dim openttd
, openttdvcxproj
, openttdfilters
, openttdfiles
389 openttd
= load_main_data(ROOT_DIR
& "/source.list", openttdvcxproj
, openttdfilters
, openttdfiles
)
390 generate openttd
, ROOT_DIR
& "/projects/openttd_vs80.vcproj", Null
391 generate openttd
, ROOT_DIR
& "/projects/openttd_vs90.vcproj", Null
392 generate openttdvcxproj
, ROOT_DIR
& "/projects/openttd_vs100.vcxproj", Null
393 generate openttdfiles
, ROOT_DIR
& "/projects/openttd_vs100.vcxproj.filters", openttdfilters
394 generate openttdvcxproj
, ROOT_DIR
& "/projects/openttd_vs140.vcxproj", Null
395 generate openttdfiles
, ROOT_DIR
& "/projects/openttd_vs140.vcxproj.filters", openttdfilters
396 generate openttdvcxproj
, ROOT_DIR
& "/projects/openttd_vs141.vcxproj", Null
397 generate openttdfiles
, ROOT_DIR
& "/projects/openttd_vs141.vcxproj.filters", openttdfilters
399 Dim lang
, langvcxproj
, langfiles
400 lang
= load_lang_data(ROOT_DIR
& "/src/lang", langvcxproj
, langfiles
)
401 generate lang
, ROOT_DIR
& "/projects/langs_vs80.vcproj", Null
402 generate lang
, ROOT_DIR
& "/projects/langs_vs90.vcproj", Null
403 generate langvcxproj
, ROOT_DIR
& "/projects/langs_vs100.vcxproj", Null
404 generate langfiles
, ROOT_DIR
& "/projects/langs_vs100.vcxproj.filters", Null
405 generate langvcxproj
, ROOT_DIR
& "/projects/langs_vs140.vcxproj", Null
406 generate langfiles
, ROOT_DIR
& "/projects/langs_vs140.vcxproj.filters", Null
407 generate langvcxproj
, ROOT_DIR
& "/projects/langs_vs141.vcxproj", Null
408 generate langfiles
, ROOT_DIR
& "/projects/langs_vs141.vcxproj.filters", Null
410 Dim settings
, settingsvcxproj
, settingscommand
, settingsfiles
411 settings
= load_settings_data(ROOT_DIR
& "/src/table", settingsvcxproj
, settingscommand
, settingsfiles
)
412 generate settings
, ROOT_DIR
& "/projects/settings_vs80.vcproj", settingscommand
413 generate settings
, ROOT_DIR
& "/projects/settings_vs90.vcproj", settingscommand
414 generate settingsvcxproj
, ROOT_DIR
& "/projects/settings_vs100.vcxproj", settingscommand
415 generate settingsfiles
, ROOT_DIR
& "/projects/settings_vs100.vcxproj.filters", Null
416 generate settingsvcxproj
, ROOT_DIR
& "/projects/settings_vs140.vcxproj", settingscommand
417 generate settingsfiles
, ROOT_DIR
& "/projects/settings_vs140.vcxproj.filters", Null
418 generate settingsvcxproj
, ROOT_DIR
& "/projects/settings_vs141.vcxproj", settingscommand
419 generate settingsfiles
, ROOT_DIR
& "/projects/settings_vs141.vcxproj.filters", Null