2007-01-02 19:19:48 +00:00
|
|
|
#!/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
|
|
|
|
|
2007-11-17 02:22:56 +00:00
|
|
|
# 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
|
|
|
|
|
2007-01-02 19:19:48 +00:00
|
|
|
# openttd_vs80.sln is for MSVC 2005
|
|
|
|
# openttd_vs80.vcproj is for MSVC 2005
|
|
|
|
# langs_vs80.vcproj is for MSVC 2005
|
2007-11-16 22:11:30 +00:00
|
|
|
# strgen_vs80.vcproj is for MSVC 2005
|
2007-01-02 19:19:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# First, collect the list of Windows files
|
|
|
|
sdl_config="1"
|
2007-06-13 18:52:06 +00:00
|
|
|
png_config="1"
|
2007-01-02 19:19:48 +00:00
|
|
|
os="MSVC"
|
|
|
|
enable_dedicated="0"
|
|
|
|
with_cocoa="0"
|
|
|
|
enable_directmusic="1"
|
2007-07-20 18:34:21 +00:00
|
|
|
with_threads="1"
|
2007-01-02 19:19:48 +00:00
|
|
|
file_prefix="..\\\\src\\\\"
|
|
|
|
|
2007-06-17 20:14:38 +00:00
|
|
|
safety_check() {
|
|
|
|
li=""
|
2007-06-17 20:30:28 +00:00
|
|
|
for i in `cat $1 | grep -v "#\|ottdres.rc\|win32.cpp\|win32_v.cpp" | xargs -n 1 basename | sort`; do
|
2007-06-17 20:14:38 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2008-04-18 09:49:23 +00:00
|
|
|
grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h' | sort > tmp.headers.source.list
|
|
|
|
find "$ROOT_DIR/src" -iname "*.h*" -and -not -iname "*svn*" -and -not -iname "*.hpp.sq" | 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.*
|
|
|
|
|
2007-01-02 19:19:48 +00:00
|
|
|
load_main_data() {
|
|
|
|
# Read the source.list and process it
|
2007-01-03 22:24:36 +00:00
|
|
|
RES="`cat $1 | tr '\r' '\n' | awk '
|
2007-01-02 19:19:48 +00:00
|
|
|
/^( *)#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; }
|
2007-06-13 18:52:06 +00:00
|
|
|
if ($0 == "PNG" && "'$png_config'" == "") { next; }
|
2007-01-02 19:19:48 +00:00
|
|
|
if ($0 == "OSX" && "'$os'" != "OSX") { next; }
|
2007-02-17 12:50:19 +00:00
|
|
|
if ($0 == "OS2" && "'$os'" != "OS2") { next; }
|
|
|
|
if ($0 == "PSP" && "'$os'" != "PSP") { next; }
|
2007-01-02 19:19:48 +00:00
|
|
|
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; }
|
2007-01-21 19:40:38 +00:00
|
|
|
if ($0 == "WINCE" && "'$os'" != "WINCE") { next; }
|
2007-01-02 19:19:48 +00:00
|
|
|
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
|
|
|
|
if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }
|
2007-02-17 12:50:19 +00:00
|
|
|
if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
|
2008-04-14 19:54:33 +00:00
|
|
|
if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
|
2007-01-02 19:19:48 +00:00
|
|
|
|
|
|
|
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"\\"";
|
2008-01-24 18:47:05 +00:00
|
|
|
print " >";
|
2007-01-02 19:19:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
/^$/ { next }
|
|
|
|
{
|
|
|
|
if (deep == skip) {
|
|
|
|
gsub(" ", "", $0);
|
|
|
|
gsub("/", "\\\\", $0);
|
|
|
|
print " <File";
|
2008-01-24 18:47:05 +00:00
|
|
|
print " RelativePath=\\".\\\\'$file_prefix'"$0"\\"";
|
|
|
|
print " >";
|
2007-01-02 19:19:48 +00:00
|
|
|
print " </File>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END { print " </Filter>"; }
|
2007-01-03 22:24:36 +00:00
|
|
|
'`"
|
2007-01-02 19:19:48 +00:00
|
|
|
|
|
|
|
eval "$2=\"\$RES\""
|
|
|
|
}
|
|
|
|
|
|
|
|
load_lang_data() {
|
|
|
|
RES=""
|
|
|
|
for i in `ls $1`
|
|
|
|
do
|
|
|
|
i=`basename $i | sed s/.txt$//g`
|
|
|
|
RES="$RES
|
|
|
|
<File
|
2008-01-24 18:47:05 +00:00
|
|
|
RelativePath=\"..\\src\\lang\\"$i".txt\"
|
|
|
|
>
|
2007-01-02 19:19:48 +00:00
|
|
|
<FileConfiguration
|
2008-01-24 18:47:05 +00:00
|
|
|
Name=\"Debug|Win32\"
|
|
|
|
>
|
2007-01-02 19:19:48 +00:00
|
|
|
<Tool
|
|
|
|
Name=\"VCCustomBuildTool\"
|
|
|
|
Description=\"Generating "$i" language file\"
|
|
|
|
CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang "\$(InputPath)"
\"
|
|
|
|
AdditionalDependencies=\"\"
|
2008-01-24 18:47:05 +00:00
|
|
|
Outputs=\"..\\bin\\lang\\"$i".lng\"
|
|
|
|
/>
|
2007-01-02 19:19:48 +00:00
|
|
|
</FileConfiguration>
|
|
|
|
</File>"
|
|
|
|
done
|
|
|
|
|
|
|
|
eval "$2=\"\$RES\""
|
|
|
|
}
|
|
|
|
|
|
|
|
generate() {
|
|
|
|
echo "Generating $2..."
|
|
|
|
# Everything above the !!FILES!! marker
|
2007-02-28 23:52:04 +00:00
|
|
|
cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
|
2007-01-03 22:24:36 +00:00
|
|
|
/^$/ { next }
|
2007-01-02 19:19:48 +00:00
|
|
|
/!!FILES!!/ { stop = 1; }
|
|
|
|
{
|
|
|
|
if (stop == 0) { print $0 }
|
|
|
|
}
|
2007-02-28 23:52:04 +00:00
|
|
|
' > "$ROOT_DIR/projects/$2"
|
2007-01-02 19:19:48 +00:00
|
|
|
|
2008-01-24 18:47:05 +00:00
|
|
|
echo "$1" >> "$ROOT_DIR/projects/$2"
|
2007-01-02 19:19:48 +00:00
|
|
|
|
|
|
|
# Everything below the !!FILES!! marker
|
2007-02-28 23:52:04 +00:00
|
|
|
cat "$ROOT_DIR/projects/$2".in | tr '\r' '\n' | awk '
|
2007-01-02 19:19:48 +00:00
|
|
|
BEGIN { stop = 1; }
|
2007-01-03 22:24:36 +00:00
|
|
|
/^$/ { next }
|
2007-01-02 19:19:48 +00:00
|
|
|
/!!FILES!!/ { stop = 2; }
|
|
|
|
{
|
|
|
|
if (stop == 0) { print $0 }
|
|
|
|
if (stop == 2) { stop = 0 }
|
|
|
|
}
|
2007-02-28 23:52:04 +00:00
|
|
|
' >> "$ROOT_DIR/projects/$2"
|
2007-01-02 19:19:48 +00:00
|
|
|
}
|
|
|
|
|
2007-06-17 20:14:38 +00:00
|
|
|
safety_check "$ROOT_DIR/source.list"
|
|
|
|
|
2007-01-02 19:19:48 +00:00
|
|
|
load_main_data "$ROOT_DIR/source.list" openttd
|
|
|
|
load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
|
|
|
|
|
2008-01-24 18:47:05 +00:00
|
|
|
generate "$openttd" "openttd_vs80.vcproj"
|
|
|
|
generate "$openttd" "openttd_vs90.vcproj"
|
|
|
|
generate "$lang" "langs_vs80.vcproj"
|
|
|
|
generate "$lang" "langs_vs90.vcproj"
|