diff --git a/source/tools/LICENSE.txt b/source/tools/LICENSE.txt index 74fb217530..65d87426ad 100644 --- a/source/tools/LICENSE.txt +++ b/source/tools/LICENSE.txt @@ -8,27 +8,15 @@ in particular, let us know and we can try to clarify it. atlas GPL version 2 (or later) - see license_gpl-2.0.txt - autobuild - MIT - - autobuild2 - Various (unspecified) - autolog MIT cmpgraph MIT - dds - MIT - dist MIT - entconvert - MIT - entdocs MIT @@ -86,4 +74,4 @@ in particular, let us know and we can try to clarify it. MIT XpartaMuPP - GPLv2 + GPL version 2 (or later) diff --git a/source/tools/autobuild/build.pl b/source/tools/autobuild/build.pl deleted file mode 100644 index 9fef3c57de..0000000000 --- a/source/tools/autobuild/build.pl +++ /dev/null @@ -1,266 +0,0 @@ -# Build script - does the actual building of the project - -use strict; -use warnings; - -use constant EXIT_BUILDCOMPLETE => 0; -use constant EXIT_NOTCOMPILED => 1; -use constant EXIT_FAILED => 2; -use constant EXIT_ABORTED => 3; - -my $svn_trunk = 'c:\0ad\trunk'; -#my $temp_trunk = 'r:\trunk'; -my $temp_trunk = 'c:\0ad\buildtrunk'; -my $output_dir = 'c:\0ad\builds'; -my $log_dir = 'c:\0ad\autobuild'; -my $doc_out_dir = 'p:\latest'; - -my $sevenz = '"C:\Program Files\7-Zip\7z.exe"'; -my $junction = 'c:\0ad\autobuild\junction.exe'; # from http://www.sysinternals.com/Utilities/Junction.html - -#my $vcbuild = '"C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\vcbuild"'; -# except I need to call vcvars32.bat then "vcbuild.exe /useenv", since the VS registry settings don't always exist -my $vcbuild = '"C:\0ad\autobuild\vcbuild_env.bat"'; - -my $time_start = time(); - -eval { # catch deaths - -# Capture all output -open STDOUT, '>', "$log_dir\\build_stdout_temp.txt"; -open STDERR, '>', "$log_dir\\build_stderr_temp.txt"; -open BUILDLOG, '>', "$log_dir\\buildlog_temp.txt" or die $!; - -our ($username, $password); -do 'login_details.pl' or die "Cannot find login details: $! / $@"; -# login_details.pl contains: -# $::username = "philip"; -# $::password = "something"; -# (but with a valid password, which I'm not going to tell you) - - -add_to_buildlog("Starting build at ".(gmtime($time_start))." GMT.\n"); - -chdir $svn_trunk or die $!; - -if (grep { $_ eq '--commitlatest' } @ARGV) -{ - add_to_buildlog("Committing latest code"); - - ### Find the latest revision number ### - opendir my $dir, $output_dir or die $!; - my @revs = grep /^\d+$/, readdir $dir; - die unless @revs; - my $rev = (sort { $b <=> $a } @revs)[0]; - - add_to_buildlog("Committing ps.exe for revision $rev"); - - ### Copy ps.exe and ps.pdb over the SVN copy ### - `copy $output_dir\\$rev\\ps.exe $svn_trunk\\binaries\\system\\`; - die $? if $?; - `copy $output_dir\\$rev\\ps.pdb $svn_trunk\\binaries\\system\\`; - die $? if $?; - - ### Commit ps.exe and ps.pdb ### - my $svn_output = `svn commit binaries\\system\\ps.exe binaries\\system\\ps.pdb --username $username --password $password --message "Automated build." 2>&1`; - add_to_buildlog($svn_output); - die $? if $?; - - # Just exit, and don't overwrite the earlier logs - exit(EXIT_NOTCOMPILED); -} - -### Update from SVN ### - -my $svn_output = `svn update --username $username --password $password 2>&1`; -add_to_buildlog($svn_output); -die $? if $?; - -allow_abort(); - -$svn_output =~ /^(?:Updated to|At) revision (\d+)\.$/m or die; -my $svn_revision = $1; - -if ($svn_output =~ m~^. (source(?![/\\](tools(?![/\\]atlas[/\\]GameInterface)|collada))|build|libraries)~m) -{ - # The source has been updated. - # ('source' means something in the source, build, or libraries directories, excluding source/tools, but including source/tools/atlas/GameInterface) -} -else -{ - # Nothing's changed. Build anyway? - if (grep { $_ eq '--force' } @ARGV) - { - # Yes - } - else - { - add_to_buildlog("*** Build $svn_revision not needed - no source changes ***"); - # Just exit, and don't overwrite the earlier logs - exit(EXIT_NOTCOMPILED); - } -} - -### Check whether we've already built this ### - -if (-e "$output_dir\\$svn_revision") -{ - add_to_buildlog("*** Build $svn_revision already exists ***"); - # Just exit, and don't overwrite the earlier logs - exit(EXIT_NOTCOMPILED); -} - -### Clean the RAM disk ### - -`rmdir /q /s $temp_trunk 2>&1`; -# ignore failures - the RAM disk might have been recently reset - -### Copy all the necessary files onto it ### - -# For some directories (which we're going to alter), do a real copy -for (qw(build)) -{ - `xcopy /e $svn_trunk\\$_ $temp_trunk\\$_\\ 2>&1`; - die "xcopy $_: $?" if $?; - allow_abort(); -} - -# For other directories (which we're only going to read), do a 'junction' (like a symbolic link) because it's faster -for (qw(source libraries)) -{ - `$junction $temp_trunk\\$_ $svn_trunk\\$_`; - die "junction $_: $?" if $?; - allow_abort(); -} - -### Create the workspace files ### - -chdir "$temp_trunk\\build\\workspaces" or die $!; -my $updateworkspaces_output = `update-workspaces.bat 2>&1`; -add_to_buildlog($updateworkspaces_output); -die $? if $?; - -### Create target directories for built files ### - -mkdir "$temp_trunk\\binaries" or die $!; -mkdir "$temp_trunk\\binaries\\system" or die $!; - -allow_abort(); - -### Do the Testing build ### - -my $build_output1 = `$vcbuild /time vc2003\\pyrogenesis.sln Testing 2>&1`; -add_to_buildlog($build_output1); -die $? if ($? and $? != 32768); # 32768 seems to be returned when it succeeds - -allow_abort(); - -### Copy the output ### - -`mkdir $output_dir\\temp`; -# ignore failures - this might already exist if the last build was aborted - -`copy $temp_trunk\\binaries\\system\\ps_test.exe $output_dir\\temp\\`; -die $? if $?; -`copy $temp_trunk\\binaries\\system\\ps_test.pdb $output_dir\\temp\\`; -die $? if $?; - -### Clean up unnecessary files to save space ### - -`rmdir /q /s $temp_trunk\\build\\workspaces\\vc2003\\obj\\Testing 2>&1`; -die $? if $?; -`rmdir /q /s $temp_trunk\\binaries 2>&1`; -die $? if $?; - -allow_abort(); - -### Recreate targets for built files ### - -mkdir "$temp_trunk\\binaries" or die $!; -mkdir "$temp_trunk\\binaries\\system" or die $!; - -### Do the Release build ### - -my $build_output2 = `$vcbuild /time vc2003\\pyrogenesis.sln Release 2>&1`; -add_to_buildlog($build_output2); -die $? if ($? and $? != 32768); - -### Copy the output ### - -`copy $temp_trunk\\binaries\\system\\ps.exe $output_dir\\temp\\`; -die $? if $?; -`copy $temp_trunk\\binaries\\system\\ps.pdb $output_dir\\temp\\`; -die $? if $?; - -### Generate the documentation ### - -chdir "$temp_trunk\\build\\docs" or die $!; -`builddoc.bat`; -if ($?) -{ - warn $?; -} -else -{ - ### Store the documentation ### - `rmdir /q /s $doc_out_dir 2>&1`; - `xcopy /e $temp_trunk\\docs\\generated\\*.* $doc_out_dir\\ 2>&1`; -} - -### Store the output permanently ### - -rename "$output_dir\\temp", "$output_dir\\$svn_revision" or die $!; - -### and make a compressed archive ### - -chdir "$output_dir\\$svn_revision" or die $!; -`$sevenz a -mx7 -bd -sfx7zC.sfx ..\\$svn_revision.exe`; -die $? if $?; - -# (TODO: delete the non-archived data when it's not needed, to save disk space) - -}; # end of eval - -if ($@) -{ - warn $@; - quit(EXIT_FAILED); -} -else -{ - quit(EXIT_BUILDCOMPLETE); -} - - -# Exit, after copying the current log files over the previous ones -sub quit -{ - my $time_end = time(); - my $time_taken = $time_end - $time_start; - add_to_buildlog("\nBuild completed at ".(gmtime($time_end))." GMT - took $time_taken seconds."); - - close BUILDLOG; - rename "$log_dir\\buildlog_temp.txt", "$log_dir\\buildlog.txt" or die $!; - close STDOUT; - rename "$log_dir\\build_stdout_temp.txt", "$log_dir\\build_stdout.txt" or die $!; - close STDERR; - rename "$log_dir\\build_stderr_temp.txt", "$log_dir\\build_stderr.txt" or die $!; - exit($_[0]); -} - - -sub add_to_buildlog -{ - print BUILDLOG "$_[0]\n--------------------------------------------------------------------------------\n"; -} - -# Call this at strategic moments, to allow builds to be aborted (when e.g. there's another revision just come in that needs to be built instead) -sub allow_abort -{ - if (-e "$log_dir\\build_abort") - { - add_to_buildlog("*** Build aborted ***\n"); - unlink "$log_dir\\build_abort"; - quit(EXIT_ABORTED); - } -} \ No newline at end of file diff --git a/source/tools/autobuild/buildd.pl b/source/tools/autobuild/buildd.pl deleted file mode 100644 index 23b7f23660..0000000000 --- a/source/tools/autobuild/buildd.pl +++ /dev/null @@ -1,300 +0,0 @@ -# Build daemon - receives notifications of commits, runs the build process (ensuring there's only one copy at once), commits the built files, and provides access to all earlier builds and the build log of the latest. - -use warnings; -use strict; - -# Exit codes used by build.pl: -use constant EXIT_BUILDCOMPLETE => 0; -use constant EXIT_NOTCOMPILED => 1; -use constant EXIT_FAILED => 2; -use constant EXIT_ABORTED => 3; - -use POE qw(Component::Server::TCP Component::Client::HTTP Filter::HTTPD Filter::Line); -use HTTP::Response; - -use Win32::Process; - -my $build_process; # stores Win32::Process handle -my $build_required = 0; # set by commits, cleared by builds; 1 for normal build, 2 for forced build (even if no source was changed) -my $commit_required = 0; # stores the time when it should happen, or 0 if never -my $build_start_time; # time that the most recent build started -my $last_exit_code; # exit code of the most recent completed build -my $build_active = 0; # 0 => build process not running; 1 => build process running within the past second - -use constant COMMIT_DELAY => 60*60; # seconds to wait after a code commit before committing ps.exe - -open my $logfile, '>>', 'access_log' or die "Error opening access_log: $!"; -$logfile->autoflush(); -sub LOG { - my ($pkg, $file, $line) = caller; - my $msg = localtime()." - $file:$line - @_\n"; - print $logfile $msg; - print $msg; -} - -my $main_session; # main POE::Session object - -POE::Component::Server::TCP->new( - Alias => "web_server", - Port => 57470, - ClientFilter => 'POE::Filter::HTTPD', - - ClientInput => sub { - my ($kernel, $heap, $request) = @_[KERNEL, HEAP, ARG0]; - - # Respond to errors in the client's request - if ($request->isa("HTTP::Response")) { - $heap->{client}->put($request); - $kernel->yield("shutdown"); - return; - } - - LOG $heap->{remote_ip}." - ".$request->uri->as_string; - - my $response = HTTP::Response->new(200); - - my $url = $request->uri->path; - - if ($url eq '/commit_notify.html') - { - $build_required = 1; - abort_build(); - $response->push_header('Content-type', 'text/plain'); - $response->content("Build initiated."); - $kernel->post($main_session, 'commit_notify'); - } - elsif ($url eq '/force_build.html') - { - $build_required = 2; - abort_build(); - $response->push_header('Content-type', 'text/plain'); - $response->content("Forced build initiated."); - } - elsif ($url eq '/commit_latest.html') - { - $commit_required = time(); - $response->push_header('Content-type', 'text/plain'); - $response->content("Commit initiated."); - } - elsif ($url eq '/abort_build.html') - { - abort_build(); - $response->push_header('Content-type', 'text/plain'); - $response->content("Build aborted."); - } - elsif ($url eq '/status.html') - { - $response->push_header('Content-type', 'text/html'); - my $text = < -@{[ $build_active ? "Build in progress - ".(time()-$build_start_time)." seconds elapsed." : "Build not in progress." ]} -

-Last build status: @{[do{ - if ($last_exit_code == EXIT_BUILDCOMPLETE or $last_exit_code == EXIT_NOTCOMPILED) { - "Succeeded"; - } elsif ($last_exit_code == EXIT_ABORTED) { - "Aborted" - } else { - "FAILED ($last_exit_code)" - } -}]}. -

-Build log: (complete logs) -

-EOF - my $buildlog = do { local $/; my $f; open $f, 'buildlog.txt' and <$f> }; - if ($buildlog) - { - $buildlog =~ s/&/&/g; - $buildlog =~ s//>/g; - } - else - { - $buildlog = "(Error opening build log)"; - } - - $text .= "
$buildlog
"; - - $text .= qq{}; - $response->content($text); - } - elsif ($url eq '/logs.html') - { - $response->push_header('Content-type', 'text/plain'); - my $text; - for my $n (qw(buildlog build_stdout build_stderr)) - { - my $filedata = do { local $/; my $f; open $f, "$n.txt" and <$f> }; - $text .= "--------------------------------------------------------------------------------\n"; - $text .= "$n\n"; - $text .= "--------------------------------------------------------------------------------\n"; - $text .= $filedata; - $text .= "\n\n\n"; - } - $response->content($text); - } - elsif ($url eq '/filelist.html') - { - my $output = ''; - eval { - opendir my $d, "..\\builds" or die $!; - my @revs; - for (grep /^\d+\.exe$/, readdir $d) - { - /^(\d+)/; - push @revs, $1; - } - $output .= qq{$_ (}.int( (stat "..\\builds\\$_.exe")[7]/1024 ).qq{k)\n} for sort { $b <=> $a } @revs; - }; - if ($@) - { - LOG "filelist failed: $@"; - $response->push_header('Content-type', 'text/plain'); - $response->content("Internal error."); - } - else - { - $response->push_header('Content-type', 'text/html'); - $response->content("
$output
"); - } - } - elsif ($url =~ m~/download/(\d+).exe~) - { - my $rev = $1; - if (-e "..\\builds\\$rev.exe" and open my $f, "..\\builds\\$rev.exe") - { - binmode $f; - $response->push_header('Content-type', 'application/octet-stream'); - $response->content(do{local $/; <$f>}); - } - else - { - LOG "Error serving file $url"; - $response->push_header('Content-type', 'text/plain'); - $response->content("File not found."); - } - } - elsif ($url eq '/favicon.ico') - { - $response = HTTP::Response->new(404); - $response->push_header('Content-type', 'text/html'); - $response->content($response->error_as_HTML); - } - else - { - $response->push_header('Content-type', 'text/plain'); - $response->content("Unrecognised request."); - } - - $heap->{client}->put($response); - $kernel->yield("shutdown"); - }, -); - -POE::Component::Client::HTTP->spawn( - Alias => "web_client", -); - -$main_session = POE::Session->create( - inline_states => { - _start => sub { - $_[KERNEL]->delay(tick => 1); - }, - tick => sub { - $_[KERNEL]->delay(tick => 1); - - if ($build_active and not build_is_running()) - { - # Build has just completed. - - $last_exit_code = get_exit_code(); - $build_active = 0; - undef $build_process; - - LOG "Build complete ($last_exit_code)"; - - if ($last_exit_code == EXIT_BUILDCOMPLETE) - { - $commit_required = $build_start_time + COMMIT_DELAY; - } - else - { - $commit_required = 0; - } - } - - if ($build_required and not $build_active) - { - start_build(force => ($build_required == 2)); - } - elsif ($commit_required and time() >= $commit_required) - { - start_build(commit => 1); - $commit_required = 0; - } - }, - - commit_notify => sub { - $_[KERNEL]->post('web_client', 'request', 'commit_notify_response', - new HTTP::Request(GET => 'http://192.168.0.223/wfg/svnlog.cgi/logupdate/doupdate')); - }, - - commit_notify_response => sub { - my $response_packet = $_[ARG1]; - my $response = $response_packet->[0]; - LOG "notified - ".$response->content; - }, - - } -); - -LOG "Starting kernel"; -$poe_kernel->run(); -LOG "Kernel exited"; -exit 0; - - -sub build_is_running -{ - my $exit_code = get_exit_code(); - return (defined $exit_code and $exit_code == 259); -} - -sub get_exit_code -{ - return undef if not $build_process; - my $exit_code; - $build_process->GetExitCode($exit_code); - return $exit_code; -} - -sub abort_build -{ - LOG "Aborting build"; - - open my $f, '>', 'build_abort'; -} - -sub start_build -{ - my %params = @_; - - LOG "Starting build"; - - unlink 'build_abort'; - - $build_start_time = time; - - Win32::Process::Create( - $build_process, - "c:\\perl\\bin\\perl.exe", - "perl build.pl" . ($params{commit} ? ' --commitlatest' : '') . ($params{force} ? ' --force' : ''), - 0, - CREATE_NO_WINDOW, - "c:\\0ad\\autobuild") or die "Error spawning build script: ".Win32::FormatMessage(Win32::GetLastError()); - - $build_required = 0; - $commit_required = 0; - $build_active = 1; -} \ No newline at end of file diff --git a/source/tools/autobuild2/aws.conf.example b/source/tools/autobuild2/aws.conf.example deleted file mode 100644 index c1520046e8..0000000000 --- a/source/tools/autobuild2/aws.conf.example +++ /dev/null @@ -1,2 +0,0 @@ -aws_access_key_id: XXXXXXXXXXXXXXXXXXXX -aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/source/tools/autobuild2/build.pl b/source/tools/autobuild2/build.pl deleted file mode 100644 index 3b16b7b2bd..0000000000 --- a/source/tools/autobuild2/build.pl +++ /dev/null @@ -1,167 +0,0 @@ -# Build script - does the actual building of the project - -use strict; -use warnings; - -use constant EXIT_BUILDCOMPLETE => 0; -use constant EXIT_FAILED => 1; - -my %config = (load_conf("c:\\0ad\\autobuild\\aws.conf"), load_conf("d:\\0ad\\autobuild\\run.conf")); -my $build_options = do "d:\\0ad\\autobuild\\options.pl"; - -my $svn_trunk = "e:\\svn"; -my $temp_trunk = "d:\\0ad\\svn"; -my $log_dir = "d:\\0ad\\buildlogs"; -my $vcbuild = "$svn_trunk\\source\\tools\\autobuild2\\vcbuild_env.bat"; - -my @gloox_libs = qw(glooxwrapper.dll glooxwrapper.lib glooxwrapper.pdb glooxwrapper_dbg.dll glooxwrapper_dbg.lib glooxwrapper_dbg.pdb); - -my $time_start = time(); - -eval { # catch deaths - -# Clean the output directory, just in case it's got old junk left over somehow -`rmdir /q /s $temp_trunk 2>&1`; # (ignore failures, they don't matter) -`rmdir /q /s $log_dir 2>&1`; # (ignore failures, they don't matter) -mkdir $temp_trunk or die $!; -mkdir $log_dir or die $!; - -# Capture all output -open STDOUT, '>', "$log_dir\\build_stdout.txt"; -open STDERR, '>', "$log_dir\\build_stderr.txt"; -open BUILDLOG, '>', "$log_dir\\buildlog.txt" or die $!; - -add_to_buildlog("Starting build"); - -chdir $svn_trunk or die $!; - -# Copy all the necessary files into the temporary working area - -# For some directories, do a real copy -for (qw(build source libraries)) -{ - add_to_buildlog("xcopying $_"); - `xcopy /e $svn_trunk\\$_ $temp_trunk\\$_\\ 2>&1`; - die "xcopy $_: $?" if $?; -} - -# # For other directories (which we're only going to read), do a 'junction' (like a symbolic link) because it's faster -# # -# # Actually don't, because it's easier to not have to install the junction tool -# for (qw(source libraries)) -# { -# `$junction $temp_trunk\\$_ $svn_trunk\\$_`; -# die "junction $_: $?" if $?; -# } - -# Store the SVN revision identifier in a file, so it can be embedded into the .exe -{ - my $rev = `svnversion -n $svn_trunk`; - die "svnversion: $?" if $?; - add_to_buildlog("SVN revision $rev"); - open my $f, '>', "$temp_trunk\\build\\svn_revision\\svn_revision.txt" or die $!; - print $f qq{L"$rev"\n}; -} - -# Create the workspace files - -my $updateworkspaces_args = ''; -$updateworkspaces_args .= ' --atlas' if $build_options->{atlas}; -$updateworkspaces_args .= ' --collada' if $build_options->{collada}; -$updateworkspaces_args .= ' --build-shared-glooxwrapper' if $build_options->{glooxwrapper}; -add_to_buildlog("Running update-workspaces$updateworkspaces_args"); -chdir "$temp_trunk\\build\\workspaces" or die $!; -my $updateworkspaces_output = `update-workspaces.bat$updateworkspaces_args 2>&1`; -add_to_buildlog($updateworkspaces_output); -die $? if $?; - -# Create target directories for built files - -mkdir "$temp_trunk\\binaries" or die $!; -mkdir "$temp_trunk\\binaries\\system" or die $!; - -# Copy the prebuilt glooxwrapper, if needed - -if (not $build_options->{glooxwrapper}) { - add_to_buildlog("copying glooxwrapper"); - for (@gloox_libs) { - `copy $svn_trunk\\binaries\\system\\$_ $temp_trunk\\binaries\\system\\`; - die "Failed to copy $_: $?" if $?; - } -} - -# Do the Release build - -add_to_buildlog("Running vcbuild (release)"); -my $build_output = `$vcbuild /time /M2 /logfile:$log_dir\\build_vcbuild.txt vc2008\\pyrogenesis.sln "Release|Win32" 2>&1`; -add_to_buildlog($build_output); -die $? if ($? and $? != 32768); - -# Do the Debug build of glooxwrapper, if needed - -if ($build_options->{glooxwrapper}) { - add_to_buildlog("Running vcbuild (debug glooxwrapper)"); - my $build_output = `$vcbuild /time /M2 /logfile:$log_dir\\build_vcbuild.txt vc2008\\glooxwrapper.vcproj "Debug|Win32" 2>&1`; - add_to_buildlog($build_output); - die $? if ($? and $? != 32768); -} - -# Copy the output - -add_to_buildlog("Copying generated binaries"); -my @binaries = qw(pyrogenesis.exe pyrogenesis.pdb); -push @binaries, 'AtlasUI.dll' if $build_options->{atlas}; -push @binaries, 'Collada.dll' if $build_options->{collada}; -push @binaries, @gloox_libs if $build_options->{glooxwrapper}; -for (@binaries) { - `copy $temp_trunk\\binaries\\system\\$_ $svn_trunk\\binaries\\system\\`; - die "Failed to copy $_: $?" if $?; -} - -# Commit to SVN - -my $commit_binaries = join ' ', map "$svn_trunk\\binaries\\system\\$_", @binaries; -my $svn_output = `svn commit --username $config{svn_username} --password $config{svn_password} $commit_binaries --message "Automated build." 2>&1`; -add_to_buildlog($svn_output); -die $? if $?; - -}; # end of eval - -if ($@) -{ - warn $@; - quit(EXIT_FAILED); -} -else -{ - quit(EXIT_BUILDCOMPLETE); -} - - -# Exit, after copying the current log files over the previous ones -sub quit -{ - my $time_end = time(); - my $time_taken = $time_end - $time_start; - add_to_buildlog("Build completed with code $_[0] - took $time_taken seconds."); - - exit($_[0]); -} - - -sub add_to_buildlog -{ - print BUILDLOG +(gmtime time)."\n$_[0]\n--------------------------------------------------------------------------------\n"; -} - -sub load_conf { - my ($filename) = @_; - open my $f, '<', $filename or die "Failed to open $filename: $!"; - my %c; - while (<$f>) { - if (/^(.+?): (.+)/) { - $c{$1} = $2; - } - } - return %c; -} diff --git a/source/tools/autobuild2/logindex.html b/source/tools/autobuild2/logindex.html deleted file mode 100644 index 60b7048973..0000000000 --- a/source/tools/autobuild2/logindex.html +++ /dev/null @@ -1,41 +0,0 @@ - -WFG Autobuilder Logs - - - - - diff --git a/source/tools/autobuild2/manage.cgi b/source/tools/autobuild2/manage.cgi deleted file mode 100755 index 1608fa23c0..0000000000 --- a/source/tools/autobuild2/manage.cgi +++ /dev/null @@ -1,352 +0,0 @@ -#!/usr/bin/perl -wT - -use strict; -use warnings; - -use CGI::Simple; -use CGI::Carp qw(fatalsToBrowser); -use DBI; -use Net::Amazon::EC2; -use DateTime::Format::ISO8601; -use Archive::Zip; -use MIME::Base64; -use IO::String; -use Data::Dumper; - -my $root = '/var/svn/autobuild'; - -my %config = load_conf("$root/manage.conf"); - -my $cgi = new CGI::Simple; - -my $user = $cgi->remote_user; -die unless $user; - -my $dbh = DBI->connect("dbi:SQLite:dbname=$root/$config{database}", '', '', { RaiseError => 1 }); - -my $ec2 = new Net::Amazon::EC2( - AWSAccessKeyId => $config{aws_access_key_id}, - SecretAccessKey => $config{aws_secret_access_key}, -); - -my @build_options = ( - { name => 'atlas', title => 'Atlas DLL' }, - { name => 'collada', title => 'Collada DLL' }, -# { name => 'glooxwrapper', title => 'Glooxwrapper DLL' }, # this requires the autobuilder to use the same VS version gloox-1.0.dll was built with -); - -my $action = $cgi->url_param('action'); - -if (not defined $action or $action eq 'index') { - log_action('index'); - print_index(''); - -} elsif ($action eq 'start') { - die "Must be POST" unless $cgi->request_method eq 'POST'; - log_action('start'); - -=pod - -Only one instance may run at once, and we need to prevent race conditions. -So: -* Use SQLite as a mutex, so only one CGI script can be trying to start at once -* If the last attempted start was only a few seconds ago, reject this one since - it's probably a double-click or something -* Check the list of active machines. If it's non-empty, reject this request. -* Otherwise, start the new machine. - -=cut - - $dbh->begin_work; - die unless 1 == $dbh->do('UPDATE state SET value = ? WHERE key = ?', undef, $$, 'process_mutex'); - my ($last_start) = $dbh->selectrow_array('SELECT value FROM state WHERE key = ?', undef, 'last_start'); - my $last_start_age = time() - $last_start; - die "Last start was only $last_start_age seconds ago - please try again later." - if $last_start_age < 10; - die unless 1 == $dbh->do('UPDATE state SET value = ? WHERE key = ?', undef, time(), 'last_start'); - - my $instances_status = get_ec2_status_table(); - for (@$instances_status) { - if (instance_is_autobuild($_) and $_->{instance_state} ne 'terminated') { - die "Already got an active instance ($_->{instance_id}) - can't start another one."; - } - } - - # No instances are currently active, and nobody else is in this - # instance-starting script, so it's safe to start a new one - - my $instances = start_ec2_instance(); - - $dbh->commit; - - for (@$instances) { - $dbh->do('INSERT INTO instances VALUES (?, ?)', undef, $_->{instance_id}, DateTime->now->iso8601); - } - - print_index(generate_status_table($instances, 'Newly started instance') . '
'); - -} elsif ($action eq 'stop') { - die "Must be POST" unless $cgi->request_method eq 'POST'; - my $id = $cgi->url_param('instance_id'); - $id =~ /\Ai-[0-9a-f]+\z/ or die "Invalid instance_id"; - log_action('stop', $id); - stop_ec2_instance($id); - print_index("Stopping instance $id
"); - -} elsif ($action eq 'console') { - my $id = $cgi->url_param('instance_id'); - $id =~ /\Ai-[0-9a-f]+\z/ or die "Invalid instance_id"; - log_action('console', $id); - my $output = get_console_output($id); - $output =~ s/Console output from $id:
\n$output

"); - -} elsif ($action eq 'activity') { - my $days = int $cgi->url_param('days') || 7; - print_activity($days); - -} else { - log_action('invalid', $action); - die "Invalid action '$action'"; -} - -$dbh->disconnect; - -sub instance_is_autobuild { - my ($instance) = @_; - return 0 if $instance->{key_name} eq 'backupserver'; - return 1; -} - -sub print_index { - my ($info) = @_; - - my $instances_status = get_ec2_status_table(); - my $got_active_instance; - for (@$instances_status) { - if (instance_is_autobuild($_) and $_->{instance_state} ne 'terminated') { - $got_active_instance = $_->{instance_id} || '?'; - } - } - - my $status = generate_status_table($instances_status, 'Current EC2 machine status'); - print < -0 A.D. autobuild manager - -

Hello $user.

-

- Refresh status | - View build logs -

-
-$info -$status -

-EOF - - if ($got_active_instance) { - print qq{\n}; - } else { - print qq{

\n}; - print qq{
Build options\n}; - for (@build_options) { - print qq{
}; - } - print qq{\n}; - print qq{
\n}; - } -} - -sub log_action { - my ($action, $params) = @_; - $dbh->do('INSERT INTO activity (user, ip, ua, action, params) VALUES (?, ?, ?, ?, ?)', - undef, $user, $cgi->remote_addr, $cgi->user_agent, $action, $params); -} - -sub print_activity { - my ($days) = @_; - print < -0 A.D. autobuild activity log - - -'; - print '
DateUserIPActionParamsUA -EOF - - my $sth = $dbh->prepare("SELECT * FROM activity WHERE timestamp > datetime('now', ?) ORDER BY id DESC"); - $sth->execute("-$days day"); - while (my $row = $sth->fetchrow_hashref) { - print '
'.$cgi->escapeHTML($row->{$_}) for qw(timestamp user ip action params ua); - print "\n"; - } - -print < -EOF - -} - -sub generate_status_table { - my ($instances, $caption) = @_; - my @columns = ( - [ reservation_id => 'Reservation ID' ], - [ instance_id => 'Instance ID' ], - [ instance_state => 'State' ], - [ image_id => 'Image ID '], - [ dns_name => 'DNS name' ], - [ launch_time => 'Launch time' ], - [ reason => 'Last change' ], - ); - my $count = @$instances; - my $status = qq{\n\n}; - for (@columns) { $status .= qq{}; - for (@columns) { - my $key = $_->[0]; - my $val = $item->{$key} // ''; - if ($key eq 'launch_time') { - my $t = DateTime::Format::ISO8601->parse_datetime($val); - my $now = DateTime->now(); - my $diff = $now - $t; - my ($days, $hours, $minutes) = $diff->in_units('days', 'hours', 'minutes'); - my $age = "$minutes minutes ago"; - $age = "$hours hours, $age" if $hours; - $age = "$days days, $age" if $days; - $status .= qq{
$caption — $count instances
$_->[1]}; } - $status .= qq{\n}; - - for my $item (@$instances) { - $status .= qq{
$val ($age)}; - } else { - $status .= qq{$val}; - } - } - $status .= qq{Console output\n}; - $status .= qq{
\n} - if instance_is_autobuild($item); - } - - $status .= qq{
}; - return $status; -} - -sub flatten_instance { - my ($reservation, $instance) = @_; - return { - reservation_id => $reservation->reservation_id, - instance_id => $instance->instance_id, - instance_state => $instance->instance_state->name, - image_id => $instance->image_id, - dns_name => $instance->dns_name, - launch_time => $instance->launch_time, - reason => $instance->reason, - key_name => $instance->key_name, - }; -} - -sub get_ec2_status_table { -# return [ ]; -# return [ { -# reservation_id => 'r-12345678', -# instance_id => 'i-12345678', -# instance_state => 'pending', -# image_id => 'ami-12345678', -# dns_name => '', -# launch_time => '2008-12-30T17:14:22.000Z', -# reason => '', -# } ]; - - my $reservations = $ec2->describe_instances(); - my @ret = (); - for my $reservation (@$reservations) { - push @ret, map flatten_instance($reservation, $_), @{$reservation->instances_set}; - } - return \@ret; -} - -sub get_console_output { - my ($instance_id) = @_; - my $output = $ec2->get_console_output(InstanceId => $instance_id); - return "(Last updated: ".$output->timestamp.")\n".$output->output; -} - -sub start_ec2_instance { -# return [ { -# reservation_id => 'r-12345678', -# instance_id => 'i-12345678', -# instance_state => 'pending', -# image_id => 'ami-12345678', -# dns_name => '', -# launch_time => '2008-12-30T17:14:22.000Z', -# reason => '', -# } ]; - - my $user_data = create_user_data(); - - my $reservation = $ec2->run_instances( - ImageId => $config{image_id}, - MinCount => 1, - MaxCount => 1, - KeyName => $config{key_name}, - SecurityGroup => $config{security_group}, - UserData => encode_base64($user_data), - InstanceType => $config{instance_type}, - 'Placement.AvailabilityZone' => $config{availability_zone}, - ); - - if (ref $reservation eq 'Net::Amazon::EC2::Errors') { - die "run_instances failed:\n".(Dumper $reservation); - } - - return [ map flatten_instance($reservation, $_), @{$reservation->instances_set} ]; -} - -sub create_user_data { - my @files = qw(run.pl run.conf); - - my $zip = new Archive::Zip; - for (@files) { - $zip->addFile("$root/$_", "$_") or die "Failed to add $root/$_ to zip"; - } - - my %options; - for (@build_options) { - $options{$_->{name}} = ($cgi->param('option_'.$_->{name}) ? 1 : 0); - } - my $options = Dumper \%options; - $zip->addString($options, 'options.pl') or die "Failed to add options.pl to zip"; - - my $fh = new IO::String; - if ($zip->writeToFileHandle($fh) != Archive::Zip::AZ_OK) { - die "writeToFileHandle failed"; - } - return ${$fh->string_ref}; -} - -sub stop_ec2_instance { - my ($instance_id) = @_; - -# return; - - $ec2->terminate_instances( - InstanceId => $instance_id, - ); -} - -sub load_conf { - my ($filename) = @_; - open my $f, '<', $filename or die "Failed to open $filename: $!"; - my %c; - while (<$f>) { - if (/^(.+?): (.+)/) { - $c{$1} = $2; - } - } - return %c; -} diff --git a/source/tools/autobuild2/manage.conf.example b/source/tools/autobuild2/manage.conf.example deleted file mode 100644 index cfe12db017..0000000000 --- a/source/tools/autobuild2/manage.conf.example +++ /dev/null @@ -1,8 +0,0 @@ -aws_access_key_id: XXXXXXXXXXXXXXXXXXXX -aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -database: manage.db -image_id: ami-XXXXXXXX -instance_type: m1.small -availability_zone: us-east-1c -key_name: XXX -security_group: XXX diff --git a/source/tools/autobuild2/manage.css b/source/tools/autobuild2/manage.css deleted file mode 100644 index 40e88426d8..0000000000 --- a/source/tools/autobuild2/manage.css +++ /dev/null @@ -1,11 +0,0 @@ -body { - font-family: sans-serif; -} - -table { - border-collapse: collapse; -} - -table th, table td { - border: 1px solid #aaa; -} diff --git a/source/tools/autobuild2/manage.sql b/source/tools/autobuild2/manage.sql deleted file mode 100644 index 834ad48722..0000000000 --- a/source/tools/autobuild2/manage.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE activity ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, - user TEXT NOT NULL, - ip TEXT NOT NULL, - ua TEXT NOT NULL, - action TEXT NOT NULL, -- like "index", "start", "stop", "console" - params TEXT -- action-dependent - typically just the instance ID -); - -CREATE TABLE instances ( - instance_id TEXT NOT NULL PRIMARY KEY, - local_launch_time TEXT NOT NULL -); - -CREATE TABLE state ( - key TEXT NOT NULL PRIMARY KEY, - value TEXT NOT NULL -); -INSERT INTO state VALUES ('process_mutex', ''); -INSERT INTO state VALUES ('last_start', '0'); diff --git a/source/tools/autobuild2/run.conf.example b/source/tools/autobuild2/run.conf.example deleted file mode 100644 index 3980aca948..0000000000 --- a/source/tools/autobuild2/run.conf.example +++ /dev/null @@ -1,7 +0,0 @@ -ec2_metadata_root: http://169.254.169.254/2008-09-01/meta-data/ -ebs_volume_id: vol-XXXXXXXX -ebs_device: xvdg -ebs_drive_letter: e -sync: c:\bin\sync.exe -svn_username: autobuild -svn_password: XXXXXXXXX diff --git a/source/tools/autobuild2/run.pl b/source/tools/autobuild2/run.pl deleted file mode 100644 index 441476bac9..0000000000 --- a/source/tools/autobuild2/run.pl +++ /dev/null @@ -1,238 +0,0 @@ -=pod - -This script does the EC2-specific stuff - -It is responsible for: - * attaching the necessary disks, - * updating from SVN, - * executing the rest of the build script that's in SVN, - * cleaning up at the end, - * and saving the logs of everything that's going on. - -i.e. everything except actually building. - -=cut - -use strict; -use warnings; - -use Net::Amazon::EC2; -use Amazon::S3; -use LWP::Simple(); -use DateTime; - -# Fix clock drift, else S3 will be unhappy -system("net time /setsntp:time.windows.com"); -system("w32tm /resync /rediscover"); - -my %config = (load_conf("c:\\0ad\\autobuild\\aws.conf"), load_conf("d:\\0ad\\autobuild\\run.conf")); -my $timestamp = DateTime->now->iso8601; - -my $s3 = new Amazon::S3( { - aws_access_key_id => $config{aws_access_key_id}, - aws_secret_access_key => $config{aws_secret_access_key}, - retry => 1, -} ); - - -my $bucket = $s3->bucket('wfg-autobuild-logs'); - -my $log = ''; - -$SIG{__WARN__} = sub { - write_log("Warning: @_"); - warn @_; -}; - -write_log("Starting"); -flush_log(); - -my $ec2; - -$SIG{__DIE__} = sub { - die @_ if $^S; # ignore deaths in eval - - write_log("Died\n@_"); - flush_log(); - if ($ec2) { - terminate_instance(); - } - die @_; -}; - -connect_to_ec2(); - -my $instance_id = get_instance_id(); -write_log("Running on instance $instance_id"); -flush_log(); - -attach_disk(); - -update_svn(); - -run_build_script(); - -save_buildlogs(); - -connect_to_ec2(); # in case it timed out while building - -detach_disk(); - -write_log("Finished"); - -terminate_instance(); - -exit; - -sub update_svn { - write_log("Updating from SVN"); - my $output = `svn up --username $config{svn_username} --password $config{svn_password} e:\\svn 2>&1`; - write_log("svn up:\n================================\n$output\n================================\n"); -} - -sub run_build_script { - write_log("Running build script"); - my $output = `perl e:\\svn\\source\\tools\\autobuild2\\build.pl 2>&1`; - write_log("Build script exited with code $?:\n================================\n$output\n================================\n"); -} - -sub save_buildlogs { - opendir my $d, "d:\\0ad\\buildlogs" or do { write_log("Can't open buildlogs directory: $!"); return }; - for my $fn (sort readdir $d) { - next if $fn =~ /^\./; - open my $f, '<', "d:\\0ad\\buildlogs\\$fn" or die "Can't open buildlogs file $fn: $!"; - my $data = do { local $/; <$f> }; - write_log("$fn:\n================================\n$data\n================================\n"); - } -} - -sub connect_to_ec2 { - # This might need to be called more than once, if you wait - # so long that the original connection times out - $ec2 = new Net::Amazon::EC2( - AWSAccessKeyId => $config{aws_access_key_id}, - SecretAccessKey => $config{aws_secret_access_key}, - ); -} - -sub attach_disk { - write_log("Attaching volume $config{ebs_volume_id} as $config{ebs_device}"); - my $status = $ec2->attach_volume( - InstanceId => $instance_id, - VolumeId => $config{ebs_volume_id}, - Device => $config{ebs_device}, - ); - write_log("Attached"); - - # Wait for the disk to get attached and visible - write_log("Waiting for volume to be visible"); - my $mounts; - for my $i (0..60) { - # mountvol emits a list of volumes, so wait until the expected one is visible - $mounts = `mountvol`; - my $letter = uc $config{ebs_drive_letter}; - if ($mounts =~ /(\\\\\?\\Volume\{\S+\}\\)\s+$letter:\\/) { - my $volume = $1; - write_log("Already got volume $volume mounted on drive $config{ebs_drive_letter}"); - return; - } elsif ($mounts =~ /(\\\\\?\\Volume\{\S+\}\\)\s+\*\*\* NO MOUNT POINTS \*\*\*/) { - my $volume = $1; - write_log("Mounting volume $volume onto drive $config{ebs_drive_letter}"); - system("mountvol $config{ebs_drive_letter}: $volume"); - return; - } - write_log("Not seen the volume yet ($i)"); - sleep 1; - } - - die "Failed to find new volume. mountvol said:\n\n$mounts"; -} - -sub detach_disk { - # Based on http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1841&categoryID=174 - write_log("Syncing drive $config{ebs_drive_letter}"); - system("$config{sync} -r $config{ebs_drive_letter}:"); - - write_log("Unmounting drive $config{ebs_drive_letter}"); - system("mountvol $config{ebs_drive_letter}: /d"); - - write_log("Detaching volume"); - my $status = $ec2->detach_volume( - InstanceId => $instance_id, - VolumeId => $config{ebs_volume_id}, - ); - write_log("Detached"); -} - -sub terminate_instance { - write_log("Terminating instance (after a delay)"); - flush_log(); - -# write_log("NOT REALLY"); -# flush_log(); -# return; - - # Delay for a while, to give me a chance to log in and manually - # abort the termination if I want to configure the machine instead - # of having it die straightaway - sleep 60*5; - write_log("Really terminating now"); - flush_log(); - - connect_to_ec2(); # in case it timed out while sleeping - - while (1) { - my $statuses = $ec2->terminate_instances( - InstanceId => $instance_id, - ); -# use Data::Dumper; -# write_log("Termination status $statuses -- ".(Dumper $statuses)); -# flush_log(); - sleep 15; - } -} - -sub get_instance_id { - my $instance_id = LWP::Simple::get("$config{ec2_metadata_root}instance-id"); - die "Invalid instance-id return value '$instance_id'" unless $instance_id =~ /\Ai-[a-f0-9]+\z/; - return $instance_id; -} - -sub write_log { - my ($msg) = @_; - - print "$msg\n"; - my $t = scalar gmtime; - $log .= "$t: $msg\n\n"; - - # Instead of using the explicit flush_log, just flush all - # the time because it helps with debugging - flush_log_really(); -} - -sub flush_log_really { - my $filename = "$timestamp.startup"; - - my $ok = $bucket->add_key($filename, $log, { - acl_short => 'public-read', - 'Content-Type' => 'text/plain', - }); - warn "Failed - ".$bucket->errstr if not $ok; -} - -sub flush_log { -# flush_log_really(); -} - - -sub load_conf { - my ($filename) = @_; - open my $f, '<', $filename or die "Failed to open $filename: $!"; - my %c; - while (<$f>) { - if (/^(.+?): (.+)/) { - $c{$1} = $2; - } - } - return %c; -} diff --git a/source/tools/autobuild2/startup.pl b/source/tools/autobuild2/startup.pl deleted file mode 100644 index ab32993fc0..0000000000 --- a/source/tools/autobuild2/startup.pl +++ /dev/null @@ -1,43 +0,0 @@ -=pod - -This script is executed on startup (via a service) on the build server. -It does as little as possible, since it is necessarily frozen -into the static machine image and is hard to update. - -The interesting code is passed in a zip file via the EC2 user-data API. - -=cut - -use strict; -use warnings; - -use LWP::Simple(); -use Archive::Zip; -use IO::String; - -open STDOUT, '>c:/0ad/autobuild/stdout.txt'; -open STDERR, '>c:/0ad/autobuild/stderr.txt'; -STDOUT->autoflush; -STDERR->autoflush; - -# This bit sometimes fails, for reasons I don't understand, so just keep trying it lots of times -for my $i (0..60) { - mkdir 'd:/0ad' and last; - warn "($i) $!"; - sleep 1; -} - -my $extract_root = 'd:/0ad/autobuild'; - -extract_user_data(); -do "$extract_root/run.pl"; - -sub extract_user_data { - my $data = LWP::Simple::get('http://169.254.169.254/2008-09-01/user-data'); - - my $zip = Archive::Zip->new(); - $zip->readFromFileHandle(new IO::String($data)); - for ($zip->members) { - $_->extractToFileNamed("$extract_root/" . $_->fileName); - } -} diff --git a/source/tools/autobuild2/startupservice/startupservice.sln b/source/tools/autobuild2/startupservice/startupservice.sln deleted file mode 100644 index fe37214646..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "startupservice", "startupservice\startupservice.vcproj", "{BF477C43-3A77-4B56-8819-85EAC97C143D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BF477C43-3A77-4B56-8819-85EAC97C143D}.Debug|Win32.ActiveCfg = Debug|Win32 - {BF477C43-3A77-4B56-8819-85EAC97C143D}.Debug|Win32.Build.0 = Debug|Win32 - {BF477C43-3A77-4B56-8819-85EAC97C143D}.Release|Win32.ActiveCfg = Release|Win32 - {BF477C43-3A77-4B56-8819-85EAC97C143D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/source/tools/autobuild2/startupservice/startupservice/AssemblyInfo.cpp b/source/tools/autobuild2/startupservice/startupservice/AssemblyInfo.cpp deleted file mode 100644 index c94f1722b5..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/AssemblyInfo.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "stdafx.h" - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly:AssemblyTitleAttribute("WFG Autobuild Startup")]; -[assembly:AssemblyDescriptionAttribute("")]; -[assembly:AssemblyConfigurationAttribute("")]; -[assembly:AssemblyCompanyAttribute("")]; -[assembly:AssemblyProductAttribute("startupservice")]; -[assembly:AssemblyCopyrightAttribute("")]; -[assembly:AssemblyTrademarkAttribute("")]; -[assembly:AssemblyCultureAttribute("")]; - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the value or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly:AssemblyVersionAttribute("1.0.*")]; - -[assembly:ComVisible(false)]; - -[assembly:CLSCompliantAttribute(true)]; - -[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; - diff --git a/source/tools/autobuild2/startupservice/startupservice/app.ico b/source/tools/autobuild2/startupservice/startupservice/app.ico deleted file mode 100644 index 3a5525fd79..0000000000 Binary files a/source/tools/autobuild2/startupservice/startupservice/app.ico and /dev/null differ diff --git a/source/tools/autobuild2/startupservice/startupservice/app.rc b/source/tools/autobuild2/startupservice/startupservice/app.rc deleted file mode 100644 index b51cf961ad..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/app.rc +++ /dev/null @@ -1,63 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon placed first or with lowest ID value becomes application icon - -LANGUAGE 9, 2 -#pragma code_page(1252) -1 ICON "app.ico" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" - "\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\0" -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/source/tools/autobuild2/startupservice/startupservice/resource.h b/source/tools/autobuild2/startupservice/startupservice/resource.h deleted file mode 100644 index 1f2251c2bd..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/resource.h +++ /dev/null @@ -1,3 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by app.rc diff --git a/source/tools/autobuild2/startupservice/startupservice/startupservice.vcproj b/source/tools/autobuild2/startupservice/startupservice/startupservice.vcproj deleted file mode 100644 index a7a4851140..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/startupservice.vcproj +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.cpp b/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.cpp deleted file mode 100644 index 14954f61a5..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// startupservice.cpp : main Windows Service project file. - -#include "stdafx.h" -#include -#include "startupserviceWinService.h" - -using namespace startupservice; -using namespace System::Text; -using namespace System::Security::Policy; -using namespace System::Reflection; - -//To install/uninstall the service, type: "startupservice.exe -Install [-u]" -int _tmain(int argc, _TCHAR* argv[]) -{ - if (argc >= 2) - { - if (argv[1][0] == _T('/')) - { - argv[1][0] = _T('-'); - } - - if (_tcsicmp(argv[1], _T("-Install")) == 0) - { - array^ myargs = System::Environment::GetCommandLineArgs(); - array^ args = gcnew array(myargs->Length - 1); - - // Set args[0] with the full path to the assembly, - Assembly^ assem = Assembly::GetExecutingAssembly(); - args[0] = assem->Location; - - Array::Copy(myargs, 2, args, 1, args->Length - 1); - AppDomain^ dom = AppDomain::CreateDomain(L"execDom"); - Type^ type = System::Object::typeid; - String^ path = type->Assembly->Location; - StringBuilder^ sb = gcnew StringBuilder(path->Substring(0, path->LastIndexOf(L"\\"))); - sb->Append(L"\\InstallUtil.exe"); - Evidence^ evidence = gcnew Evidence(); - dom->ExecuteAssembly(sb->ToString(), evidence, args); - } - } - else - { - ServiceBase::Run(gcnew startupserviceWinService()); - } -} diff --git a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.h b/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.h deleted file mode 100644 index e6a1f923c6..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -using namespace System; -using namespace System::Collections; -using namespace System::ServiceProcess; -using namespace System::ComponentModel; - -#include - -namespace startupservice { - - /// - /// Summary for startupserviceWinService - /// - /// - /// WARNING: If you change the name of this class, you will need to change the - /// 'Resource File Name' property for the managed resource compiler tool - /// associated with all .resx files this class depends on. Otherwise, - /// the designers will not be able to interact properly with localized - /// resources associated with this form. - public ref class startupserviceWinService : public System::ServiceProcess::ServiceBase - { - public: - startupserviceWinService() - { - InitializeComponent(); - // - //TODO: Add the constructor code here - // - } - protected: - /// - /// Clean up any resources being used. - /// - ~startupserviceWinService() - { - if (components) - { - delete components; - } - } - - /// - /// Set things in motion so your service can do its work. - /// - virtual void OnStart(array^ args) override - { - STARTUPINFO startupinfo = { 0 }; - startupinfo.cb = sizeof(startupinfo); - PROCESS_INFORMATION procinfo = { 0 }; - CreateProcessW(L"c:\\perl\\bin\\perl.exe", L"perl c:\\0ad\\autobuild\\startup.pl", NULL, NULL, FALSE, 0, NULL, NULL, &startupinfo, &procinfo); - } - - /// - /// Stop this service. - /// - virtual void OnStop() override - { - // TODO: Add code here to perform any tear-down necessary to stop your service. - } - - private: - /// - /// Required designer variable. - /// - System::ComponentModel::Container ^components; - -#pragma region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - void InitializeComponent(void) - { - this->components = gcnew System::ComponentModel::Container(); - this->CanStop = true; - this->CanPauseAndContinue = true; - this->AutoLog = true; - this->ServiceName = L"startupserviceWinService"; - } -#pragma endregion - }; -} diff --git a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.resX b/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.resX deleted file mode 100644 index c05ddc01f1..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/startupserviceWinService.resX +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/source/tools/autobuild2/startupservice/startupservice/stdafx.cpp b/source/tools/autobuild2/startupservice/startupservice/stdafx.cpp deleted file mode 100644 index ae2588dd98..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/stdafx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// startupservice.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" \ No newline at end of file diff --git a/source/tools/autobuild2/startupservice/startupservice/stdafx.h b/source/tools/autobuild2/startupservice/startupservice/stdafx.h deleted file mode 100644 index f74490ad10..0000000000 --- a/source/tools/autobuild2/startupservice/startupservice/stdafx.h +++ /dev/null @@ -1,11 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include -#include - -// TODO: reference additional headers your program requires here - diff --git a/source/tools/autobuild2/terminator.pl b/source/tools/autobuild2/terminator.pl deleted file mode 100755 index 48f180fcd6..0000000000 --- a/source/tools/autobuild2/terminator.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/perl - -=pod - -To prevent runaway server instances eating up lots of money, this script -is run frequently by cron and will kill any that have been running for too long. - -(The instances attempt to terminate themselves once they're finished building, -so typically this script won't be required.) - -To cope with dodgy clock synchronisation, two launch times are used per instance: -the launch_time reported by EC2's describe_instances, and the local_launch_time -stored in SQLite by manage.cgi. The process is killed if either time exceeds -the cutoff limit. - -=cut - -use strict; -use warnings; - -use DBI; -use Net::Amazon::EC2; -use DateTime::Format::ISO8601; - -my $root = '/var/svn/autobuild'; - -my %config = load_conf("$root/manage.conf"); - -my $dbh = DBI->connect("dbi:SQLite:dbname=$root/$config{database}", '', '', { RaiseError => 1 }); - -my $now = DateTime->now; - -print "\n", $now->iso8601, "\n"; - -# Builds should complete in <1 hour and then shut themselves off -# automatically. In case that fails, allow them to run up to 2 hours -# before forcibly terminating them, minus 20 minutes tolerance so we -# don't exceed 2 hours even if this script only runs once every ~10 -# minutes. -my $cutoff = DateTime::Duration->new(minutes => 120-20); - -my $ec2 = new Net::Amazon::EC2( - AWSAccessKeyId => $config{aws_access_key_id}, - SecretAccessKey => $config{aws_secret_access_key}, -); - -my @instances; - -my $reservations = $ec2->describe_instances(); -for my $reservation (@$reservations) { - for my $instance (@{$reservation->instances_set}) { - my ($local_launch_time) = $dbh->selectrow_array('SELECT local_launch_time FROM instances WHERE instance_id = ?', undef, $instance->instance_id); - push @instances, { - id => $instance->instance_id, - state => $instance->instance_state->name, - launch_time => $instance->launch_time, - local_launch_time => $local_launch_time, - key_name => $instance->key_name, - }; - } -} - -use Data::Dumper; print Dumper \@instances; -# @instances = ( { -# id => 'i-12345678', -# state => 'pending', -# launch_time => '2008-12-30T17:14:22.000Z', -# local_launch_time => '2008-12-30T17:14:22.000Z', -# } ); - -for my $instance (@instances) { - next if $instance->{state} eq 'terminated'; - next if $instance->{key_name} eq 'backupserver'; - - my $too_old = 0; - my $age = $now - DateTime::Format::ISO8601->parse_datetime($instance->{launch_time}); - $too_old = 1 if DateTime::Duration->compare($age, $cutoff) > 0; - if (defined $instance->{local_launch_time}) { - my $local_age = $now - DateTime::Format::ISO8601->parse_datetime($instance->{local_launch_time}); - $too_old = 1 if DateTime::Duration->compare($local_age, $cutoff) > 0; - } - next unless $too_old; - - print "Terminating $instance->{id}, launched at $instance->{launch_time} / ", ($instance->{local_launch_time} || ''), "\n"; - - log_action('terminate', $instance->{id}); - - $ec2->terminate_instances( - InstanceId => $instance->{id}, - ); -} - - -$dbh->disconnect; - -sub log_action { - my ($action, $params) = @_; - $dbh->do('INSERT INTO activity (user, ip, ua, action, params) VALUES (?, ?, ?, ?, ?)', - undef, 'local', '', '', $action, $params); -} - -sub load_conf { - my ($filename) = @_; - open my $f, '<', $filename or die "Failed to open $filename: $!"; - my %c; - while (<$f>) { - if (/^(.+?): (.+)/) { - $c{$1} = $2; - } - } - return %c; -} diff --git a/source/tools/autobuild2/vcbuild_env.bat b/source/tools/autobuild2/vcbuild_env.bat deleted file mode 100644 index 916e8035f7..0000000000 --- a/source/tools/autobuild2/vcbuild_env.bat +++ /dev/null @@ -1,2 +0,0 @@ -call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" -vcbuild %* diff --git a/source/tools/dds/DDS.pm b/source/tools/dds/DDS.pm deleted file mode 100644 index 737e1c503b..0000000000 --- a/source/tools/dds/DDS.pm +++ /dev/null @@ -1,132 +0,0 @@ -use strict; -use warnings; - -package DDS; - -sub new -{ - my $proto = shift; - my $class = ref($proto) || $proto; - - my $fh; - if (ref $_[0]) - { - $fh = $_[0]; - } - else - { - open $fh, '<', $_[0] or die "Cannot open $_[0]"; - binmode $fh; - } - - my %dds; - $dds{dwMagic} = pack L => read_DWORD($fh); - for (qw(Size Flags Height Width PitchOrLinearSize Depth MipMapCount)) - { - $dds{"dw$_"} = read_DWORD($fh); - } - read_DWORD($fh) for 1..11; # dwReserved1 - - $dds{dwFlags} = expand_flags($dds{dwFlags}, 'sd'); - - $dds{ddpfPixelFormat} = read_DDPIXELFORMAT($fh); - $dds{ddsCaps} = read_DDCAPS2($fh); - - read_DWORD($fh);# dwReserved2 - - bless \%dds, $class; -} - -sub getType -{ - my ($self) = @_; - if (grep $_ eq 'DDPF_RGB', @{$self->{ddpfPixelFormat}{dwFlags}}) - { - return pack N => ( - ((unpack L => 'RRRR') & $self->{ddpfPixelFormat}{dwRBitMask}) | - ((unpack L => 'GGGG') & $self->{ddpfPixelFormat}{dwGBitMask}) | - ((unpack L => 'BBBB') & $self->{ddpfPixelFormat}{dwBBitMask}) | - ((unpack L => 'AAAA') & $self->{ddpfPixelFormat}{dwRGBAlphaBitMask}) - ); - } - elsif (grep $_ eq 'DDPF_FOURCC', @{$self->{ddpfPixelFormat}{dwFlags}}) - { - return $self->{ddpfPixelFormat}{dwFourCC} - } - else - { - die "Unknown type"; - } -} - - -sub read_DWORD -{ - die "Failed to read DWORD" unless (read $_[0], my $b, 4) == 4; - return unpack L => $b; -} - -sub read_DDPIXELFORMAT -{ - my $r = { map +("dw$_" => read_DWORD($_[0])), - qw(Size Flags FourCC RGBBitCount RBitMask GBitMask BBitMask RGBAlphaBitMask) }; - - $r->{dwFourCC} = pack L => $r->{dwFourCC}; - $r->{dwFlags} = expand_flags($r->{dwFlags}, 'pf'); - - return $r; -} - -sub read_DDCAPS2 -{ - my $r = { map +("dw$_" => read_DWORD($_[0])), - qw(Caps1 Caps2) }; - - $r->{dwCaps1} = expand_flags($r->{dwCaps1}, 'cap1'); - $r->{dwCaps2} = expand_flags($r->{dwCaps2}, 'cap2'); - - return $r; -} - - - -my %flag_names = ( - sd => { - DDSD_CAPS => 0x00000001, - DDSD_HEIGHT => 0x00000002, - DDSD_WIDTH => 0x00000004, - DDSD_PITCH => 0x00000008, - DDSD_PIXELFORMAT => 0x00001000, - DDSD_MIPMAPCOUNT => 0x00020000, - DDSD_LINEARSIZE => 0x00080000, - DDSD_DEPTH => 0x00800000, - }, - pf => { - DDPF_ALPHAPIXELS => 0x00000001, - DDPF_FOURCC => 0x00000004, - DDPF_RGB => 0x00000040, - }, - cap1 => { - DDSCAPS_COMPLEX => 0x00000008, - DDSCAPS_TEXTURE => 0x00001000, - DDSCAPS_MIPMAP => 0x00400000, - }, - cap2 => { - DDSCAPS2_CUBEMAP => 0x00000200, - DDSCAPS2_CUBEMAP_POSITIVEX => 0x00000400, - DDSCAPS2_CUBEMAP_NEGATIVEX => 0x00000800, - DDSCAPS2_CUBEMAP_POSITIVEY => 0x00001000, - DDSCAPS2_CUBEMAP_NEGATIVEY => 0x00002000, - DDSCAPS2_CUBEMAP_POSITIVEZ => 0x00004000, - DDSCAPS2_CUBEMAP_NEGATIVEZ => 0x00008000, - DDSCAPS2_VOLUME => 0x00200000, - }, -); - -sub expand_flags -{ - my ($n, $name) = @_; - return [ grep $flag_names{$name}{$_} & $n, keys %{$flag_names{$name}} ]; -} - -1; diff --git a/source/tools/dds/dds_analyse.pl b/source/tools/dds/dds_analyse.pl deleted file mode 100644 index 64419055eb..0000000000 --- a/source/tools/dds/dds_analyse.pl +++ /dev/null @@ -1,47 +0,0 @@ -use DDS; -use Data::Dumper; -use File::Find; - -my @dds; -find({ - wanted => sub { - if (/(\.svn|CVS)$/) - { - $File::Find::prune = 1; - } - else - { - push @dds, $File::Find::name if /\.dds$/; - } - }, - no_chdir => 1, -}, "../../../binaries/data/mods/official/art/textures/"); - - -=pod -for my $f (@dds) -{ - my $dds = new DDS($f); - print "$f\t", $dds->getType(), "\n"; -} -=cut - -#=pod -my @c; -for my $f (@dds) -{ - my $dds = new DDS($f); - if ($dds->getType() eq 'ARGB') - { - $f =~ /(.*).dds/ or die; - push @c, $1; - } -} -print "textureconv -tga ".(join ' ', map "$_.dds", @c)."\n"; -print "textureconv -abgr ".(join ' ', map "$_.tga", @c)."\n"; -=cut - -=pod -my $dds = new DDS("../../../binaries/data/mods/official/art/textures/ui/session/status_pane.dds"); -print Dumper $dds; -=cut \ No newline at end of file