ryb 0.0.0.dev → 0.1.0

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.
@@ -0,0 +1,34 @@
1
+ require 'ryb/name'
2
+ require 'ryb/properties'
3
+
4
+ require 'ryb/architecture'
5
+ require 'ryb/configuration'
6
+ require 'ryb/library'
7
+ require 'ryb/application'
8
+
9
+ module Ryb
10
+ class Project
11
+ include Properties::Named
12
+ include Properties::Defines
13
+ include Properties::Flags
14
+ include Properties::Paths
15
+ include Properties::Architectures
16
+ include Properties::Targets
17
+ include Properties::Configurations
18
+
19
+ def initialize(name, opts={})
20
+ @name = Name.new(name, opts[:pretty])
21
+ yield self if block_given?
22
+ end
23
+
24
+ def libraries; @libraries ||= [] end
25
+ def library(*args, &block)
26
+ self.libraries << Library.new(*args, &block)
27
+ end
28
+
29
+ def applications; @applications ||= [] end
30
+ def application(*args, &block)
31
+ self.applications << Application.new(*args, &block)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ require 'ryb/properties/named'
2
+ require 'ryb/properties/suffix'
3
+ require 'ryb/properties/defines'
4
+ require 'ryb/properties/flags'
5
+ require 'ryb/properties/paths'
6
+ require 'ryb/properties/files'
7
+ require 'ryb/properties/dependencies'
8
+ require 'ryb/properties/architectures'
9
+ require 'ryb/properties/targets'
10
+ require 'ryb/properties/configurations'
@@ -0,0 +1,32 @@
1
+ require 'ryb/architectures/x86'
2
+ require 'ryb/architectures/x86_64'
3
+
4
+ module Ryb
5
+ module Properties
6
+ module Architectures
7
+ module ClassMethods
8
+ end
9
+
10
+ module InstanceMethods
11
+ def architectures
12
+ @architectures ||= {}
13
+ end
14
+
15
+ def architecture(name, &block)
16
+ arch = {:x86 => Ryb::Architectures::X86,
17
+ :x86_64 => Ryb::Architectures::X86_64}[name].new(&block)
18
+ architectures.merge!(name => arch) do |_, *archs|
19
+ archs[0].suffix ||= archs[1].suffix
20
+ archs[0].defines.merge!(archs[1].defines)
21
+ archs[0]
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.included(klass)
27
+ klass.extend(ClassMethods)
28
+ klass.include(InstanceMethods)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ module Ryb
2
+ module Properties
3
+ module Configurations
4
+ module ClassMethods
5
+ end
6
+
7
+ module InstanceMethods
8
+ def configurations
9
+ @configurations ||= {}
10
+ end
11
+
12
+ def configuration(name, opts={}, &block)
13
+ config = Configuration.new(name, opts, &block)
14
+ configurations.merge!(name => config) do |_, *configs|
15
+ configs[0].suffix ||= configs[1].suffix
16
+ configs[0].defines.merge!(configs[1].defines)
17
+ configs[0].instance_variable_set(:@flags, configs[1].instance_variable_get(:@flags))
18
+ configs[0]
19
+ end
20
+ end
21
+ end
22
+
23
+ def self.included(klass)
24
+ klass.extend(ClassMethods)
25
+ klass.include(InstanceMethods)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ module Ryb
2
+ module Properties
3
+ module Defines
4
+ module ClassMethods
5
+ end
6
+
7
+ module InstanceMethods
8
+ def defines
9
+ @defines ||= {}
10
+ end
11
+
12
+ def define(new_defines)
13
+ defines.merge!((new_defines.map do |identifier, value|
14
+ if value.is_a? FalseClass
15
+ [identifier, '0']
16
+ elsif value.is_a? TrueClass
17
+ [identifier, '1']
18
+ else
19
+ [identifier, value.to_s]
20
+ end
21
+ end).to_h)
22
+ end
23
+ end
24
+
25
+ def self.included(klass)
26
+ klass.extend(ClassMethods)
27
+ klass.include(InstanceMethods)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ module Ryb
2
+ module Properties
3
+ module Dependencies
4
+ module ClassMethods
5
+ end
6
+
7
+ module InstanceMethods
8
+ def dependencies
9
+ @dependencies ||= []
10
+ end
11
+
12
+ def add_dependency(dependency)
13
+ dependencies.push(*dependency)
14
+ end
15
+ end
16
+
17
+ def self.included(klass)
18
+ klass.extend(ClassMethods)
19
+ klass.include(InstanceMethods)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,36 @@
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
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,33 @@
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
@@ -0,0 +1,13 @@
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,9 +1,10 @@
1
1
  module Ryb
2
2
  module VERSION #:nodoc:
3
- MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 'dev']
3
+ MAJOR, MINOR, PATCH, PRE = [0, 1, 0]
4
4
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
5
5
  end
6
6
 
7
+ # Returns the semantic version of Ryb.
7
8
  def self.version
8
9
  Ryb::VERSION::STRING
9
10
  end
@@ -0,0 +1,66 @@
1
+ module Ryb
2
+ module VisualStudio
3
+ POSSIBLE_INSTALL_DIRECTORY_REGISTRY_KEYS =
4
+ ["SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\12.0\\Setup\\VC",
5
+ "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\Setup\\VC",
6
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\12.0\\Setup\\VC",
7
+ "SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC",
8
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\11.0\\Setup\\VC",
9
+ "SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC",
10
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\11.0\\Setup\\VC",
11
+ "SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC",
12
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\10.0\\Setup\\VC",
13
+ "SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC",
14
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\10.0\\Setup\\VC",
15
+ "SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC",
16
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC",
17
+ "SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC",
18
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\9.0\\Setup\\VC",
19
+ "SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC",
20
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\8.0\\Setup\\VC",
21
+ "SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC",
22
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\8.0\\Setup\\VC",
23
+ "SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC",
24
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\7.1\\Setup\\VC",
25
+ "SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC",
26
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\7.1\\Setup\\VC",
27
+ "SOFTWARE\\Microsoft\\VCExpress\\7.1\\Setup\\VC",
28
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\7.0\\Setup\\VC",
29
+ "SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VC",
30
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\7.0\\Setup\\VC",
31
+ "SOFTWARE\\Microsoft\\VCExpress\\7.0\\Setup\\VC",
32
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\6.0\\Setup\\VC",
33
+ "SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\VC",
34
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\6.0\\Setup\\VC",
35
+ "SOFTWARE\\Microsoft\\VCExpress\\6.0\\Setup\\VC"]
36
+
37
+ def self.install
38
+ if Ryb.platform == :windows
39
+ if ENV.key?('VCInstallDir')
40
+ ENV['VCInstallDir']
41
+ else
42
+ # TODO(mtwilliams): Escape, i.e. .gsub(/\\/,'/').gsub(/\ /,'\\ ')?
43
+ self.installs.first
44
+ end
45
+ end
46
+ end
47
+
48
+ def self.installed?
49
+ !self.install.nil?
50
+ end
51
+
52
+ def self.installs
53
+ if Ryb.platform == :windows
54
+ require 'win32/registry'
55
+ @installs ||= begin
56
+ (POSSIBLE_INSTALL_DIRECTORY_REGISTRY_KEYS.map do |key|
57
+ begin
58
+ ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['ProductDir']
59
+ rescue
60
+ end
61
+ end).compact
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end