autobuild script ;)
authorRudolf Polzer <divVerent@alientrap.org>
Thu, 6 May 2010 14:58:03 +0000 (16:58 +0200)
committerRudolf Polzer <divVerent@alientrap.org>
Thu, 6 May 2010 14:58:03 +0000 (16:58 +0200)
misc/tools/xonotic-map-compiler
misc/tools/xonotic-map-compiler-autobuild [new file with mode: 0755]

index ae819b07f77905379c8eccca922d81c22f3e7971..3820aff435f1bb68db8bd3a2886f0c8613251e8c 100755 (executable)
@@ -99,6 +99,10 @@ while(@ARGV)
        {
                $options->{minimap} = undef;
        }
        {
                $options->{minimap} = undef;
        }
+       elsif($_ eq '-noshaderlist')
+       {
+               $options->{noshaderlist} = 1;
+       }
        elsif($_ eq '-order')
        {
                $options->{order} = [split /\s*,\s*/, shift @ARGV];
        elsif($_ eq '-order')
        {
                $options->{order} = [split /\s*,\s*/, shift @ARGV];
@@ -171,60 +175,65 @@ for my $m(@{$options->{maps}})
 
        my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
 
 
        my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
 
-       my $previous_shaderlist = undef;
-       my $shaderlist = "";
-       if(open my $fh, "<", "$XONOTICDIR/data/xonotic-maps.pk3dir/scripts/shaderlist.txt")
+       my $restore_shaderlist = sub { };
+       if(!$options->{noshaderlist})
        {
        {
-               while(<$fh>)
+               my $previous_shaderlist = undef;
+               my $shaderlist = "";
+               if(open my $fh, "<", "$XONOTICDIR/data/xonotic-maps.pk3dir/scripts/shaderlist.txt")
                {
                {
-                       $shaderlist .= $_;
-               }
+                       while(<$fh>)
+                       {
+                               $shaderlist .= $_;
+                       }
 
 
-               # we may have to restore the file on exit
-               $previous_shaderlist = $shaderlist
-                       if "$XONOTICDIR/data" eq $mapdir;
-       }
-       else
-       {
-               # possibly extract the shader list from a pk3?
-               local $ENV{N} = $XONOTICDIR;
-               $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`;
-       }
+                       # we may have to restore the file on exit
+                       $previous_shaderlist = $shaderlist
+                               if "$XONOTICDIR/data" eq $mapdir;
+               }
+               else
+               {
+                       # possibly extract the shader list from a pk3?
+                       local $ENV{N} = $XONOTICDIR;
+                       $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`;
+               }
 
 
-       my $shaderlist_new = "";
-       for(split /\r?\n|\r/, $shaderlist)
-       {
-               delete $shaders{$_};
-               $shaderlist_new .= "$_\n";
-       }
-       if(%shaders)
-       {
-               for(sort keys %shaders)
+               my $shaderlist_new = "";
+               for(split /\r?\n|\r/, $shaderlist)
                {
                {
+                       delete $shaders{$_};
                        $shaderlist_new .= "$_\n";
                }
                        $shaderlist_new .= "$_\n";
                }
-       }
-       else
-       {
-               $shaderlist_new = undef;
-       }
-
-       my $restore_shaderlist = sub
-       {
-               if(defined $shaderlist_new)
+               if(%shaders)
                {
                {
-                       if(defined $previous_shaderlist)
+                       for(sort keys %shaders)
                        {
                        {
-                               open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
-                               print $fh $previous_shaderlist;
-                               close $fh;
+                               $shaderlist_new .= "$_\n";
                        }
                        }
-                       else
+               }
+               else
+               {
+                       $shaderlist_new = undef;
+               }
+
+               $restore_shaderlist = sub
+               {
+                       if(defined $shaderlist_new)
                        {
                        {
-                               unlink "$mapdir/scripts/shaderlist.txt";
+                               if(defined $previous_shaderlist)
+                               {
+                                       open my $fh, ">", "$mapdir/scripts/shaderlist.txt";
+                                       print $fh $previous_shaderlist;
+                                       close $fh;
+                               }
+                               else
+                               {
+                                       unlink "$mapdir/scripts/shaderlist.txt";
+                               }
                        }
                        }
-               }
-       };
+               };
+       }
+
        local $SIG{INT} = sub
        {
                print "SIGINT caught, cleaning up...\n";
        local $SIG{INT} = sub
        {
                print "SIGINT caught, cleaning up...\n";
diff --git a/misc/tools/xonotic-map-compiler-autobuild b/misc/tools/xonotic-map-compiler-autobuild
new file mode 100755 (executable)
index 0000000..6683636
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+bspdir="$PWD/bspfiles"
+mkdir -p "$bspdir"
+cd data/xonotic-maps.pk3dir
+git for-each-ref 'refs/remotes' | while read -r HASH TYPE REFNAME; do
+       git checkout "$HASH"
+       for F in maps/*.map.options; do
+               if ! [ -f "$F" ]; then
+                       continue
+               fi
+               if ! [ -f "${F%.options}" ]; then
+                       continue
+               fi
+               M=${F#maps/}
+               M=${M%.map.options}
+               blobhash="$M"-`git ls-files -s -- "$F" | cut -d ' ' -f 2`-`git ls-files -s -- "${F%.options}" | cut -d ' ' -f 2`
+               if [ -f "$bspdir/$blobhash.pk3" ]; then
+                       continue
+               fi
+               (
+                       cd maps
+                       ../../../misc/tools/xonotic-map-compiler "$M" -noshaderlist `head -n 1 "../$F"` 2>&1 | tee "$M.log"
+               )
+               zip -9r "$bspdir/$blobhash.pk3" "maps/$M.bsp" "maps/$M.log" "maps/$M/" "gfx/${M}_mini.tga"
+       done
+done
+git checkout master