X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2Fbuild-fntable.pl;h=ed294aadbab9d8f62d003281f0cb1d865e2acf16;hp=f5e3b1f3dc69fc07c4d49854707b38783ef833d9;hb=4ade52359b6eba3621566dac79793a33aa4c915f;hpb=ff35d056d723c9a5ffe728dbba5f1c25e141be04 diff --git a/OSX/build-fntable.pl b/OSX/build-fntable.pl index f5e3b1f3..ed294aad 100755 --- a/OSX/build-fntable.pl +++ b/OSX/build-fntable.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2012 Jamie Zawinski +# Copyright © 2012-2013 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -9,7 +9,7 @@ # software for any purpose. It is provided "as is" without express or # implied warranty. # -# Generates a .h file that lists all the function tables we use, because +# Generates a .c file that lists all the function tables we use, because # CFBundleGetDataPointerForName doesn't work in "Archive" builds. # What a crock of shit. # @@ -23,7 +23,7 @@ require 5; use strict; my $progname = $0; $progname =~ s@.*/@@g; -my $version = q{ $Revision: 1.1 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; +my $version = q{ $Revision: 1.2 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 1; @@ -42,20 +42,40 @@ sub build_h($$) { my $suf = 'xscreensaver_function_table'; - my $body = "extern struct $suf"; + my $body = ("/* Generated file, do not edit.\n" . + " Created: " . localtime() . " by $progname $version.\n" . + " */\n" . + "\n" . + "#import \n" . + "#import \n" . + "\n" . + "extern NSDictionary *make_function_table_dict(void);\n" . + "\n"); + + $body .= "extern struct $suf"; foreach my $s (@names) { $body .= "\n *${s}_${suf},"; } $body =~ s/,\s*$/;/s; - $body .= ("\n\n" . - "static NSDictionary *make_function_tables_dict(void)\n{\n" . - " return\n [NSDictionary dictionaryWithObjectsAndKeys:\n"); - foreach my $s (@names) { - $body .= "\t[NSValue valueWithPointer:&${s}_${suf}], @\"${s}\",\n"; + sub line($$) { + my ($s, $suf) = @_; + return "\t[NSValue valueWithPointer:&${s}_${suf}], @\"${s}\",\n"; } - $body .= ("\tnil];\n" . - "}\n"); + + $body .= ("\n\n" . + "NSDictionary *make_function_table_dict(void)\n{\n" . + " return\n [NSDictionary dictionaryWithObjectsAndKeys:\n" . + "\n" . + "#if defined(APPLE2_ONLY)\n" . + " " . line('apple2', $suf) . + "#elif defined(PHOSPHOR_ONLY)\n" . + " " . line('phosphor', $suf) . + "#else\n"); + foreach my $s (@names) { $body .= line($s, $suf); } + $body .= ("#endif\n" . + "\tnil];\n" . + "}\n\n"); my $obody = ''; if (open (my $in, '<', $outfile)) { @@ -64,7 +84,11 @@ sub build_h($$) { close $in; } - if ($obody eq $body) { + # strip comments/date for diff. + my ($body2, $obody2) = ($body, $obody); + foreach ($body2, $obody2) { s@/\*.*?\*/@@gs; } + + if ($body2 eq $obody2) { print STDERR "$progname: $outfile: unchanged\n" if ($verbose > 1); } else { my $file_tmp = "$outfile.tmp"; @@ -88,7 +112,7 @@ sub error($) { } sub usage() { - print STDERR "usage: $progname [--verbose] program.app output.h\n"; + print STDERR "usage: $progname [--verbose] program.app output.c\n"; exit 1; }