ryb 0.0.0.dev → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/Gemfile.lock +69 -2
- data/README.md +6 -1
- data/bin/ryb +15 -5
- data/lib/ryb.rb +25 -6
- data/lib/ryb/application.rb +24 -0
- data/lib/ryb/architecture.rb +16 -0
- data/lib/ryb/architectures/x86.rb +11 -0
- data/lib/ryb/architectures/x86_64.rb +11 -0
- data/lib/ryb/configuration.rb +16 -0
- data/lib/ryb/library.rb +29 -0
- data/lib/ryb/name.rb +9 -0
- data/lib/ryb/ninja.rb +181 -0
- data/lib/ryb/project.rb +34 -0
- data/lib/ryb/properties.rb +10 -0
- data/lib/ryb/properties/architectures.rb +32 -0
- data/lib/ryb/properties/configurations.rb +29 -0
- data/lib/ryb/properties/defines.rb +31 -0
- data/lib/ryb/properties/dependencies.rb +23 -0
- data/lib/ryb/properties/files.rb +25 -0
- data/lib/ryb/properties/flags.rb +33 -0
- data/lib/ryb/properties/named.rb +17 -0
- data/lib/ryb/properties/paths.rb +37 -0
- data/lib/ryb/properties/suffix.rb +17 -0
- data/lib/ryb/properties/targets.rb +36 -0
- data/lib/ryb/target.rb +16 -0
- data/lib/ryb/targets/linux.rb +11 -0
- data/lib/ryb/targets/macosx.rb +33 -0
- data/lib/ryb/targets/windows.rb +13 -0
- data/lib/ryb/version.rb +2 -1
- data/lib/ryb/visual_studio.rb +66 -0
- data/lib/ryb/windows.rb +40 -0
- data/lib/ryb/xcode.rb +145 -0
- data/lib/rybfile.rb +15 -0
- data/ryb.gemspec +7 -0
- data/ryb.sublime-project +19 -0
- metadata +119 -8
- data/lib/ryb/dsl.rb +0 -19
- data/lib/ryb/toolsets.rb +0 -17
data/lib/ryb/windows.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Ryb
|
2
|
+
module Windows
|
3
|
+
POSSIBLE_SDK_INSTALL_DIRECTORY_REGISTRY_KEYS =
|
4
|
+
["SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows",
|
5
|
+
"SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows"]
|
6
|
+
|
7
|
+
def self.sdk
|
8
|
+
if Ryb.platform == :windows
|
9
|
+
if ENV.key?('WindowsSdkDir')
|
10
|
+
ENV['WindowsSdkDir']
|
11
|
+
else
|
12
|
+
# TODO(mtwilliams): Escape, i.e. .gsub(/\\/,'/').gsub(/\ /,'\\ ')?
|
13
|
+
self.sdks.first
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.sdk?
|
19
|
+
!self.sdk.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.sdks
|
23
|
+
if Ryb.platform == :windows
|
24
|
+
require 'win32/registry'
|
25
|
+
@sdks ||= begin
|
26
|
+
(POSSIBLE_SDK_INSTALL_DIRECTORY_REGISTRY_KEYS.map do |key|
|
27
|
+
begin
|
28
|
+
::Win32::Registry::HKEY_CURRENT_USER.open(key, ::Win32::Registry::KEY_READ)['CurrentInstallFolder']
|
29
|
+
rescue
|
30
|
+
begin
|
31
|
+
::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['CurrentInstallFolder']
|
32
|
+
rescue
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end).compact
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ryb/xcode.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'ryb/project'
|
2
|
+
|
3
|
+
module Ryb
|
4
|
+
module XCode
|
5
|
+
module Project
|
6
|
+
end
|
7
|
+
|
8
|
+
module Target
|
9
|
+
def self.setup_for_version(xc_project, xc_target, version)
|
10
|
+
xc_target.build_configuration_list.set_setting('SDKROOT', "macosx#{version}")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.add_file_references(xc_project, xc_target, files)
|
14
|
+
sources = xc_project.main_group['Source'] || xc_project.main_group.new_group('Source')
|
15
|
+
files.each do |file|
|
16
|
+
*dirs, file = Pathname(file).each_filename.to_a
|
17
|
+
group = dirs.reduce(sources) {|group, dir| group[dir] || group.new_group(dir, dir)}
|
18
|
+
ref = group.new_file(file)
|
19
|
+
xc_target.add_file_references([ref])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.generate_project_files_for(project, opts={})
|
25
|
+
# TODO(mtwilliams): Take into account opts[:root].
|
26
|
+
xc_proj = Xcodeproj::Project.new("#{project.name}.xcodeproj")
|
27
|
+
puts "Generating #{xc_proj.path}..."
|
28
|
+
|
29
|
+
xc_products_group = xc_proj.main_group['Products']
|
30
|
+
xc_products_group_for_libs = xc_products_group.new_group('lib', 'lib')
|
31
|
+
xc_products_group_for_bins = xc_products_group.new_group('bin', 'bin')
|
32
|
+
|
33
|
+
project.configurations.each do |name, config|
|
34
|
+
xc_build_configuration = xc_proj.build_configuration_list[config.name]
|
35
|
+
xc_build_configuration ||= xc_proj.build_configuration_list[config.name.capitalize]
|
36
|
+
xc_build_configuration ||= xc_proj.add_build_configuration(config.name, :release)
|
37
|
+
xc_build_configuration.name = (config.name.pretty || config.name.capitalize)
|
38
|
+
defines = project.defines.merge(config.defines)
|
39
|
+
xc_build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = defines.map {|name, value| "#{name}=#{value}"}
|
40
|
+
end
|
41
|
+
|
42
|
+
xc_proj.build_configuration_list.set_setting('SYMROOT', opts[:built])
|
43
|
+
xc_proj.build_configuration_list.set_setting('CONFIGURATION_BUILD_DIR', opts[:built])
|
44
|
+
xc_proj.build_configuration_list.sort
|
45
|
+
|
46
|
+
(project.libraries + project.applications).each do |target|
|
47
|
+
puts " Adding '#{target.name.pretty || target.name}' as target..."
|
48
|
+
type = :application if target.is_a? Ryb::Application
|
49
|
+
type = {:static => :static_library, :dynamic => :dynamic_library}[target.linkage] if target.is_a? Ryb::Library
|
50
|
+
name = target.name
|
51
|
+
platform = :osx
|
52
|
+
deployment_target = (target.targets[:macosx].version.to_s if (target.targets[:macosx] and target.targets[:macosx].verison))
|
53
|
+
xc_target = xc_proj.new_target(type, name, platform, deployment_target)
|
54
|
+
|
55
|
+
# case type
|
56
|
+
# when :application
|
57
|
+
# xc_target.product_reference.move(xc_products_group_for_bins)
|
58
|
+
# when :static_library
|
59
|
+
# xc_target.product_reference.move(xc_products_group_for_libs)
|
60
|
+
# when :dynamic_library
|
61
|
+
# xc_target.product_reference.move(xc_products_group_for_bins)
|
62
|
+
# end
|
63
|
+
# xc_target.product_reference.set_source_tree(:group)
|
64
|
+
|
65
|
+
# if target.name.pretty
|
66
|
+
# xc_target.name = target.name.pretty
|
67
|
+
# xc_target.product_name = target.name
|
68
|
+
# end
|
69
|
+
|
70
|
+
if target.targets[:macosx] and target.targets[:macosx].verison
|
71
|
+
Target.setup_for_version(xc_proj, xc_target, target.targets[:macosx].version)
|
72
|
+
end
|
73
|
+
|
74
|
+
# TODO(mtwilliams): Refactor.
|
75
|
+
configs = ((project.configurations.keys | target.configurations.keys).map do |config|
|
76
|
+
project_config = project.configurations[config]
|
77
|
+
if project_config
|
78
|
+
project_config = project_config.dup
|
79
|
+
project_config.instance_variable_set(:@defines, project.defines.merge(project_config.defines))
|
80
|
+
end
|
81
|
+
target_config = target.configurations[config]
|
82
|
+
if target_config
|
83
|
+
target_config = target_config.dup
|
84
|
+
target_config.instance_variable_set(:@defines, target.defines.merge(target_config.defines))
|
85
|
+
end
|
86
|
+
config = if project_config and target_config
|
87
|
+
project_config.instance_variable_set(:@defines, project_config.defines.merge(target_config.defines))
|
88
|
+
project_config
|
89
|
+
else
|
90
|
+
project_config || target_config
|
91
|
+
end
|
92
|
+
|
93
|
+
[config.name, config]
|
94
|
+
end).to_h
|
95
|
+
|
96
|
+
configs.each do |name, config|
|
97
|
+
xc_build_configuration = xc_target.build_configuration_list[config.name]
|
98
|
+
xc_build_configuration ||= xc_target.build_configuration_list[config.name.capitalize]
|
99
|
+
xc_build_configuration ||= xc_target.add_build_configuration(config.name, :release)
|
100
|
+
xc_build_configuration.name = (config.name.pretty || config.name.capitalize)
|
101
|
+
xc_build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = config.defines.map {|name, value| "#{name}=#{value}"}
|
102
|
+
end
|
103
|
+
|
104
|
+
expand_path_variables = lambda { |path|
|
105
|
+
path.gsub(/\:built/, opts[:built])
|
106
|
+
}
|
107
|
+
|
108
|
+
includes = target.paths[:includes].map(&expand_path_variables).map(&File.method(:expand_path))
|
109
|
+
xc_target.build_configuration_list.set_setting('USER_HEADER_SEARCH_PATHS', includes)
|
110
|
+
libraries = target.paths[:libraries].map(&expand_path_variables).map(&File.method(:expand_path))
|
111
|
+
libraries.each(&FileUtils.method(:mkdir_p))
|
112
|
+
xc_target.build_configuration_list.set_setting('LIBRARY_SEARCH_PATHS', libraries)
|
113
|
+
binaries = target.paths[:binaries].map(&expand_path_variables).map(&File.method(:expand_path))
|
114
|
+
binaries.each(&FileUtils.method(:mkdir_p))
|
115
|
+
# ???
|
116
|
+
|
117
|
+
xc_target.build_configuration_list.sort
|
118
|
+
|
119
|
+
xc_target.build_configuration_list.set_setting('BUILT_PRODUCTS_DIR', opts[:built])
|
120
|
+
case type
|
121
|
+
when :application
|
122
|
+
xc_target.build_configuration_list.set_setting('CONFIGURATION_BUILD_DIR', File.join(opts[:built], 'bin'))
|
123
|
+
when :static_library
|
124
|
+
xc_target.build_configuration_list.set_setting('CONFIGURATION_BUILD_DIR', File.join(opts[:built], 'lib'))
|
125
|
+
when :dynamic_library
|
126
|
+
xc_target.build_configuration_list.set_setting('CONFIGURATION_BUILD_DIR', File.join(opts[:built], 'bin'))
|
127
|
+
end
|
128
|
+
|
129
|
+
Target.add_file_references(xc_proj, xc_target, target.files[:source])
|
130
|
+
|
131
|
+
target.dependencies.each do |dependency|
|
132
|
+
xc_target_for_dep = [*(xc_proj.targets.objects.select {|target| target.product_name == dependency})].first
|
133
|
+
if xc_target_for_dep
|
134
|
+
xc_target.add_dependency(xc_target_for_dep)
|
135
|
+
xc_target
|
136
|
+
else
|
137
|
+
raise "Not implemented, yet!"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
xc_proj.save
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
data/lib/rybfile.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'ryb'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
# TODO(mtwilliams): Improve the handling of Rybfiles.
|
5
|
+
module Rybfile
|
6
|
+
def self.load(path)
|
7
|
+
begin
|
8
|
+
return OpenStruct.new(:project => eval(File.read(path), binding(), path)).freeze
|
9
|
+
rescue SignalException, SystemExit
|
10
|
+
raise
|
11
|
+
rescue SyntaxError, Exception => e
|
12
|
+
raise "Invalid Rybfile!\n #{path}\n #{e}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/ryb.gemspec
CHANGED
@@ -20,5 +20,12 @@ Gem::Specification.new do |s|
|
|
20
20
|
# TODO(mtwilliams): Handle this gracefuly in `bin/ryb'.
|
21
21
|
s.require_paths = %w(lib)
|
22
22
|
|
23
|
+
s.add_dependency 'facets'
|
23
24
|
s.add_dependency 'gli'
|
25
|
+
s.add_dependency 'xcodeproj'
|
26
|
+
s.add_dependency 'ninja-gen'
|
27
|
+
|
28
|
+
s.add_development_dependency 'rspec'
|
29
|
+
s.add_development_dependency 'cucumber'
|
30
|
+
s.add_development_dependency 'aruba'
|
24
31
|
end
|
data/ryb.sublime-project
ADDED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ryb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: facets
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: gli
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,76 @@ dependencies:
|
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: xcodeproj
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ninja-gen
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cucumber
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aruba
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
27
111
|
description: Ryb is a clean and extensible Ruby DSL for generating project files.
|
28
112
|
email: m.t.williams@live.com
|
29
113
|
executables:
|
@@ -31,16 +115,44 @@ executables:
|
|
31
115
|
extensions: []
|
32
116
|
extra_rdoc_files: []
|
33
117
|
files:
|
118
|
+
- ".gitignore"
|
34
119
|
- Gemfile
|
35
120
|
- Gemfile.lock
|
36
121
|
- README.md
|
37
122
|
- Rakefile
|
38
123
|
- bin/ryb
|
39
124
|
- lib/ryb.rb
|
40
|
-
- lib/ryb/
|
41
|
-
- lib/ryb/
|
125
|
+
- lib/ryb/application.rb
|
126
|
+
- lib/ryb/architecture.rb
|
127
|
+
- lib/ryb/architectures/x86.rb
|
128
|
+
- lib/ryb/architectures/x86_64.rb
|
129
|
+
- lib/ryb/configuration.rb
|
130
|
+
- lib/ryb/library.rb
|
131
|
+
- lib/ryb/name.rb
|
132
|
+
- lib/ryb/ninja.rb
|
133
|
+
- lib/ryb/project.rb
|
134
|
+
- lib/ryb/properties.rb
|
135
|
+
- lib/ryb/properties/architectures.rb
|
136
|
+
- lib/ryb/properties/configurations.rb
|
137
|
+
- lib/ryb/properties/defines.rb
|
138
|
+
- lib/ryb/properties/dependencies.rb
|
139
|
+
- lib/ryb/properties/files.rb
|
140
|
+
- lib/ryb/properties/flags.rb
|
141
|
+
- lib/ryb/properties/named.rb
|
142
|
+
- lib/ryb/properties/paths.rb
|
143
|
+
- lib/ryb/properties/suffix.rb
|
144
|
+
- lib/ryb/properties/targets.rb
|
145
|
+
- lib/ryb/target.rb
|
146
|
+
- lib/ryb/targets/linux.rb
|
147
|
+
- lib/ryb/targets/macosx.rb
|
148
|
+
- lib/ryb/targets/windows.rb
|
42
149
|
- lib/ryb/version.rb
|
150
|
+
- lib/ryb/visual_studio.rb
|
151
|
+
- lib/ryb/windows.rb
|
152
|
+
- lib/ryb/xcode.rb
|
153
|
+
- lib/rybfile.rb
|
43
154
|
- ryb.gemspec
|
155
|
+
- ryb.sublime-project
|
44
156
|
homepage: https://RubifyYourBuild.com/
|
45
157
|
licenses:
|
46
158
|
- Public Domain
|
@@ -56,14 +168,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
168
|
version: 1.9.3
|
57
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
170
|
requirements:
|
59
|
-
- - "
|
171
|
+
- - ">="
|
60
172
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
173
|
+
version: '0'
|
62
174
|
requirements: []
|
63
175
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.4.
|
176
|
+
rubygems_version: 2.4.5
|
65
177
|
signing_key:
|
66
178
|
specification_version: 4
|
67
179
|
summary: Rubify Your Build!
|
68
180
|
test_files: []
|
69
|
-
has_rdoc:
|
data/lib/ryb/dsl.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Ryb
|
2
|
-
module DSL
|
3
|
-
# TODO(mtwilliams): Refactor into Ryb::Runner? Ryb::Builder?
|
4
|
-
@_on_project_callbacks = []
|
5
|
-
def on_project(&block); @_on_project_callbacks << block; end
|
6
|
-
|
7
|
-
def project(name=nil, opts={}, &block)
|
8
|
-
# TODO(mtwilliams): Freak out if a name is not specified.
|
9
|
-
# TODO(mtwilliams): Freak out if `opts` is malformed, i.e. an unknown
|
10
|
-
# option is specified or a specified option is invalid.
|
11
|
-
project = Docile.dsl_eval(Ryb::Project::Builder.new, &block).build
|
12
|
-
|
13
|
-
# TODO(mtwilliams): Handle exceptions.
|
14
|
-
@_on_project_callbacks.each {|callback| callback(project)}
|
15
|
-
|
16
|
-
return project
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/ryb/toolsets.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Ryb
|
2
|
-
module Toolsets
|
3
|
-
AVAILABLE = %w{gmake vs2008 vs2010 vs2012 vs2013 vs2015}
|
4
|
-
def self.available?(toolset)
|
5
|
-
AVAILABLE.include?(toolset)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.generate_project_files(toolset, projects)
|
10
|
-
# ({:gmake => Ryb::GMake.generate_project_files,
|
11
|
-
# :vs2008 => Ryb::VS2008.generate_project_files,
|
12
|
-
# :vs2010 => Ryb::VS2010.generate_project_files,
|
13
|
-
# :vs2012 => Ryb::VS2012.generate_project_files,
|
14
|
-
# :vs2013 => Ryb::VS2013.generate_project_files,
|
15
|
-
# :vs2015 => Ryb::VS2015.generate_project_files}[toolset](projects))
|
16
|
-
end
|
17
|
-
end
|