projects/generate
branchcustombridgeheads
changeset 5643 3778051e8095
child 5648 1608018c5ff2
equal deleted inserted replaced
5642:bfa6074e2833 5643:3778051e8095
       
     1 #!/bin/bash
       
     2 
       
     3 # This file generates all project files based on sources.list, so everyone who
       
     4 #  can start a bash process, can update the project files.
       
     5 
       
     6 ROOT_DIR="`pwd`/.."
       
     7 if ! [ -e "$ROOT_DIR/source.list" ]
       
     8 then
       
     9 	ROOT_DIR="`pwd`"
       
    10 fi
       
    11 if ! [ -e "$ROOT_DIR/source.list" ]
       
    12 then
       
    13 	echo "Can't find source.list, needed in order to make this run. Please go to either"
       
    14 	echo " the project dir, or the root dir of a clean SVN checkout."
       
    15 	exit 1
       
    16 fi
       
    17 
       
    18 # openttd_vs80.sln    is for MSVC 2005
       
    19 # openttd_vs80.vcproj is for MSVC 2005
       
    20 # langs_vs80.vcproj   is for MSVC 2005
       
    21 # strgen_vs80.vcprojc is vor MSVC 2005
       
    22 
       
    23 # openttd.sln         is for MSVC 2003
       
    24 # openttd.vcproj      is for MSVC 2003
       
    25 # langs.vcproj        is for MSVC 2003
       
    26 # strgen.vcproj       is for MSVC 2003
       
    27 
       
    28 # openttd.tgt         is for WatCom
       
    29 
       
    30 
       
    31 
       
    32 # First, collect the list of Windows files
       
    33 sdl_config="1"
       
    34 os="MSVC"
       
    35 enable_dedicated="0"
       
    36 with_cocoa="0"
       
    37 enable_directmusic="1"
       
    38 file_prefix="..\\\\src\\\\"
       
    39 
       
    40 load_main_data() {
       
    41 	# Read the source.list and process it
       
    42 	RES="`awk '
       
    43 		/^(	*)#end/  { if (deep == skip) { skip -= 1; } deep -= 1; next; }
       
    44 		/^(	*)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
       
    45 		/^(	*)#if/   {
       
    46 			gsub("	", "", $0);
       
    47 			gsub("^#if", "", $0);
       
    48 			gsub("^ ", "", $0);
       
    49 
       
    50 			if (deep != skip) { deep += 1; next; }
       
    51 
       
    52 			deep += 1;
       
    53 
       
    54 			if ($0 == "SDL"         && "'$sdl_config'" == "")          { next; }
       
    55 			if ($0 == "OSX"         && "'$os'" != "OSX")               { next; }
       
    56 			if ($0 == "DEDICATED"   && "'$enable_dedicated'" != "1")   { next; }
       
    57 			if ($0 == "COCOA"       && "'$with_cocoa'" == "0")         { next; }
       
    58 			if ($0 == "BEOS"        && "'$os'" != "BEOS")              { next; }
       
    59 			if ($0 == "WIN32"       && "'$os'" != "MINGW" &&
       
    60 											"'$os'" != "CYGWIN" && "'$os'" != "MSVC" ) { next; }
       
    61 			if ($0 == "MSVC"        && "'$os'" != "MSVC")              { next; }
       
    62 			if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }
       
    63 
       
    64 			skip += 1;
       
    65 
       
    66 			next;
       
    67 		}
       
    68 		/^(	*)#/ {
       
    69 			if (deep == skip) {
       
    70 				gsub("	", "", $0);
       
    71 				gsub("^#", "", $0);
       
    72 				gsub("^ ", "", $0);
       
    73 
       
    74 				if (first_time != 0) {
       
    75 					print "		</Filter>";
       
    76 				} else {
       
    77 					first_time = 1;
       
    78 				}
       
    79 
       
    80 				print "		<Filter";
       
    81 				print "			Name=\\""$0"\\"";
       
    82 				print "			Filter=\\"\\">";
       
    83 			}
       
    84 
       
    85 			next;
       
    86 		}
       
    87 		/^$/ { next }
       
    88 		{
       
    89 			if (deep == skip) {
       
    90 				gsub("	", "", $0);
       
    91 				gsub("/", "\\\\", $0);
       
    92 				print "			<File";
       
    93 				print "				RelativePath=\\".\\\\'$file_prefix'"$0"\\">";
       
    94 				print "			</File>";
       
    95 			}
       
    96 		}
       
    97 		END { print "		</Filter>"; }
       
    98 	' < $1`"
       
    99 
       
   100 	eval "$2=\"\$RES\""
       
   101 }
       
   102 
       
   103 load_lang_data() {
       
   104 	RES=""
       
   105 	for i in `ls $1`
       
   106 	do
       
   107 		i=`basename $i | sed s/.txt$//g`
       
   108 		RES="$RES
       
   109 		<File
       
   110 			RelativePath=\"..\\src\\lang\\"$i".txt\"
       
   111 			>
       
   112 			<FileConfiguration
       
   113 				Name=\"Debug|Win32\">
       
   114 				<Tool
       
   115 					Name=\"VCCustomBuildTool\"
       
   116 					Description=\"Generating "$i" language file\"
       
   117 					CommandLine=\"..\\objs\\strgen\\strgen.exe -s ..\\src\\lang -d ..\\bin\\lang &quot;\$(InputPath)&quot;&#x0D;&#x0A;\"
       
   118 					AdditionalDependencies=\"\"
       
   119 					Outputs=\"..\\bin\\lang\\"$i".lng\"
       
   120 				/>
       
   121 			</FileConfiguration>
       
   122 		</File>"
       
   123 	done
       
   124 
       
   125 	eval "$2=\"\$RES\""
       
   126 }
       
   127 
       
   128 generate() {
       
   129 	echo "Generating $2..."
       
   130 	# Everything above the !!FILES!! marker
       
   131 	RES="`awk '
       
   132 		/!!FILES!!/ { stop = 1; }
       
   133 		{
       
   134 			if (stop == 0) { print $0 }
       
   135 		}
       
   136 	' < \"$ROOT_DIR/projects/$2\".in > \"$ROOT_DIR/projects/$2\"`"
       
   137 
       
   138 	# The files-list
       
   139 	echo "$1" >> "$ROOT_DIR/projects/$2"
       
   140 
       
   141 	# Everything below the !!FILES!! marker
       
   142 	RES="`awk '
       
   143 		BEGIN { stop = 1; }
       
   144 		/!!FILES!!/ { stop = 2; }
       
   145 		{
       
   146 			if (stop == 0) { print $0 }
       
   147 			if (stop == 2) { stop = 0 }
       
   148 		}
       
   149 	' < \"$ROOT_DIR/projects/$2.in\" >> \"$ROOT_DIR/projects/$2\"`"
       
   150 }
       
   151 
       
   152 load_main_data "$ROOT_DIR/source.list" openttd
       
   153 load_lang_data "$ROOT_DIR/src/lang/*.txt" lang
       
   154 
       
   155 generate "$openttd" "openttd.vcproj"
       
   156 generate "$openttd" "openttd_vs80.vcproj"
       
   157 generate "$lang" "langs_vs80.vcproj"
       
   158 generate "$lang" "langs.vcproj"