teapot 0.5.1 → 0.6.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.
- data/bin/teapot +0 -4
- data/lib/teapot/build/targets/directory.rb +1 -1
- data/lib/teapot/build/targets/external.rb +91 -0
- data/lib/teapot/build.rb +15 -4
- data/lib/teapot/commands.rb +9 -1
- data/lib/teapot/context.rb +10 -4
- data/lib/teapot/dependency.rb +1 -1
- data/lib/teapot/environment/system.rb +0 -18
- data/lib/teapot/environment.rb +1 -1
- data/lib/teapot/target.rb +1 -1
- data/lib/teapot/version.rb +1 -1
- metadata +5 -4
data/bin/teapot
CHANGED
@@ -0,0 +1,91 @@
|
|
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 install(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)
|
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
|
data/lib/teapot/build.rb
CHANGED
@@ -23,6 +23,7 @@ require 'teapot/build/targets/files'
|
|
23
23
|
require 'teapot/build/targets/library'
|
24
24
|
require 'teapot/build/targets/executable'
|
25
25
|
require 'teapot/build/targets/application'
|
26
|
+
require 'teapot/build/targets/external'
|
26
27
|
|
27
28
|
module Teapot
|
28
29
|
module Build
|
@@ -30,12 +31,22 @@ module Teapot
|
|
30
31
|
Targets::Directory.target(nil, path)
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
module Helpers
|
35
|
+
def install_directory(root, directory, *args)
|
36
|
+
target = Build.top(root)
|
35
37
|
|
36
|
-
|
38
|
+
target.add_directory(directory)
|
37
39
|
|
38
|
-
|
40
|
+
target.execute(:install, *args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def install_external(root, directory, *args, &block)
|
44
|
+
target = Build.top(root)
|
45
|
+
|
46
|
+
target << Targets::External.new(target, directory, &block)
|
47
|
+
|
48
|
+
target.execute(:install, *args)
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
data/lib/teapot/commands.rb
CHANGED
@@ -48,7 +48,7 @@ module Teapot
|
|
48
48
|
if system(*args)
|
49
49
|
true
|
50
50
|
else
|
51
|
-
raise CommandError.new("Non-zero exit status")
|
51
|
+
raise CommandError.new("Non-zero exit status!")
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -62,6 +62,14 @@ module Teapot
|
|
62
62
|
# No parallel execution supported by default.
|
63
63
|
end
|
64
64
|
|
65
|
+
def self.make(*args)
|
66
|
+
run("make", *args, "-j", processor_count)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.make_install
|
70
|
+
make("install")
|
71
|
+
end
|
72
|
+
|
65
73
|
class Pool
|
66
74
|
def initialize(options = {})
|
67
75
|
@commands = []
|
data/lib/teapot/context.rb
CHANGED
@@ -22,14 +22,19 @@ require 'pathname'
|
|
22
22
|
require 'rainbow'
|
23
23
|
|
24
24
|
require 'teapot/target'
|
25
|
+
require 'teapot/build'
|
25
26
|
|
26
27
|
module Teapot
|
27
|
-
LOADER_VERSION = "0.
|
28
|
+
LOADER_VERSION = "0.6"
|
29
|
+
MINIMUM_LOADER_VERSION = "0.6"
|
28
30
|
|
29
31
|
class IncompatibleTeapot < StandardError
|
30
32
|
end
|
31
33
|
|
32
34
|
class Loader
|
35
|
+
# Provides install_directory and install_external methods
|
36
|
+
include Build::Helpers
|
37
|
+
|
33
38
|
def initialize(context, package)
|
34
39
|
@context = context
|
35
40
|
@package = package
|
@@ -43,17 +48,18 @@ module Teapot
|
|
43
48
|
attr :version
|
44
49
|
|
45
50
|
def required_version(version)
|
46
|
-
if version <= LOADER_VERSION
|
51
|
+
if version >= MINIMUM_LOADER_VERSION && version <= LOADER_VERSION
|
47
52
|
@version = version
|
48
53
|
else
|
49
|
-
raise IncompatibleTeapot.new("Version #{version}
|
54
|
+
raise IncompatibleTeapot.new("Version #{version} isn't compatible with current loader!\n" \
|
55
|
+
"Minimum supported version: #{MINIMUM_LOADER_VERSION}; Current version: #{LOADER_VERSION}.")
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
53
59
|
def define_target(*args, &block)
|
54
60
|
target = Target.new(@context, @package, *args)
|
55
61
|
|
56
|
-
yield
|
62
|
+
yield target
|
57
63
|
|
58
64
|
@context.targets[target.name] = target
|
59
65
|
|
data/lib/teapot/dependency.rb
CHANGED
@@ -52,23 +52,5 @@ module Teapot
|
|
52
52
|
def self.system_environment(env = ENV)
|
53
53
|
self.new(Hash[env.map{|key, value| [key.downcase.to_sym, value]}])
|
54
54
|
end
|
55
|
-
|
56
|
-
# Apply the environment to the current process temporarily:
|
57
|
-
def use(options = {}, &block)
|
58
|
-
# Flatten the environment to a hash:
|
59
|
-
values = flatten
|
60
|
-
|
61
|
-
# Convert the hash to suit typical shell specific arguments:
|
62
|
-
build_environment = System::convert_to_shell(values)
|
63
|
-
|
64
|
-
# Show the environment to the user:
|
65
|
-
System::dump(build_environment)
|
66
|
-
|
67
|
-
Dir.chdir(options[:in] || ".") do
|
68
|
-
RExec.env(build_environment) do
|
69
|
-
block.call(Environment::Evaluator.new(values))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
55
|
end
|
74
56
|
end
|
data/lib/teapot/environment.rb
CHANGED
data/lib/teapot/target.rb
CHANGED
@@ -64,7 +64,7 @@ module Teapot
|
|
64
64
|
# The base configuration environment:
|
65
65
|
environments << context.config.environment
|
66
66
|
|
67
|
-
#
|
67
|
+
# Calculate the dependency chain's ordered environments:
|
68
68
|
environments += chain.provisions.collect do |provision|
|
69
69
|
Environment.new(&provision.value)
|
70
70
|
end
|
data/lib/teapot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teapot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/teapot/build/targets/compiler.rb
|
102
102
|
- lib/teapot/build/targets/directory.rb
|
103
103
|
- lib/teapot/build/targets/executable.rb
|
104
|
+
- lib/teapot/build/targets/external.rb
|
104
105
|
- lib/teapot/build/targets/files.rb
|
105
106
|
- lib/teapot/build/targets/library.rb
|
106
107
|
- lib/teapot/commands.rb
|
@@ -133,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
134
|
version: '0'
|
134
135
|
segments:
|
135
136
|
- 0
|
136
|
-
hash: -
|
137
|
+
hash: -3435379409085677514
|
137
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
139
|
none: false
|
139
140
|
requirements:
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
segments:
|
144
145
|
- 0
|
145
|
-
hash: -
|
146
|
+
hash: -3435379409085677514
|
146
147
|
requirements: []
|
147
148
|
rubyforge_project:
|
148
149
|
rubygems_version: 1.8.24
|