ryb 0.1.3.1 → 0.2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +36 -47
  3. data/NOTES +0 -0
  4. data/README.md +3 -1
  5. data/TODO +4 -0
  6. data/bin/ryb +2 -42
  7. data/lib/ryb.rb +31 -20
  8. data/lib/ryb/cli.rb +103 -0
  9. data/lib/ryb/code.rb +7 -0
  10. data/lib/ryb/configuration.rb +18 -12
  11. data/lib/ryb/configurations.rb +9 -0
  12. data/lib/ryb/dependencies.rb +7 -0
  13. data/lib/ryb/dependency.rb +30 -0
  14. data/lib/ryb/dsl.rb +280 -0
  15. data/lib/ryb/environment.rb +9 -0
  16. data/lib/ryb/flags.rb +17 -0
  17. data/lib/ryb/gem.rb +58 -0
  18. data/lib/ryb/helpers/defaults.rb +26 -0
  19. data/lib/ryb/helpers/pretty_string.rb +47 -0
  20. data/lib/ryb/languages.rb +13 -0
  21. data/lib/ryb/name.rb +3 -5
  22. data/lib/ryb/ninja.rb +257 -200
  23. data/lib/ryb/paths.rb +7 -0
  24. data/lib/ryb/preprocessor.rb +10 -0
  25. data/lib/ryb/product.rb +31 -0
  26. data/lib/ryb/project.rb +6 -29
  27. data/lib/ryb/source_file.rb +62 -0
  28. data/lib/ryb/visual_studio.rb +93 -57
  29. data/lib/rybfile.rb +30 -10
  30. data/lib/rybfile/walker.rb +202 -0
  31. data/lib/yb.rb +4 -0
  32. data/lib/ybfile.rb +3 -0
  33. data/ryb.gemspec +18 -13
  34. data/ryb.sublime-project +18 -17
  35. metadata +45 -31
  36. data/lib/ryb/application.rb +0 -24
  37. data/lib/ryb/architecture.rb +0 -16
  38. data/lib/ryb/architectures/x86.rb +0 -11
  39. data/lib/ryb/architectures/x86_64.rb +0 -11
  40. data/lib/ryb/library.rb +0 -29
  41. data/lib/ryb/properties.rb +0 -10
  42. data/lib/ryb/properties/architectures.rb +0 -32
  43. data/lib/ryb/properties/configurations.rb +0 -29
  44. data/lib/ryb/properties/defines.rb +0 -31
  45. data/lib/ryb/properties/dependencies.rb +0 -23
  46. data/lib/ryb/properties/files.rb +0 -25
  47. data/lib/ryb/properties/flags.rb +0 -33
  48. data/lib/ryb/properties/named.rb +0 -17
  49. data/lib/ryb/properties/paths.rb +0 -37
  50. data/lib/ryb/properties/suffix.rb +0 -17
  51. data/lib/ryb/properties/targets.rb +0 -36
  52. data/lib/ryb/target.rb +0 -16
  53. data/lib/ryb/targets/linux.rb +0 -11
  54. data/lib/ryb/targets/macosx.rb +0 -33
  55. data/lib/ryb/targets/windows.rb +0 -13
  56. data/lib/ryb/version.rb +0 -11
  57. data/lib/ryb/windows.rb +0 -40
  58. data/lib/ryb/xcode.rb +0 -145
@@ -1,25 +0,0 @@
1
- module Ryb
2
- module Properties
3
- module Files
4
- module ClassMethods
5
- end
6
-
7
- module InstanceMethods
8
- def files
9
- @files ||= {
10
- :source => []
11
- }
12
- end
13
-
14
- def add_source_files(*files)
15
- self.files[:source].push(*((([*files]).flatten).map(&Dir.method(:glob)).flatten))
16
- end
17
- end
18
-
19
- def self.included(klass)
20
- klass.extend(ClassMethods)
21
- klass.include(InstanceMethods)
22
- end
23
- end
24
- end
25
- end
@@ -1,33 +0,0 @@
1
- module Ryb
2
- module Properties
3
- module Flags
4
- module ClassMethods
5
- end
6
-
7
- module InstanceMethods
8
- def flags
9
- @flags ||= {
10
- :generate_debug_symbols => false,
11
- :optimize => :none
12
- }
13
- end
14
-
15
- def generate_debug_symbols; flags[:generate_debug_symbols]; end
16
- def generate_debug_symbols=(do_generate_debug_symbols)
17
- flags[:generate_debug_symbols] = do_generate_debug_symbols
18
- end
19
-
20
- def optimize; flags[:optimize]; end
21
- def optimize=(optimization)
22
- raise "..." unless [:none, :size, :speed].include?(optimization)
23
- flags[:optimization] = optimization
24
- end
25
- end
26
-
27
- def self.included(klass)
28
- klass.extend(ClassMethods)
29
- klass.include(InstanceMethods)
30
- end
31
- end
32
- end
33
- end
@@ -1,17 +0,0 @@
1
- module Ryb
2
- module Properties
3
- module Named
4
- module ClassMethods
5
- end
6
-
7
- module InstanceMethods
8
- attr_reader :name
9
- end
10
-
11
- def self.included(klass)
12
- klass.extend(ClassMethods)
13
- klass.include(InstanceMethods)
14
- end
15
- end
16
- end
17
- end
@@ -1,37 +0,0 @@
1
- module Ryb
2
- module Properties
3
- module Paths
4
- module ClassMethods
5
- end
6
-
7
- module InstanceMethods
8
- def paths
9
- @paths ||= {
10
- :includes => [],
11
- :libraries => [],
12
- :binaries => []
13
- }
14
- end
15
-
16
- # TODO(mtwilliams): Refactor.
17
- # TODO(mtwilliams): Verify existence of paths.
18
- def add_includes_paths(*paths)
19
- self.paths[:includes].push(*(([*paths]).flatten))
20
- end
21
-
22
- def add_libraries_paths(*paths)
23
- self.paths[:libraries].push(*(([*paths]).flatten))
24
- end
25
-
26
- def add_binaries_paths(*paths)
27
- self.paths[:binaries].push(*(([*paths]).flatten))
28
- end
29
- end
30
-
31
- def self.included(klass)
32
- klass.extend(ClassMethods)
33
- klass.include(InstanceMethods)
34
- end
35
- end
36
- end
37
- end
@@ -1,17 +0,0 @@
1
- module Ryb
2
- module Properties
3
- module Suffix
4
- module ClassMethods
5
- end
6
-
7
- module InstanceMethods
8
- attr_accessor :suffix
9
- end
10
-
11
- def self.included(klass)
12
- klass.extend(ClassMethods)
13
- klass.include(InstanceMethods)
14
- end
15
- end
16
- end
17
- end
@@ -1,36 +0,0 @@
1
- require 'ryb/targets/windows'
2
- require 'ryb/targets/macosx'
3
- require 'ryb/targets/linux'
4
-
5
- module Ryb
6
- module Properties
7
- module Targets
8
- module ClassMethods
9
- end
10
-
11
- module InstanceMethods
12
- def targets
13
- @targets ||= {}
14
- end
15
-
16
- def target(name, &block)
17
- target = {:windows => Ryb::Targets::Windows,
18
- :macosx => Ryb::Targets::MacOSX,
19
- :linux => Ryb::Targets::Linux}[name].new(&block)
20
- targets.merge!(name => target) do |_, *targets|
21
- targets[0].instance_variable_set(:@version, targets[1].instance_variable_get(:@version))
22
- targets[0].suffix ||= targets[1].suffix
23
- targets[0].defines.merge!(targets[1].defines)
24
- targets[0].flags.merge!(targets[1].flags)
25
- targets[0]
26
- end
27
- end
28
- end
29
-
30
- def self.included(klass)
31
- klass.extend(ClassMethods)
32
- klass.include(InstanceMethods)
33
- end
34
- end
35
- end
36
- end
@@ -1,16 +0,0 @@
1
- require 'ryb/name'
2
- require 'ryb/properties'
3
-
4
- module Ryb
5
- class Target
6
- include Properties::Named
7
- include Properties::Suffix
8
- include Properties::Defines
9
- include Properties::Flags
10
-
11
- def initialize(name, opts={})
12
- @name = Name.new(name, opts[:pretty])
13
- yield self if block_given?
14
- end
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- require 'ryb/target'
2
-
3
- module Ryb
4
- module Targets
5
- class Linux < Target
6
- def initialize(&block)
7
- super('linux', pretty: 'Linux', &block)
8
- end
9
- end
10
- end
11
- end
@@ -1,33 +0,0 @@
1
- require 'ryb/target'
2
-
3
- module Ryb
4
- module Targets
5
- class MacOSX < Target
6
- class Version
7
- attr_accessor :major
8
- attr_accessor :minor
9
-
10
- def initialize(major, minor)
11
- @major = major; @minor = minor;
12
- end
13
-
14
- def to_s
15
- "#{major}.#{minor}"
16
- end
17
- end
18
-
19
- attr_reader :version
20
- def version=(version)
21
- raise "..." unless version =~ /^(\d+)\.(\d+)$/
22
- major, minor = *((/^(\d+)\.(\d+)$/.match(version))[1..2].map(&:to_i))
23
- raise "..." if major != 10
24
- raise "..." if minor <= 5
25
- @version = Version.new(major, minor)
26
- end
27
-
28
- def initialize(&block)
29
- super('macosx', pretty: 'Mac OS X', &block)
30
- end
31
- end
32
- end
33
- end
@@ -1,13 +0,0 @@
1
- require 'ryb/target'
2
-
3
- module Ryb
4
- module Targets
5
- class Windows < Target
6
- attr_accessor :sdk
7
-
8
- def initialize(&block)
9
- super('windows', pretty: 'Windows', &block)
10
- end
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- module Ryb
2
- module VERSION #:nodoc:
3
- MAJOR, MINOR, PATCH, PRE = [0, 1, 3, 1]
4
- STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
5
- end
6
-
7
- # Returns the semantic version of Ryb.
8
- def self.version
9
- Ryb::VERSION::STRING
10
- end
11
- end
@@ -1,40 +0,0 @@
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
@@ -1,145 +0,0 @@
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