blob: c874c2438e9d0b08baa400dcf2bf660aeb3b9cbf [file] [log] [blame]
Greg Clayton54e7afa2010-07-09 20:39:50 +00001#!/usr/bin/perl
2
3sub usage()
4{
5 print "Usage: generate-vers.pl /path/toproject.pbxproj";
6 exit(0);
7}
8
9(scalar @ARGV == 1) or usage();
10
11open $pbxproj, $ARGV[0] or die "Couldn't open ".$ARGV[0];
12
13$current_project_version = None;
14$product_name = None;
15
16while ($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
33if (!$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
42close $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
46print $file_string;