Compare commits
19
Commits
a19c2e908e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af7aad716d | ||
|
|
13bd827d57 | ||
|
|
a3d739c472 | ||
|
|
319432bc61 | ||
|
|
d38cd2e8fb | ||
|
|
72d2802d1e | ||
|
|
e6317ae236 | ||
|
|
baf4e036fb | ||
|
|
9d6321685e | ||
|
|
3a5db626ac | ||
|
|
94a86e3433 | ||
|
|
fc18c9f123 | ||
|
|
1d020d1aef | ||
|
|
19c5c8cfba | ||
|
|
4fc7ab6b25 | ||
|
|
161da80ffe | ||
|
|
8d9f19cb34 | ||
|
|
18a2a075c1 | ||
|
|
1a280a8994 |
No files matched your search
@@ -0,0 +1,38 @@
|
||||
name: Run RScons Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
ruby-version: ['2.7', '3.0', '3.4']
|
||||
|
||||
steps:
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc gdc ldc clang flex bison
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install gcc ldc flex bison
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: bundle install
|
||||
|
||||
- name: Run tests
|
||||
run: rake all
|
||||
+1
-1
@@ -7,5 +7,5 @@
|
||||
/gen/
|
||||
/large_project/
|
||||
/pkg/
|
||||
/test/
|
||||
/test_run/
|
||||
/yard/
|
||||
@@ -1,3 +1,12 @@
|
||||
## v3.3.0
|
||||
|
||||
### New Features
|
||||
|
||||
- Add support for Ruby 3.4.
|
||||
- Fix up some macOS test cases.
|
||||
- #177 - Remove dependency on base64
|
||||
- #175 - Add support for building object files from LLVM assembly sources
|
||||
|
||||
## v3.2.0
|
||||
|
||||
### New Features
|
||||
|
||||
@@ -3,7 +3,8 @@ source 'https://rubygems.org'
|
||||
gem "base64"
|
||||
gem "rspec"
|
||||
gem "rake"
|
||||
gem "simplecov", "~> 0.15.0"
|
||||
gem "simplecov"
|
||||
gem "openssl"
|
||||
if RbConfig::CONFIG["host"]["msys"]
|
||||
gem "json", "2.1.0"
|
||||
else
|
||||
|
||||
+29
-22
@@ -1,39 +1,45 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
base64 (0.2.0)
|
||||
date (3.4.1)
|
||||
diff-lcs (1.6.0)
|
||||
docile (1.1.5)
|
||||
json (2.10.2)
|
||||
psych (5.2.3)
|
||||
base64 (0.3.0)
|
||||
date (3.5.1)
|
||||
diff-lcs (1.6.2)
|
||||
docile (1.4.1)
|
||||
erb (6.0.1)
|
||||
json (2.18.0)
|
||||
openssl (4.0.0)
|
||||
psych (5.3.1)
|
||||
date
|
||||
stringio
|
||||
rake (13.2.1)
|
||||
rdoc (6.13.0)
|
||||
rake (13.3.1)
|
||||
rdoc (7.1.0)
|
||||
erb
|
||||
psych (>= 4.0.0)
|
||||
tsort
|
||||
redcarpet (3.6.1)
|
||||
rspec (3.13.0)
|
||||
rspec (3.13.2)
|
||||
rspec-core (~> 3.13.0)
|
||||
rspec-expectations (~> 3.13.0)
|
||||
rspec-mocks (~> 3.13.0)
|
||||
rspec-core (3.13.3)
|
||||
rspec-core (3.13.6)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-expectations (3.13.3)
|
||||
rspec-expectations (3.13.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-mocks (3.13.2)
|
||||
rspec-mocks (3.13.7)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.13.0)
|
||||
rspec-support (3.13.2)
|
||||
simplecov (0.15.1)
|
||||
docile (~> 1.1.0)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
stringio (3.1.5)
|
||||
rspec-support (3.13.6)
|
||||
simplecov (0.22.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
simplecov_json_formatter (~> 0.1)
|
||||
simplecov-html (0.13.2)
|
||||
simplecov_json_formatter (0.1.4)
|
||||
stringio (3.2.0)
|
||||
syntax (1.2.2)
|
||||
yard (0.9.37)
|
||||
tsort (0.2.0)
|
||||
yard (0.9.38)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -42,13 +48,14 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
base64
|
||||
json
|
||||
openssl
|
||||
rake
|
||||
rdoc
|
||||
redcarpet
|
||||
rspec
|
||||
simplecov (~> 0.15.0)
|
||||
simplecov
|
||||
syntax
|
||||
yard
|
||||
|
||||
BUNDLED WITH
|
||||
2.4.17
|
||||
2.6.2
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2013-2022 Josh Holtrop
|
||||
Copyright (c) 2013-2025 Josh Holtrop
|
||||
|
||||
MIT License
|
||||
|
||||
|
||||
+28
-7
@@ -8,8 +8,10 @@ end
|
||||
require "rspec/core/rake_task"
|
||||
require "rake/clean"
|
||||
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]
|
||||
|
||||
task :build_dist do
|
||||
@@ -19,24 +21,43 @@ end
|
||||
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
|
||||
ENV["specs"] = "1"
|
||||
if args.example_string
|
||||
ENV["partial_specs"] = "1"
|
||||
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
|
||||
end
|
||||
end
|
||||
task :spec => :build_dist
|
||||
task :spec do
|
||||
ENV.delete("specs")
|
||||
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
|
||||
# useful for coverage information.
|
||||
desc "Dist Specs"
|
||||
task :dspec, [:example_string] => :build_dist do |task, args|
|
||||
FileUtils.mkdir_p("test")
|
||||
FileUtils.cp("dist/rscons", "test/rscons.rb")
|
||||
ENV["dist_specs"] = "1"
|
||||
FileUtils.rm_rf("test_run")
|
||||
FileUtils.mkdir_p("test_run")
|
||||
FileUtils.cp("dist/rscons", "test_run/rscons.rb")
|
||||
ENV["rscons_dist_specs"] = "1"
|
||||
Rake::Task["spec"].execute(args)
|
||||
ENV.delete("dist_specs")
|
||||
Rake::Task["build_tests"].execute(args)
|
||||
ENV.delete("rscons_dist_specs")
|
||||
FileUtils.rm_f(Dir.glob(".rscons-*"))
|
||||
end
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
@@ -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,5 +3,5 @@ env do |env|
|
||||
env["CFLAGS"] += %w[-S]
|
||||
env.Object("one.ssss", "one.c", "CPPFLAGS" => ["-DONE"])
|
||||
env.Object("two.sss", "two.c")
|
||||
env.Program("two_sources.exe", %w[one.ssss two.sss], "ASFLAGS" => env["ASFLAGS"] + %w[-x assembler])
|
||||
env.Program("two_sources.exe", %w[one.ssss two.sss], "ASFLAGS" => env["ASFLAGS"] + %w[-x assembler-with-cpp])
|
||||
end
|
||||
@@ -3,7 +3,6 @@ env(echo: :command) do |env|
|
||||
env.add_build_hook do |builder|
|
||||
if builder.name == "Object" && builder.sources.first =~ %r{one\.c}
|
||||
builder.vars["CFLAGS"] << "-O1"
|
||||
builder.sources = ['src/two/two.c']
|
||||
elsif builder.name == "Object" && builder.target =~ %r{two\.o}
|
||||
new_vars = builder.vars.clone
|
||||
new_vars["CFLAGS"] << "-O2"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Custom < Rscons::Builder
|
||||
def run(options)
|
||||
print_run_message("#{name} #{target}", nil)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
env do |env|
|
||||
env.add_builder(Custom)
|
||||
env.Custom("t3", :phony1)
|
||||
env.Custom(:phony1, "t2")
|
||||
env.Custom("t2", :phony2)
|
||||
env.Custom(:phony2, "t1")
|
||||
env.Custom("t1", [])
|
||||
end
|
||||
@@ -23,6 +23,7 @@ module Rscons
|
||||
# Names of the default builders which will be added to all newly created
|
||||
# {Environment} objects.
|
||||
DEFAULT_BUILDERS = [
|
||||
:Barrier,
|
||||
:Command,
|
||||
:Copy,
|
||||
:Directory,
|
||||
@@ -66,6 +67,13 @@ module Rscons
|
||||
target.is_a?(Symbol)
|
||||
end
|
||||
|
||||
# Generate a random phony target name.
|
||||
#
|
||||
# @return [Symbol] Phony target name.
|
||||
def gen_phony_target
|
||||
("t" + sprintf("%08x", rand(1_000_000..4_000_000_000))).to_sym
|
||||
end
|
||||
|
||||
# Return the system shell and arguments for executing a shell command.
|
||||
#
|
||||
# @return [Array<String>] The shell and flag.
|
||||
@@ -136,6 +144,7 @@ require_relative "rscons/builders/mixins/object_deps"
|
||||
require_relative "rscons/builders/mixins/program"
|
||||
|
||||
# default builders
|
||||
require_relative "rscons/builders/barrier"
|
||||
require_relative "rscons/builders/command"
|
||||
require_relative "rscons/builders/copy"
|
||||
require_relative "rscons/builders/directory"
|
||||
|
||||
+21
-9
@@ -29,19 +29,27 @@ module Rscons
|
||||
|
||||
# @return [String, Symbol]
|
||||
# Target file name.
|
||||
attr_accessor :target
|
||||
attr_reader :target
|
||||
|
||||
# @return [Array<String>]
|
||||
# Source file name(s).
|
||||
attr_accessor :sources
|
||||
# @return [String, Symbol]
|
||||
# Absolute target file name.
|
||||
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]
|
||||
# Cache instance.
|
||||
attr_accessor :cache
|
||||
attr_reader :cache
|
||||
|
||||
# @return [Environment]
|
||||
# The {Environment} performing the build operation.
|
||||
attr_accessor :env
|
||||
attr_reader :env
|
||||
|
||||
# @return [Hash, VarSet]
|
||||
# Construction variables used to perform the build operation.
|
||||
@@ -49,7 +57,7 @@ module Rscons
|
||||
|
||||
# @return [Set<String>]
|
||||
# Side effect file(s) produced when this builder runs.
|
||||
attr_accessor :side_effects
|
||||
attr_reader :side_effects
|
||||
|
||||
# @return [Integer]
|
||||
# Build step.
|
||||
@@ -71,7 +79,11 @@ module Rscons
|
||||
# Extra construction variables.
|
||||
def initialize(options)
|
||||
@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]
|
||||
@env = options[:env]
|
||||
@vars = options[:vars]
|
||||
@@ -103,7 +115,7 @@ module Rscons
|
||||
# @return [void]
|
||||
def produces(*side_effects)
|
||||
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)
|
||||
@side_effects << side_effect_expanded
|
||||
end
|
||||
|
||||
@@ -27,8 +27,8 @@ module Rscons
|
||||
# env.Directory("dest")
|
||||
# env.Install("dest", "bin")
|
||||
# env.Install("dest", "share")
|
||||
self[builder.target] ||= []
|
||||
self[builder.target] << builder
|
||||
self[builder.abstarget] ||= []
|
||||
self[builder.abstarget] << builder
|
||||
end
|
||||
|
||||
# Return the number of remaining build steps.
|
||||
@@ -37,7 +37,7 @@ module Rscons
|
||||
# The number of remaining build steps.
|
||||
def build_steps_remaining
|
||||
self.reduce(0) do |result, (target, builders)|
|
||||
result + builders.size
|
||||
result + builders.count {|b| !b.is_a?(Rscons::Builders::Barrier)}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ module Rscons
|
||||
# The next builder to run.
|
||||
def get_next_builder_to_run(targets_still_building)
|
||||
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
|
||||
# All dependencies must have been built for this target to be ready to
|
||||
# build.
|
||||
deps.all? do |dep|
|
||||
@@ -79,7 +79,7 @@ module Rscons
|
||||
# not find a builder to run above, then there might be a circular
|
||||
# dependency introduced by the user.
|
||||
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
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
# The Barrier builder does not perform any action. It exists as a builder
|
||||
# on which to place dependencies to ensure that each of its sources are
|
||||
# built before any build targets which depend on the barrier build target.
|
||||
class Barrier < Builder
|
||||
|
||||
# Run the builder.
|
||||
def run(options)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
+12
-6
@@ -142,12 +142,14 @@ module Rscons
|
||||
# - each cached dependency file's current checksum matches the checksum
|
||||
# stored in the cache file
|
||||
def up_to_date?(targets, command, deps, env, options = {})
|
||||
deps = deps.map {|dep| Util.absolute_path(dep)}
|
||||
Array(targets).each do |target|
|
||||
cache_key = get_cache_key(target)
|
||||
abstarget = Util.absolute_path(target)
|
||||
cache_key = get_cache_key(abstarget)
|
||||
|
||||
unless Rscons.phony_target?(target)
|
||||
unless Rscons.phony_target?(abstarget)
|
||||
# target file must exist on disk
|
||||
unless File.exist?(target)
|
||||
unless File.exist?(abstarget)
|
||||
if options[:debug]
|
||||
puts "Target #{target} needs rebuilding because it does not exist on disk"
|
||||
end
|
||||
@@ -163,9 +165,9 @@ module Rscons
|
||||
return false
|
||||
end
|
||||
|
||||
unless Rscons.phony_target?(target)
|
||||
unless Rscons.phony_target?(abstarget)
|
||||
# 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]
|
||||
puts "Target #{target} needs rebuilding because it has been changed on disk since being built last"
|
||||
end
|
||||
@@ -202,7 +204,7 @@ module Rscons
|
||||
end
|
||||
|
||||
# set of user dependencies must match
|
||||
user_deps = env.get_user_deps(target) || []
|
||||
user_deps = env.get_user_deps(abstarget) || []
|
||||
cached_user_deps = @cache["targets"][cache_key]["user_deps"] || []
|
||||
cached_user_deps_fnames = cached_user_deps.map { |dc| dc["fname"] }
|
||||
unless user_deps == cached_user_deps_fnames
|
||||
@@ -247,12 +249,16 @@ module Rscons
|
||||
# @return [void]
|
||||
def register_build(targets, command, deps, env, options = {})
|
||||
Array(targets).each do |target|
|
||||
target = Util.absolute_path(target)
|
||||
target_checksum =
|
||||
if options[:side_effect] or Rscons.phony_target?(target)
|
||||
""
|
||||
else
|
||||
calculate_checksum(target)
|
||||
end
|
||||
deps = deps.map do |dep|
|
||||
Util.absolute_path(dep)
|
||||
end.uniq
|
||||
@cache["targets"][get_cache_key(target)] = {
|
||||
"command" => Digest::MD5.hexdigest(command.inspect),
|
||||
"checksum" => target_checksum,
|
||||
|
||||
+30
-15
@@ -371,8 +371,8 @@ module Rscons
|
||||
@builder_sets << build_builder_set
|
||||
end
|
||||
@builder_sets.last << builder
|
||||
@build_steps += 1
|
||||
@build_targets[target] = builder
|
||||
@build_steps += 1 unless builder.is_a?(Rscons::Builders::Barrier)
|
||||
@build_targets[builder.abstarget] = builder
|
||||
builder
|
||||
else
|
||||
super
|
||||
@@ -396,8 +396,14 @@ module Rscons
|
||||
end
|
||||
expand(ud)
|
||||
end
|
||||
target = Util.absolute_path(target)
|
||||
@user_deps[target] ||= []
|
||||
@user_deps[target] = (@user_deps[target] + user_deps).uniq
|
||||
user_deps.map! {|ud| Util.absolute_path(ud)}
|
||||
user_deps.each do |ud|
|
||||
unless Rscons.phony_target?(ud) || @user_deps[target].include?(ud)
|
||||
@user_deps[target] << ud
|
||||
end
|
||||
end
|
||||
build_after(target, user_deps)
|
||||
end
|
||||
|
||||
@@ -428,13 +434,13 @@ module Rscons
|
||||
targets = Array(targets)
|
||||
prerequisites = Array(prerequisites)
|
||||
targets.each do |target|
|
||||
target = expand(target)
|
||||
target = Util.absolute_path(expand(target))
|
||||
@registered_build_dependencies[target] ||= Set.new
|
||||
prerequisites.each do |prerequisite|
|
||||
if prerequisite.is_a?(Builder)
|
||||
prerequisite = prerequisite.target
|
||||
end
|
||||
prerequisite = expand(prerequisite)
|
||||
prerequisite = Util.absolute_path(expand(prerequisite))
|
||||
@registered_build_dependencies[target] << prerequisite
|
||||
end
|
||||
end
|
||||
@@ -450,9 +456,9 @@ module Rscons
|
||||
#
|
||||
# @return [void]
|
||||
def produces(target, *side_effects)
|
||||
target = expand(target)
|
||||
abstarget = Util.absolute_path(expand(target))
|
||||
@builder_sets.reverse.each do |builder_set|
|
||||
if builders = builder_set[target]
|
||||
if builders = builder_set[abstarget]
|
||||
builders.last.produces(*side_effects)
|
||||
return
|
||||
end
|
||||
@@ -469,7 +475,7 @@ module Rscons
|
||||
# @param side_effect [String]
|
||||
# Side effect fiel name.
|
||||
def register_side_effect(side_effect)
|
||||
@side_effects << side_effect
|
||||
@side_effects << Util.absolute_path(side_effect)
|
||||
end
|
||||
|
||||
# Return the list of user dependencies for a given target.
|
||||
@@ -480,6 +486,7 @@ module Rscons
|
||||
# List of user-specified dependencies for the target, or nil if none were
|
||||
# specified.
|
||||
def get_user_deps(target)
|
||||
target = Util.absolute_path(target)
|
||||
@user_deps[target]
|
||||
end
|
||||
|
||||
@@ -503,10 +510,11 @@ module Rscons
|
||||
# @return [String]
|
||||
# Output file name.
|
||||
def register_dependency_build(target, source, suffix, vars, builder_class)
|
||||
target = Util.absolute_path(target)
|
||||
output_fname = get_build_fname(source, suffix, builder_class)
|
||||
self.__send__(builder_class.name, output_fname, source, vars)
|
||||
@registered_build_dependencies[target] ||= Set.new
|
||||
@registered_build_dependencies[target] << output_fname
|
||||
@registered_build_dependencies[target] << Util.absolute_path(output_fname)
|
||||
output_fname
|
||||
end
|
||||
|
||||
@@ -583,6 +591,7 @@ module Rscons
|
||||
# @return [Builder, nil]
|
||||
# The {Builder} for target, or +nil+ if none found.
|
||||
def builder_for(target)
|
||||
target = Util.absolute_path(target)
|
||||
@build_targets[target]
|
||||
end
|
||||
|
||||
@@ -623,7 +632,9 @@ module Rscons
|
||||
#
|
||||
# @return [void]
|
||||
def run_builder(builder)
|
||||
builder.build_step ||= get_next_build_step
|
||||
unless builder.is_a?(Rscons::Builders::Barrier)
|
||||
builder.build_step ||= get_next_build_step
|
||||
end
|
||||
case result = builder.run({})
|
||||
when Array
|
||||
result.each do |waititem|
|
||||
@@ -649,8 +660,10 @@ module Rscons
|
||||
Cache.instance.register_build(side_effect, nil, [], self, side_effect: true)
|
||||
@side_effects.delete(side_effect)
|
||||
end
|
||||
@build_hooks[:post].each do |build_hook_block|
|
||||
build_hook_block.call(builder)
|
||||
unless builder.is_a?(Rscons::Builders::Barrier)
|
||||
@build_hooks[:post].each do |build_hook_block|
|
||||
build_hook_block.call(builder)
|
||||
end
|
||||
end
|
||||
process_remove_wait(builder)
|
||||
else
|
||||
@@ -722,13 +735,15 @@ module Rscons
|
||||
# If no builder was found to run yet and there are threads available, try
|
||||
# to get a runnable builder from the builder set.
|
||||
targets_still_building = @threads.reduce([]) do |result, (thread, obj)|
|
||||
result << builder_for_thread(thread).target
|
||||
result << builder_for_thread(thread).abstarget
|
||||
end
|
||||
if @builder_sets.size > 0
|
||||
if builder = @builder_sets[0].get_next_builder_to_run(targets_still_building)
|
||||
builder.vars = @varset.merge(builder.vars)
|
||||
@build_hooks[:pre].each do |build_hook_block|
|
||||
build_hook_block.call(builder)
|
||||
unless builder.is_a?(Rscons::Builders::Barrier)
|
||||
@build_hooks[:pre].each do |build_hook_block|
|
||||
build_hook_block.call(builder)
|
||||
end
|
||||
end
|
||||
return run_builder(builder)
|
||||
end
|
||||
|
||||
@@ -16,6 +16,21 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Return the absolute path for a given target if not a phony target.
|
||||
#
|
||||
# @param path [String, Symbol, nil]
|
||||
# Given target name.
|
||||
#
|
||||
# @return [String, Symbol, nil]
|
||||
# Absolute path of given target.
|
||||
def absolute_path(path)
|
||||
if path.is_a?(String)
|
||||
File.expand_path(path)
|
||||
else
|
||||
path
|
||||
end
|
||||
end
|
||||
|
||||
# Colorize a builder run message.
|
||||
#
|
||||
# @param message [String]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# Project version.
|
||||
VERSION = "3.2.0"
|
||||
VERSION = "3.3.0"
|
||||
end
|
||||
+45
-10
@@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "fileutils"
|
||||
require "base64"
|
||||
require "digest/md5"
|
||||
require "fileutils"
|
||||
require "stringio"
|
||||
require "zlib"
|
||||
|
||||
if File.read("lib/rscons/version.rb") =~ /VERSION = "(.+)"/
|
||||
VERSION = $1
|
||||
@@ -68,11 +71,15 @@ license = File.read("LICENSE.txt").gsub(/^(.*?)$/) do |line|
|
||||
end
|
||||
end
|
||||
|
||||
require "zlib"
|
||||
require "base64"
|
||||
compressed_script = Zlib::Deflate.deflate(stripped.join)
|
||||
hash = Digest::MD5.hexdigest(compressed_script)
|
||||
encoded_compressed_script = Base64.encode64(compressed_script).gsub("\n", "")
|
||||
hash = Digest::MD5.hexdigest(encoded_compressed_script)
|
||||
encoded_compressed_script_io = StringIO.new(encoded_compressed_script)
|
||||
commented_encoded_compressed_script = ""
|
||||
until encoded_compressed_script_io.eof?
|
||||
line = encoded_compressed_script_io.read(64)
|
||||
commented_encoded_compressed_script += "##{line}\n"
|
||||
end
|
||||
|
||||
FileUtils.rm_rf(DIST)
|
||||
FileUtils.mkdir_p(DIST)
|
||||
@@ -82,25 +89,53 @@ File.open("#{DIST}/#{PROG_NAME}", "wb", 0755) do |fh|
|
||||
|
||||
#{license}
|
||||
|
||||
BASE64CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
|
||||
def base64_decode(s)
|
||||
out = ""
|
||||
v = 0
|
||||
bits = 0
|
||||
s.each_char do |c|
|
||||
if cv = BASE64CHARS.index(c)
|
||||
v = (v << 6) | cv
|
||||
bits += 6
|
||||
elsif c == "="
|
||||
break
|
||||
end
|
||||
if bits >= 8
|
||||
out += (v >> (bits - 8)).chr
|
||||
v &= 0xFFFFFFFF >> (32 - (bits - 8))
|
||||
bits -= 8
|
||||
end
|
||||
end
|
||||
out
|
||||
end
|
||||
|
||||
script = File.join(File.dirname(__FILE__), ".rscons-#{VERSION}-#{hash}.rb")
|
||||
unless File.exist?(script)
|
||||
if File.read(__FILE__, mode: "rb") =~ /^#==>(.*)/
|
||||
if File.read(__FILE__, mode: "rb") =~ /^#==>(.*)/m
|
||||
require "zlib"
|
||||
require "base64"
|
||||
encoded_compressed = $1
|
||||
unescaped_compressed = Base64.decode64(encoded_compressed)
|
||||
inflated = Zlib::Inflate.inflate(unescaped_compressed)
|
||||
compressed = base64_decode(encoded_compressed)
|
||||
if ENV["rscons_dist_specs"]
|
||||
require "digest/md5"
|
||||
if Digest::MD5.hexdigest(compressed) != "#{hash}"
|
||||
raise "Hash mismatch when decompressing rscons executable"
|
||||
end
|
||||
end
|
||||
inflated = Zlib::Inflate.inflate(compressed)
|
||||
File.open(script, "wb") do |fh|
|
||||
fh.write(inflated)
|
||||
end
|
||||
else
|
||||
raise "Could not decompress."
|
||||
raise "Error expanding rscons executable"
|
||||
end
|
||||
end
|
||||
load script
|
||||
if __FILE__ == $0
|
||||
Rscons::Cli.new.run(ARGV)
|
||||
end
|
||||
#==>#{encoded_compressed_script}
|
||||
#==>
|
||||
#{commented_encoded_compressed_script}
|
||||
EOF
|
||||
end
|
||||
File diff suppressed because it is too large.
Load diff
@@ -138,27 +138,6 @@ module Rscons
|
||||
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
|
||||
it "executes the given shell command and returns the results" do
|
||||
env = Environment.new
|
||||
|
||||
+8
-8
@@ -1,8 +1,12 @@
|
||||
if ENV["dist_specs"]
|
||||
require_relative "../test/rscons"
|
||||
if ENV["rscons_dist_specs"]
|
||||
require_relative "../test_run/rscons"
|
||||
else
|
||||
require "simplecov"
|
||||
|
||||
class MyFormatter
|
||||
def format(*args)
|
||||
end
|
||||
end
|
||||
SimpleCov.start do
|
||||
add_filter "/spec/"
|
||||
add_filter "/.bundle/"
|
||||
@@ -11,14 +15,10 @@ else
|
||||
else
|
||||
command_name "RSpec"
|
||||
end
|
||||
if ENV["dist_specs"]
|
||||
add_filter "/bin/"
|
||||
add_filter "/lib/"
|
||||
else
|
||||
add_filter "test/rscons.rb"
|
||||
end
|
||||
add_filter "test_run/rscons.rb"
|
||||
project_name "Rscons"
|
||||
merge_timeout 3600
|
||||
formatter(MyFormatter)
|
||||
end
|
||||
|
||||
require "rscons"
|
||||
|
||||
Reference in new issue
Block a user