]> git.saurik.com Git - apple/dyld.git/blob - bin/expand.pl
dyld-519.2.1.tar.gz
[apple/dyld.git] / bin / expand.pl
1 #!/usr/bin/perl
2
3 use strict;
4
5
6 my $sdk = $ENV{"SDKROOT"};
7 my $availCmd = $sdk . "/usr/local/libexec/availability.pl";
8
9 sub expandVersions
10 {
11 my $macroPrefix = shift;
12 my $availArg = shift;
13
14 my $cmd = $availCmd . " " . $availArg;
15 my $versionList = `$cmd`;
16 my $tmp = $versionList;
17 while ($tmp =~ m/^\s*([\S]+)(.*)$/) {
18 my $vers = $1;
19 $tmp = $2;
20
21 my $major = 0;
22 my $minor = 0;
23 my $revision = 0;
24 my $uvers;
25
26 if ($vers =~ m/^(\d+)$/) {
27 $major = $1;
28 $uvers = sprintf("%d_0", $major);
29 } elsif ($vers =~ m/^(\d+).(\d+)$/) {
30 $major = $1;
31 $minor = $2;
32 $uvers = sprintf("%d_%d", $major, $minor);
33 } elsif ($vers =~ m/^(\d+).(\d+).(\d+)$/) {
34 $major = $1;
35 $minor = $2;
36 $revision = $3;
37 if ($revision == 0) {
38 $uvers = sprintf("%d_%d", $major, $minor);
39 }
40 else {
41 $uvers = sprintf("%d_%d_%d", $major, $minor, $revision);
42 }
43 }
44 printf "#define %s%-18s 0x00%02X%02X%02X\n", $macroPrefix, $uvers, $major, $minor, $revision;
45 }
46 }
47
48
49
50
51 while(<STDIN>)
52 {
53 if(m/^\/\/\@MAC_VERSION_DEFS\@$/) {
54 expandVersions("DYLD_MACOSX_VERSION_", "--macosx");
55 }
56 elsif(m/^\/\/\@IOS_VERSION_DEFS\@$/) {
57 expandVersions("DYLD_IOS_VERSION_", "--ios");
58 }
59 elsif(m/^\/\/\@WATCHOS_VERSION_DEFS\@$/) {
60 expandVersions("DYLD_WATCHOS_VERSION_", "--watchos");
61 }
62 else {
63 print $_;
64 }
65 }
66