Compare commits
10 Commits
wip-precom
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| af7aad716d | |||
| 13bd827d57 | |||
| a3d739c472 | |||
| 319432bc61 | |||
| d38cd2e8fb | |||
| 72d2802d1e | |||
| e6317ae236 | |||
| baf4e036fb | |||
| 9d6321685e | |||
| 3a5db626ac |
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,5 +7,5 @@
|
|||||||
/gen/
|
/gen/
|
||||||
/large_project/
|
/large_project/
|
||||||
/pkg/
|
/pkg/
|
||||||
/test/
|
/test_run/
|
||||||
/yard/
|
/yard/
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@ -3,7 +3,7 @@ source 'https://rubygems.org'
|
|||||||
gem "base64"
|
gem "base64"
|
||||||
gem "rspec"
|
gem "rspec"
|
||||||
gem "rake"
|
gem "rake"
|
||||||
gem "simplecov", "~> 0.15.0"
|
gem "simplecov"
|
||||||
gem "openssl"
|
gem "openssl"
|
||||||
if RbConfig::CONFIG["host"]["msys"]
|
if RbConfig::CONFIG["host"]["msys"]
|
||||||
gem "json", "2.1.0"
|
gem "json", "2.1.0"
|
||||||
|
|||||||
15
Gemfile.lock
15
Gemfile.lock
@ -4,7 +4,7 @@ GEM
|
|||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
date (3.5.1)
|
date (3.5.1)
|
||||||
diff-lcs (1.6.2)
|
diff-lcs (1.6.2)
|
||||||
docile (1.1.5)
|
docile (1.4.1)
|
||||||
erb (6.0.1)
|
erb (6.0.1)
|
||||||
json (2.18.0)
|
json (2.18.0)
|
||||||
openssl (4.0.0)
|
openssl (4.0.0)
|
||||||
@ -30,11 +30,12 @@ GEM
|
|||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.13.0)
|
rspec-support (~> 3.13.0)
|
||||||
rspec-support (3.13.6)
|
rspec-support (3.13.6)
|
||||||
simplecov (0.15.1)
|
simplecov (0.22.0)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1)
|
||||||
json (>= 1.8, < 3)
|
simplecov-html (~> 0.11)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov_json_formatter (~> 0.1)
|
||||||
simplecov-html (0.10.2)
|
simplecov-html (0.13.2)
|
||||||
|
simplecov_json_formatter (0.1.4)
|
||||||
stringio (3.2.0)
|
stringio (3.2.0)
|
||||||
syntax (1.2.2)
|
syntax (1.2.2)
|
||||||
tsort (0.2.0)
|
tsort (0.2.0)
|
||||||
@ -52,7 +53,7 @@ DEPENDENCIES
|
|||||||
rdoc
|
rdoc
|
||||||
redcarpet
|
redcarpet
|
||||||
rspec
|
rspec
|
||||||
simplecov (~> 0.15.0)
|
simplecov
|
||||||
syntax
|
syntax
|
||||||
yard
|
yard
|
||||||
|
|
||||||
|
|||||||
32
Rakefile.rb
32
Rakefile.rb
@ -8,8 +8,10 @@ end
|
|||||||
require "rspec/core/rake_task"
|
require "rspec/core/rake_task"
|
||||||
require "rake/clean"
|
require "rake/clean"
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
|
require "simplecov"
|
||||||
|
require "stringio"
|
||||||
|
|
||||||
CLEAN.include %w[build_test_run .yardoc yard coverage test]
|
CLEAN.include %w[build_test_run .yardoc yard coverage test_run]
|
||||||
CLOBBER.include %w[dist gen large_project pkg]
|
CLOBBER.include %w[dist gen large_project pkg]
|
||||||
|
|
||||||
task :build_dist do
|
task :build_dist do
|
||||||
@ -19,24 +21,42 @@ end
|
|||||||
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
|
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
|
||||||
ENV["specs"] = "1"
|
ENV["specs"] = "1"
|
||||||
if args.example_string
|
if args.example_string
|
||||||
ENV["partial_specs"] = "1"
|
|
||||||
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
|
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
task :spec => :build_dist
|
|
||||||
task :spec do
|
task :spec do
|
||||||
ENV.delete("specs")
|
ENV.delete("specs")
|
||||||
end
|
end
|
||||||
|
task :spec => :build_tests
|
||||||
|
task :spec do
|
||||||
|
unless ENV["rscons_dist_specs"]
|
||||||
|
original_stdout = $stdout
|
||||||
|
sio = StringIO.new
|
||||||
|
$stdout = sio
|
||||||
|
SimpleCov.collate Dir["coverage/.resultset.json", "coverage/bt*/.resultset.json"]
|
||||||
|
$stdout = original_stdout
|
||||||
|
sio.string.lines.each do |line|
|
||||||
|
$stdout.write(line) unless line =~ /Coverage report generated for/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :build_tests do |task, args|
|
||||||
|
ENV["specs"] = "1"
|
||||||
|
sh "ruby -Ilib build_tests/build_tests.rb"
|
||||||
|
ENV.delete("specs")
|
||||||
|
end
|
||||||
|
|
||||||
# dspec task is useful to test the distributable release script, but is not
|
# dspec task is useful to test the distributable release script, but is not
|
||||||
# useful for coverage information.
|
# useful for coverage information.
|
||||||
desc "Dist Specs"
|
desc "Dist Specs"
|
||||||
task :dspec, [:example_string] => :build_dist do |task, args|
|
task :dspec, [:example_string] => :build_dist do |task, args|
|
||||||
FileUtils.rm_rf("test")
|
FileUtils.rm_rf("test_run")
|
||||||
FileUtils.mkdir_p("test")
|
FileUtils.mkdir_p("test_run")
|
||||||
FileUtils.cp("dist/rscons", "test/rscons.rb")
|
FileUtils.cp("dist/rscons", "test_run/rscons.rb")
|
||||||
ENV["rscons_dist_specs"] = "1"
|
ENV["rscons_dist_specs"] = "1"
|
||||||
Rake::Task["spec"].execute(args)
|
Rake::Task["spec"].execute(args)
|
||||||
|
Rake::Task["build_tests"].execute(args)
|
||||||
ENV.delete("rscons_dist_specs")
|
ENV.delete("rscons_dist_specs")
|
||||||
FileUtils.rm_f(Dir.glob(".rscons-*"))
|
FileUtils.rm_f(Dir.glob(".rscons-*"))
|
||||||
end
|
end
|
||||||
|
|||||||
3568
build_tests/build_tests.rb
Normal file
3568
build_tests/build_tests.rb
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,5 @@ configure do
|
|||||||
end
|
end
|
||||||
|
|
||||||
env(echo: :command) do |env|
|
env(echo: :command) do |env|
|
||||||
env["D_IMPORT_PATH"] << "src"
|
env.Program("hello-d.exe", glob("*.d"))
|
||||||
env.Program("hello-d.exe", glob("src/*.d"))
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,6 +3,5 @@ configure do
|
|||||||
end
|
end
|
||||||
|
|
||||||
env(echo: :command) do |env|
|
env(echo: :command) do |env|
|
||||||
env["D_IMPORT_PATH"] << "src"
|
env.Program("hello-d.exe", glob("*.d"))
|
||||||
env.Program("hello-d.exe", glob("src/*.d"))
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
env(echo: :command) do |env|
|
env(echo: :command) do |env|
|
||||||
env["LD_LIBRARY_PATH"] << "src"
|
env.Object("main.o", "main.d")
|
||||||
env.Object("main.o", "src/main.d")
|
env.Object("mod.o", "mod.d")
|
||||||
env.Object("mod.o", "src/mod.d")
|
|
||||||
env.Program("hello-d.exe", ["main.o", "mod.o"])
|
env.Program("hello-d.exe", ["main.o", "mod.o"])
|
||||||
end
|
end
|
||||||
|
|||||||
14
build_tests/simple/abs_rel_paths.rb
Normal file
14
build_tests/simple/abs_rel_paths.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class B < Builder
|
||||||
|
def run(*args)
|
||||||
|
puts @target
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env do |env|
|
||||||
|
env.add_builder(B)
|
||||||
|
env.B("one", File.expand_path("two"))
|
||||||
|
env.B("two")
|
||||||
|
env.B("three")
|
||||||
|
env.depends("two", File.expand_path("three"))
|
||||||
|
end
|
||||||
15
build_tests/simple/barrier_builder.rb
Normal file
15
build_tests/simple/barrier_builder.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class B < Builder
|
||||||
|
def run(*args)
|
||||||
|
puts "B:#{@target}"
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
env do |env|
|
||||||
|
env.add_builder(B)
|
||||||
|
env.B("one")
|
||||||
|
env.B("two")
|
||||||
|
env.B("three")
|
||||||
|
env.Barrier(:bar, %w[two three])
|
||||||
|
env.depends("one", :bar)
|
||||||
|
end
|
||||||
@ -3,7 +3,6 @@ env(echo: :command) do |env|
|
|||||||
env.add_build_hook do |builder|
|
env.add_build_hook do |builder|
|
||||||
if builder.name == "Object" && builder.sources.first =~ %r{one\.c}
|
if builder.name == "Object" && builder.sources.first =~ %r{one\.c}
|
||||||
builder.vars["CFLAGS"] << "-O1"
|
builder.vars["CFLAGS"] << "-O1"
|
||||||
builder.sources = ['src/two/two.c']
|
|
||||||
elsif builder.name == "Object" && builder.target =~ %r{two\.o}
|
elsif builder.name == "Object" && builder.target =~ %r{two\.o}
|
||||||
new_vars = builder.vars.clone
|
new_vars = builder.vars.clone
|
||||||
new_vars["CFLAGS"] << "-O2"
|
new_vars["CFLAGS"] << "-O2"
|
||||||
|
|||||||
@ -33,7 +33,6 @@ module Rscons
|
|||||||
:Lex,
|
:Lex,
|
||||||
:Library,
|
:Library,
|
||||||
:Object,
|
:Object,
|
||||||
:Precompile,
|
|
||||||
:Preprocess,
|
:Preprocess,
|
||||||
:Program,
|
:Program,
|
||||||
:SharedLibrary,
|
:SharedLibrary,
|
||||||
@ -153,7 +152,6 @@ require_relative "rscons/builders/disassemble"
|
|||||||
require_relative "rscons/builders/lex"
|
require_relative "rscons/builders/lex"
|
||||||
require_relative "rscons/builders/library"
|
require_relative "rscons/builders/library"
|
||||||
require_relative "rscons/builders/object"
|
require_relative "rscons/builders/object"
|
||||||
require_relative "rscons/builders/precompile"
|
|
||||||
require_relative "rscons/builders/preprocess"
|
require_relative "rscons/builders/preprocess"
|
||||||
require_relative "rscons/builders/program"
|
require_relative "rscons/builders/program"
|
||||||
require_relative "rscons/builders/shared_library"
|
require_relative "rscons/builders/shared_library"
|
||||||
|
|||||||
@ -29,19 +29,27 @@ module Rscons
|
|||||||
|
|
||||||
# @return [String, Symbol]
|
# @return [String, Symbol]
|
||||||
# Target file name.
|
# Target file name.
|
||||||
attr_accessor :target
|
attr_reader :target
|
||||||
|
|
||||||
# @return [Array<String>]
|
# @return [String, Symbol]
|
||||||
# Source file name(s).
|
# Absolute target file name.
|
||||||
attr_accessor :sources
|
attr_reader :abstarget
|
||||||
|
|
||||||
|
# @return [Array<String, Symbol>]
|
||||||
|
# Source file names.
|
||||||
|
attr_reader :sources
|
||||||
|
|
||||||
|
# @return [Array<String, Symbol>]
|
||||||
|
# Absolute source file names.
|
||||||
|
attr_reader :abssources
|
||||||
|
|
||||||
# @return [Cache]
|
# @return [Cache]
|
||||||
# Cache instance.
|
# Cache instance.
|
||||||
attr_accessor :cache
|
attr_reader :cache
|
||||||
|
|
||||||
# @return [Environment]
|
# @return [Environment]
|
||||||
# The {Environment} performing the build operation.
|
# The {Environment} performing the build operation.
|
||||||
attr_accessor :env
|
attr_reader :env
|
||||||
|
|
||||||
# @return [Hash, VarSet]
|
# @return [Hash, VarSet]
|
||||||
# Construction variables used to perform the build operation.
|
# Construction variables used to perform the build operation.
|
||||||
@ -49,7 +57,7 @@ module Rscons
|
|||||||
|
|
||||||
# @return [Set<String>]
|
# @return [Set<String>]
|
||||||
# Side effect file(s) produced when this builder runs.
|
# Side effect file(s) produced when this builder runs.
|
||||||
attr_accessor :side_effects
|
attr_reader :side_effects
|
||||||
|
|
||||||
# @return [Integer]
|
# @return [Integer]
|
||||||
# Build step.
|
# Build step.
|
||||||
@ -71,7 +79,11 @@ module Rscons
|
|||||||
# Extra construction variables.
|
# Extra construction variables.
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
@target = options[:target]
|
@target = options[:target]
|
||||||
@sources = options[:sources]
|
@abstarget = Util.absolute_path(@target)
|
||||||
|
@sources = Array(options[:sources])
|
||||||
|
@abssources = @sources.map do |source|
|
||||||
|
Util.absolute_path(source)
|
||||||
|
end
|
||||||
@cache = options[:cache]
|
@cache = options[:cache]
|
||||||
@env = options[:env]
|
@env = options[:env]
|
||||||
@vars = options[:vars]
|
@vars = options[:vars]
|
||||||
@ -103,7 +115,7 @@ module Rscons
|
|||||||
# @return [void]
|
# @return [void]
|
||||||
def produces(*side_effects)
|
def produces(*side_effects)
|
||||||
side_effects.each do |side_effect|
|
side_effects.each do |side_effect|
|
||||||
side_effect_expanded = @env.expand(side_effect)
|
side_effect_expanded = Util.absolute_path(@env.expand(side_effect))
|
||||||
@env.register_side_effect(side_effect_expanded)
|
@env.register_side_effect(side_effect_expanded)
|
||||||
@side_effects << side_effect_expanded
|
@side_effects << side_effect_expanded
|
||||||
end
|
end
|
||||||
|
|||||||
@ -27,9 +27,8 @@ module Rscons
|
|||||||
# env.Directory("dest")
|
# env.Directory("dest")
|
||||||
# env.Install("dest", "bin")
|
# env.Install("dest", "bin")
|
||||||
# env.Install("dest", "share")
|
# env.Install("dest", "share")
|
||||||
target = Util.absolute_path(builder.target)
|
self[builder.abstarget] ||= []
|
||||||
self[target] ||= []
|
self[builder.abstarget] << builder
|
||||||
self[target] << builder
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the number of remaining build steps.
|
# Return the number of remaining build steps.
|
||||||
@ -55,15 +54,10 @@ module Rscons
|
|||||||
# The next builder to run.
|
# The next builder to run.
|
||||||
def get_next_builder_to_run(targets_still_building)
|
def get_next_builder_to_run(targets_still_building)
|
||||||
to_build = self.find do |target, builders|
|
to_build = self.find do |target, builders|
|
||||||
deps = builders.first.sources + (@build_dependencies[target] || []).to_a
|
deps = builders.first.abssources + (@build_dependencies[target] || []).to_a
|
||||||
deps.map! {|dep| Util.absolute_path(dep)}
|
|
||||||
# All dependencies must have been built for this target to be ready to
|
# All dependencies must have been built for this target to be ready to
|
||||||
# build.
|
# build.
|
||||||
deps.all? do |dep|
|
deps.all? do |dep|
|
||||||
puts "BuilderSet: #{target}: dep #{dep}"
|
|
||||||
puts " still building? #{targets_still_building.include?(dep)}"
|
|
||||||
puts " self.include? #{self.include?(dep)}"
|
|
||||||
puts " @side_effects.include? #{@side_effects.include?(dep)}"
|
|
||||||
!(targets_still_building.include?(dep) ||
|
!(targets_still_building.include?(dep) ||
|
||||||
self.include?(dep) ||
|
self.include?(dep) ||
|
||||||
@side_effects.include?(dep))
|
@side_effects.include?(dep))
|
||||||
@ -72,7 +66,6 @@ module Rscons
|
|||||||
|
|
||||||
if to_build
|
if to_build
|
||||||
target, builders = *to_build
|
target, builders = *to_build
|
||||||
puts "Selecting #{target.inspect} to build"
|
|
||||||
builder = builders.first
|
builder = builders.first
|
||||||
if builders.size > 1
|
if builders.size > 1
|
||||||
builders.slice!(0)
|
builders.slice!(0)
|
||||||
@ -86,7 +79,7 @@ module Rscons
|
|||||||
# not find a builder to run above, then there might be a circular
|
# not find a builder to run above, then there might be a circular
|
||||||
# dependency introduced by the user.
|
# dependency introduced by the user.
|
||||||
if (self.size > 0) and targets_still_building.empty?
|
if (self.size > 0) and targets_still_building.empty?
|
||||||
raise "Could not find a runnable builder. Possible circular dependency for #{self.keys.first}"
|
raise "Could not find a runnable builder. Possible circular dependency for #{self.first[1].first.target}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -15,16 +15,11 @@ module Rscons
|
|||||||
# List of paths to the object or static library dependencies.
|
# List of paths to the object or static library dependencies.
|
||||||
def register_object_deps(builder_class)
|
def register_object_deps(builder_class)
|
||||||
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
suffixes = @env.expand_varref(["${OBJSUFFIX}", "${LIBSUFFIX}"], @vars)
|
||||||
barrier_target = @env.setup_precompile(@sources)
|
|
||||||
@sources.map do |source|
|
@sources.map do |source|
|
||||||
if source.end_with?(*suffixes)
|
if source.end_with?(*suffixes)
|
||||||
source
|
source
|
||||||
else
|
else
|
||||||
object_file_path = @env.register_dependency_build(@target, source, suffixes.first, @vars, builder_class)
|
@env.register_dependency_build(@target, source, suffixes.first, @vars, builder_class)
|
||||||
if barrier_target
|
|
||||||
@env.depends(object_file_path, barrier_target)
|
|
||||||
end
|
|
||||||
object_file_path
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
module Rscons
|
|
||||||
module Builders
|
|
||||||
# The Precompile builder generates .di interface files from .d source files
|
|
||||||
# for D.
|
|
||||||
class Precompile < Builder
|
|
||||||
|
|
||||||
# Run the builder to produce a build target.
|
|
||||||
def run(options)
|
|
||||||
if @command
|
|
||||||
finalize_command
|
|
||||||
else
|
|
||||||
if @sources.find {|s| s.end_with?(*@env.expand_varref("${DSUFFIX}", @vars))}
|
|
||||||
pcc = @env.expand_varref("${DC}")
|
|
||||||
if pcc =~ /ldc/
|
|
||||||
dpc_cmd = "${DPC_CMD:ldc}"
|
|
||||||
else
|
|
||||||
dpc_cmd = "${DPC_CMD:gdc}"
|
|
||||||
end
|
|
||||||
@vars["_TARGET"] = @target
|
|
||||||
@vars["_SOURCES"] = @sources
|
|
||||||
command = @env.build_command(dpc_cmd, @vars)
|
|
||||||
standard_command("Precompile <source>#{Util.short_format_paths(@sources)}<reset>", command)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -142,16 +142,16 @@ module Rscons
|
|||||||
# - each cached dependency file's current checksum matches the checksum
|
# - each cached dependency file's current checksum matches the checksum
|
||||||
# stored in the cache file
|
# stored in the cache file
|
||||||
def up_to_date?(targets, command, deps, env, options = {})
|
def up_to_date?(targets, command, deps, env, options = {})
|
||||||
deps.map! {|dep| Util.absolute_path(dep)}
|
deps = deps.map {|dep| Util.absolute_path(dep)}
|
||||||
Array(targets).each do |target|
|
Array(targets).each do |target|
|
||||||
target = Util.absolute_path(target)
|
abstarget = Util.absolute_path(target)
|
||||||
cache_key = get_cache_key(target)
|
cache_key = get_cache_key(abstarget)
|
||||||
|
|
||||||
unless Rscons.phony_target?(target)
|
unless Rscons.phony_target?(abstarget)
|
||||||
# target file must exist on disk
|
# target file must exist on disk
|
||||||
unless File.exist?(target)
|
unless File.exist?(abstarget)
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because it does not exist on disk"
|
puts "Target #{target} needs rebuilding because it does not exist on disk"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -159,17 +159,17 @@ module Rscons
|
|||||||
|
|
||||||
# target must be registered in the cache
|
# target must be registered in the cache
|
||||||
unless @cache["targets"].has_key?(cache_key)
|
unless @cache["targets"].has_key?(cache_key)
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because there is no cached build information for it"
|
puts "Target #{target} needs rebuilding because there is no cached build information for it"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Rscons.phony_target?(target)
|
unless Rscons.phony_target?(abstarget)
|
||||||
# target must have the same checksum as when it was built last
|
# target must have the same checksum as when it was built last
|
||||||
unless @cache["targets"][cache_key]["checksum"] == lookup_checksum(target)
|
unless @cache["targets"][cache_key]["checksum"] == lookup_checksum(abstarget)
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because it has been changed on disk since being built last"
|
puts "Target #{target} needs rebuilding because it has been changed on disk since being built last"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -177,8 +177,8 @@ module Rscons
|
|||||||
|
|
||||||
# command used to build target must be identical
|
# command used to build target must be identical
|
||||||
unless @cache["targets"][cache_key]["command"] == Digest::MD5.hexdigest(command.inspect)
|
unless @cache["targets"][cache_key]["command"] == Digest::MD5.hexdigest(command.inspect)
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because the command used to build it has changed"
|
puts "Target #{target} needs rebuilding because the command used to build it has changed"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -188,29 +188,28 @@ module Rscons
|
|||||||
if options[:strict_deps]
|
if options[:strict_deps]
|
||||||
# depedencies passed in must exactly equal those in the cache
|
# depedencies passed in must exactly equal those in the cache
|
||||||
unless deps == cached_deps_fnames
|
unless deps == cached_deps_fnames
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies"
|
puts "Target #{target} needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# all dependencies passed in must exist in cache (but cache may have more)
|
# all dependencies passed in must exist in cache (but cache may have more)
|
||||||
unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?
|
unless (Set.new(deps) - Set.new(cached_deps_fnames)).empty?
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because there are new dependencies"
|
puts "Target #{target} needs rebuilding because there are new dependencies"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# set of user dependencies must match
|
# set of user dependencies must match
|
||||||
user_deps = env.get_user_deps(target) || []
|
user_deps = env.get_user_deps(abstarget) || []
|
||||||
user_deps.map! {|dep| Util.absolute_path(dep)}
|
|
||||||
cached_user_deps = @cache["targets"][cache_key]["user_deps"] || []
|
cached_user_deps = @cache["targets"][cache_key]["user_deps"] || []
|
||||||
cached_user_deps_fnames = cached_user_deps.map { |dc| dc["fname"] }
|
cached_user_deps_fnames = cached_user_deps.map { |dc| dc["fname"] }
|
||||||
unless user_deps == cached_user_deps_fnames
|
unless user_deps == cached_user_deps_fnames
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because the set of user-specified dependency files has changed"
|
puts "Target #{target} needs rebuilding because the set of user-specified dependency files has changed"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -218,14 +217,12 @@ module Rscons
|
|||||||
# all cached dependencies must have their checksums match
|
# all cached dependencies must have their checksums match
|
||||||
(cached_deps + cached_user_deps).each do |dep_cache|
|
(cached_deps + cached_user_deps).each do |dep_cache|
|
||||||
unless dep_cache["checksum"] == lookup_checksum(dep_cache["fname"])
|
unless dep_cache["checksum"] == lookup_checksum(dep_cache["fname"])
|
||||||
if options[:debug] || ENV["RSCONS_CACHE_DEBUG"]
|
if options[:debug]
|
||||||
puts "Cache: up_to_date?: Target #{target} needs rebuilding because dependency file #{dep_cache["fname"]} has changed"
|
puts "Target #{target} needs rebuilding because dependency file #{dep_cache["fname"]} has changed"
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Cache: up_to_date?: Target #{target} is up to date" if ENV["RSCONS_CACHE_DEBUG"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
@ -259,19 +256,19 @@ module Rscons
|
|||||||
else
|
else
|
||||||
calculate_checksum(target)
|
calculate_checksum(target)
|
||||||
end
|
end
|
||||||
puts "Cache: register_build(#{target}, #{target_checksum})"
|
deps = deps.map do |dep|
|
||||||
|
Util.absolute_path(dep)
|
||||||
|
end.uniq
|
||||||
@cache["targets"][get_cache_key(target)] = {
|
@cache["targets"][get_cache_key(target)] = {
|
||||||
"command" => Digest::MD5.hexdigest(command.inspect),
|
"command" => Digest::MD5.hexdigest(command.inspect),
|
||||||
"checksum" => target_checksum,
|
"checksum" => target_checksum,
|
||||||
"deps" => deps.map do |dep|
|
"deps" => deps.map do |dep|
|
||||||
dep = Util.absolute_path(dep)
|
|
||||||
{
|
{
|
||||||
"fname" => dep,
|
"fname" => dep,
|
||||||
"checksum" => lookup_checksum(dep),
|
"checksum" => lookup_checksum(dep),
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
"user_deps" => (env.get_user_deps(target) || []).map do |dep|
|
"user_deps" => (env.get_user_deps(target) || []).map do |dep|
|
||||||
dep = Util.absolute_path(dep)
|
|
||||||
{
|
{
|
||||||
"fname" => dep,
|
"fname" => dep,
|
||||||
"checksum" => lookup_checksum(dep),
|
"checksum" => lookup_checksum(dep),
|
||||||
@ -390,8 +387,6 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [String] The file's checksum.
|
# @return [String] The file's checksum.
|
||||||
def lookup_checksum(file)
|
def lookup_checksum(file)
|
||||||
file = Util.absolute_path(file)
|
|
||||||
puts "Cache: lookup_checksum(#{file})" if ENV["RSCONS_CACHE_DEBUG"]
|
|
||||||
@lookup_checksums[file] || calculate_checksum(file)
|
@lookup_checksums[file] || calculate_checksum(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -401,10 +396,7 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [String] The file's checksum.
|
# @return [String] The file's checksum.
|
||||||
def calculate_checksum(file)
|
def calculate_checksum(file)
|
||||||
file = Util.absolute_path(file)
|
@lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
||||||
cs = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
|
||||||
puts "Cache: calculate_checksum(#{file}) = #{cs}" if ENV["RSCONS_CACHE_DEBUG"]
|
|
||||||
@lookup_checksums[file] = cs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -43,8 +43,6 @@ module Rscons
|
|||||||
"DFLAGS" => [],
|
"DFLAGS" => [],
|
||||||
"DISASM_CMD" => %w[${OBJDUMP} ${DISASM_FLAGS} ${_SOURCES}],
|
"DISASM_CMD" => %w[${OBJDUMP} ${DISASM_FLAGS} ${_SOURCES}],
|
||||||
"DISASM_FLAGS" => %w[--disassemble --source],
|
"DISASM_FLAGS" => %w[--disassemble --source],
|
||||||
"DPC_CMD:ldc" => %w[${DC} -H -Hf ${_TARGET} -o- ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
|
||||||
"DPC_CMD:gdc" => %w[${DC} -H -Hf ${_TARGET} -fsyntax-only ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
|
||||||
"DSUFFIX" => %w[.d],
|
"DSUFFIX" => %w[.d],
|
||||||
"D_IMPORT_PATH" => [],
|
"D_IMPORT_PATH" => [],
|
||||||
"INCPREFIX" => "-I",
|
"INCPREFIX" => "-I",
|
||||||
|
|||||||
@ -291,17 +291,6 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get a path under the build root for precompile outputs.
|
|
||||||
#
|
|
||||||
# @param end_path [String]
|
|
||||||
# Path to append to precompile build root.
|
|
||||||
#
|
|
||||||
# @return [String]
|
|
||||||
# Precompile directory name.
|
|
||||||
def get_pc_build_dir(end_path)
|
|
||||||
"#{@build_root}/pc/#{Util.make_relative_path(end_path)}"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build all build targets specified in the Environment.
|
# Build all build targets specified in the Environment.
|
||||||
#
|
#
|
||||||
# When a block is passed to Environment.new, this method is automatically
|
# When a block is passed to Environment.new, this method is automatically
|
||||||
@ -382,8 +371,8 @@ module Rscons
|
|||||||
@builder_sets << build_builder_set
|
@builder_sets << build_builder_set
|
||||||
end
|
end
|
||||||
@builder_sets.last << builder
|
@builder_sets.last << builder
|
||||||
@build_steps += 1
|
@build_steps += 1 unless builder.is_a?(Rscons::Builders::Barrier)
|
||||||
@build_targets[target] = builder
|
@build_targets[builder.abstarget] = builder
|
||||||
builder
|
builder
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
@ -400,19 +389,19 @@ module Rscons
|
|||||||
if target.is_a?(Builder)
|
if target.is_a?(Builder)
|
||||||
target = target.target
|
target = target.target
|
||||||
end
|
end
|
||||||
unless Rscons.phony_target?(target)
|
target = expand(target.to_s)
|
||||||
target = Util.absolute_path(expand(target))
|
|
||||||
end
|
|
||||||
user_deps = user_deps.map do |ud|
|
user_deps = user_deps.map do |ud|
|
||||||
if ud.is_a?(Builder)
|
if ud.is_a?(Builder)
|
||||||
ud = ud.target
|
ud = ud.target
|
||||||
end
|
end
|
||||||
expand(ud)
|
expand(ud)
|
||||||
end
|
end
|
||||||
|
target = Util.absolute_path(target)
|
||||||
@user_deps[target] ||= []
|
@user_deps[target] ||= []
|
||||||
|
user_deps.map! {|ud| Util.absolute_path(ud)}
|
||||||
user_deps.each do |ud|
|
user_deps.each do |ud|
|
||||||
unless @user_deps[target].include?(ud)
|
unless Rscons.phony_target?(ud) || @user_deps[target].include?(ud)
|
||||||
@user_deps[target] << Util.absolute_path(ud)
|
@user_deps[target] << ud
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
build_after(target, user_deps)
|
build_after(target, user_deps)
|
||||||
@ -445,16 +434,14 @@ module Rscons
|
|||||||
targets = Array(targets)
|
targets = Array(targets)
|
||||||
prerequisites = Array(prerequisites)
|
prerequisites = Array(prerequisites)
|
||||||
targets.each do |target|
|
targets.each do |target|
|
||||||
unless Rscons.phony_target?(target)
|
|
||||||
target = Util.absolute_path(expand(target))
|
target = Util.absolute_path(expand(target))
|
||||||
end
|
|
||||||
@registered_build_dependencies[target] ||= Set.new
|
@registered_build_dependencies[target] ||= Set.new
|
||||||
prerequisites.each do |prerequisite|
|
prerequisites.each do |prerequisite|
|
||||||
if prerequisite.is_a?(Builder)
|
if prerequisite.is_a?(Builder)
|
||||||
prerequisite = prerequisite.target
|
prerequisite = prerequisite.target
|
||||||
end
|
end
|
||||||
prerequisite = expand(prerequisite)
|
prerequisite = Util.absolute_path(expand(prerequisite))
|
||||||
@registered_build_dependencies[target] << Util.absolute_path(prerequisite)
|
@registered_build_dependencies[target] << prerequisite
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -469,9 +456,9 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def produces(target, *side_effects)
|
def produces(target, *side_effects)
|
||||||
target = Util.absolute_path(expand(target))
|
abstarget = Util.absolute_path(expand(target))
|
||||||
@builder_sets.reverse.each do |builder_set|
|
@builder_sets.reverse.each do |builder_set|
|
||||||
if builders = builder_set[target]
|
if builders = builder_set[abstarget]
|
||||||
builders.last.produces(*side_effects)
|
builders.last.produces(*side_effects)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -488,7 +475,7 @@ module Rscons
|
|||||||
# @param side_effect [String]
|
# @param side_effect [String]
|
||||||
# Side effect fiel name.
|
# Side effect fiel name.
|
||||||
def register_side_effect(side_effect)
|
def register_side_effect(side_effect)
|
||||||
@side_effects << side_effect
|
@side_effects << Util.absolute_path(side_effect)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return the list of user dependencies for a given target.
|
# Return the list of user dependencies for a given target.
|
||||||
@ -499,6 +486,7 @@ module Rscons
|
|||||||
# List of user-specified dependencies for the target, or nil if none were
|
# List of user-specified dependencies for the target, or nil if none were
|
||||||
# specified.
|
# specified.
|
||||||
def get_user_deps(target)
|
def get_user_deps(target)
|
||||||
|
target = Util.absolute_path(target)
|
||||||
@user_deps[target]
|
@user_deps[target]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -522,10 +510,11 @@ module Rscons
|
|||||||
# @return [String]
|
# @return [String]
|
||||||
# Output file name.
|
# Output file name.
|
||||||
def register_dependency_build(target, source, suffix, vars, builder_class)
|
def register_dependency_build(target, source, suffix, vars, builder_class)
|
||||||
|
target = Util.absolute_path(target)
|
||||||
output_fname = get_build_fname(source, suffix, builder_class)
|
output_fname = get_build_fname(source, suffix, builder_class)
|
||||||
self.__send__(builder_class.name, output_fname, source, vars)
|
self.__send__(builder_class.name, output_fname, source, vars)
|
||||||
@registered_build_dependencies[target] ||= Set.new
|
@registered_build_dependencies[target] ||= Set.new
|
||||||
@registered_build_dependencies[target] << output_fname
|
@registered_build_dependencies[target] << Util.absolute_path(output_fname)
|
||||||
output_fname
|
output_fname
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -602,6 +591,7 @@ module Rscons
|
|||||||
# @return [Builder, nil]
|
# @return [Builder, nil]
|
||||||
# The {Builder} for target, or +nil+ if none found.
|
# The {Builder} for target, or +nil+ if none found.
|
||||||
def builder_for(target)
|
def builder_for(target)
|
||||||
|
target = Util.absolute_path(target)
|
||||||
@build_targets[target]
|
@build_targets[target]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -615,42 +605,6 @@ module Rscons
|
|||||||
@builder_sets << build_builder_set
|
@builder_sets << build_builder_set
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set up builders and barrier for a precompile phase if needed.
|
|
||||||
#
|
|
||||||
# @param sources [Array<String>]
|
|
||||||
# Sources for the build operation.
|
|
||||||
#
|
|
||||||
# @return [Symbol, nil]
|
|
||||||
# Barrier target name if a precompile phase is needed, otherwise nil.
|
|
||||||
def setup_precompile(sources)
|
|
||||||
barrier_target = nil
|
|
||||||
precompile_paths = Set.new
|
|
||||||
sources.each do |source|
|
|
||||||
next unless source.end_with?(".d")
|
|
||||||
unless barrier_target
|
|
||||||
barrier_target = Rscons.gen_phony_target
|
|
||||||
self.Barrier(barrier_target)
|
|
||||||
end
|
|
||||||
next unless module_name = Util.get_module_name(source)
|
|
||||||
next unless import_path = Util.find_import_path_for_d_source(self["D_IMPORT_PATH"], source, module_name)
|
|
||||||
precompile_path = get_pc_build_dir(import_path)
|
|
||||||
unless precompile_paths.include?(precompile_path)
|
|
||||||
Util.clean_d_precompile_path(precompile_path, import_path)
|
|
||||||
precompile_paths << precompile_path
|
|
||||||
end
|
|
||||||
unless self["D_IMPORT_PATH"].include?(precompile_path)
|
|
||||||
# Put the precompile path containing the .di files for the given
|
|
||||||
# import path immediately before the import path.
|
|
||||||
index = self["D_IMPORT_PATH"].find_index {|ip| ip == import_path}
|
|
||||||
self["D_IMPORT_PATH"].insert(index, precompile_path)
|
|
||||||
end
|
|
||||||
pctarget = "#{precompile_path}/#{module_name.gsub(".", "/")}.di"
|
|
||||||
self.Precompile(pctarget, source)
|
|
||||||
self.depends(barrier_target, pctarget)
|
|
||||||
end
|
|
||||||
barrier_target
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Build a BuilderSet.
|
# Build a BuilderSet.
|
||||||
@ -781,7 +735,7 @@ module Rscons
|
|||||||
# If no builder was found to run yet and there are threads available, try
|
# If no builder was found to run yet and there are threads available, try
|
||||||
# to get a runnable builder from the builder set.
|
# to get a runnable builder from the builder set.
|
||||||
targets_still_building = @threads.reduce([]) do |result, (thread, obj)|
|
targets_still_building = @threads.reduce([]) do |result, (thread, obj)|
|
||||||
result << Util.absolute_path(builder_for_thread(thread).target)
|
result << builder_for_thread(thread).abstarget
|
||||||
end
|
end
|
||||||
if @builder_sets.size > 0
|
if @builder_sets.size > 0
|
||||||
if builder = @builder_sets[0].get_next_builder_to_run(targets_still_building)
|
if builder = @builder_sets[0].get_next_builder_to_run(targets_still_building)
|
||||||
|
|||||||
@ -34,7 +34,15 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [Array<String>] Paths matching the specified pattern(s).
|
# @return [Array<String>] Paths matching the specified pattern(s).
|
||||||
def glob(*patterns)
|
def glob(*patterns)
|
||||||
Util.glob(*patterns)
|
require "pathname"
|
||||||
|
patterns.reduce([]) do |result, pattern|
|
||||||
|
if pattern.end_with?("/**")
|
||||||
|
pattern += "/"
|
||||||
|
end
|
||||||
|
result += Dir.glob(pattern).map do |path|
|
||||||
|
Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
|
||||||
|
end
|
||||||
|
end.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Download a file.
|
# Download a file.
|
||||||
|
|||||||
@ -16,39 +16,18 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the absolute path for a given path.
|
# Return the absolute path for a given target if not a phony target.
|
||||||
#
|
#
|
||||||
# If the path is a phony target, leave it as is.
|
# @param path [String, Symbol, nil]
|
||||||
|
# Given target name.
|
||||||
#
|
#
|
||||||
# @param path [String, Symbol]
|
# @return [String, Symbol, nil]
|
||||||
# Input path.
|
# Absolute path of given target.
|
||||||
#
|
|
||||||
# @return [String, Symbol]
|
|
||||||
# Output path.
|
|
||||||
def absolute_path(path)
|
def absolute_path(path)
|
||||||
if Rscons.phony_target?(path)
|
if path.is_a?(String)
|
||||||
path
|
|
||||||
else
|
|
||||||
File.expand_path(path)
|
File.expand_path(path)
|
||||||
end
|
else
|
||||||
end
|
path
|
||||||
|
|
||||||
# Remove any stale .di files from the precompile path.
|
|
||||||
#
|
|
||||||
# @param pc_path [String]
|
|
||||||
# Path to precompile build directory containing .di generated
|
|
||||||
# interface files.
|
|
||||||
# @param import_path [String]
|
|
||||||
# D import path containing .d source files.
|
|
||||||
#
|
|
||||||
# @return [void]
|
|
||||||
def clean_d_precompile_path(pc_path, import_path)
|
|
||||||
glob("#{pc_path}/**/*.di").each do |di_path|
|
|
||||||
end_path = di_path[(pc_path.size+1)..]
|
|
||||||
path = "#{import_path}/#{end_path}".sub(/\.di$/, ".d")
|
|
||||||
unless File.exist?(path)
|
|
||||||
FileUtils.rm_f(path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -156,29 +135,6 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find the D import path that will be used to import the given module.
|
|
||||||
#
|
|
||||||
# @param import_paths [Array<String>]
|
|
||||||
# Import paths.
|
|
||||||
# @param source [String]
|
|
||||||
# Source file name.
|
|
||||||
# @param module_name [String]
|
|
||||||
# Module name.
|
|
||||||
#
|
|
||||||
# @return [String, nil]
|
|
||||||
# Import path used to import the given module.
|
|
||||||
def find_import_path_for_d_source(import_paths, source, module_name)
|
|
||||||
source = source.gsub("\\", "/")
|
|
||||||
module_path = module_name.gsub(".", "/") + ".d"
|
|
||||||
import_paths.each do |import_path|
|
|
||||||
path = "#{import_path}/#{module_path}".gsub("\\", "/")
|
|
||||||
if path == source
|
|
||||||
return import_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Format an elapsed time in human-readable format.
|
# Format an elapsed time in human-readable format.
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
@ -200,52 +156,6 @@ module Rscons
|
|||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the module name for a D source file.
|
|
||||||
#
|
|
||||||
# @param source_path [String]
|
|
||||||
# D source file.
|
|
||||||
#
|
|
||||||
# @return [String, nil]
|
|
||||||
# Module name.
|
|
||||||
def get_module_name(source_path)
|
|
||||||
if File.exist?(source_path)
|
|
||||||
if File.binread(source_path) =~ /^\s*module\s(\S*);/
|
|
||||||
return $1
|
|
||||||
end
|
|
||||||
name = File.basename(source_path).sub(/\.d$/, "")
|
|
||||||
if name =~ /^\w+$/
|
|
||||||
return name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return a list of paths matching the specified pattern(s).
|
|
||||||
#
|
|
||||||
# A pattern can contain a "/**" component to recurse through directories.
|
|
||||||
# If the pattern ends with "/**" then only the recursive list of
|
|
||||||
# directories will be returned.
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
# - "src/**": return all directories under "src", recursively (including
|
|
||||||
# "src" itself).
|
|
||||||
# - "src/**/*": return all files and directories recursively under the src
|
|
||||||
# directory.
|
|
||||||
# - "src/**/*.c": return all .c files recursively under the src directory.
|
|
||||||
# - "dir/*/": return all directories in dir, but no files.
|
|
||||||
#
|
|
||||||
# @return [Array<String>] Paths matching the specified pattern(s).
|
|
||||||
def glob(*patterns)
|
|
||||||
require "pathname"
|
|
||||||
patterns.reduce([]) do |result, pattern|
|
|
||||||
if pattern.end_with?("/**")
|
|
||||||
pattern += "/"
|
|
||||||
end
|
|
||||||
result += Dir.glob(pattern).map do |path|
|
|
||||||
Pathname.new(path.gsub("\\", "/")).cleanpath.to_s
|
|
||||||
end
|
|
||||||
end.sort
|
|
||||||
end
|
|
||||||
|
|
||||||
# Make a relative path corresponding to a possibly absolute one.
|
# Make a relative path corresponding to a possibly absolute one.
|
||||||
#
|
#
|
||||||
# @param path [String]
|
# @param path [String]
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -138,27 +138,6 @@ module Rscons
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#depends" do
|
|
||||||
it "records the given dependencies in @user_deps" do
|
|
||||||
env = Environment.new
|
|
||||||
env.depends("foo", "bar", "baz")
|
|
||||||
expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]})
|
|
||||||
end
|
|
||||||
it "records user dependencies only once" do
|
|
||||||
env = Environment.new
|
|
||||||
env.instance_variable_set(:@user_deps, {"foo" => ["bar"]})
|
|
||||||
env.depends("foo", "bar", "baz")
|
|
||||||
expect(env.instance_variable_get(:@user_deps)).to eq({"foo" => ["bar", "baz"]})
|
|
||||||
end
|
|
||||||
it "expands arguments for construction variable references" do
|
|
||||||
env = Environment.new
|
|
||||||
env["foo"] = "foo.exe"
|
|
||||||
env["bar"] = "bar.c"
|
|
||||||
env.depends("${foo}", "${bar}", "a.h")
|
|
||||||
expect(env.instance_variable_get(:@user_deps)).to eq({"foo.exe" => ["bar.c", "a.h"]})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#shell" do
|
describe "#shell" do
|
||||||
it "executes the given shell command and returns the results" do
|
it "executes the given shell command and returns the results" do
|
||||||
env = Environment.new
|
env = Environment.new
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
if ENV["rscons_dist_specs"]
|
if ENV["rscons_dist_specs"]
|
||||||
require_relative "../test/rscons"
|
require_relative "../test_run/rscons"
|
||||||
else
|
else
|
||||||
require "simplecov"
|
require "simplecov"
|
||||||
|
|
||||||
|
class MyFormatter
|
||||||
|
def format(*args)
|
||||||
|
end
|
||||||
|
end
|
||||||
SimpleCov.start do
|
SimpleCov.start do
|
||||||
add_filter "/spec/"
|
add_filter "/spec/"
|
||||||
add_filter "/.bundle/"
|
add_filter "/.bundle/"
|
||||||
@ -11,9 +15,10 @@ else
|
|||||||
else
|
else
|
||||||
command_name "RSpec"
|
command_name "RSpec"
|
||||||
end
|
end
|
||||||
add_filter "test/rscons.rb"
|
add_filter "test_run/rscons.rb"
|
||||||
project_name "Rscons"
|
project_name "Rscons"
|
||||||
merge_timeout 3600
|
merge_timeout 3600
|
||||||
|
formatter(MyFormatter)
|
||||||
end
|
end
|
||||||
|
|
||||||
require "rscons"
|
require "rscons"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user