From 4eedea2563354762e7965f32d42df5447c1b6893 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 7 Feb 2015 09:57:44 -0500 Subject: [PATCH] add Copy builder as a copy of Install --- lib/rscons.rb | 3 ++- lib/rscons/builders/install.rb | 4 ++++ spec/build_tests_spec.rb | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/rscons.rb b/lib/rscons.rb index 9add59d..38c115e 100644 --- a/lib/rscons.rb +++ b/lib/rscons.rb @@ -22,8 +22,9 @@ module Rscons # Names of the default builders which will be added to all newly created # {Environment} objects. DEFAULT_BUILDERS = [ - :Command, :CFile, + :Command, + :Copy, :Directory, :Disassemble, :Install, diff --git a/lib/rscons/builders/install.rb b/lib/rscons/builders/install.rb index e8df7ac..f76397b 100644 --- a/lib/rscons/builders/install.rb +++ b/lib/rscons/builders/install.rb @@ -54,6 +54,10 @@ module Rscons target if (target_is_dir ? Dir.exists?(target) : File.exists?(target)) end + end + + class Copy < Install; end + end end diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index c607a22..fa66ee6 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -859,6 +859,23 @@ EOF expect(lines).to eq(["Install inst.exe"]) end + it "operates the same as a Copy builder" do + env = base_env.clone do |env| + lines + env.Copy("inst.exe", "simple.exe") + end + expect(lines).to eq(["Copy inst.exe"]) + env.Copy("inst.exe", "simple.exe") + env.process + expect(lines).to eq([]) + expect(File.exists?("inst.exe")).to be_truthy + expect(File.read("inst.exe", mode: "rb")).to eq(File.read("simple.exe", mode: "rb")) + FileUtils.rm("inst.exe") + env.Copy("inst.exe", "simple.exe") + env.process + expect(lines).to eq(["Copy inst.exe"]) + end + it "copies a file to the target directory name" do env = base_env.clone do |env| lines