teapot 0.9.10 → 1.0.0.pre.rc1
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 +4 -4
- data/.travis.yml +6 -3
- data/README.md +3 -4
- data/Rakefile +3 -6
- data/bin/teapot +3 -7
- data/lib/teapot/build.rb +166 -18
- data/lib/teapot/configuration.rb +0 -1
- data/lib/teapot/context.rb +37 -21
- data/lib/teapot/controller/build.rb +24 -7
- data/lib/teapot/controller/fetch.rb +1 -1
- data/lib/teapot/controller.rb +1 -0
- data/lib/teapot/definition.rb +1 -1
- data/lib/teapot/dependency.rb +2 -6
- data/lib/teapot/environment/base.rb +7 -15
- data/lib/teapot/environment/constructor.rb +28 -0
- data/lib/teapot/environment/flatten.rb +42 -1
- data/lib/teapot/environment/system.rb +3 -3
- data/lib/teapot/extractors/linker_extractor.rb +2 -2
- data/lib/teapot/loader.rb +9 -11
- data/lib/teapot/name.rb +4 -0
- data/lib/teapot/package.rb +5 -4
- data/lib/teapot/repository.rb +29 -1
- data/lib/teapot/rule.rb +196 -0
- data/lib/teapot/rulebook.rb +91 -0
- data/lib/teapot/target.rb +15 -40
- data/lib/teapot/version.rb +1 -1
- data/{lib/teapot/build/targets/application.rb → spec/teapot/build_spec.rb} +26 -29
- data/{test/test_teapot.rb → spec/teapot/context_spec.rb} +13 -13
- data/spec/teapot/dependency_spec.rb +113 -0
- data/spec/teapot/environment_spec.rb +91 -0
- data/{lib/teapot/build/graph.rb → spec/teapot/name_spec.rb} +26 -26
- data/{test/test_substitutions.rb → spec/teapot/substitutions_spec.rb} +36 -36
- data/{test → spec/teapot}/teapot.rb +1 -1
- data/teapot.gemspec +16 -9
- metadata +98 -51
- data/lib/teapot/build/component.rb +0 -69
- data/lib/teapot/build/file_list.rb +0 -67
- data/lib/teapot/build/linker.rb +0 -49
- data/lib/teapot/build/target.rb +0 -76
- data/lib/teapot/build/targets/compiler.rb +0 -83
- data/lib/teapot/build/targets/directory.rb +0 -63
- data/lib/teapot/build/targets/executable.rb +0 -56
- data/lib/teapot/build/targets/external.rb +0 -91
- data/lib/teapot/build/targets/files.rb +0 -82
- data/lib/teapot/build/targets/library.rb +0 -117
- data/lib/teapot/commands.rb +0 -139
- data/lib/teapot/controller/run.rb +0 -43
- data/lib/teapot/graph.rb +0 -136
- data/test/test_dependency.rb +0 -112
- data/test/test_environment.rb +0 -102
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'fileutils'
|
22
|
-
|
23
|
-
module Teapot
|
24
|
-
module Build
|
25
|
-
class Component
|
26
|
-
def initialize(root, name, environment)
|
27
|
-
@root = root
|
28
|
-
@name = name
|
29
|
-
@environment = environment
|
30
|
-
|
31
|
-
@parts = [@name]
|
32
|
-
end
|
33
|
-
|
34
|
-
attr :root
|
35
|
-
attr :name
|
36
|
-
attr :parts
|
37
|
-
|
38
|
-
def add(path)
|
39
|
-
@parts << path
|
40
|
-
end
|
41
|
-
|
42
|
-
def variant
|
43
|
-
@environment[:variant]
|
44
|
-
end
|
45
|
-
|
46
|
-
def destination_path
|
47
|
-
@environment[:build_prefix] + "source"
|
48
|
-
end
|
49
|
-
|
50
|
-
def prepare!
|
51
|
-
source_path = destination_path + @name
|
52
|
-
|
53
|
-
if source_path.exist?
|
54
|
-
source_path.rmtree
|
55
|
-
end
|
56
|
-
|
57
|
-
source_path.mkpath
|
58
|
-
|
59
|
-
@parts.each do |path|
|
60
|
-
full_path = @root + path
|
61
|
-
|
62
|
-
FileUtils.cp_r(full_path.children, source_path.to_s, :preserve => true)
|
63
|
-
end
|
64
|
-
|
65
|
-
return source_path
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'pathname'
|
22
|
-
require 'fileutils'
|
23
|
-
|
24
|
-
module Teapot
|
25
|
-
module Build
|
26
|
-
class FileList
|
27
|
-
include Enumerable
|
28
|
-
|
29
|
-
def self.[] (root, pattern, prefix = nil)
|
30
|
-
self.new(root, pattern, prefix)
|
31
|
-
end
|
32
|
-
|
33
|
-
def initialize(root, pattern, prefix = nil)
|
34
|
-
@root = root
|
35
|
-
@pattern = pattern
|
36
|
-
@prefix = Pathname.new(prefix || ".")
|
37
|
-
end
|
38
|
-
|
39
|
-
attr :root
|
40
|
-
attr :pattern
|
41
|
-
attr :prefix
|
42
|
-
|
43
|
-
def each(&block)
|
44
|
-
Pathname.glob(@root + @pattern).each &block
|
45
|
-
end
|
46
|
-
|
47
|
-
def copy(destination)
|
48
|
-
self.each do |path|
|
49
|
-
# Compute the destination path, which is formed using the relative path:
|
50
|
-
relative_path = path.relative_path_from(@root)
|
51
|
-
destination_path = destination + @prefix + relative_path
|
52
|
-
|
53
|
-
if path.directory?
|
54
|
-
# Make a directory at the destination:
|
55
|
-
destination_path.mkpath
|
56
|
-
else
|
57
|
-
# Make the path if it doesn't already exist:
|
58
|
-
destination_path.dirname.mkpath
|
59
|
-
|
60
|
-
# Copy the file to the destination:
|
61
|
-
FileUtils.cp(path, destination_path, :preserve => true)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/lib/teapot/build/linker.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/commands'
|
22
|
-
|
23
|
-
module Teapot
|
24
|
-
module Build
|
25
|
-
module Linker
|
26
|
-
class UnsupportedPlatform < StandardError
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.link_static(environment, library_file, objects)
|
30
|
-
if RUBY_PLATFORM =~ /darwin/
|
31
|
-
Commands.run(
|
32
|
-
environment[:libtool] || "libtool",
|
33
|
-
"-static", "-o", library_file, objects,
|
34
|
-
)
|
35
|
-
elsif RUBY_PLATFORM =~ /linux/
|
36
|
-
FileUtils.rm_rf library_file
|
37
|
-
|
38
|
-
Commands.run(
|
39
|
-
environment[:ar] || 'ar',
|
40
|
-
environment[:arflags] || "-cru",
|
41
|
-
library_file, objects
|
42
|
-
)
|
43
|
-
else
|
44
|
-
raise UnsupportedPlatform.new("Cannot determine linker for #{RUBY_PLATFORM}!")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/teapot/build/target.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/commands'
|
22
|
-
require 'teapot/environment'
|
23
|
-
|
24
|
-
require 'pathname'
|
25
|
-
require 'fileutils'
|
26
|
-
|
27
|
-
require 'teapot/build/linker'
|
28
|
-
require 'teapot/build/component'
|
29
|
-
require 'teapot/build/file_list'
|
30
|
-
|
31
|
-
module Teapot
|
32
|
-
module Build
|
33
|
-
class Target
|
34
|
-
def initialize(parent)
|
35
|
-
@parent = parent
|
36
|
-
@configure = nil
|
37
|
-
end
|
38
|
-
|
39
|
-
attr :parent
|
40
|
-
|
41
|
-
def root
|
42
|
-
@parent.root
|
43
|
-
end
|
44
|
-
|
45
|
-
def configure(&block)
|
46
|
-
@configure = Proc.new &block
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.target(*args, &block)
|
50
|
-
instance = self.new(*args)
|
51
|
-
|
52
|
-
if block_given?
|
53
|
-
instance.instance_eval(&block)
|
54
|
-
end
|
55
|
-
|
56
|
-
return instance
|
57
|
-
end
|
58
|
-
|
59
|
-
def execute(command, environment, *arguments)
|
60
|
-
if @configure
|
61
|
-
environment = environment.merge &@configure
|
62
|
-
end
|
63
|
-
|
64
|
-
# Flatten the environment to a hash:
|
65
|
-
flat_environment = environment.flatten
|
66
|
-
|
67
|
-
puts "Performing #{self.class}/#{command} for #{root}...".color(:cyan)
|
68
|
-
|
69
|
-
# Show the environment to the user:
|
70
|
-
Environment::System::dump(flat_environment)
|
71
|
-
|
72
|
-
self.send(command, flat_environment, *arguments)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'pathname'
|
22
|
-
|
23
|
-
require 'teapot/build/graph'
|
24
|
-
|
25
|
-
module Teapot
|
26
|
-
module Build
|
27
|
-
module Targets
|
28
|
-
module Compiler
|
29
|
-
def build_prefix!(environment)
|
30
|
-
build_prefix = Pathname.new(environment[:build_prefix]) + "compiled"
|
31
|
-
|
32
|
-
build_prefix.mkpath
|
33
|
-
|
34
|
-
return build_prefix
|
35
|
-
end
|
36
|
-
|
37
|
-
def link_prefix!(environment)
|
38
|
-
prefix = Pathname.new(environment[:build_prefix]) + "linked"
|
39
|
-
|
40
|
-
prefix.mkpath
|
41
|
-
|
42
|
-
return prefix
|
43
|
-
end
|
44
|
-
|
45
|
-
def compile!(environment, root, source_file, object_file, commands)
|
46
|
-
# Ensure there is a directory for the output file:
|
47
|
-
object_file.dirname.mkpath
|
48
|
-
|
49
|
-
# Make sure there is no pre-existing object file
|
50
|
-
object_file.rmtree if object_file.exist?
|
51
|
-
|
52
|
-
case source_file.extname
|
53
|
-
when ".cpp", ".mm"
|
54
|
-
commands.run(
|
55
|
-
environment[:cxx],
|
56
|
-
environment[:cxxflags],
|
57
|
-
"-c", root + source_file, "-o", object_file
|
58
|
-
)
|
59
|
-
when ".c", ".m"
|
60
|
-
commands.run(
|
61
|
-
environment[:cc],
|
62
|
-
environment[:cflags],
|
63
|
-
"-c", root + source_file, "-o", object_file
|
64
|
-
)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def compile(environment, root, source_file, commands)
|
69
|
-
object_file = (build_prefix!(environment) + source_file).sub_ext('.o')
|
70
|
-
|
71
|
-
# The graph is recreated once per file. This could be improved.
|
72
|
-
graph = Build::dependency_graph(environment)
|
73
|
-
|
74
|
-
if graph.regenerate?(object_file, root + source_file)
|
75
|
-
compile!(environment, root, source_file, object_file, commands)
|
76
|
-
end
|
77
|
-
|
78
|
-
return object_file
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/build/target'
|
22
|
-
|
23
|
-
module Teapot
|
24
|
-
module Build
|
25
|
-
module Targets
|
26
|
-
class Directory < Build::Target
|
27
|
-
BUILD_FILE = "build.rb"
|
28
|
-
|
29
|
-
def initialize(parent, root = nil)
|
30
|
-
super parent
|
31
|
-
|
32
|
-
@root = root
|
33
|
-
@targets = []
|
34
|
-
end
|
35
|
-
|
36
|
-
def root
|
37
|
-
@root || @parent.root
|
38
|
-
end
|
39
|
-
|
40
|
-
attr :targets
|
41
|
-
|
42
|
-
def << (target)
|
43
|
-
@targets << target
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_directory(path)
|
47
|
-
directory = Directory.target(self, @root + path)
|
48
|
-
|
49
|
-
build_path = (directory.root + BUILD_FILE).to_s
|
50
|
-
directory.instance_eval(File.read(build_path), build_path)
|
51
|
-
|
52
|
-
self << directory
|
53
|
-
end
|
54
|
-
|
55
|
-
def execute(command, *arguments)
|
56
|
-
@targets.each do |target|
|
57
|
-
target.execute(command, *arguments)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/build/targets/library'
|
22
|
-
|
23
|
-
module Teapot
|
24
|
-
module Build
|
25
|
-
module Targets
|
26
|
-
class Executable < Library
|
27
|
-
def subdirectory
|
28
|
-
options[:subdirectory] || "bin"
|
29
|
-
end
|
30
|
-
|
31
|
-
def link(environment, objects)
|
32
|
-
executable_file = link_prefix!(environment) + @name
|
33
|
-
|
34
|
-
graph = Build::dependency_graph(environment)
|
35
|
-
|
36
|
-
if graph.regenerate?(executable_file, objects + dependent_libraries(environment))
|
37
|
-
Commands.run(
|
38
|
-
environment[:cxx],
|
39
|
-
environment[:cxxflags],
|
40
|
-
"-o", executable_file, objects,
|
41
|
-
environment[:ldflags]
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
return executable_file
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class Directory
|
50
|
-
def compile_executable(*args, &block)
|
51
|
-
self << Executable.target(self, *args, &block)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/build/target'
|
22
|
-
require 'digest/md5'
|
23
|
-
|
24
|
-
module Teapot
|
25
|
-
module Build
|
26
|
-
module Targets
|
27
|
-
class External < Build::Target
|
28
|
-
# This file contains a checksum of the build environment. If it changes, even though the source code hasn't changed, it means that we need to recompile.
|
29
|
-
ENVIRONMENT_CHECKSUM_FILE = ".teapot-environment-checksum"
|
30
|
-
|
31
|
-
def initialize(parent, directory, &block)
|
32
|
-
super parent
|
33
|
-
|
34
|
-
@directory = directory
|
35
|
-
|
36
|
-
# Callback for preparing the target and compiling/installing the target.
|
37
|
-
@install = block
|
38
|
-
end
|
39
|
-
|
40
|
-
def root
|
41
|
-
@parent.root + @directory
|
42
|
-
end
|
43
|
-
|
44
|
-
def build(values)
|
45
|
-
return unless @install
|
46
|
-
|
47
|
-
source_path = @parent.root + @directory
|
48
|
-
build_source_path = values[:build_prefix] + @directory
|
49
|
-
build_source_checksum_path = build_source_path + ENVIRONMENT_CHECKSUM_FILE
|
50
|
-
|
51
|
-
fresh = false
|
52
|
-
|
53
|
-
# Check the environment checksum to catch any changes to the build environment:
|
54
|
-
if build_source_checksum_path.exist? and File.read(build_source_checksum_path.to_s) != checksum(values)
|
55
|
-
FileUtils.rm_rf(build_source_path.to_s) if build_source_path.exist?
|
56
|
-
end
|
57
|
-
|
58
|
-
if !build_source_path.exist?
|
59
|
-
build_source_path.mkpath
|
60
|
-
|
61
|
-
FileUtils.cp_r(source_path.children, build_source_path.to_s, :preserve => true)
|
62
|
-
|
63
|
-
# Write the environment checksum out to a file:
|
64
|
-
File.write(build_source_checksum_path, checksum(values))
|
65
|
-
|
66
|
-
fresh = true
|
67
|
-
end
|
68
|
-
|
69
|
-
# Convert the hash to suit typical shell specific arguments:
|
70
|
-
shell_environment = Environment::System::convert_to_shell(values)
|
71
|
-
|
72
|
-
Dir.chdir(build_source_path) do
|
73
|
-
RExec.env(shell_environment) do
|
74
|
-
@install.call(Environment::Evaluator.new(values), fresh)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def checksum(values)
|
82
|
-
# Calculate a canonical text representation of the environment:
|
83
|
-
text = values.sort.inspect
|
84
|
-
|
85
|
-
# Digest the text:
|
86
|
-
Digest::MD5.hexdigest(text)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
# THE SOFTWARE.
|
20
|
-
|
21
|
-
require 'teapot/build/target'
|
22
|
-
require 'teapot/build/targets/directory'
|
23
|
-
require 'teapot/build/targets/compiler'
|
24
|
-
|
25
|
-
require 'fileutils'
|
26
|
-
|
27
|
-
module Teapot
|
28
|
-
module Build
|
29
|
-
module Targets
|
30
|
-
module Installation
|
31
|
-
def install_prefix!(environment)
|
32
|
-
install_prefix = Pathname.new(environment[:install_prefix])
|
33
|
-
|
34
|
-
install_prefix.mkpath
|
35
|
-
|
36
|
-
return install_prefix
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class Files < Build::Target
|
41
|
-
include Installation
|
42
|
-
|
43
|
-
def initialize(parent, options = {})
|
44
|
-
super parent
|
45
|
-
@options = options
|
46
|
-
end
|
47
|
-
|
48
|
-
attr :options
|
49
|
-
|
50
|
-
def subdirectory
|
51
|
-
options[:subdirectory] || "./"
|
52
|
-
end
|
53
|
-
|
54
|
-
def build(environment)
|
55
|
-
prefix = install_prefix!(environment)
|
56
|
-
|
57
|
-
if self.respond_to? :source_files
|
58
|
-
file_list = self.source_files(environment)
|
59
|
-
|
60
|
-
file_list.copy(prefix + subdirectory)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class Headers < Files
|
66
|
-
def subdirectory
|
67
|
-
super + "include/"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class Directory
|
72
|
-
def copy_files(*args, &block)
|
73
|
-
self << Files.target(self, *args, &block)
|
74
|
-
end
|
75
|
-
|
76
|
-
def copy_headers(*args, &block)
|
77
|
-
self << Headers.target(self, *args, &block)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|