rscons 1.9.3 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rscons.rb +53 -1
- data/lib/rscons/builder.rb +184 -11
- data/lib/rscons/builders/cfile.rb +18 -3
- data/lib/rscons/builders/command.rb +24 -9
- data/lib/rscons/builders/disassemble.rb +20 -4
- data/lib/rscons/builders/library.rb +37 -16
- data/lib/rscons/builders/object.rb +35 -22
- data/lib/rscons/builders/preprocess.rb +25 -17
- data/lib/rscons/builders/program.rb +35 -12
- data/lib/rscons/builders/shared_library.rb +116 -0
- data/lib/rscons/builders/shared_object.rb +113 -0
- data/lib/rscons/cache.rb +7 -2
- data/lib/rscons/cli.rb +4 -0
- data/lib/rscons/environment.rb +394 -104
- data/lib/rscons/job_set.rb +93 -0
- data/lib/rscons/threaded_command.rb +63 -0
- data/lib/rscons/version.rb +1 -1
- metadata +7 -3
@@ -0,0 +1,93 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Rscons
|
4
|
+
# Class to keep track of a set of jobs that need to be performed.
|
5
|
+
class JobSet
|
6
|
+
|
7
|
+
# Create a JobSet
|
8
|
+
#
|
9
|
+
# @param build_dependencies [Hash]
|
10
|
+
# Hash mapping targets to a set of build dependencies. A job will not be
|
11
|
+
# returned as ready to run if any of its dependencies are still building.
|
12
|
+
def initialize(build_dependencies)
|
13
|
+
@jobs = {}
|
14
|
+
@build_dependencies = build_dependencies
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add a job to the JobSet.
|
18
|
+
#
|
19
|
+
# @param options [Hash]
|
20
|
+
# Options.
|
21
|
+
# @option options [Symbol, String] :target
|
22
|
+
# Build target name.
|
23
|
+
# @option options [Builder] :builder
|
24
|
+
# The {Builder} to use to build the target.
|
25
|
+
# @option options [Array<String>] :sources
|
26
|
+
# Source file name(s).
|
27
|
+
# @option options [Hash] :vars
|
28
|
+
# Construction variable overrides.
|
29
|
+
def add_job(options)
|
30
|
+
# We allow multiple jobs to be registered per target for cases like:
|
31
|
+
# env.Directory("dest")
|
32
|
+
# env.Install("dest", "bin")
|
33
|
+
# env.Install("dest", "share")
|
34
|
+
@jobs[options[:target]] ||= []
|
35
|
+
@jobs[options[:target]] << options
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get the next job that is ready to run from the JobSet.
|
39
|
+
#
|
40
|
+
# This method will remove the job from the JobSet.
|
41
|
+
#
|
42
|
+
# @param targets_still_building [Array<String>]
|
43
|
+
# Targets that are not finished building. This is used to avoid returning
|
44
|
+
# a job as available to run if it depends on one of the targets that are
|
45
|
+
# still building as a source.
|
46
|
+
#
|
47
|
+
# @return [nil, Hash]
|
48
|
+
# The next job to run.
|
49
|
+
def get_next_job_to_run(targets_still_building)
|
50
|
+
@jobs.keys.each do |target|
|
51
|
+
skip = false
|
52
|
+
(@jobs[target][0][:sources] + (@build_dependencies[target] || []).to_a).each do |src|
|
53
|
+
if @jobs.include?(src)
|
54
|
+
# Skip this target because it depends on another target later in
|
55
|
+
# the job set.
|
56
|
+
skip = true
|
57
|
+
break
|
58
|
+
end
|
59
|
+
if targets_still_building.include?(src)
|
60
|
+
# Skip this target because it depends on another target that is
|
61
|
+
# still being built.
|
62
|
+
skip = true
|
63
|
+
break
|
64
|
+
end
|
65
|
+
end
|
66
|
+
next if skip
|
67
|
+
job = @jobs[target][0]
|
68
|
+
if @jobs[target].size > 1
|
69
|
+
@jobs[target].slice!(0)
|
70
|
+
else
|
71
|
+
@jobs.delete(target)
|
72
|
+
end
|
73
|
+
return job
|
74
|
+
end
|
75
|
+
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
# Remove all jobs from the JobSet.
|
80
|
+
def clear!
|
81
|
+
@jobs.clear
|
82
|
+
end
|
83
|
+
|
84
|
+
# Get the JobSet size.
|
85
|
+
#
|
86
|
+
# @return [Integer]
|
87
|
+
# JobSet size.
|
88
|
+
def size
|
89
|
+
@jobs.size
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Rscons
|
2
|
+
# If a builder returns an instance of this class from its #run method, then
|
3
|
+
# Rscons will execute the command specified in a thread and allow other
|
4
|
+
# builders to continue executing in parallel.
|
5
|
+
class ThreadedCommand
|
6
|
+
|
7
|
+
# @return [Array<String>]
|
8
|
+
# The command to execute.
|
9
|
+
attr_reader :command
|
10
|
+
|
11
|
+
# @return [Object]
|
12
|
+
# Arbitrary object to store builder-specific info. This object value will
|
13
|
+
# be passed back into the builder's #finalize method.
|
14
|
+
attr_reader :builder_info
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
# Short description of the command. This will be printed to standard
|
18
|
+
# output if the Environment's echo mode is :short.
|
19
|
+
attr_reader :short_description
|
20
|
+
|
21
|
+
# @return [Hash]
|
22
|
+
# Environment Hash to pass to Kernel#system.
|
23
|
+
attr_reader :system_env
|
24
|
+
|
25
|
+
# @return [Hash]
|
26
|
+
# Options Hash to pass to Kernel#system.
|
27
|
+
attr_reader :system_options
|
28
|
+
|
29
|
+
# @return [Hash]
|
30
|
+
# Field for Rscons to store the build operation while this threaded
|
31
|
+
# command is executing.
|
32
|
+
attr_accessor :build_operation
|
33
|
+
|
34
|
+
# @return [Thread]
|
35
|
+
# The thread waiting on this command to terminate.
|
36
|
+
attr_accessor :thread
|
37
|
+
|
38
|
+
# Create a ThreadedCommand object.
|
39
|
+
#
|
40
|
+
# @param command [Array<String>]
|
41
|
+
# The command to execute.
|
42
|
+
# @param options [Hash]
|
43
|
+
# Optional parameters.
|
44
|
+
# @option options [Object] :builder_info
|
45
|
+
# Arbitrary object to store builder-specific info. This object value will
|
46
|
+
# be passed back into the builder's #finalize method.
|
47
|
+
# @option options [String] :short_description
|
48
|
+
# Short description of the command. This will be printed to standard
|
49
|
+
# output if the Environment's echo mode is :short.
|
50
|
+
# @option options [Hash] :system_env
|
51
|
+
# Environment Hash to pass to Kernel#system.
|
52
|
+
# @option options [Hash] :system_options
|
53
|
+
# Options Hash to pass to Kernel#system.
|
54
|
+
def initialize(command, options = {})
|
55
|
+
@command = command
|
56
|
+
@builder_info = options[:builder_info]
|
57
|
+
@short_description = options[:short_description]
|
58
|
+
@system_env = options[:system_env]
|
59
|
+
@system_options = options[:system_options]
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
data/lib/rscons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Holtrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -130,10 +130,14 @@ files:
|
|
130
130
|
- lib/rscons/builders/object.rb
|
131
131
|
- lib/rscons/builders/preprocess.rb
|
132
132
|
- lib/rscons/builders/program.rb
|
133
|
+
- lib/rscons/builders/shared_library.rb
|
134
|
+
- lib/rscons/builders/shared_object.rb
|
133
135
|
- lib/rscons/builders/simple_builder.rb
|
134
136
|
- lib/rscons/cache.rb
|
135
137
|
- lib/rscons/cli.rb
|
136
138
|
- lib/rscons/environment.rb
|
139
|
+
- lib/rscons/job_set.rb
|
140
|
+
- lib/rscons/threaded_command.rb
|
137
141
|
- lib/rscons/varset.rb
|
138
142
|
- lib/rscons/version.rb
|
139
143
|
- rscons.gemspec
|
@@ -157,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
161
|
version: '0'
|
158
162
|
requirements: []
|
159
163
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.6.
|
164
|
+
rubygems_version: 2.6.12
|
161
165
|
signing_key:
|
162
166
|
specification_version: 4
|
163
167
|
summary: Software construction library inspired by SCons and implemented in Ruby
|