[Box Backup-commit] COMMIT r980 - box/trunk/infrastructure

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Oct 12 21:50:25 BST 2006


Author: chris
Date: 2006-10-12 21:50:24 +0100 (Thu, 12 Oct 2006)
New Revision: 980

Modified:
   box/trunk/infrastructure/makebuildenv.pl.in
Log:
 * Support multiple implicit dependencies
 * Add lib/win32 as an implicit dependency on Win32
 * Make lib/common depend on lib/win32 on Win32
 * Fix space between test file name platform executable extension,
and between executable name and arguments, in test shell scripts
 * Add support for compiling resource files (.rc) on Win32
 * Fix dependencies to avoid unnecessary rebuilds when not using BSD make
 * Code cleanups
 * Fix typos


Modified: box/trunk/infrastructure/makebuildenv.pl.in
===================================================================
--- box/trunk/infrastructure/makebuildenv.pl.in	2006-10-12 20:47:14 UTC (rev 979)
+++ box/trunk/infrastructure/makebuildenv.pl.in	2006-10-12 20:50:24 UTC (rev 980)
@@ -14,9 +14,8 @@
 
 print "Box build environment setup.\n\n";
 
+my @implicit_deps = ('lib/common');
 
-my $implicit_dep = 'lib/common';
-
 # work out platform variables
 use lib 'infrastructure';
 use BoxPlatform;
@@ -38,12 +37,16 @@
 # flags about the environment
 my %env_flags;
 
-my $windows_include_path = "-I../../lib/win32 ";
-if ($target_os ne "mingw32" && $target_os ne "winnt")
+my $windows_include_path = "";
+if ($target_windows)
 {
-	$windows_include_path = "";
-	$env_flags{'IGNORE_lib/win32'} = 1;
+	$module_dependency{"lib/common"} = ["lib/win32"];
+	push @implicit_deps, "lib/win32";
 }
+else
+{
+	# $env_flags{'IGNORE_lib/win32'} = 1;
+}
 
 # print "Flag: $_\n" for(keys %env_flags);
 
@@ -271,7 +274,7 @@
 			push @md,$_ unless ignore_module($_)
 		}
 	}
-	$module_dependency{$mod} = [$implicit_dep, at md];
+	$module_dependency{$mod} = [@implicit_deps, at md];
 	$module_library_link_opts{$mod} = [@lo];
 	
 	# make directories, but not if we're using an external library and this a library module
@@ -286,8 +289,11 @@
 }
 
 # make dirs for implicit dep
-mkdir "release/$implicit_dep",0755;
-mkdir "debug/$implicit_dep",0755;
+foreach my $dep (@implicit_deps)
+{
+	mkdir "release/$dep",0755;
+	mkdir "debug/$dep",0755;
+}
 
 # write a list of all the modules we've configured to use
 open CONFIGURED_MODS,'>local/modules.h' or die "Can't write configured modules list";
@@ -296,7 +302,7 @@
 #ifndef _CONFIGURED_MODULES__H
 #define _CONFIGURED_MODULES__H
 __E
-for($implicit_dep, at modules)
+for(@implicit_deps, at modules)
 {
 	my $m = $_;
 	$m =~ s~/~_~;
@@ -310,7 +316,7 @@
 
 # now make a list of all the .h files we can find, recording which module they're in
 my %hfiles;
-for my $mod (@modules, $implicit_dep)
+for my $mod (@modules, @implicit_deps)
 {
 	opendir DIR,$mod;
 	my @items = readdir DIR;
@@ -347,7 +353,7 @@
 	}
 }
 
-for my $mod (@modules, $implicit_dep)
+for my $mod (@modules, @implicit_deps)
 {
 	opendir DIR,$mod;
 	for my $h (grep /\.h\Z/i, readdir DIR)
@@ -373,9 +379,10 @@
 
 print "done\n\nGenerating Makefiles...\n";
 
+my %module_resources_win32;
 
 # Then write a makefile for each module
-for my $mod (@modules, $implicit_dep)
+for my $mod (@implicit_deps, @modules)
 {
 	print $mod,"\n";
 	
@@ -416,9 +423,9 @@
 		}
 		
 		writetestfile("$mod/_t", 
-			'./test' . $platform_exe_ext . '$1 $2 $3 $4 $5', $mod);
+			'./test' . $platform_exe_ext . ' $1 $2 $3 $4 $5', $mod);
 		writetestfile("$mod/_t-gdb", 
-			'gdb ./test ' . $platform_exe_ext, $mod);
+			'gdb ./test' . $platform_exe_ext, $mod);
 		
 	}
 	
@@ -441,14 +448,14 @@
 		add_mod_deps(\@deps_raw, $mod);
 		# and then dedup and reorder them
 		my %d_done;
-		for(my $a = $#deps_raw; $a >= 0; $a--)
+		foreach my $dep (reverse @deps_raw)
 		{
-			if(!exists $d_done{$deps_raw[$a]})
+			if(!exists $d_done{$dep})
 			{
 				# insert
-				push @all_deps_for_module, $deps_raw[$a];
+				push @all_deps_for_module, $dep;
 				# mark as done
-				$d_done{$deps_raw[$a]} = 1;
+				$d_done{$dep} = 1;
 			}
 		}
 	}	
@@ -484,7 +491,7 @@
 	my $debug_link_extra = ($target_is_library)?'':'../../debug/lib/debug/debug.a';
 
 	my $release_flags = "-O2";
-	if ($target_os eq "mingw32")
+	if ($target_windows)
 	{
 		$release_flags = "-O0 -g";
 	}
@@ -499,6 +506,7 @@
 AR = ar
 RANLIB = ranlib
 PERL = "@PERL@"
+WINDRES = windres
 .ifdef RELEASE
 CXXFLAGS = -DNDEBUG $release_flags -Wall $include_paths $extra_platform_defines -DBOX_VERSION="\\"$product_version\\""
 OUTBASE = ../../release
@@ -546,7 +554,7 @@
 		@items = (@items, @autogen_items);
 	}
 	
-	# first, obtain a list of depenencies within the .h files
+	# first, obtain a list of dependencies within the .h files
 	my %headers;
 	for my $h (grep /\.h\Z/i, @items)
 	{
@@ -566,19 +574,30 @@
 	
 	# then... do the cpp files...
 	my @obj_base;
-	for my $cpp (@items)
+	for my $file (@items)
 	{
-		next unless $cpp =~ m/\A(.+)\.cpp\Z/i;
-		next if $cpp =~ /\A\._/;	# Temp Mac OS Resource hack
+		my $is_cpp = $file =~ m/\A(.+)\.cpp\Z/i;
+		my $is_rc  = $file =~ m/\A(.+)\.rc\Z/i;
+		my $base = $1;
 
+		if ($target_windows)
+		{
+			next if not $is_cpp and not $is_rc;
+		}
+		else
+		{
+			next if not $is_cpp;
+		}
+
+		next if $file =~ /\A\._/; # Temp Mac OS Resource hack
+
 		# store for later
-		my $base = $1;
 		push @obj_base,$base;
 	
 		# get the file...
-		open FL,"$mod/$cpp";
+		open FL,"$mod/$file";
 		my $f;
-		read FL,$f,-s "$mod/$cpp";
+		read FL,$f,-s "$mod/$file";
 		close FL;
 		
 		my %dep;
@@ -592,10 +611,29 @@
 		my $out_name = '$(OUTDIR)/'.$base.'.o';
 		
 		# write the line for this cpp file
-		$make .= $out_name.': '.join(' ',$cpp,map
-			{ ($hfiles{$_} eq $mod)?$_:'../../'.$hfiles{$_}."/$_" } keys %dep)."\n";
-		$make .= "\t\$(CXX) \$(CXXFLAGS) $compile_line_extra -c $cpp -o $out_name\n\n";
+		my @dep_paths = map 
+		{ 
+			($hfiles{$_} eq $mod)
+			? $_ 
+			: '../../'.$hfiles{$_}."/$_"
+		}
+		keys %dep;
 
+		$make .= $out_name.': '.join(' ',$file, at dep_paths)."\n";
+
+		if ($is_cpp)
+		{
+			$make .= "\t\$(CXX) \$(CXXFLAGS) $compile_line_extra ".
+				"-c $file -o $out_name\n\n";
+		}
+		elsif ($is_rc)
+		{
+			$make .= "\t\$(WINDRES) $file $out_name\n\n";
+			my $res_list = $module_resources_win32{$mod};
+			$res_list ||= [];
+			push @$res_list, $base.'.o';
+			$module_resources_win32{$mod} = $res_list;
+		}
 	}
 
 	my $has_deps = ($#{$module_dependency{$mod}} >= 0);
@@ -647,11 +685,28 @@
 	additional_objects_from_make_fragment("$mod/Makefile.extra.$build_os", \@objs, \@makefile_includes);
 
 	my $o_file_list = join(' ',map {'$(OUTDIR)/'.$_.'.o'} @objs);
+
+	if ($has_deps and not $bsd_make)
+	{
+		print MAKE ".PHONY: all\n" .
+			"all: dep_modules $end_target\n\n";
+	}
+
 	print MAKE $end_target,': ',$o_file_list;
-	print MAKE ' dep_modules' if $has_deps and not $bsd_make;
 	print MAKE " ",$lib_files unless $target_is_library;
 	print MAKE "\n";
 	
+	if ($target_windows)
+	{
+		foreach my $dep (@all_deps_for_module)
+		{
+			my $res_list = $module_resources_win32{$dep};
+			next unless $res_list;
+			$o_file_list .= ' '.join(' ', 
+				map {'$(OUTBASE)/'.$dep."/$_"} @$res_list);
+		}
+	}
+
 	# stuff to make the final target...
 	if($target_is_library)
 	{




More information about the Boxbackup-commit mailing list