Changeset - r23053:dd141824d835
[Not reviewed]
projects/generate
Show inline comments
 
#!/bin/bash
 

	
 
# $Id$
 

	
 
# This file is part of OpenTTD.
 
# 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.
 
# 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.
 
# 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/>.
 

	
 
# This file generates all project files based on sources.list, so everyone who
 
#  can start a bash process, can update the project files.
 

	
 
ROOT_DIR="`pwd`/.."
 
if ! [ -e "$ROOT_DIR/source.list" ]
 
then
 
	ROOT_DIR="`pwd`"
 
fi
 
if ! [ -e "$ROOT_DIR/source.list" ]
 
then
 
	echo "Can't find source.list, needed in order to make this run. Please go to either"
 
	echo " the project dir, or the root dir of a clean SVN checkout."
 
	exit 1
 
fi
 

	
 
# openttd_vs141.sln             is for MSVC 2017
 
# openttd_vs141.vcxproj         is for MSVC 2017
 
# openttd_vs141.vcxproj.filters is for MSVC 2017
 
# langs_vs141.vcxproj           is for MSVC 2017
 
# strgen_vs141.vcxproj          is for MSVC 2017
 
# strgen_vs141.vcxproj.filters  is for MSVC 2017
 
# generate_vs141.vcxproj        is for MSVC 2017
 
# version_vs141.vcxproj         is for MSVC 2017
 

	
 
# openttd_vs140.sln             is for MSVC 2015
 
# openttd_vs140.vcxproj         is for MSVC 2015
 
# openttd_vs140.vcxproj.filters is for MSVC 2015
 
# langs_vs140.vcxproj           is for MSVC 2015
 
# strgen_vs140.vcxproj          is for MSVC 2015
 
# strgen_vs140.vcxproj.filters  is for MSVC 2015
 
# generate_vs140.vcxproj        is for MSVC 2015
 
# version_vs140.vcxproj         is for MSVC 2015
 

	
 
# openttd_vs100.sln             is for MSVC 2010
 
# openttd_vs100.vcxproj         is for MSVC 2010
 
# openttd_vs100.vcxproj.filters is for MSVC 2010
 
# langs_vs100.vcxproj           is for MSVC 2010
 
# strgen_vs100.vcxproj          is for MSVC 2010
 
# strgen_vs100.vcxproj.filters  is for MSVC 2010
 
# generate_vs100.vcxproj        is for MSVC 2010
 
# version_vs100.vcxproj         is for MSVC 2010
 

	
 
# openttd_vs90.sln              is for MSVC 2008
 
# openttd_vs90.vcproj           is for MSVC 2008
 
# langs_vs90.vcproj             is for MSVC 2008
 
# strgen_vs90.vcproj            is for MSVC 2008
 
# generate_vs90.vcproj          is for MSVC 2008
 
# version_vs90.vcproj           is for MSVC 2008
 

	
 
# openttd_vs80.sln              is for MSVC 2005
 
# openttd_vs80.vcproj           is for MSVC 2005
 
# langs_vs80.vcproj             is for MSVC 2005
 
# strgen_vs80.vcproj            is for MSVC 2005
 
# generate_vs80.vcproj          is for MSVC 2005
 
# version_vs80.vcproj           is for MSVC 2005
 

	
 

	
 

	
 
# First, collect the list of Windows files
 
allegro_config=""
 
sdl_config="1"
 
png_config="1"
 
os="MSVC"
 
enable_dedicated="0"
 
enable_ai="1"
 
with_cocoa="0"
 
enable_directmusic="1"
 
enable_fluidsynth="0"
 
with_threads="1"
 
file_prefix="..\\\\src\\\\"
 

	
 
safety_check() {
 
	li=""
 
	for i in `cat $1 | grep -v "#\|ottdres.rc\|win32.cpp\|win32_v.cpp" | xargs -n 1 basename | sort`; do
 
		if [ "$li" = "$i" ]; then
 
			echo " !! ERROR !!"
 
			echo ""
 
			echo "The filename '$i' is already used in this project."
 
			echo "Because MSVC uses one single directory for all object files, it"
 
			echo "cannot handle filenames with the same name inside the same project."
 
			echo "Please rename either one of the file and try generating again."
 
			echo ""
 
			echo " !! ERROR !!"
 
			exit 1
 
		fi
 
		li="$i"
 
	done
 
}
 

	
 
grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h\|../objs/settings/table/settings.h' | sed 's/	//g' | sort > tmp.headers.source.list
 
find "$ROOT_DIR/src" \( -iname "*.h" -or -iname "*.hpp" \) -and -not -ipath "*/.svn/*" | sed "s~$ROOT_DIR/src/~~" | sort > tmp.headers.src
 
if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then
 
	echo "The following headers are missing in source.list and not in /src/ or vice versa."
 
	diff tmp.headers.source.list tmp.headers.src | grep '[<>]' | sort
 
	echo ""
 
fi
 
rm tmp.headers.*
 

	
 
load_main_data() {
 
	# Read the source.list and process it
 
	RES="`cat $1 | tr '\r' '\n' | awk '
 
		/^(	*)#end/  { if (deep == skip) { skip -= 1; } deep -= 1; next; }
 
		/^(	*)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
 
@@ -277,72 +255,60 @@ generate() {
 
				if (stop == 0) { print $0 }
 
				if (stop == 2) { stop = 0 }
 
			}
 
		' >> "$ROOT_DIR/projects/$2"
 
	else
 
		# Everything above the !!FILES!! marker
 
		cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
 
			/^$/ { next }
 
			/!!FILES!!/ { stop = 1; }
 
			{
 
				if (stop == 0) { print $0 }
 
			}
 
		' > "$ROOT_DIR/projects/$2"
 
	fi
 

	
 
	echo "$1" >> "$ROOT_DIR/projects/$2"
 

	
 
	# Everything below the !!FILES!! marker
 
	cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
 
		BEGIN { stop = 1; }
 
		/^$/ { next }
 
		/!!FILES!!/ { stop = 2; }
 
		{
 
			if (stop == 0) { print $0 }
 
			if (stop == 2) { stop = 0 }
 
		}
 
	' >> "$ROOT_DIR/projects/$2"
 
}
 

	
 
safety_check "$ROOT_DIR/source.list"
 

	
 
load_main_data "$ROOT_DIR/source.list" openttd
 
openttdfiles=`echo "$openttd" | grep "^#4" | sed "s~#4~~g"`
 
openttdfilters=`echo "$openttd" | grep "^#3" | sed "s~#3~~g"`
 
openttdvcxproj=`echo "$openttd" | grep "^#2" | sed "s~#2~~g"`
 
openttd=`echo "$openttd" | grep "^#1" | sed "s~#1~~g"`
 

	
 
load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
 
langfiles=`echo "$lang" | grep "^#3" | sed "s~#3~~g"`
 
langvcxproj=`echo "$lang" | grep "^#2" | sed "s~#2~~g"`
 
lang=`echo "$lang" | grep "^#1" | sed "s~#1~~g"`
 

	
 
load_settings_data "$ROOT_DIR/src/table/*.ini" settings
 
settingsfiles=`echo "$settings" | grep "^#4" | sed "s~#4~~g"`
 
settingscommand=`echo "$settings" | grep "^#3" | sed "s~#3~~g"`
 
settingsvcxproj=`echo "$settings" | grep "^#2" | sed "s~#2~~g"`
 
settings=`echo "$settings" | grep "^#1" | sed "s~#1~~g"`
 

	
 
generate "$openttd" "openttd_vs80.vcproj"
 
generate "$openttd" "openttd_vs90.vcproj"
 
generate "$openttdvcxproj" "openttd_vs100.vcxproj"
 
generate "$openttdfiles" "openttd_vs100.vcxproj.filters" "$openttdfilters"
 
generate "$openttdvcxproj" "openttd_vs140.vcxproj"
 
generate "$openttdfiles" "openttd_vs140.vcxproj.filters" "$openttdfilters"
 
generate "$openttdvcxproj" "openttd_vs141.vcxproj"
 
generate "$openttdfiles" "openttd_vs141.vcxproj.filters" "$openttdfilters"
 
generate "$lang" "langs_vs80.vcproj"
 
generate "$lang" "langs_vs90.vcproj"
 
generate "$langvcxproj" "langs_vs100.vcxproj"
 
generate "$langfiles" "langs_vs100.vcxproj.filters"
 
generate "$langvcxproj" "langs_vs140.vcxproj"
 
generate "$langfiles" "langs_vs140.vcxproj.filters"
 
generate "$langvcxproj" "langs_vs141.vcxproj"
 
generate "$langfiles" "langs_vs141.vcxproj.filters"
 
generate "$settings" "settings_vs80.vcproj" "$settingscommand"
 
generate "$settings" "settings_vs90.vcproj" "$settingscommand"
 
generate "$settingsvcxproj" "settings_vs100.vcxproj" "$settingscommand"
 
generate "$settingsfiles" "settings_vs100.vcxproj.filters"
 
generate "$settingsvcxproj" "settings_vs140.vcxproj" "$settingscommand"
 
generate "$settingsfiles" "settings_vs140.vcxproj.filters"
 
generate "$settingsvcxproj" "settings_vs141.vcxproj" "$settingscommand"
 
generate "$settingsfiles" "settings_vs141.vcxproj.filters"
projects/generate.vbs
Show inline comments
 
Option Explicit
 

	
 
' $Id$
 
'
 
' This file is part of OpenTTD.
 
' 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.
 
' 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.
 
' 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/>.
 

	
 
Dim FSO
 
Set FSO = CreateObject("Scripting.FileSystemObject")
 

	
 
' openttd_vs141.sln             is for MSVC 2017
 
' openttd_vs141.vcxproj         is for MSVC 2017
 
' openttd_vs141.vcxproj.filters is for MSVC 2017
 
' langs_vs141.vcxproj           is for MSVC 2017
 
' strgen_vs141.vcxproj          is for MSVC 2017
 
' strgen_vs141.vcxproj.filters  is for MSVC 2017
 
' generate_vs141.vcxproj        is for MSVC 2017
 
' version_vs141.vcxproj         is for MSVC 2017
 

	
 
' openttd_vs140.sln             is for MSVC 2015
 
' openttd_vs140.vcxproj         is for MSVC 2015
 
' openttd_vs140.vcxproj.filters is for MSVC 2015
 
' langs_vs140.vcxproj           is for MSVC 2015
 
' strgen_vs140.vcxproj          is for MSVC 2015
 
' strgen_vs140.vcxproj.filters  is for MSVC 2015
 
' generate_vs140.vcxproj        is for MSVC 2015
 
' version_vs140.vcxproj         is for MSVC 2015
 

	
 
' openttd_vs100.sln             is for MSVC 2010
 
' openttd_vs100.vcxproj         is for MSVC 2010
 
' openttd_vs100.vcxproj.filters is for MSVC 2010
 
' langs_vs100.vcxproj           is for MSVC 2010
 
' strgen_vs100.vcxproj          is for MSVC 2010
 
' strgen_vs100.vcxproj.filters  is for MSVC 2010
 
' generate_vs100.vcxproj        is for MSVC 2010
 
' version_vs100.vcxproj         is for MSVC 2010
 

	
 
' openttd_vs90.sln              is for MSVC 2008
 
' openttd_vs90.vcproj           is for MSVC 2008
 
' langs_vs90.vcproj             is for MSVC 2008
 
' strgen_vs90.vcproj            is for MSVC 2008
 
' generate_vs90.vcproj          is for MSVC 2008
 
' version_vs90.vcproj           is for MSVC 2008
 

	
 
' openttd_vs80.sln              is for MSVC 2005
 
' openttd_vs80.vcproj           is for MSVC 2005
 
' langs_vs80.vcproj             is for MSVC 2005
 
' strgen_vs80.vcproj            is for MSVC 2005
 
' generate_vs80.vcproj          is for MSVC 2005
 
' version_vs80.vcproj           is for MSVC 2005
 

	
 
Sub safety_check(filename)
 
	Dim file, line, regexp, list
 

	
 
	' Define regexp
 
	Set regexp = New RegExp
 
	regexp.Pattern = "#|ottdres.rc|win32.cpp|win32_v.cpp"
 
	regexp.Global = True
 

	
 
	' We use a dictionary to check duplicates
 
	Set list = CreateObject("Scripting.Dictionary")
 

	
 
	Set file = FSO.OpenTextFile(filename, 1, 0, 0)
 
	While Not file.AtEndOfStream
 
		line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
 
		If Len(line) > 0 And Not regexp.Test(line) Then
 
			line = FSO.GetFileName(line)
 
			if list.Exists(line) Then
 
				WScript.Echo " !! ERROR !!" _
 
				& vbCrLf & "" _
 
				& vbCrLf & "The filename '" & line & "' is already used in this project." _
 
				& vbCrLf & "Because MSVC uses one single directory for all object files, it" _
 
				& vbCrLf & "cannot handle filenames with the same name inside the same project." _
 
				& vbCrLf & "Please rename either one of the file and try generating again." _
 
				& vbCrLf & "" _
 
				& vbCrLf & " !! ERROR !!"
 
				WScript.Quit(1)
 
			End If
 
			list.Add line, line
 
		End If
 
	Wend
 
	file.Close
 
End Sub
 

	
 
Sub get_files(srcdir, dir, list)
 
	Dim file, filename
 
	Dim rekeep, reskip
 

	
 
	' pattern for files to keep
 
	Set rekeep = New RegExp
 
	rekeep.Pattern = "\.h(pp)?$"
 
	rekeep.Global = True
 

	
 
	' pattern for files to exclude
 
	Set reskip = New RegExp
 
	reskip.Pattern = "\.svn"
 
	reskip.Global = True
 

	
 
	For Each file in dir.Files
 
@@ -338,78 +315,66 @@ Sub generate(data, dest, data2)
 

	
 
	If Not IsNull(data2) Then
 
		' Everything above the !!FILTERS!! marker
 
		line = srcfile.ReadLine()
 
		While line <> "!!FILTERS!!"
 
			If len(line) > 0 Then destfile.WriteLine(line)
 
			line = srcfile.ReadLine()
 
		Wend
 

	
 
		' Our generated content
 
		destfile.WriteLine(data2)
 
	End If
 

	
 
	' Everything above the !!FILES!! marker
 
	line = srcfile.ReadLine()
 
	While line <> "!!FILES!!"
 
		If len(line) > 0 Then destfile.WriteLine(line)
 
		line = srcfile.ReadLine()
 
	Wend
 

	
 
	' Our generated content
 
	destfile.WriteLine(data)
 

	
 
	' Everything below the !!FILES!! marker
 
	While Not srcfile.AtEndOfStream
 
		line = srcfile.ReadLine()
 
		If len(line) > 0 Then destfile.WriteLine(line)
 
	Wend
 
	srcfile.Close()
 
	destfile.Close()
 
End Sub
 

	
 
Dim ROOT_DIR
 
ROOT_DIR = FSO.GetFolder("..").Path
 
If Not FSO.FileExists(ROOT_DIR & "/source.list") Then
 
	ROOT_DIR = FSO.GetFolder(".").Path
 
End If
 
If Not FSO.FileExists(ROOT_DIR & "/source.list") Then
 
	WScript.Echo "Can't find source.list, needed in order to make this run." _
 
	& vbCrLf & "Please go to either the project dir, or the root dir of a clean SVN checkout."
 
	WScript.Quit(1)
 
End If
 

	
 
safety_check ROOT_DIR & "/source.list"
 
headers_check ROOT_DIR & "/source.list", ROOT_DIR & "\src\" ' Backslashes needed for DoFiles
 

	
 
Dim openttd, openttdvcxproj, openttdfilters, openttdfiles
 
openttd = load_main_data(ROOT_DIR & "/source.list", openttdvcxproj, openttdfilters, openttdfiles)
 
generate openttd, ROOT_DIR & "/projects/openttd_vs80.vcproj", Null
 
generate openttd, ROOT_DIR & "/projects/openttd_vs90.vcproj", Null
 
generate openttdvcxproj, ROOT_DIR & "/projects/openttd_vs100.vcxproj", Null
 
generate openttdfiles, ROOT_DIR & "/projects/openttd_vs100.vcxproj.filters", openttdfilters
 
generate openttdvcxproj, ROOT_DIR & "/projects/openttd_vs140.vcxproj", Null
 
generate openttdfiles, ROOT_DIR & "/projects/openttd_vs140.vcxproj.filters", openttdfilters
 
generate openttdvcxproj, ROOT_DIR & "/projects/openttd_vs141.vcxproj", Null
 
generate openttdfiles, ROOT_DIR & "/projects/openttd_vs141.vcxproj.filters", openttdfilters
 

	
 
Dim lang, langvcxproj, langfiles
 
lang = load_lang_data(ROOT_DIR & "/src/lang", langvcxproj, langfiles)
 
generate lang, ROOT_DIR & "/projects/langs_vs80.vcproj", Null
 
generate lang, ROOT_DIR & "/projects/langs_vs90.vcproj", Null
 
generate langvcxproj, ROOT_DIR & "/projects/langs_vs100.vcxproj", Null
 
generate langfiles, ROOT_DIR & "/projects/langs_vs100.vcxproj.filters", Null
 
generate langvcxproj, ROOT_DIR & "/projects/langs_vs140.vcxproj", Null
 
generate langfiles, ROOT_DIR & "/projects/langs_vs140.vcxproj.filters", Null
 
generate langvcxproj, ROOT_DIR & "/projects/langs_vs141.vcxproj", Null
 
generate langfiles, ROOT_DIR & "/projects/langs_vs141.vcxproj.filters", Null
 

	
 
Dim settings, settingsvcxproj, settingscommand, settingsfiles
 
settings = load_settings_data(ROOT_DIR & "/src/table", settingsvcxproj, settingscommand, settingsfiles)
 
generate settings, ROOT_DIR & "/projects/settings_vs80.vcproj", settingscommand
 
generate settings, ROOT_DIR & "/projects/settings_vs90.vcproj", settingscommand
 
generate settingsvcxproj, ROOT_DIR & "/projects/settings_vs100.vcxproj", settingscommand
 
generate settingsfiles, ROOT_DIR & "/projects/settings_vs100.vcxproj.filters", Null
 
generate settingsvcxproj, ROOT_DIR & "/projects/settings_vs140.vcxproj", settingscommand
 
generate settingsfiles, ROOT_DIR & "/projects/settings_vs140.vcxproj.filters", Null
 
generate settingsvcxproj, ROOT_DIR & "/projects/settings_vs141.vcxproj", settingscommand
 
generate settingsfiles, ROOT_DIR & "/projects/settings_vs141.vcxproj.filters", Null
projects/generate_vs100.vcxproj
Show inline comments
 
deleted file
projects/generate_vs80.vcproj
Show inline comments
 
deleted file
projects/generate_vs90.vcproj
Show inline comments
 
deleted file
projects/langs_vs100.vcxproj
Show inline comments
 
deleted file
projects/langs_vs100.vcxproj.filters
Show inline comments
 
deleted file
projects/langs_vs100.vcxproj.filters.in
Show inline comments
 
deleted file
projects/langs_vs100.vcxproj.in
Show inline comments
 
deleted file
projects/langs_vs80.vcproj
Show inline comments
 
deleted file
projects/langs_vs80.vcproj.in
Show inline comments
 
deleted file
projects/langs_vs90.vcproj
Show inline comments
 
deleted file
projects/langs_vs90.vcproj.in
Show inline comments
 
deleted file
projects/openttd_vs100.sln
Show inline comments
 
deleted file
projects/openttd_vs100.vcxproj
Show inline comments
 
deleted file

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)