Files
@ r21369:b317f0570ed2
Branch filter:
Location: cpp/openttd-patchpack/source/projects/generate
r21369:b317f0570ed2
10.7 KiB
text/plain
(svn r26468) -Update from WebTranslator v3.0:
catalan - 3 changes by arnau
czech - 4 changes by djst
english_AU - 2 changes by mrtux
catalan - 3 changes by arnau
czech - 4 changes by djst
english_AU - 2 changes by mrtux
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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | #!/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_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"
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/ //' | 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; }
/^( *)#if/ {
gsub(" ", "", $0);
gsub("^#if", "", $0);
gsub("^ ", "", $0);
if (deep != skip) { deep += 1; next; }
deep += 1;
if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next; }
if ($0 == "SDL" && "'$sdl_config'" == "") { next; }
if ($0 == "PNG" && "'$png_config'" == "") { next; }
if ($0 == "OSX" && "'$os'" != "OSX") { next; }
if ($0 == "OS2" && "'$os'" != "OS2") { next; }
if ($0 == "PSP" && "'$os'" != "PSP") { next; }
if ($0 == "DOS" && "'$os'" != "DOS") { next; }
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
if ($0 == "AI" && "'$enable_ai'" == "0") { 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; }
if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
skip += 1;
next;
}
/^( *)#/ {
if (deep == skip) {
gsub(" ", "", $0);
gsub("^#", "", $0);
gsub("^ ", "", $0);
if (first_time != 0) {
print "#1 </Filter>";
} else {
first_time = 1;
}
filter = $0;
print "#1 <Filter";
print "#1 Name=\\""filter"\\"";
print "#1 >";
print "#3 <Filter Include=\\""filter"\\">";
printf "#3 <UniqueIdentifier>{c76ff9f1-1e62-46d8-8d55-%012d}</UniqueIdentifier>\n", i;
print "#3 </Filter>";
i += 1;
}
next;
}
/^$/ { next }
{
if (deep == skip) {
gsub(" ", "", $0);
gsub("/", "\\\\", $0);
print "#1 <File";
print "#1 RelativePath=\\".\\\\'$file_prefix'"$0"\\"";
print "#1 >";
print "#1 </File>";
split($0, file, ".");
cltype = "ClInclude"
if (file[2] == "cpp") cltype = "ClCompile";
if (file[2] == "rc") cltype = "ResourceCompile";
print "#2 <"cltype" Include=\\"'$file_prefix'"$0"\\" />";
print "#4 <"cltype" Include=\\"'$file_prefix'"$0"\\">";
print "#4 <Filter>"filter"</Filter>";
print "#4 </"cltype">";
}
}
END { print "#1 </Filter>"; }
'`"
eval "$2=\"\$RES\""
}
load_lang_data() {
RES=""
for i in `ls $1`
do
i=`basename $i | sed s~.txt$~~g`
if [ "$i" == "english" ]
then
continue
fi
RES="$RES
#1 <File
#1 RelativePath=\"..\\src\\lang\\"$i".txt\"
#1 >
#1 <FileConfiguration
#1 Name=\"Debug|Win32\"
#1 >
#1 <Tool
#1 Name=\"VCCustomBuildTool\"
#1 Description=\"Generating "$i" language file\"
#1 CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
exit 0
\"
#1 AdditionalDependencies=\"..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe\"
#1 Outputs=\"..\\bin\\lang\\"$i".lng\"
#1 />
#1 </FileConfiguration>
#1 </File>
#2 <CustomBuild Include=\"..\\src\\lang\\"$i".txt\">
#2 <Message Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">Generating "$i" language file</Message>
#2 <Command Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang \"%(FullPath)\"</Command>
#2 <AdditionalInputs Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\src\\lang\\english.txt;..\\objs\\strgen\\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
#2 <Outputs Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|Win32'\">..\\bin\\lang\\"$i".lng;%(Outputs)</Outputs>
#2 </CustomBuild>
#3 <CustomBuild Include=\"..\\src\\lang\\"$i".txt\">
#3 <Filter>Translations</Filter>
#3 </CustomBuild>"
done
eval "$2=\"\$RES\""
}
load_settings_data() {
RES=""
RES2="
#3..\\objs\\settings\\settings_gen.exe -o ..\\objs\\settings\\table\\settings.h -b ..\\src\\table\\settings.h.preamble -a ..\\src\\table\\settings.h.postamble"
for i in `ls $1`
do
i=`basename $i`
RES="$RES
#1 <File
#1 RelativePath=\"..\\src\\table\\"$i"\"
#1 >
#1 </File>
#2 <None Include=\"..\\src\\table\\"$i"\" />
#4 <None Include=\"..\\src\\table\\"$i"\">
#4 <Filter>INI</Filter>
#4 </None>"
RES2="$RES2 ..\\src\\table\\"$i
done
eval "$2=\"\$RES\$RES2\""
}
generate() {
echo "Generating $2..."
if [ $# -eq 3 ]; then
# Everything above the !!FILTERS!! marker
cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
/^$/ { next }
/!!FILTERS!!/ { stop = 1; }
{
if (stop == 0) { print $0 }
}
' > "$ROOT_DIR/projects/$2"
echo "$3" >> "$ROOT_DIR/projects/$2"
# Everything below the !!FILTERS!! marker and above the !!FILES!! marker
cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
BEGIN { stop = 1; }
/^$/ { next }
/!!FILTERS!!/ { stop = 2; }
/!!FILES!!/ { stop = 1; }
{
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 "$lang" "langs_vs80.vcproj"
generate "$lang" "langs_vs90.vcproj"
generate "$langvcxproj" "langs_vs100.vcxproj"
generate "$langfiles" "langs_vs100.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"
|