build 1.0.10 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +1 -1
- data/Rakefile +5 -4
- data/build.gemspec +4 -4
- data/lib/build/controller.rb +2 -2
- data/lib/build/target_node.rb +3 -2
- data/lib/build/task.rb +15 -7
- data/lib/build/version.rb +1 -1
- data/spec/build/controller_spec.rb +70 -70
- data/spec/build/name_spec.rb +24 -26
- data/spec/build/rule_spec.rb +11 -13
- data/spec/build/rulebook_spec.rb +22 -24
- data/spec/spec_helper.rb +29 -0
- metadata +13 -12
- data/.simplecov +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c59b2e49cb23e01f0ce4729b592c3d91e84e0c7c
|
4
|
+
data.tar.gz: c9d16ef4c2b0d1d868d28857ddd7fdc6d0eb0f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d013e5ed507dc6ff3ed70c11f1d1fc2c3c4c4a7fa0997c2ee3ba72b89a2dd34f22fdc17dd7f046d6f0d2fd5764ae27798bc9896e866c8c8e8061623bd2ef86de
|
7
|
+
data.tar.gz: 546ca321ef164736ac482e346e518e278dd95cdd21d311fb84432508e2cb5d8719962621a0a87e8c4dfa57b12f1174635e91c066c8c9c2d7c84d13799c69a127
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
4
|
+
# Load all rake tasks:
|
5
|
+
import(*Dir.glob('tasks/**/*.rake'))
|
7
6
|
|
8
|
-
|
7
|
+
RSpec::Core::RakeTask.new(:test)
|
8
|
+
|
9
|
+
task :default => :test
|
data/build.gemspec
CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
spec.required_ruby_version = '>= 2.0'
|
19
19
|
|
20
|
-
spec.add_dependency "build-graph", "~> 1.0
|
21
|
-
spec.add_dependency "build-environment", "~> 1.1
|
22
|
-
spec.add_dependency "build-makefile", "~> 1.0
|
20
|
+
spec.add_dependency "build-graph", "~> 1.0"
|
21
|
+
spec.add_dependency "build-environment", "~> 1.1"
|
22
|
+
spec.add_dependency "build-makefile", "~> 1.0"
|
23
23
|
|
24
24
|
spec.add_dependency "graphviz"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
28
28
|
spec.add_development_dependency "rake"
|
29
29
|
end
|
data/lib/build/controller.rb
CHANGED
@@ -73,14 +73,14 @@ module Build
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Add a build target to the controller.
|
76
|
-
def add_target(target, environment)
|
76
|
+
def add_target(target, environment, arguments = [])
|
77
77
|
task_class = Rulebook.for(environment).with(Task, environment: environment, target: target)
|
78
78
|
|
79
79
|
# Not sure if this is a good idea - makes debugging slightly easier.
|
80
80
|
Object.const_set("TaskClassFor#{Name.from_target(target.name).identifier}_#{task_class.object_id}", task_class)
|
81
81
|
|
82
82
|
# A target node will invoke the build callback on target.
|
83
|
-
@nodes << TargetNode.new(task_class, target)
|
83
|
+
@nodes << TargetNode.new(task_class, target, arguments)
|
84
84
|
|
85
85
|
return @nodes.last
|
86
86
|
end
|
data/lib/build/target_node.rb
CHANGED
@@ -23,9 +23,10 @@ require 'build/graph'
|
|
23
23
|
|
24
24
|
module Build
|
25
25
|
class TargetNode < Graph::Node
|
26
|
-
def initialize(task_class, target)
|
26
|
+
def initialize(task_class, target, arguments)
|
27
27
|
@target = target
|
28
28
|
@task_class = task_class
|
29
|
+
@arguments = arguments
|
29
30
|
|
30
31
|
# Wait here, for all dependent targets, to be done:
|
31
32
|
super(Files::List::NONE, :inherit, target)
|
@@ -38,7 +39,7 @@ module Build
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def apply!(scope)
|
41
|
-
scope.instance_exec(&@target.build)
|
42
|
+
scope.instance_exec(*@arguments, &@target.build)
|
42
43
|
end
|
43
44
|
|
44
45
|
def inspect
|
data/lib/build/task.rb
CHANGED
@@ -80,21 +80,21 @@ module Build
|
|
80
80
|
def touch(path)
|
81
81
|
return unless wet?
|
82
82
|
|
83
|
-
@logger.info(:shell){
|
83
|
+
@logger.info(:shell) {['touch', path]}
|
84
84
|
FileUtils.touch(path)
|
85
85
|
end
|
86
86
|
|
87
87
|
def cp(source_path, destination_path)
|
88
88
|
return unless wet?
|
89
89
|
|
90
|
-
@logger.info(:shell){
|
90
|
+
@logger.info(:shell) {['cp', source_path, destination_path]}
|
91
91
|
FileUtils.copy(source_path, destination_path)
|
92
92
|
end
|
93
93
|
|
94
94
|
def rm(path)
|
95
95
|
return unless wet?
|
96
96
|
|
97
|
-
@logger.info(:shell){
|
97
|
+
@logger.info(:shell) {['rm -rf', path]}
|
98
98
|
FileUtils.rm_rf(path)
|
99
99
|
end
|
100
100
|
|
@@ -102,8 +102,7 @@ module Build
|
|
102
102
|
return unless wet?
|
103
103
|
|
104
104
|
unless File.exist?(path)
|
105
|
-
@logger.info(:shell){
|
106
|
-
|
105
|
+
@logger.info(:shell) {['mkpath', path]}
|
107
106
|
FileUtils.mkpath(path)
|
108
107
|
end
|
109
108
|
end
|
@@ -111,11 +110,20 @@ module Build
|
|
111
110
|
def install(source_path, destination_path)
|
112
111
|
return unless wet?
|
113
112
|
|
114
|
-
@logger.info(:shell){
|
113
|
+
@logger.info(:shell) {['install', source_path, destination_path]}
|
115
114
|
FileUtils.install(source_path, destination_path)
|
116
115
|
end
|
117
116
|
|
118
|
-
|
117
|
+
def write(path, data, mode = "w")
|
118
|
+
return unless wet?
|
119
|
+
|
120
|
+
@logger.info(:shell) {["write", path, "#{data.size}bytes"]}
|
121
|
+
File.open(path, mode) do |file|
|
122
|
+
file.write(data)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# @deprecated Please use {#self} instead.
|
119
127
|
def fs
|
120
128
|
self
|
121
129
|
end
|
data/lib/build/version.rb
CHANGED
@@ -23,92 +23,92 @@
|
|
23
23
|
require 'build/rulebook'
|
24
24
|
require 'build/controller'
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def build(&block)
|
35
|
-
@build = block if block_given?
|
26
|
+
RSpec.describe Build::Controller do
|
27
|
+
let(:target_class) do
|
28
|
+
Class.new do
|
29
|
+
def initialize(name)
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
|
33
|
+
attr :name
|
36
34
|
|
37
|
-
|
35
|
+
def build(&block)
|
36
|
+
@build = block if block_given?
|
37
|
+
|
38
|
+
return @build
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
run! "exit -1"
|
49
|
-
end
|
43
|
+
it "build graph should fail" do
|
44
|
+
environment = Build::Environment.new do
|
45
|
+
define Build::Rule, "make.file" do
|
46
|
+
output :destination
|
47
|
+
|
48
|
+
apply do |parameters|
|
49
|
+
run! "exit -1"
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
|
-
target = Target.new('fail')
|
54
|
-
target.build do
|
55
|
-
foo_path = Build::Files::Path['foo']
|
56
|
-
make destination: foo_path
|
57
|
-
end
|
58
|
-
|
59
|
-
controller = Build::Controller.new do |controller|
|
60
|
-
controller.add_target(target, environment)
|
61
|
-
end
|
62
|
-
|
63
|
-
controller.logger.level = Logger::DEBUG
|
64
|
-
|
65
|
-
controller.update
|
66
|
-
|
67
|
-
expect(controller.failed?).to be_truthy
|
68
52
|
end
|
69
53
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
54
|
+
target = target_class.new('fail')
|
55
|
+
target.build do
|
56
|
+
foo_path = Build::Files::Path['foo']
|
57
|
+
make destination: foo_path
|
58
|
+
end
|
59
|
+
|
60
|
+
controller = Build::Controller.new do |controller|
|
61
|
+
controller.add_target(target, environment)
|
62
|
+
end
|
63
|
+
|
64
|
+
controller.logger.level = Logger::DEBUG
|
65
|
+
|
66
|
+
controller.update
|
67
|
+
|
68
|
+
expect(controller.failed?).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should execute the build graph" do
|
72
|
+
environment = Build::Environment.new do
|
73
|
+
define Build::Rule, "make.file" do
|
74
|
+
output :destination
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
output :destination
|
83
|
-
|
84
|
-
apply do |parameters|
|
85
|
-
cp parameters[:source], parameters[:destination]
|
86
|
-
end
|
76
|
+
apply do |parameters|
|
77
|
+
touch parameters[:destination]
|
87
78
|
end
|
88
79
|
end
|
89
80
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
bar_path = Build::Files::Path['bar']
|
81
|
+
define Build::Rule, "copy.file" do
|
82
|
+
input :source
|
83
|
+
output :destination
|
94
84
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
controller = Build::Controller.new do |controller|
|
101
|
-
controller.add_target(target, environment)
|
85
|
+
apply do |parameters|
|
86
|
+
cp parameters[:source], parameters[:destination]
|
87
|
+
end
|
102
88
|
end
|
89
|
+
end
|
90
|
+
|
91
|
+
target = target_class.new('copy')
|
92
|
+
target.build do
|
93
|
+
foo_path = Build::Files::Path['foo']
|
94
|
+
bar_path = Build::Files::Path['bar']
|
103
95
|
|
104
|
-
|
105
|
-
|
106
|
-
controller.update
|
107
|
-
|
108
|
-
expect(File).to be_exist('foo')
|
109
|
-
expect(File).to be_exist('bar')
|
96
|
+
make destination: foo_path
|
110
97
|
|
111
|
-
|
98
|
+
copy source: foo_path, destination: bar_path
|
99
|
+
end
|
100
|
+
|
101
|
+
controller = Build::Controller.new do |controller|
|
102
|
+
controller.add_target(target, environment)
|
112
103
|
end
|
104
|
+
|
105
|
+
expect(controller.nodes.size).to be 1
|
106
|
+
|
107
|
+
controller.update
|
108
|
+
|
109
|
+
expect(File).to be_exist('foo')
|
110
|
+
expect(File).to be_exist('bar')
|
111
|
+
|
112
|
+
FileUtils.rm ['foo', 'bar']
|
113
113
|
end
|
114
114
|
end
|
data/spec/build/name_spec.rb
CHANGED
@@ -20,31 +20,29 @@
|
|
20
20
|
|
21
21
|
require 'build/name'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
expect(Build::Name.from_target(name.target).text).to be == name.text
|
48
|
-
end
|
23
|
+
RSpec.describe Build::Name do
|
24
|
+
let(:name) {Build::Name.new('Foo Bar')}
|
25
|
+
it "retains the original text" do
|
26
|
+
expect(name.text).to be == 'Foo Bar'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should generate useful identifiers" do
|
30
|
+
expect(name.identifier).to be == 'FooBar'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should generate useful target names" do
|
34
|
+
expect(name.target).to be == 'foo-bar'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should generate useful macro names" do
|
38
|
+
expect(name.macro).to be == 'FOO_BAR'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should generate useful macro names" do
|
42
|
+
expect(name.macro).to be == 'FOO_BAR'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can be constructed from target name" do
|
46
|
+
expect(Build::Name.from_target(name.target).text).to be == name.text
|
49
47
|
end
|
50
48
|
end
|
data/spec/build/rule_spec.rb
CHANGED
@@ -20,18 +20,16 @@
|
|
20
20
|
|
21
21
|
require 'build/rule'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(rule.applicable?(source: 'foo')).to be_falsey
|
35
|
-
end
|
23
|
+
RSpec.describe Build::Rule do
|
24
|
+
it "should validate input and output parameters" do
|
25
|
+
rule = Build::Rule.new("compile", "cpp")
|
26
|
+
|
27
|
+
rule.input :source
|
28
|
+
rule.output :destination
|
29
|
+
|
30
|
+
expect(rule.parameters.size).to be 2
|
31
|
+
|
32
|
+
expect(rule.applicable?(source: 'foo', destination: 'bar')).to be_truthy
|
33
|
+
expect(rule.applicable?(source: 'foo')).to be_falsey
|
36
34
|
end
|
37
35
|
end
|
data/spec/build/rulebook_spec.rb
CHANGED
@@ -21,34 +21,32 @@
|
|
21
21
|
require 'build/environment'
|
22
22
|
require 'build/rulebook'
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
output :destination
|
31
|
-
|
32
|
-
apply do |parameters|
|
33
|
-
cp parameters[:source], parameters[:destination]
|
34
|
-
end
|
35
|
-
end
|
24
|
+
RSpec.describe Build::Rulebook do
|
25
|
+
it "should generate a valid rulebook" do
|
26
|
+
environment = Build::Environment.new do
|
27
|
+
define Build::Rule, "copy.file" do
|
28
|
+
input :source
|
29
|
+
output :destination
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
apply do |parameters|
|
41
|
-
rm parameters[:target]
|
42
|
-
end
|
31
|
+
apply do |parameters|
|
32
|
+
cp parameters[:source], parameters[:destination]
|
43
33
|
end
|
44
34
|
end
|
45
35
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
36
|
+
define Build::Rule, "delete.file" do
|
37
|
+
input :target
|
38
|
+
|
39
|
+
apply do |parameters|
|
40
|
+
rm parameters[:target]
|
41
|
+
end
|
42
|
+
end
|
52
43
|
end
|
44
|
+
|
45
|
+
rulebook = Build::Rulebook.for(environment)
|
46
|
+
|
47
|
+
expect(rulebook.rules.size).to be 2
|
48
|
+
|
49
|
+
expect(rulebook.rules).to be_include 'copy.file'
|
50
|
+
expect(rulebook.rules).to be_include 'delete.file'
|
53
51
|
end
|
54
52
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
if ENV['COVERAGE'] || ENV['TRAVIS']
|
3
|
+
begin
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter "/spec/"
|
8
|
+
end
|
9
|
+
|
10
|
+
if ENV['TRAVIS']
|
11
|
+
require 'coveralls'
|
12
|
+
Coveralls.wear!
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
warn "Could not load simplecov: #{$!}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require "bundler/setup"
|
20
|
+
require "build"
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# Enable flags like --only-failures and --next-failure
|
24
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
25
|
+
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = :expect
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: build-graph
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: build-environment
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.1
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: build-makefile
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: graphviz
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.
|
89
|
+
version: '3.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,6 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
|
-
- ".simplecov"
|
121
120
|
- ".travis.yml"
|
122
121
|
- Gemfile
|
123
122
|
- Gemfile.local
|
@@ -139,6 +138,7 @@ files:
|
|
139
138
|
- spec/build/name_spec.rb
|
140
139
|
- spec/build/rule_spec.rb
|
141
140
|
- spec/build/rulebook_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
142
|
homepage: ''
|
143
143
|
licenses:
|
144
144
|
- MIT
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.6.12
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Build is a framework for working with task based build systems.
|
@@ -168,3 +168,4 @@ test_files:
|
|
168
168
|
- spec/build/name_spec.rb
|
169
169
|
- spec/build/rule_spec.rb
|
170
170
|
- spec/build/rulebook_spec.rb
|
171
|
+
- spec/spec_helper.rb
|