forked from rubycocoa/rubycocoa
/
metaconfig
126 lines (97 loc) · 3.67 KB
/
metaconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*-ruby-*-
module RubyCocoaConfig
eval File.open('VERSION'){|f|f.read}
# "10.9.3"
SYSTEM_VERSION = `/usr/bin/sw_vers -productVersion`.chomp
module_function
def libruby_path
path = File.join(RbConfig::CONFIG['libdir'], RbConfig::CONFIG['LIBRUBY'])
unless File.exist?( path ) then
path = File.join(RbConfig::CONFIG['archdir'], RbConfig::CONFIG['LIBRUBY_A'])
end
return path
end
# "10.9"
def os_version
SYSTEM_VERSION.split('.')[0..1].join('.')
end
# "10.9" >= "10.7"
def os_version_ge?(other)
self.os_version.split('.').zip(other.split('.')) do |v1, v2|
v1 ||= 0
v2 ||= 0
if v1.to_i < v2.to_i
return false
end
end
return true
end
def framework_version
# "#{RubyCocoaConfig::VERSION}_RUBY-#{RUBY_VERSION}"
"A"
end
def archs
# collect ruby's -arch flags from RbConfig::CONFIG
flags = [RbConfig::CONFIG['CFLAGS'], RbConfig::CONFIG['LDFLAGS'],
RbConfig::CONFIG['ARCH_FLAG']].join(' ')
archs = flags.scan(/(?:\s?-arch\s+(\w+))/).flatten.uniq
archs.join(' ')
end
end
### install destination ###
add_path_config 'install-root', '',
'path to the root directory for Frameworks and "ProjectBuilder Extras"'
add_path_config 'frameworks', '/Library/Frameworks',
'path to the directory for installing RubyCocoa.framework'
if File.exist?('/Developer/Applications/Xcode.app') or File.exist?('/usr/bin/xcrun') then
if RubyCocoaConfig.os_version_ge?('10.7')
xcode_templates_dir = nil
else
xcode_templates_dir = '/Library/Application Support/Developer/Shared/Xcode/'
end
add_path_config 'xcode-extras',
xcode_templates_dir,
'path to the directory for "Xcode Extras"'
end
add_path_config 'examples', '/Developer/Examples',
'path to the directory for Examples'
add_path_config 'documentation', '/Developer/Documentation',
'path to the directory for Documentation'
# on OS X 10.11, RubyCocoa.framwork shoud not be @executable_path
add_bool_config 'build-as-embeddable', !RubyCocoaConfig.os_version_ge?('10.11'),
'yes, build the framework as embeddable (with INSTALL_PATH pointing to the current application\'s Frameworks directory)'
### build configuration ###
add_path_config 'ruby-header-dir', RbConfig::CONFIG['rubyhdrdir'] || RbConfig::CONFIG['archdir'],
'path to the ruby ruby.h header directory'
add_path_config 'ruby-archheader-dir', RbConfig::CONFIG['rubyarchhdrdir'] || RbConfig::CONFIG['archdir'],
'path to the ruby config.h header directory'
add_path_config 'libruby-path', RubyCocoaConfig.libruby_path,
'path to the libruby file'
add_path_config 'ri-dir',
"#{RbConfig::CONFIG['datadir']}/ri/#{RbConfig::CONFIG['ruby_version']}/site",
'the directory for ri files'
add_config 'macosx-deployment-target', 'version',
RubyCocoaConfig.os_version,
'target Mac OS X version'
sdkroot =
if RubyCocoaConfig.os_version_ge?('10.8')
`xcrun --sdk macosx --show-sdk-path`.chomp
else
''
end
add_config 'sdkroot', 'sdkroot-path', sdkroot, '$SDKROOT of Xcode.'
add_config 'target-archs', 'arch(s)', RubyCocoaConfig.archs,
'$ARCHS of Xcode. target architecture type(s)'
### versioning ###
add_config 'rubycocoa-version', 'name',
RubyCocoaConfig::VERSION + RubyCocoaConfig::STAGE,
'RubyCocoa version'
add_config 'rubycocoa-version-short', 'name',
RubyCocoaConfig::VERSION,
'RubyCocoa version short'
add_config 'rubycocoa-release-date', 'name',
RubyCocoaConfig::RELEASE_DATE, 'RubyCocoa release date'
add_config 'rubycocoa-svn-revision', 'name',
RubyCocoaConfig::SVN_REVISION, 'RubyCocoa subversion revision number'
add_config 'rubycocoa-framework-version', 'name',
RubyCocoaConfig.framework_version, 'RubyCocoa Framework version name'