]>
git.saurik.com Git - apple/dyld.git/blob - bin/expand.rb
5 $availCmd = ENV["SDKROOT"] +
"/usr/local/libexec/availability.pl";
7 def versionString(vers
)
11 elsif vers
=~
/^(\d+).(\d+)$/
13 elsif vers
=~
/^(\d+).(\d+).(\d+)$/
17 uvers
= "#{$1}_#{$2}_#{$3}"
30 elsif vers
=~
/^(\d+).(\d+)$/
33 elsif vers
=~
/^(\d+).(\d+).(\d+)$/
38 "0x00#{major.to_s(16).rjust(2, '0')}#{minor.to_s(16).rjust(2, '0')}#{revision.to_s(16).rjust(2, '0')}"
41 def expandVersions(prefix
, arg
)
42 versionList
= `#{$availCmd} #{arg}`.gsub(/\s+/m
, ' ').strip
.split(" ")
43 versionList
.each
{ |version|
44 puts
"#define #{prefix}#{versionString(version)}".ljust(48, ' ') +
versionHex(version)
48 def expandPlatformVersions(prefix
, platform
, arg
)
49 versionList
= `#{$availCmd} #{arg}`.gsub(/\s+/m
, ' ').strip
.split(" ")
50 versionList
.each
{ |version|
51 puts
"static dyld_build_version_t dyld_platform_version_#{prefix}_#{versionString(version)}".ljust(72, ' ') +
"= { .platform = #{platform}, .version = #{versionHex(version)} };"
55 def versionSetsForOSes(versionSets
, key
, platform
, target
)
57 versionSets
.each
{ |k
,v
|
58 puts
"#define dyld_#{k}_os_versions dyld_platform_version_#{platform}_#{versionString(v[key].to_s)}"
60 puts
"#endif /* #{target} */"
63 def expandVersionSets()
64 versionSets
= YAML
.load(`#{$availCmd} --sets`)
65 versionSetsForOSes(versionSets
, "macos", "macOS", "TARGET_OS_OSX")
66 versionSetsForOSes(versionSets
, "ios", "iOS", "TARGET_OS_IOS")
67 versionSetsForOSes(versionSets
, "tvos", "tvOS", "TARGET_OS_TV")
68 versionSetsForOSes(versionSets
, "watchos", "watchOS", "TARGET_OS_WATCH")
69 versionSetsForOSes(versionSets
, "bridgeos", "bridgeOS", "TARGET_OS_BRIDGE")
73 if line
=~
/^\/\
/\@MAC_VERSION_DEFS\@$/
74 expandVersions("DYLD_MACOSX_VERSION_", "--macosx")
75 elsif line
=~
/^\/\
/\@IOS_VERSION_DEFS\@$/
76 expandVersions("DYLD_IOS_VERSION_", "--ios")
77 elsif line
=~
/^\/\
/\@WATCHOS_VERSION_DEFS\@$/
78 expandVersions("DYLD_WATCHOS_VERSION_", "--watchos")
79 elsif line
=~
/^\/\
/\@MACOS_PLATFORM_VERSION_DEFS\@$/
80 expandPlatformVersions("macOS", "PLATFORM_MACOS", "--macosx")
81 elsif line
=~
/^\/\
/\@IOS_PLATFORM_VERSION_DEFS\@$/
82 expandPlatformVersions("iOS", "PLATFORM_IOS", "--ios")
83 elsif line
=~
/^\/\
/\@WATCHOS_PLATFORM_VERSION_DEFS\@$/
84 expandPlatformVersions("watchOS", "PLATFORM_WATCHOS", "--watchos")
85 elsif line
=~
/^\/\
/\@TVOS_PLATFORM_VERSION_DEFS\@$/
86 expandPlatformVersions("tvOS", "PLATFORM_TVOS", "--appletvos")
87 elsif line
=~
/^\/\
/\@BRIDGEOS_PLATFORM_VERSION_DEFS\@$/
88 expandPlatformVersions("bridgeOS", "PLATFORM_BRIDGEOS", "--bridgeos")
89 elsif line
=~
/^\/\
/\@VERSION_SET_DEFS\@$/