bake 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +40 -0
- data/README.md +99 -0
- data/Rakefile +6 -0
- data/bake.gemspec +25 -0
- data/bin/bake +25 -10
- data/lib/bake.rb +21 -140
- data/lib/bake/book.rb +79 -0
- data/lib/bake/command.rb +29 -0
- data/lib/bake/command/invoke.rb +67 -0
- data/lib/bake/command/list.rb +76 -0
- data/lib/bake/command/top.rb +111 -0
- data/lib/bake/context.rb +103 -110
- data/lib/bake/loader.rb +82 -0
- data/lib/bake/loaders.rb +110 -0
- data/lib/bake/recipe.rb +109 -0
- data/lib/bake/version.rb +23 -0
- metadata +73 -85
- data/CHANGELOG +0 -38
- data/CONCEPTS +0 -54
- data/MIT-LICENSE +0 -21
- data/README +0 -38
- data/REFERENCE +0 -2
- data/TUTORIAL +0 -128
- data/lib/bake/addon.rb +0 -20
- data/lib/bake/configuration.rb +0 -126
- data/lib/bake/extensions.rb +0 -3
- data/lib/bake/extensions/class.rb +0 -11
- data/lib/bake/extensions/object.rb +0 -22
- data/lib/bake/extensions/string.rb +0 -22
- data/lib/bake/file_target.rb +0 -19
- data/lib/bake/plugin.rb +0 -49
- data/lib/bake/plugins/cpp.rb +0 -188
- data/lib/bake/plugins/cpp/darwin.rb +0 -26
- data/lib/bake/plugins/cpp/gcc.rb +0 -14
- data/lib/bake/plugins/cpp/gcc_toolset_base.rb +0 -101
- data/lib/bake/plugins/cpp/msvc.rb +0 -118
- data/lib/bake/plugins/cpp/qt.rb +0 -53
- data/lib/bake/plugins/cpp/toolset_base.rb +0 -56
- data/lib/bake/plugins/macro.rb +0 -18
- data/lib/bake/plugins/runner.rb +0 -40
- data/lib/bake/plugins/system.rb +0 -30
- data/lib/bake/project.rb +0 -91
- data/lib/bake/project_loader.rb +0 -116
- data/lib/bake/system_utils.rb +0 -42
- data/lib/bake/target.rb +0 -155
- data/lib/bake/toolset.rb +0 -25
- data/lib/bake_version.rb +0 -5
- data/test/test_bake.rb +0 -2
- data/test/test_configuration.rb +0 -58
data/lib/bake/system_utils.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
class SystemUtils
|
5
|
-
def initialize(options = {})
|
6
|
-
@options = options
|
7
|
-
if options[:dry_run]
|
8
|
-
@file_utils = FileUtils::DryRun
|
9
|
-
elsif options[:verbose]
|
10
|
-
@file_utils = FileUtils::Verbose
|
11
|
-
else
|
12
|
-
@file_utils = FileUtils
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def dry_run?
|
17
|
-
return @options[:dry_run]
|
18
|
-
end
|
19
|
-
|
20
|
-
def verbose?
|
21
|
-
return @options[:dry_run] || @options[:verbose]
|
22
|
-
end
|
23
|
-
|
24
|
-
def sh(*args)
|
25
|
-
cmd = args.join(' ')
|
26
|
-
puts cmd if verbose?
|
27
|
-
if !dry_run?
|
28
|
-
system(*args)
|
29
|
-
raise "error: #{cmd}" if !$? || !$?.success?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def fwrite(file, contents)
|
34
|
-
puts "writing '#{file}'" if verbose?
|
35
|
-
File.open(file, "w") { |f| f.puts(contents) } if !dry_run?
|
36
|
-
end
|
37
|
-
|
38
|
-
def method_missing(name, *args)
|
39
|
-
@file_utils.send(name, *args)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/bake/target.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'bake/configuration'
|
2
|
-
require 'bake/toolset'
|
3
|
-
|
4
|
-
module Bake
|
5
|
-
class Target
|
6
|
-
include Configuration
|
7
|
-
|
8
|
-
attr_reader :parent, :children, :deps, :posts, :toolset
|
9
|
-
attr_accessor :name
|
10
|
-
|
11
|
-
def initialize(parent, *args)
|
12
|
-
@parent = parent
|
13
|
-
@children = []
|
14
|
-
@deps = []
|
15
|
-
@posts = []
|
16
|
-
@stale = nil
|
17
|
-
parent.children << self if parent
|
18
|
-
|
19
|
-
@toolset = args.first.is_a?(Toolset) ? args.shift : nil
|
20
|
-
@building = false
|
21
|
-
props = args.last.respond_to?(:to_hash) ? args.pop : {}
|
22
|
-
props.each_pair { |name, val| opt(name => val) }
|
23
|
-
|
24
|
-
post_initialize(*args) if respond_to?(:post_initialize)
|
25
|
-
mix_in_toolset
|
26
|
-
end
|
27
|
-
|
28
|
-
def stale?
|
29
|
-
return @stale if !@stale.nil?
|
30
|
-
tmin = mtimes.min
|
31
|
-
@stale = deps.any? { |dep| dep.stale? || dep.mtimes.max > tmin }
|
32
|
-
return @stale
|
33
|
-
end
|
34
|
-
|
35
|
-
def products
|
36
|
-
return nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def built?
|
40
|
-
return @built
|
41
|
-
end
|
42
|
-
|
43
|
-
def build_r
|
44
|
-
return if @built
|
45
|
-
raise "circular dependency detected in '#{self}'" if @building
|
46
|
-
@building = true
|
47
|
-
deps.each { |dep| dep.build_r }
|
48
|
-
Dir.chdir(get(:cwdir)) do
|
49
|
-
if stale?
|
50
|
-
if products
|
51
|
-
outdir = get(:outdir)
|
52
|
-
toolset.sys.mkdir_p(outdir) if !File.exists?(outdir)
|
53
|
-
end
|
54
|
-
build if respond_to?(:build)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
@building = false
|
58
|
-
@built = true
|
59
|
-
posts.each { |post| post.build_r }
|
60
|
-
end
|
61
|
-
|
62
|
-
def clean_r
|
63
|
-
children.each { |child| child.clean_r }
|
64
|
-
clean
|
65
|
-
end
|
66
|
-
|
67
|
-
def clean
|
68
|
-
prods = products.make_array
|
69
|
-
toolset.sys.rm_f(prods) if !prods.empty?
|
70
|
-
end
|
71
|
-
|
72
|
-
def dep(*targets)
|
73
|
-
targets = normalize_targets(*targets)
|
74
|
-
targets.each { |target| add_dep(target) }
|
75
|
-
end
|
76
|
-
|
77
|
-
def add_dep(target)
|
78
|
-
deps << target
|
79
|
-
end
|
80
|
-
|
81
|
-
def post(*targets)
|
82
|
-
normalize_targets(*targets).each { |target| posts << target }
|
83
|
-
end
|
84
|
-
|
85
|
-
def current_project
|
86
|
-
return parent.current_project
|
87
|
-
end
|
88
|
-
|
89
|
-
def mtimes
|
90
|
-
prods = products.make_array
|
91
|
-
return [ Time.now ] if prods.empty?
|
92
|
-
return products.make_array.collect do |prod|
|
93
|
-
File.exists?(prod) ? File.mtime(prod) : Time.at(0)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
alias :id :name
|
98
|
-
|
99
|
-
def to_s
|
100
|
-
return "<#{class_name}: #{id}>"
|
101
|
-
end
|
102
|
-
|
103
|
-
protected
|
104
|
-
def class_name
|
105
|
-
return self.class.name.split('::').last
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
def normalize_targets(*targets)
|
110
|
-
normalized_targets = []
|
111
|
-
targets.flatten.each do |target|
|
112
|
-
if !target.is_a?(Target)
|
113
|
-
begin
|
114
|
-
# resolve normal targets
|
115
|
-
target = current_project.resolve(target)
|
116
|
-
rescue RuntimeError => e
|
117
|
-
# when no normal target exists, see if a file exists
|
118
|
-
if File.exists?(target)
|
119
|
-
target = FileTarget.new(self, toolset, target)
|
120
|
-
else
|
121
|
-
raise e
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
normalized_targets << target
|
126
|
-
end
|
127
|
-
return normalized_targets
|
128
|
-
end
|
129
|
-
|
130
|
-
def mix_in_toolset
|
131
|
-
return if !toolset
|
132
|
-
mixin_name = self.class.name.split('::').last
|
133
|
-
# collect all the relevant mixins
|
134
|
-
modules = []
|
135
|
-
toolset_class = toolset.class
|
136
|
-
while toolset_class && !toolset_class.equal?(::Object)
|
137
|
-
if toolset_class.const_defined?(mixin_name)
|
138
|
-
modules << toolset_class.const_get(mixin_name)
|
139
|
-
end
|
140
|
-
toolset_class = toolset_class.superclass
|
141
|
-
end
|
142
|
-
# add them in reverse order to preserve inheritance relations
|
143
|
-
modules.reverse_each do |mod|
|
144
|
-
extend(mod)
|
145
|
-
if mod.instance_methods.include?('post_initialize')
|
146
|
-
post_initialize
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
require 'bake/file_target'
|
154
|
-
require 'bake/project'
|
155
|
-
|
data/lib/bake/toolset.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'bake/plugin'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module Bake
|
5
|
-
class Toolset
|
6
|
-
include Addon
|
7
|
-
|
8
|
-
attr_reader :sys
|
9
|
-
|
10
|
-
def initialize(sys)
|
11
|
-
@sys = sys
|
12
|
-
end
|
13
|
-
|
14
|
-
def constructor(name, target_class)
|
15
|
-
toolset = self
|
16
|
-
command(name) do |*args|
|
17
|
-
block = args.last.is_a?(Proc) ? args.pop : nil
|
18
|
-
target = target_class.new(current, toolset, *args)
|
19
|
-
context_eval(target, &block) if block
|
20
|
-
return target
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
data/lib/bake_version.rb
DELETED
data/test/test_bake.rb
DELETED
data/test/test_configuration.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
$: << File.dirname(__FILE__) + '/../lib'
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'bake/configuration'
|
5
|
-
|
6
|
-
class ConfigTree
|
7
|
-
include Bake::Configuration
|
8
|
-
|
9
|
-
def initialize(parent = nil)
|
10
|
-
@parent = parent
|
11
|
-
parent.children << self if parent
|
12
|
-
@children = []
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
attr_reader :parent, :children
|
17
|
-
end
|
18
|
-
|
19
|
-
class TestConfigTree < Test::Unit::TestCase
|
20
|
-
def setup
|
21
|
-
@cfg = ConfigTree.new
|
22
|
-
@parent = ConfigTree.new
|
23
|
-
@child = ConfigTree.new(@parent)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_opt
|
27
|
-
assert_raise(RuntimeError) { @cfg.opt(:yes => true, :no => false) }
|
28
|
-
assert_raise(RuntimeError) { @cfg.opt(:yes => true, :no => false) }
|
29
|
-
|
30
|
-
@cfg.opt(:defines => 'DEBUG')
|
31
|
-
assert_equal(1, @cfg[:defines].size)
|
32
|
-
assert(@cfg[:defines].include?('DEBUG'))
|
33
|
-
|
34
|
-
@cfg.opt(:defines => 'WIN32')
|
35
|
-
assert_equal(2, @cfg[:defines].size)
|
36
|
-
assert(@cfg[:defines].include?('DEBUG'))
|
37
|
-
assert(@cfg[:defines].include?('WIN32'))
|
38
|
-
|
39
|
-
@cfg.opt(:libtype => 'static')
|
40
|
-
assert_equal('static', @cfg[:libtype])
|
41
|
-
|
42
|
-
@cfg.opt(:libtype => 'dynamic')
|
43
|
-
assert_equal('dynamic', @cfg[:libtype])
|
44
|
-
|
45
|
-
assert_raise(Bake::PropertyNotFoundException) { @cfg[:random] }
|
46
|
-
|
47
|
-
assert_equal(0, @child[:defines].size)
|
48
|
-
|
49
|
-
@parent.opt(:defines => 'DEBUG')
|
50
|
-
@child.opt(:defines => 'WIN32')
|
51
|
-
assert_equal(1, @parent[:defines].size)
|
52
|
-
assert(@child[:defines].include?('DEBUG'))
|
53
|
-
assert_equal(2, @child[:defines].size)
|
54
|
-
assert(@child[:defines].include?('DEBUG'))
|
55
|
-
assert(@child[:defines].include?('WIN32'))
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|