summaryrefslogtreecommitdiff
path: root/infrastructure
diff options
context:
space:
mode:
Diffstat (limited to 'infrastructure')
-rw-r--r--infrastructure/BoxPlatform.pm.in64
-rw-r--r--infrastructure/buildenv-testmain-template.cpp7
-rwxr-xr-xinfrastructure/makebuildenv.pl.in144
-rw-r--r--infrastructure/msvc/2003/boxbackup.ncbbin650240 -> 0 bytes
-rw-r--r--infrastructure/msvc/2003/boxbackup.suobin22528 -> 0 bytes
5 files changed, 167 insertions, 48 deletions
diff --git a/infrastructure/BoxPlatform.pm.in b/infrastructure/BoxPlatform.pm.in
index 04e6cda4..8297b93b 100644
--- a/infrastructure/BoxPlatform.pm.in
+++ b/infrastructure/BoxPlatform.pm.in
@@ -1,16 +1,30 @@
package BoxPlatform;
use Exporter;
@ISA = qw/Exporter/;
-@EXPORT = qw/$build_os $build_cpu $target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext/;
+@EXPORT = qw/$build_os $build_cpu $target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext $target_windows update_if_changed/;
BEGIN
{
# which OS are we building under?
- $build_os = `uname`;
- chomp $build_os;
- $build_cpu = `uname -p`;
- chomp $build_cpu;
+ $target_os = '@target_os@';
+ $target_windows = 0;
+ $target_windows = 1 if $target_os =~ m'^mingw32'
+ or $target_os eq "winnt";
+
+ if ($^O eq "MSWin32" and not -x "/usr/bin/uname")
+ {
+ $build_os = "winnt";
+ $build_cpu = "ix86";
+ }
+ else
+ {
+ $build_os = `uname`;
+ chomp $build_os;
+ $build_cpu = `uname -m`;
+ chomp $build_cpu;
+ }
+
# Cygwin Builds usually something like CYGWIN_NT-5.0, CYGWIN_NT-5.1
# Box Backup tried on Win2000,XP only :)
@@ -24,11 +38,18 @@ BEGIN
$platform_compile_line_extra =~ s/ -O2//;
$platform_link_line_extra = '@LDFLAGS@';
$platform_lib_files = '@LIBS@';
- $target_os = '@target_os@';
$platform_exe_ext = '@EXEEXT@';
# get version
- open VERSION,"VERSION.txt" or die "VERSION.txt: $!";
+ if (! -r "VERSION.txt" and -r "../../VERSION.txt")
+ {
+ open VERSION,"../../VERSION.txt" or die "../../VERSION.txt: $!";
+ }
+ else
+ {
+ open VERSION,"VERSION.txt" or die "VERSION.txt: $!";
+ }
+
$product_version = <VERSION>;
chomp $product_version;
$product_name = <VERSION>;
@@ -89,5 +110,34 @@ sub make_flag
return $_[0].'=1';
}
+sub update_if_changed ($)
+{
+ my ($file) = @_;
+ die "$file.new: not found" unless -r "$file.new";
+
+ if (-r $file)
+ {
+ die "$file.new: not found" unless -r "$file.new";
+ if (system("diff --brief $file $file.new") == 0)
+ {
+ unlink "$file.new";
+ return;
+ }
+ }
+
+ if (system("cp $file.new $file") != 0)
+ {
+ die "failed to copy $file.new to $file";
+ }
+
+ if (system("diff --brief $file $file.new") != 0)
+ {
+ die "$file and $file.new are still different";
+ }
+
+ unlink "$file.new";
+ return;
+}
+
1;
diff --git a/infrastructure/buildenv-testmain-template.cpp b/infrastructure/buildenv-testmain-template.cpp
index f95f01e6..c64c1fa5 100644
--- a/infrastructure/buildenv-testmain-template.cpp
+++ b/infrastructure/buildenv-testmain-template.cpp
@@ -41,6 +41,8 @@ int test(int argc, const char *argv[]);
#endif
int failures = 0;
+int first_fail_line;
+std::string first_fail_file;
int filedes_open_at_beginning = -1;
@@ -128,7 +130,10 @@ int main(int argc, const char *argv[])
}
if(failures > 0)
{
- printf("FAILED: %d tests failed\n", failures);
+ printf("FAILED: %d tests failed (first at "
+ "%s:%d)\n", failures,
+ first_fail_file.c_str(),
+ first_fail_line);
}
else
{
diff --git a/infrastructure/makebuildenv.pl.in b/infrastructure/makebuildenv.pl.in
index f70321a7..9306a8c1 100755
--- a/infrastructure/makebuildenv.pl.in
+++ b/infrastructure/makebuildenv.pl.in
@@ -14,8 +14,7 @@ $|=1;
print "Box build environment setup.\n\n";
-
-my $implicit_dep = 'lib/common';
+my @implicit_deps = ('lib/common');
# work out platform variables
use lib 'infrastructure';
@@ -38,11 +37,15 @@ unless(-d 'local')
# 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)
+{
+ $module_dependency{"lib/common"} = ["lib/win32"];
+ push @implicit_deps, "lib/win32";
+}
+else
{
- $windows_include_path = "";
- $env_flags{'IGNORE_lib/win32'} = 1;
+ # $env_flags{'IGNORE_lib/win32'} = 1;
}
# print "Flag: $_\n" for(keys %env_flags);
@@ -111,7 +114,7 @@ close FINDAUTOGEN;
print "done\n\n";
-# open test mail program template file
+# open test main program template file
my $test_template_file = 'infrastructure/buildenv-testmain-template.cpp';
open FL,$test_template_file or die "Can't open test template file\n";
my $test_template;
@@ -271,7 +274,7 @@ for(@modules_files)
push @md,$_ unless ignore_module($_)
}
}
- $module_dependency{$mod} = [$implicit_dep,@md];
+ $module_dependency{$mod} = [@implicit_deps,@md];
$module_library_link_opts{$mod} = [@lo];
# make directories, but not if we're using an external library and this a library module
@@ -286,17 +289,21 @@ for(@modules_files)
}
# 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";
+open CONFIGURED_MODS,'>local/modules.h.new' or die
+ "Can't write configured modules list";
print CONFIGURED_MODS <<__E;
// automatically generated file, do not edit
#ifndef _CONFIGURED_MODULES__H
#define _CONFIGURED_MODULES__H
__E
-for($implicit_dep,@modules)
+for(@implicit_deps,@modules)
{
my $m = $_;
$m =~ s~/~_~;
@@ -306,11 +313,11 @@ print CONFIGURED_MODS <<__E;
#endif // _CONFIGURED_MODULES__H
__E
close CONFIGURED_MODS;
-
+update_if_changed("local/modules.h");
# 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 +354,7 @@ for my $mod (@modules, $implicit_dep)
}
}
-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 +380,10 @@ for my $mod (@modules, $implicit_dep)
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";
@@ -386,15 +394,19 @@ for my $mod (@modules, $implicit_dep)
{
my $testmain = $test_template;
$testmain =~ s/TEST_NAME/$name/g;
- open TESTMAIN,">$mod/_main.cpp" or die "Can't open test main file for $mod for writing\n";
+ open TESTMAIN,">$mod/_main.cpp.new" or die
+ "Can't open test main file for $mod for writing\n";
print TESTMAIN $testmain;
close TESTMAIN;
+ update_if_changed("$mod/_main.cpp");
# test file...
sub writetestfile
{
my ($filename,$runcmd,$module) = @_;
- open TESTFILE,">$filename" or die "Can't open test script file for $module for writing\n";
+ open TESTFILE,">$filename.new" or die
+ "Can't open test script file for $module " .
+ "for writing\n";
print TESTFILE "#!/bin/sh\necho TEST: $module\n";
if(-d "$module/testfiles")
{
@@ -413,12 +425,13 @@ __E
}
print TESTFILE "$runcmd\n";
close TESTFILE;
+ update_if_changed($filename);
}
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 +454,14 @@ __E
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;
}
}
}
@@ -480,11 +493,12 @@ __E
# start the makefile
my $mk_name_extra = ($bsd_make)?'':'X';
- open MAKE,">$mod/Makefile".$mk_name_extra or die "Can't open Makefile for $mod\n";
+ open MAKE,">$mod/Makefile".$mk_name_extra.".new" or die
+ "Can't open Makefile for $mod\n";
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 +513,7 @@ CXX = g++
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 +561,7 @@ __E
@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 +581,30 @@ __E
# 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 +618,29 @@ __E
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,@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 +692,28 @@ __E
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)
{
@@ -730,8 +792,8 @@ __E
if(!$bsd_make)
{
# need to post process this into a GNU makefile
- open MAKE,">$mod/Makefile";
- open MAKEB,"$mod/MakefileX";
+ open MAKE,">$mod/Makefile.new" or die $!;
+ open MAKEB,"$mod/MakefileX.new" or die $!;
while(<MAKEB>)
{
@@ -743,8 +805,10 @@ __E
close MAKEB;
close MAKE;
- unlink "$mod/MakefileX";
+ unlink "$mod/MakefileX.new";
}
+
+ update_if_changed("$mod/Makefile");
}
print "\nType 'cd <module_dir>; $make_command' to build a module\n\n";
diff --git a/infrastructure/msvc/2003/boxbackup.ncb b/infrastructure/msvc/2003/boxbackup.ncb
deleted file mode 100644
index 8aacb715..00000000
--- a/infrastructure/msvc/2003/boxbackup.ncb
+++ /dev/null
Binary files differ
diff --git a/infrastructure/msvc/2003/boxbackup.suo b/infrastructure/msvc/2003/boxbackup.suo
deleted file mode 100644
index c461ff26..00000000
--- a/infrastructure/msvc/2003/boxbackup.suo
+++ /dev/null
Binary files differ