bake 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +16 -0
- data/CONCEPTS +52 -0
- data/TUTORIAL +12 -23
- data/lib/bake.rb +7 -34
- data/lib/bake/addon.rb +20 -0
- data/lib/bake/context.rb +40 -60
- data/lib/bake/file_target.rb +14 -0
- data/lib/bake/plugin.rb +72 -0
- data/lib/bake/plugins/cpp.rb +122 -0
- data/lib/bake/plugins/cpp/darwin.rb +27 -0
- data/lib/bake/plugins/cpp/gcc.rb +9 -0
- data/lib/bake/plugins/cpp/gcc_toolset_base.rb +118 -0
- data/lib/bake/plugins/cpp/msvc.rb +124 -0
- data/lib/bake/plugins/cpp/qt.rb +50 -0
- data/lib/bake/plugins/cpp/toolset_base.rb +98 -0
- data/lib/bake/plugins/macro.rb +18 -0
- data/lib/bake/plugins/system.rb +46 -0
- data/lib/bake/project.rb +50 -0
- data/lib/bake/project_loader.rb +11 -15
- data/lib/bake/string_utils.rb +4 -0
- data/lib/bake/target.rb +43 -80
- data/lib/bake/toolset.rb +13 -6
- data/lib/bake_version.rb +1 -1
- metadata +19 -7
- data/lib/bake/common_scheme.rb +0 -42
- data/lib/bake/cpp_scheme.rb +0 -460
- data/lib/bake/qt_scheme.rb +0 -62
- data/lib/bake/scheme.rb +0 -104
- data/lib/bake/scheme_loader.rb +0 -28
data/lib/bake/qt_scheme.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'bake/toolset'
|
2
|
-
require 'bake/target'
|
3
|
-
require 'bake/cpp_scheme.rb'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
module Qt
|
7
|
-
class Moc < Bake::Toolset
|
8
|
-
def build(target)
|
9
|
-
raise "unknown target '#{target}'" if !target.is_a?(MocFile)
|
10
|
-
return if !stale?(target)
|
11
|
-
src = target.src
|
12
|
-
sh("moc -o #{target.output} #{target.src}")
|
13
|
-
end
|
14
|
-
|
15
|
-
def clean(target)
|
16
|
-
FileUtils.rm_f(target.output)
|
17
|
-
end
|
18
|
-
|
19
|
-
def stale?(target)
|
20
|
-
return true if !File.exists?(target.output)
|
21
|
-
return File.mtime(target.src) > File.mtime(target.output)
|
22
|
-
end
|
23
|
-
|
24
|
-
def sh(*args)
|
25
|
-
cmd = args.join(' ')
|
26
|
-
puts cmd
|
27
|
-
system(*args)
|
28
|
-
raise "error: #{cmd}" if !$? || !$?.success?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class MocFile < Bake::Target
|
33
|
-
attr_reader :output
|
34
|
-
attr_accessor :src
|
35
|
-
|
36
|
-
def initialize(parent, src)
|
37
|
-
super(parent)
|
38
|
-
ext = File.extname(src)
|
39
|
-
@output = File.basename(src, ext) + '.moc' + ext
|
40
|
-
@src = src
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module Cpp
|
46
|
-
class Library
|
47
|
-
def moc(*args)
|
48
|
-
return args.flatten.collect do |file|
|
49
|
-
Qt::MocFile.new(Cpp::Object.new(self), file)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class Executable
|
55
|
-
def moc(*args)
|
56
|
-
return args.flatten.collect do |file|
|
57
|
-
Qt::MocFile.new(Cpp::Object.new(self), file)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
data/lib/bake/scheme.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
require 'bake/target'
|
2
|
-
require 'bake/toolset'
|
3
|
-
|
4
|
-
module Bake
|
5
|
-
class Scheme
|
6
|
-
attr_reader :name, :targets, :toolsets, :toolset
|
7
|
-
|
8
|
-
def initialize(mod)
|
9
|
-
@name = underscore(mod.name)
|
10
|
-
@module = mod
|
11
|
-
@targets = []
|
12
|
-
@toolsets = []
|
13
|
-
populate_targets_and_toolsets
|
14
|
-
raise "no toolsets in scheme '#{@name}'" if @toolsets.size == 0
|
15
|
-
raise "no targets in scheme '#{@name}'" if @targets.size == 0
|
16
|
-
@accessors = {}
|
17
|
-
populate_accessors
|
18
|
-
end
|
19
|
-
|
20
|
-
def toolset=(toolset)
|
21
|
-
if !toolset.is_a?(Toolset)
|
22
|
-
ts = toolset_class(toolset.to_s)
|
23
|
-
raise "could not find toolset '#{toolset}'" if !ts
|
24
|
-
@toolset = ts.new
|
25
|
-
return
|
26
|
-
end
|
27
|
-
if !@toolsets.include?(toolset.class)
|
28
|
-
raise "toolset #{toolset.class.name} is not in scheme #{name}"
|
29
|
-
end
|
30
|
-
@toolset = toolset
|
31
|
-
end
|
32
|
-
|
33
|
-
def has_constructor?(accessor)
|
34
|
-
return accessors.has_key?(accessor)
|
35
|
-
end
|
36
|
-
|
37
|
-
def construct(type, *args)
|
38
|
-
if type.instance_of?(Class)
|
39
|
-
target_class = type
|
40
|
-
raise "#{type} not in #{name}" if !targets.include?(type)
|
41
|
-
else
|
42
|
-
target_class = accessors[type]
|
43
|
-
raise "no such constructor #{type}" if !target_class
|
44
|
-
end
|
45
|
-
target = target_class.new(*args)
|
46
|
-
return target
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
attr_reader :accessors
|
51
|
-
|
52
|
-
def underscore(str)
|
53
|
-
str = str.gsub(/[A-Z][a-z0-9]*/) { |val| val.downcase + '_' }.chop
|
54
|
-
return str.gsub('_::', '/')
|
55
|
-
end
|
56
|
-
|
57
|
-
def capitalize(str)
|
58
|
-
str = str.gsub(/[a-z0-9]+/) { |val| val.capitalize }
|
59
|
-
return str.gsub('_', '')
|
60
|
-
end
|
61
|
-
|
62
|
-
def toolset_class(name)
|
63
|
-
name = @module.name + '::' + capitalize(name)
|
64
|
-
return @toolsets.find { |t| t.name == name }
|
65
|
-
end
|
66
|
-
|
67
|
-
def populate_targets_and_toolsets
|
68
|
-
@module.constants.each do |const|
|
69
|
-
klazz = @module.const_get(const.to_sym)
|
70
|
-
if klazz.instance_of?(Class)
|
71
|
-
sup = klazz.superclass
|
72
|
-
while sup
|
73
|
-
if sup.equal?(Toolset)
|
74
|
-
@toolsets << klazz
|
75
|
-
break
|
76
|
-
elsif sup.equal?(Target)
|
77
|
-
@targets << klazz
|
78
|
-
break
|
79
|
-
end
|
80
|
-
sup = sup.superclass
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def populate_accessors
|
87
|
-
@targets.each do |target|
|
88
|
-
if target.const_defined?(:ACCESSORS)
|
89
|
-
accessors = target.const_get(:ACCESSORS)
|
90
|
-
if accessors.respond_to?(:to_ary)
|
91
|
-
accessors = accessors.to_ary
|
92
|
-
else
|
93
|
-
accessors = [ accessors ]
|
94
|
-
end
|
95
|
-
accessors.each { |accessor| @accessors[accessor] = target }
|
96
|
-
end
|
97
|
-
if !target.const_defined?(:SCHEME)
|
98
|
-
target.const_set(:SCHEME, self)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
data/lib/bake/scheme_loader.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'bake/scheme'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
class SchemeLoader
|
5
|
-
attr_reader :schemes
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@schemes = {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def scheme(name)
|
12
|
-
scheme = @schemes[name]
|
13
|
-
return scheme if scheme
|
14
|
-
return load_scheme(name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def load_scheme(name)
|
18
|
-
file = File.join(File.dirname(__FILE__), "#{name}_scheme.rb")
|
19
|
-
raise "unknown scheme '#{name}'" if !File.exists?(file)
|
20
|
-
require "bake/#{name}_scheme"
|
21
|
-
mod = Bake.const_get(name.capitalize.to_sym)
|
22
|
-
scheme = Scheme.new(mod)
|
23
|
-
@schemes[scheme.name] = scheme
|
24
|
-
return scheme
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|