projects/generate.vbs
changeset 10238 05c80dbcb98c
parent 10175 1119f6640ee6
child 10340 15ad6fc1c780
equal deleted inserted replaced
10237:f14be17a032a 10238:05c80dbcb98c
    42 			End If
    42 			End If
    43 			list.Add line, line
    43 			list.Add line, line
    44 		End If
    44 		End If
    45 	Wend
    45 	Wend
    46 	file.Close
    46 	file.Close
       
    47 End Sub
       
    48 
       
    49 Sub get_files(srcdir, dir, list)
       
    50 	Dim file, filename
       
    51 	Dim rekeep, reskip
       
    52 
       
    53 	' pattern for files to keep
       
    54 	Set rekeep = New RegExp
       
    55 	rekeep.Pattern = "\.h"
       
    56 	rekeep.Global = True
       
    57 
       
    58 	' pattern for files to exclude
       
    59 	Set reskip = New RegExp
       
    60 	reskip.Pattern = "\.svn|\.hpp\.sq"
       
    61 	reskip.Global = True
       
    62 
       
    63 	For Each file in dir.Files
       
    64 		filename = Replace(file.path, srcdir, "") ' Remove */src/
       
    65 		filename = Replace(filename, "\", "/") ' Replace separators
       
    66 		If rekeep.Test(filename) And Not reskip.Test(filename) Then
       
    67 			list.Add filename, filename
       
    68 		End If
       
    69 	Next
       
    70 End Sub
       
    71 
       
    72 Sub get_dir_files(srcdir, dir, list)
       
    73 	Dim folder
       
    74 	' Get files
       
    75 	get_files srcdir, dir, list
       
    76 
       
    77 	' Recurse in subfolders
       
    78 	For Each folder in dir.SubFolders
       
    79 		get_dir_files srcdir, folder, list
       
    80 	Next
       
    81 End Sub
       
    82 
       
    83 Sub headers_check(filename, dir)
       
    84 	Dim source_list_headers, src_dir_headers, regexp, line, file, str
       
    85 
       
    86 	' Define regexp for source.list parsing
       
    87 	Set regexp = New RegExp
       
    88 	regexp.Pattern = "\.h"
       
    89 	regexp.Global = True
       
    90 
       
    91 	' Parse source.list and store headers in a dictionary
       
    92 	Set source_list_headers = CreateObject("Scripting.Dictionary")
       
    93 	Set file = FSO.OpenTextFile(filename, 1, 0, 0)
       
    94 	While Not file.AtEndOfStream
       
    95 		line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
       
    96 		If Len(line) > 0 And regexp.Test(line) And line <> "../objs/langs/table/strings.h" Then
       
    97 			source_list_headers.Add line, line
       
    98 		End If
       
    99 	Wend
       
   100 	file.Close()
       
   101 
       
   102 	' Get header files in /src/
       
   103 	Set src_dir_headers = CreateObject("Scripting.Dictionary")
       
   104 	get_dir_files dir, FSO.GetFolder(dir), src_dir_headers
       
   105 
       
   106 	' Finding files in source.list but not in /src/
       
   107 	For Each line In source_list_headers
       
   108 		If Not src_dir_headers.Exists(line) Then
       
   109 			str = str & "< " & line & vbCrLf
       
   110 		End If
       
   111 	Next
       
   112 
       
   113 	' Finding files in /src/ but not in source.list
       
   114 	For Each line In src_dir_headers
       
   115 		If Not source_list_headers.Exists(line) Then
       
   116 			str = str & "> " & line & vbCrLf
       
   117 		End If
       
   118 	Next
       
   119 
       
   120 	' Display the missing files if any
       
   121 	If str <> "" Then
       
   122 		str = "The following headers are missing in source.list and not in /src/ or vice versa." _
       
   123 		& vbCrLf & str
       
   124 		WScript.Echo str
       
   125 	End If
    47 End Sub
   126 End Sub
    48 
   127 
    49 Function load_main_data(filename)
   128 Function load_main_data(filename)
    50 	Dim res, file, line, deep, skip, first_time
   129 	Dim res, file, line, deep, skip, first_time
    51 	res = ""
   130 	res = ""
   169 	& vbCrLf & "Please go to either the project dir, or the root dir of a clean SVN checkout."
   248 	& vbCrLf & "Please go to either the project dir, or the root dir of a clean SVN checkout."
   170 	WScript.Quit(1)
   249 	WScript.Quit(1)
   171 End If
   250 End If
   172 
   251 
   173 safety_check ROOT_DIR & "/source.list"
   252 safety_check ROOT_DIR & "/source.list"
       
   253 headers_check ROOT_DIR & "/source.list", ROOT_DIR & "\src\" ' Backslashes needed for DoFiles
   174 
   254 
   175 Dim openttd
   255 Dim openttd
   176 openttd = load_main_data(ROOT_DIR &"/source.list")
   256 openttd = load_main_data(ROOT_DIR &"/source.list")
   177 generate openttd, ROOT_DIR & "/projects/openttd_vs80.vcproj"
   257 generate openttd, ROOT_DIR & "/projects/openttd_vs80.vcproj"
   178 generate openttd, ROOT_DIR & "/projects/openttd_vs90.vcproj"
   258 generate openttd, ROOT_DIR & "/projects/openttd_vs90.vcproj"