Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewriting the build system, allowing us to create x86/AnyCPU and CLR2…

…/CLR4 binaries in one go
  • Loading branch information...
commit 21d64eac663659707093631ea518d320bd217086 1 parent 0f1d11e
Alexander Groß authored
8 Tools/Rake/task.rb
View
@@ -0,0 +1,8 @@
+class Rake::Task
+ old_execute = self.instance_method(:execute)
+
+ define_method(:execute) do |args|
+ puts "\n[#{name}]\n"
+ old_execute.bind(self).call(args)
+ end
+end
1  build-3.5-debug.cmd
View
@@ -1 +0,0 @@
-@build.cmd version=net_35 target=Debug %*
1  build-3.5-release.cmd
View
@@ -1 +0,0 @@
-@build.cmd version=net_35 target=Release %*
1  build-4.0-debug.cmd
View
@@ -1 +0,0 @@
-@build.cmd version=net_40 target=Debug %*
1  build-4.0-release.cmd
View
@@ -1 +0,0 @@
-@build.cmd version=net_40 target=Release %*
1  build-debug.cmd
View
@@ -0,0 +1 @@
+@build.cmd target=Debug %*
1  build-release.cmd
View
@@ -0,0 +1 @@
+@build.cmd target=Release %*
8 rakefile.net-3.5.rb
View
@@ -1,8 +0,0 @@
-# Build tasks specific to .NET 3.5 builds.
-
-namespace :tests do
- task :run do
- puts 'Running Gallio tests...'
- sh "Tools/Gallio/v3.1.397/Gallio.Echo.exe", "#{configatron.out_dir}/Tests/Gallio/Machine.Specifications.TestGallioAdapter.3.1.Tests.dll", "/plugin-directory:#{configatron.out_dir}", "/r:Local"
- end
-end
132 rakefile.rb
View
@@ -1,4 +1,5 @@
require 'rake'
+require 'rake/clean'
require 'fileutils'
require 'configatron'
Dir.glob(File.join(File.dirname(__FILE__), 'tools/Rake/*.rb')).each do |f|
@@ -6,40 +7,20 @@
end
include FileUtils
-project = "Machine.Specifications"
-mspec_options = []
-
task :configure do
- version = ENV.include?('version') ? ENV['version'].to_sym : :net_35
- target = ENV.include?('target') ? ENV['target'] : 'Debug'
+ project = "Machine.Specifications"
+ target = ENV['target'] || 'Debug'
build_config = {
- :net_35 => {
- :friendly_name => 'net-3.5',
- :version => 'v3.5',
- :project => project,
- :solution => project,
- :target => target,
- :compile_target => target,
- :out_dir => "Build/#{target}/",
- :package_name => "Distribution/#{project}-net-3.5-#{target}.zip",
- :nunit_framework => "net-3.5"
- },
- :net_40 => {
- :friendly_name => 'net-4.0',
- :version => 'v4\Full',
- :project => project,
- :solution => project,
- :target => target,
- :compile_target => "#{target} .NET 4.0".escape,
- :out_dir => "Build/#{target}/",
- :package_name => "Distribution/#{project}-net-4.0-#{target}.zip",
- :nunit_framework => "net-3.5",
- :additional_specs => ["Machine.Specifications.Example.Clr4.dll"],
- }
+ :project => project,
+ :target => target,
+ :out_dir => "Build/#{target}/",
+ :package_name => "Distribution/#{project}-#{target}.zip",
+ :nunit_framework => "net-3.5",
+ :mspec_options => []
}
- configatron.configure_from_hash build_config[version]
+ configatron.configure_from_hash build_config
configatron.protect_all!
puts configatron.inspect
end
@@ -49,30 +30,53 @@
desc "Build and run specs"
task :default => [ "build", "tests:run", "specs:run" ]
-desc "Clean"
-task :clean do
- MSBuild.compile \
- :project => "Source/#{configatron.solution}.sln",
- :version => configatron.version,
- :properties => {
- :Configuration => configatron.compile_target
- },
- :switches => {
- :target => 'Clean'
- }
-
- rm_f configatron.package_name
- rm_rf "Build"
-end
+CLEAN.clear
+CLEAN.include('teamcity-info.xml')
+CLEAN.include('Source/**/obj')
+CLEAN.include('Build')
+CLEAN.include(configatron.package_name)
desc "Build"
task :build do
- MSBuild.compile \
- :project => "Source/#{configatron.solution}.sln",
- :version => configatron.version,
- :properties => {
- :Configuration => configatron.compile_target
+ opts = {
+ :version => 'v4\Full',
+ :switches => { :verbosity => :minimal, :target => :Build },
+ :properties => {
+ :Configuration => configatron.target
+ }
}
+
+ FileList.new('Source/**/*.csproj').each do |project|
+ MSBuild.compile opts.merge({ :project => project })
+ end
+
+ def build (msbuild_options, config)
+ project = msbuild_options[:project]
+
+ xml = File.read project
+ config.each do |element, value|
+ xml.gsub! /<#{element}>.*?<\/#{element}>/, "<#{element}>#{value}</#{element}>"
+ end
+
+ patched_project = project + config.hash.to_s
+ File.open(patched_project, "w") { |file| file.puts xml }
+
+ MSBuild.compile msbuild_options.merge({ :project => patched_project })
+
+ rm patched_project
+ end
+
+ console_runner = {
+ :x86 => { :TargetFrameworkVersion => 'v3.5', :PlatformTarget => 'x86', :AssemblyName => 'mspec-x86' },
+ :AnyCPU => { :TargetFrameworkVersion => 'v3.5', :PlatformTarget => 'AnyCPU', :AssemblyName => 'mspec' },
+ :clr4_x86 => { :TargetFrameworkVersion => 'v4.0', :PlatformTarget => 'x86', :AssemblyName => 'mspec-x86-clr4' },
+ :clr4_AnyCPU => { :TargetFrameworkVersion => 'v4.0', :PlatformTarget => 'AnyCPU', :AssemblyName => 'mspec-clr4' }
+ }
+
+ console_runner.values.each do |config|
+ project = 'Source/Machine.Specifications.ConsoleRunner/Machine.Specifications.ConsoleRunner.csproj'
+ build opts.merge({ :project => project }), config
+ end
end
desc "Rebuild"
@@ -85,10 +89,13 @@
task :run do
puts 'Running Specs...'
- specs = ["Machine.Specifications.Specs.dll", "Machine.Specifications.Reporting.Specs.dll", "Machine.Specifications.ConsoleRunner.Specs.dll"]
- specs = specs | configatron.additional_specs if configatron.exists?(:additional_specs)
- specs.map! {|spec| "#{configatron.out_dir}/Tests/#{spec}"}
- sh "#{configatron.out_dir}/mspec.exe", "--html", "Specs/#{configatron.project}.Specs.html", "-x", "example", *(mspec_options + specs)
+
+ specs = FileList.new("#{configatron.out_dir}/Tests/*.Specs.dll").to_a
+ sh "#{configatron.out_dir}/mspec.exe", "--html", "Specs/#{configatron.project}.Specs.html", "-x", "example", *(configatron.mspec_options + specs)
+
+ specs = ["#{configatron.out_dir}/Tests/Machine.Specifications.Example.Clr4.dll"]
+ sh "#{configatron.out_dir}/mspec-clr4.exe", "-x", "example", *(configatron.mspec_options + specs)
+
puts "Wrote specs to Specs/#{configatron.project}.Specs.html, run 'rake specs:view' to see them"
end
end
@@ -96,16 +103,15 @@
namespace :tests do
task :run do
puts 'Running NUnit tests...'
- tests = ["Machine.Specifications.Tests.dll"].map {|test| "#{configatron.out_dir}/Tests/#{test}"}
+
+ tests = FileList.new("#{configatron.out_dir}/Tests/*.Tests.dll").to_a
runner = NUnitRunner.new :platform => 'x86', :results => "Specs", :clr_version => configatron.nunit_framework
runner.executeTests tests
end
-end
-
-desc "Open solution in VS"
-task :sln do
- Thread.new do
- system "devenv Source/#{configatron.solution}.sln"
+
+ task :run do
+ puts 'Running Gallio tests...'
+ sh "Tools/Gallio/v3.1.397/Gallio.Echo.exe", "#{configatron.out_dir}/Tests/Gallio/Machine.Specifications.TestGallioAdapter.3.1.Tests.dll", "/plugin-directory:#{configatron.out_dir}", "/r:Local"
end
end
@@ -147,7 +153,5 @@
desc "Sets up the TeamCity environment"
task :teamcity_environment do
- mspec_options.push "--teamcity"
-end
-
-require "rakefile.#{configatron.friendly_name}.rb" if File.exists? "rakefile.#{configatron.friendly_name}.rb"
+ configatron.mspec_options.push "--teamcity"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.