summaryrefslogtreecommitdiff
path: root/projects/generate
blob: fc87904b5a56bb50e06b7c8b7f608f833f49473f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash

# 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_vs80.sln    is for MSVC 2005
# openttd_vs80.vcproj is for MSVC 2005
# langs_vs80.vcproj   is for MSVC 2005
# strgen_vs80.vcprojc is vor MSVC 2005

# openttd.sln         is for MSVC 2003
# openttd.vcproj      is for MSVC 2003
# langs.vcproj        is for MSVC 2003
# strgen.vcproj       is for MSVC 2003

# openttd.tgt         is for WatCom



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

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; }
		/^(	*)#if/   {
			gsub("	", "", $0);
			gsub("^#if", "", $0);
			gsub("^ ", "", $0);

			if (deep != skip) { deep += 1; next; }

			deep += 1;

			if ($0 == "SDL"         && "'$sdl_config'" == "")          { next; }
			if ($0 == "OSX"         && "'$os'" != "OSX")               { next; }
			if ($0 == "DEDICATED"   && "'$enable_dedicated'" != "1")   { next; }
			if ($0 == "COCOA"       && "'$with_cocoa'" == "0")         { next; }
			if ($0 == "BEOS"        && "'$os'" != "BEOS")              { next; }
			if ($0 == "WIN32"       && "'$os'" != "MINGW" &&
											"'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
			if ($0 == "WINCE"       && "'$os'" != "WINCE")             { next; }
			if ($0 == "MSVC"        && "'$os'" != "MSVC")              { next; }
			if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }

			skip += 1;

			next;
		}
		/^(	*)#/ {
			if (deep == skip) {
				gsub("	", "", $0);
				gsub("^#", "", $0);
				gsub("^ ", "", $0);

				if (first_time != 0) {
					print "		</Filter>";
				} else {
					first_time = 1;
				}

				print "		<Filter";
				print "			Name=\\""$0"\\"";
				print "			Filter=\\"\\">";
			}

			next;
		}
		/^$/ { next }
		{
			if (deep == skip) {
				gsub("	", "", $0);
				gsub("/", "\\\\", $0);
				print "			<File";
				print "				RelativePath=\\".\\\\'$file_prefix'"$0"\\">";
				print "			</File>";
			}
		}
		END { print "		</Filter>"; }
	'`"

	eval "$2=\"\$RES\""
}

load_lang_data() {
	RES=""
	for i in `ls $1`
	do
		i=`basename $i | sed s/.txt$//g`
		RES="$RES
		<File
			RelativePath=\"..\\src\\lang\\"$i".txt\"
			>
			<FileConfiguration
				Name=\"Debug|Win32\">
				<Tool
					Name=\"VCCustomBuildTool\"
					Description=\"Generating "$i" language file\"
					CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang &quot;\$(InputPath)&quot;&#x0D;&#x0A;\"
					AdditionalDependencies=\"\"
					Outputs=\"..\\bin\\lang\\"$i".lng\"
				/>
			</FileConfiguration>
		</File>"
	done

	eval "$2=\"\$RES\""
}

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

	# The files-list
	echo "$1" >> "$ROOT_DIR/projects/$2"

	# Everything below the !!FILES!! marker
	RES="`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\"`"
}

load_main_data "$ROOT_DIR/source.list" openttd
load_lang_data "$ROOT_DIR/src/lang/*.txt" lang

generate "$openttd" "openttd.vcproj"
generate "$openttd" "openttd_vs80.vcproj"
generate "$lang" "langs_vs80.vcproj"
generate "$lang" "langs.vcproj"