]>
git.saurik.com Git - apple/dyld.git/blob - bin/expand.rb
5 if ENV["DRIVERKITROOT"]
6 $availCmd = ENV["SDKROOT"] +
ENV["DRIVERKITROOT"] +
"/usr/local/libexec/availability.pl";
8 $availCmd = ENV["SDKROOT"] +
"/usr/local/libexec/availability.pl";
11 def versionString(vers
)
15 elsif vers
=~
/^(\d+).(\d+)$/
17 elsif vers
=~
/^(\d+).(\d+).(\d+)$/
21 uvers
= "#{$1}_#{$2}_#{$3}"
34 elsif vers
=~
/^(\d+).(\d+)$/
37 elsif vers
=~
/^(\d+).(\d+).(\d+)$/
42 "0x00#{major.to_s(16).rjust(2, '0')}#{minor.to_s(16).rjust(2, '0')}#{revision.to_s(16).rjust(2, '0')}"
45 def expandVersions(prefix
, arg
)
46 versionList
= `#{$availCmd} #{arg}`.gsub(/\s+/m
, ' ').strip
.split(" ")
47 versionList
.each
{ |version|
48 puts
"#define #{prefix}#{versionString(version)}".ljust(48, ' ') +
versionHex(version)
52 def expandPlatformVersions(prefix
, platform
, arg
)
53 versionList
= `#{$availCmd} #{arg}`.gsub(/\s+/m
, ' ').strip
.split(" ")
54 versionList
.each
{ |version|
55 puts
"static dyld_build_version_t dyld_platform_version_#{prefix}_#{versionString(version)}".ljust(72, ' ') +
"= { .platform = #{platform}, .version = #{versionHex(version)} };"
59 def versionSetsForOSes(versionSets
, key
, platform
, target
)
61 versionSets
.each
{ |k
,v
|
62 puts
"#define dyld_#{k}_os_versions dyld_platform_version_#{platform}_#{versionString(v[key].to_s)}"
64 puts
"#endif /* #{target} */"
67 def expandVersionSets()
68 versionSets
= YAML
.load(`#{$availCmd} --sets`)
69 versionSetsForOSes(versionSets
, "macos", "macOS", "TARGET_OS_OSX")
70 versionSetsForOSes(versionSets
, "ios", "iOS", "TARGET_OS_IOS")
71 versionSetsForOSes(versionSets
, "tvos", "tvOS", "TARGET_OS_TV")
72 versionSetsForOSes(versionSets
, "watchos", "watchOS", "TARGET_OS_WATCH")
73 versionSetsForOSes(versionSets
, "bridgeos", "bridgeOS", "TARGET_OS_BRIDGE")
77 if line
=~
/^\/\
/\@MAC_VERSION_DEFS\@$/
78 expandVersions("DYLD_MACOSX_VERSION_", "--macosx")
79 elsif line
=~
/^\/\
/\@IOS_VERSION_DEFS\@$/
80 expandVersions("DYLD_IOS_VERSION_", "--ios")
81 elsif line
=~
/^\/\
/\@WATCHOS_VERSION_DEFS\@$/
82 expandVersions("DYLD_WATCHOS_VERSION_", "--watchos")
83 elsif line
=~
/^\/\
/\@TVOS_VERSION_DEFS\@$/
84 expandVersions("DYLD_TVOS_VERSION_", "--appletvos")
85 elsif line
=~
/^\/\
/\@BRIDGEOS_VERSION_DEFS\@$/
86 expandVersions("DYLD_BRIDGEOS_VERSION_", "--bridgeos")
87 elsif line
=~
/^\/\
/\@MACOS_PLATFORM_VERSION_DEFS\@$/
88 expandPlatformVersions("macOS", "PLATFORM_MACOS", "--macosx")
89 elsif line
=~
/^\/\
/\@IOS_PLATFORM_VERSION_DEFS\@$/
90 expandPlatformVersions("iOS", "PLATFORM_IOS", "--ios")
91 elsif line
=~
/^\/\
/\@WATCHOS_PLATFORM_VERSION_DEFS\@$/
92 expandPlatformVersions("watchOS", "PLATFORM_WATCHOS", "--watchos")
93 elsif line
=~
/^\/\
/\@TVOS_PLATFORM_VERSION_DEFS\@$/
94 expandPlatformVersions("tvOS", "PLATFORM_TVOS", "--appletvos")
95 elsif line
=~
/^\/\
/\@BRIDGEOS_PLATFORM_VERSION_DEFS\@$/
96 expandPlatformVersions("bridgeOS", "PLATFORM_BRIDGEOS", "--bridgeos")
97 elsif line
=~
/^\/\
/\@VERSION_SET_DEFS\@$/