bake 0.1.2 → 0.2.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.
- 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
@@ -1,22 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# If +self+ is nil, returns a zero-length array, otherwise, if +self+
|
3
|
-
# responds to the +to_ary+ method, returns +to_ary+. Otherwise, returns
|
4
|
-
# an array of length one containing +self+.
|
5
|
-
def make_array
|
6
|
-
if nil?
|
7
|
-
return []
|
8
|
-
elsif respond_to?(:to_ary)
|
9
|
-
return to_ary
|
10
|
-
end
|
11
|
-
return [ self ]
|
12
|
-
end
|
13
|
-
|
14
|
-
# Returns the singleton class for this object's class.
|
15
|
-
def metaclass
|
16
|
-
return class << self; self; end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
main = self
|
21
|
-
Object.metaclass.send(:define_method, :main_object) { main }
|
22
|
-
Object.metaclass.send(:public, :main_object)
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def basename(options = {})
|
3
|
-
if options[:ext]
|
4
|
-
return File.basename(self, extname) + options[:ext]
|
5
|
-
elsif options[:noext]
|
6
|
-
return File.basename(self, extname)
|
7
|
-
end
|
8
|
-
return File.basename(self)
|
9
|
-
end
|
10
|
-
|
11
|
-
def dirname
|
12
|
-
return File.dirname(self)
|
13
|
-
end
|
14
|
-
|
15
|
-
def extname
|
16
|
-
return File.extname(self)
|
17
|
-
end
|
18
|
-
|
19
|
-
def underscore
|
20
|
-
return gsub(/([a-z0-9])([A-Z])/) { |val| $1 + '_' + $2 }.downcase
|
21
|
-
end
|
22
|
-
end
|
data/lib/bake/file_target.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'bake/target'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
class FileTarget < Target
|
5
|
-
attr_reader :path
|
6
|
-
|
7
|
-
def post_initialize(path)
|
8
|
-
@path = path
|
9
|
-
@built = true
|
10
|
-
end
|
11
|
-
|
12
|
-
def mtimes
|
13
|
-
raise "file no longer exists '#{path}'" if !File.exists?(path)
|
14
|
-
return [ File.mtime(path) ]
|
15
|
-
end
|
16
|
-
|
17
|
-
alias :id :path
|
18
|
-
end
|
19
|
-
end
|
data/lib/bake/plugin.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module Bake
|
2
|
-
module PluginManager
|
3
|
-
def load_plugin(full_name)
|
4
|
-
plugin = Object.main_object.class
|
5
|
-
full_name.to_s.split('::').each do |name|
|
6
|
-
plugin = load_child_plugin(plugin, name)
|
7
|
-
end
|
8
|
-
return plugin
|
9
|
-
end
|
10
|
-
|
11
|
-
def load_child_plugin(parent, name)
|
12
|
-
name = name.to_s
|
13
|
-
full_name = parent.equal?(Object.main_object.class) ?
|
14
|
-
name : parent.name + '::' + name
|
15
|
-
plugin_file = full_name.underscore.gsub('::', '/')
|
16
|
-
|
17
|
-
plugin = nil
|
18
|
-
if parent.const_defined?(name)
|
19
|
-
plugin = parent.const_get(name)
|
20
|
-
return plugin if plugin.equal?(Bake)
|
21
|
-
end
|
22
|
-
|
23
|
-
search_dirs.each do |rootdir|
|
24
|
-
if File.exists?(File.join(rootdir, plugin_file + '.rb'))
|
25
|
-
require plugin_file
|
26
|
-
if !plugin && parent.const_defined?(name)
|
27
|
-
plugin = parent.const_get(name)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if File.directory?(File.join(rootdir, plugin_file))
|
32
|
-
if !plugin
|
33
|
-
plugin = Module.new
|
34
|
-
parent.const_set(name, plugin)
|
35
|
-
end
|
36
|
-
plugin_manager = self
|
37
|
-
plugin.metaclass.send(
|
38
|
-
:define_method, :const_missing) do |name|
|
39
|
-
return plugin_manager.load_child_plugin(self, name)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
raise "could not find plugin '#{name}'" if !plugin
|
45
|
-
return plugin
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
data/lib/bake/plugins/cpp.rb
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
require 'bake/target'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
module Plugins
|
5
|
-
module Cpp
|
6
|
-
class SystemLibrary < Target
|
7
|
-
attr_reader :file
|
8
|
-
|
9
|
-
def post_initialize(name, file)
|
10
|
-
@built = true
|
11
|
-
@name = name
|
12
|
-
@file = file
|
13
|
-
end
|
14
|
-
|
15
|
-
def products
|
16
|
-
return nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def mtimes
|
20
|
-
return [ Time.at(0) ]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# +MainTarget+ is a mix-in for the +Library+ and +Executable+
|
25
|
-
# classes containing code common to both types of targets.
|
26
|
-
module MainTarget
|
27
|
-
# A special override of +stale?+ that ignores changes to
|
28
|
-
# dlls when determining if this target is stale. The only
|
29
|
-
# case in which a lib or exe should have to update when a
|
30
|
-
# dll dependency is updated is when the interface changes.
|
31
|
-
# Since exes and libs depend on the headers implicitly,
|
32
|
-
# they will be updated if the interface changes
|
33
|
-
# automatically.
|
34
|
-
def stale?
|
35
|
-
return @stale if !@stale.nil?
|
36
|
-
tmin = mtimes.min
|
37
|
-
@stale = deps.any? do |dep|
|
38
|
-
is_dll = dep.is_a?(Library) &&
|
39
|
-
dep[:libtype] == 'dynamic'
|
40
|
-
(dep.stale? || dep.mtimes.max > tmin) && !is_dll
|
41
|
-
end
|
42
|
-
return @stale
|
43
|
-
end
|
44
|
-
|
45
|
-
def add_dep(target)
|
46
|
-
if target.is_a?(FileTarget)
|
47
|
-
target = Source.new(self, toolset, target)
|
48
|
-
end
|
49
|
-
return super if !target.is_a?(Source)
|
50
|
-
deps << Cpp::Object.new(self, toolset, target)
|
51
|
-
end
|
52
|
-
|
53
|
-
def build
|
54
|
-
toolset.build(self)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class Library < Target
|
59
|
-
include MainTarget
|
60
|
-
|
61
|
-
def post_initialize(name)
|
62
|
-
@name = name
|
63
|
-
default(:libtype => 'static')
|
64
|
-
default(:debug_symbols? => false)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class Executable < Target
|
69
|
-
include MainTarget
|
70
|
-
|
71
|
-
def post_initialize(name)
|
72
|
-
@name = name
|
73
|
-
default(:debug_symbols? => false)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Enables +Executable+ to be run via a +Runner+ target.
|
77
|
-
def run_command
|
78
|
-
return toolset.exe_fn(self)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Source < Target
|
83
|
-
def post_initialize(source)
|
84
|
-
@source = source
|
85
|
-
@includes = IncludeList.new(self, toolset, source)
|
86
|
-
dep(source, @includes)
|
87
|
-
end
|
88
|
-
|
89
|
-
def path
|
90
|
-
return @source.path
|
91
|
-
end
|
92
|
-
|
93
|
-
alias :id :path
|
94
|
-
|
95
|
-
def mtimes
|
96
|
-
return @includes.mtimes
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class IncludeList < Target
|
101
|
-
attr_reader :includes
|
102
|
-
|
103
|
-
def post_initialize(source)
|
104
|
-
@src = source.path
|
105
|
-
if File.exists?(products)
|
106
|
-
@includes = load_includes
|
107
|
-
@calculated = false
|
108
|
-
else
|
109
|
-
@includes = calc_includes(@src)
|
110
|
-
@calculated = true
|
111
|
-
end
|
112
|
-
dep(source, *@includes)
|
113
|
-
end
|
114
|
-
|
115
|
-
def id
|
116
|
-
return @src
|
117
|
-
end
|
118
|
-
|
119
|
-
def build
|
120
|
-
@includes = calc_includes(@src) if !@calculated
|
121
|
-
toolset.sys.fwrite(products, includes.to_a.join("\n"))
|
122
|
-
end
|
123
|
-
|
124
|
-
def products
|
125
|
-
return "#{get(:outdir)}/#{@src.basename}.includes"
|
126
|
-
end
|
127
|
-
|
128
|
-
private
|
129
|
-
def load_includes
|
130
|
-
includes = Set.new
|
131
|
-
file = File.open(products)
|
132
|
-
while line = file.gets
|
133
|
-
line.chomp!
|
134
|
-
includes << line if !line.empty?
|
135
|
-
end
|
136
|
-
file.close
|
137
|
-
return includes
|
138
|
-
end
|
139
|
-
|
140
|
-
def calc_includes(src, include_fns = Set.new)
|
141
|
-
new_include_fns = Set.new
|
142
|
-
File.open(src) do |file|
|
143
|
-
incdirs = get(:incdirs)
|
144
|
-
while line = file.gets
|
145
|
-
if line =~ /\s*#\s*include\s+("|<)([^"]+)("|>)/
|
146
|
-
inc = $2
|
147
|
-
incdirs.each do |include_dir|
|
148
|
-
fn = File.join(include_dir, inc)
|
149
|
-
break if include_fns.include?(fn)
|
150
|
-
if File.exists?(fn)
|
151
|
-
new_include_fns << fn
|
152
|
-
include_fns << fn
|
153
|
-
break
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
new_include_fns.each do |inc|
|
161
|
-
calc_includes(inc, include_fns)
|
162
|
-
end
|
163
|
-
return include_fns
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class Object < Target
|
168
|
-
attr_reader :src
|
169
|
-
|
170
|
-
alias :id :src
|
171
|
-
|
172
|
-
def post_initialize(source)
|
173
|
-
@src = source.path
|
174
|
-
dep(source)
|
175
|
-
default(:exceptions? => true)
|
176
|
-
default(:rtti? => true)
|
177
|
-
default(:optimizations? => false)
|
178
|
-
default(:multithreaded? => true)
|
179
|
-
end
|
180
|
-
|
181
|
-
def build
|
182
|
-
toolset.build(self)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Bake
|
2
|
-
module Plugins
|
3
|
-
module Cpp
|
4
|
-
class Darwin < GccToolsetBase
|
5
|
-
def ar(lib)
|
6
|
-
obj_str, lib_str, flags = process_inputs(lib)
|
7
|
-
|
8
|
-
output = lib_fn(lib)
|
9
|
-
if lib[:libtype] == 'dynamic'
|
10
|
-
sys.sh("g++ #{flags} -dynamiclib -o #{output} #{obj_str} #{lib_str}")
|
11
|
-
else
|
12
|
-
sys.sh("ar rcs #{output} #{obj_str}")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def lib_fn(lib)
|
17
|
-
if lib[:libtype] == 'dynamic'
|
18
|
-
return File.join(lib[:outdir], "lib#{lib.name}.dylib")
|
19
|
-
end
|
20
|
-
return File.join(lib[:outdir], "lib#{lib.name}.a")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
data/lib/bake/plugins/cpp/gcc.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
module Plugins
|
5
|
-
module Cpp
|
6
|
-
class GccToolsetBase < ToolsetBase
|
7
|
-
def output(target)
|
8
|
-
if target.is_a?(Cpp::Object)
|
9
|
-
return obj_fn(target)
|
10
|
-
elsif target.is_a?(Cpp::Library)
|
11
|
-
return lib_fn(target)
|
12
|
-
elsif target.is_a?(Cpp::Executable)
|
13
|
-
return exe_fn(target)
|
14
|
-
end
|
15
|
-
return nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def compile(obj)
|
19
|
-
src = obj.src
|
20
|
-
output = obj_fn(obj)
|
21
|
-
flags = build_flags('-I', obj[:incdirs] + obj[:sysincdirs]) +
|
22
|
-
build_flags('-D', obj[:defines])
|
23
|
-
flags += obj[:cflags].join(' ')
|
24
|
-
flags += ' -fno-rtti' if !obj[:rtti?]
|
25
|
-
flags += ' -O3' if obj[:optimizations?]
|
26
|
-
flags += ' -g' if obj[:debug_symbols?]
|
27
|
-
sys.sh("g++ -c -o #{output} #{flags} #{src}")
|
28
|
-
end
|
29
|
-
|
30
|
-
def ar(lib)
|
31
|
-
obj_str, lib_str, flags = process_inputs(lib)
|
32
|
-
|
33
|
-
output = lib_fn(lib)
|
34
|
-
if lib[:libtype] == 'dynamic'
|
35
|
-
sys.sh("g++ #{flags} -shared -Wl,-soname,#{output} -o #{output} #{obj_str} #{lib_str}")
|
36
|
-
if lib.has_prop?(:gcc_lib_path)
|
37
|
-
fn = File.join(lib[:gcc_lib_path], output.basename)
|
38
|
-
File.symlink(output, fn) if !File.exists?(fn)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
sys.sh("ar rcs #{output} #{obj_str}")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def link(exe)
|
46
|
-
obj_str, lib_str, flags = process_inputs(exe)
|
47
|
-
|
48
|
-
output = exe_fn(exe)
|
49
|
-
sys.sh("g++ #{flags} -o #{output} #{obj_str} #{lib_str}")
|
50
|
-
end
|
51
|
-
|
52
|
-
def obj_fn(obj)
|
53
|
-
src = obj.src
|
54
|
-
basename = File.basename(src, File.extname(src)) + '.o'
|
55
|
-
return File.join(obj[:outdir], basename)
|
56
|
-
end
|
57
|
-
|
58
|
-
def lib_fn(lib)
|
59
|
-
if lib[:libtype] == 'dynamic'
|
60
|
-
return File.join(lib[:outdir], "lib#{lib.name}.so")
|
61
|
-
end
|
62
|
-
return File.join(lib[:outdir], "lib#{lib.name}.a")
|
63
|
-
end
|
64
|
-
|
65
|
-
def exe_fn(exe)
|
66
|
-
return File.join(exe[:outdir], exe.name)
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
def build_flags(flag, args)
|
71
|
-
return args.inject('') { |str, arg| str + "#{flag}#{arg} " }
|
72
|
-
end
|
73
|
-
|
74
|
-
def process_inputs(target)
|
75
|
-
output = output(target)
|
76
|
-
obj_str = ''
|
77
|
-
lib_str = ''
|
78
|
-
libdirs = []
|
79
|
-
target.deps.each do |input|
|
80
|
-
if input.is_a?(Cpp::Object)
|
81
|
-
fn = obj_fn(input)
|
82
|
-
obj_str += fn + ' '
|
83
|
-
elsif input.is_a?(Cpp::SystemLibrary)
|
84
|
-
lib_str += '-l' + input.file + ' '
|
85
|
-
elsif input.is_a?(Cpp::Library)
|
86
|
-
fn = lib_fn(input)
|
87
|
-
lib_str += '-l' + input.name + ' '
|
88
|
-
libdir = File.dirname(fn)
|
89
|
-
libdirs << libdir if !libdirs.include?(libdir)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
libdirs.concat(target[:libdirs])
|
94
|
-
flags = build_flags('-L', libdirs)
|
95
|
-
return [ obj_str, lib_str, flags ]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|