• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/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$lldb_version = None;
14$lldb_train = None;
15$lldb_revision = None;
16$lldb_version_string = None;
17
18$product_name = "lldb";
19
20while ($line = <$pbxproj>)
21{
22  chomp ($line);
23
24  if ($lldb_version == None &&
25      $line =~ /CURRENT_PROJECT_VERSION = ([0-9]+).([0-9]+).([0-9]+)(.[0-9])?/)
26  {
27    $lldb_version = $1;
28    $lldb_train = $2;
29    $lldb_revision = $3;
30    $lldb_patchlevel = $4;
31
32    if ($lldb_patchlevel != None)
33    {
34      $lldb_version_string = $lldb_version.".".$lldb_train.".".$lldb_revision.".".$lldb_patchlevel;
35    }
36    else
37    {
38      $lldb_version_string = $lldb_version.".".$lldb_train.".".$lldb_revision;
39    }
40  }
41}
42
43if (!$product_name || !$lldb_version_string)
44{
45  print "Couldn't get needed information from the .pbxproj";
46  exit(-1);
47}
48
49$uppercase_name = uc $product_name;
50$lowercase_name = lc $product_name;
51
52close $pbxproj;
53
54$file_string = " const unsigned char liblldb_coreVersionString[] __attribute__ ((used)) = \"@(#)PROGRAM:".$uppercase_name."  PROJECT:".$lowercase_name."-".$lldb_version_string."\" \"\\n\"; const double liblldb_coreVersionNumber __attribute__ ((used)) = (double)".$lldb_version.".".$lldb_train.";\n";
55
56print $file_string;
57