Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
| 3 | sub usage() |
| 4 | { |
| 5 | print "Usage: generate-vers.pl /path/toproject.pbxproj"; |
| 6 | exit(0); |
| 7 | } |
| 8 | |
| 9 | (scalar @ARGV == 1) or usage(); |
| 10 | |
| 11 | open $pbxproj, $ARGV[0] or die "Couldn't open ".$ARGV[0]; |
| 12 | |
| 13 | $current_project_version = None; |
| 14 | $product_name = None; |
| 15 | |
| 16 | while ($line = <$pbxproj>) |
| 17 | { |
| 18 | chomp ($line); |
| 19 | |
| 20 | if ($current_project_version == None && |
| 21 | $line =~ /CURRENT_PROJECT_VERSION = ([0-9]+)/) |
| 22 | { |
| 23 | $current_project_version = $1; |
| 24 | } |
| 25 | |
| 26 | if ($product_name == None && |
| 27 | $line =~ /productName = ([^;]+)/) |
| 28 | { |
| 29 | $product_name = $1; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if (!$product_name || !$current_project_version) |
| 34 | { |
| 35 | print "Couldn't get needed information from the .pbxproj"; |
| 36 | exit(-1); |
| 37 | } |
| 38 | |
| 39 | $uppercase_name = uc $product_name; |
| 40 | $lowercase_name = lc $product_name; |
| 41 | |
| 42 | close $pbxproj; |
| 43 | |
| 44 | $file_string = " const unsigned char ".$uppercase_name."VersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:".$uppercase_name." PROJECT:".$lowercase_name."-".$current_project_version."\" \"\\n\"; const double ".$uppercase_name."VersionNumber __attribute__ ((used)) = (double)".$current_project_version.".;\n"; |
| 45 | |
| 46 | print $file_string; |