Skip to content

Commit fe3363f

Browse files
committed
More cleaning of rakefile
1 parent b520ad7 commit fe3363f

File tree

4 files changed

+73
-35
lines changed

4 files changed

+73
-35
lines changed

Rakefile

+64-17
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,31 @@ require 'rubygems'
22
require 'albacore'
33

44
load 'support/platform.rb'
5-
load 'support/buildUtils.rb'
65
load 'VERSION.txt'
76

87
ROOT_NAMESPACE = 'Fleck'
98
RESULTS_DIR = 'build/test-reports'
109
PRODUCT = ROOT_NAMESPACE
1110
COPYRIGHT = 'Copyright Jason Staten 2010-2011. All rights reserved.';
1211
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs';
13-
CLR_VERSION = 'v4.0'
1412
COMPILE_TARGET = 'Debug'
13+
COMPILE_PLATFORM = 'Any CPU'
1514
CLR_TOOLS_VERSION = 'v4.0.30319'
15+
BUILD_RUNNER = Platform.nix? ? 'xbuild' : 'msbuild'
1616

1717
props = { :archive => 'artifacts', :stage => 'stage' }
1818

19+
1920
desc 'Compiles and runs unit tests'
2021
task :all => [:default]
2122

22-
desc '**Default**, compiles and runs tests'
23-
task :default => [:compile, :test]
23+
desc 'Compiles and runs tests'
24+
task :default => [:build, :test]
25+
26+
desc 'Build application'
27+
task :build => [:clean, :version, :compile] do
28+
copyOutputFiles "src/#{ROOT_NAMESPACE}/bin/#{COMPILE_TARGET}", "*.{dll,pdb}", props[:archive]
29+
end
2430

2531
desc 'Update the version information for the build'
2632
assemblyinfo :version do |asm|
@@ -50,7 +56,35 @@ end
5056

5157
desc 'Prepares the working directory for a new build'
5258
task :clean do
53-
puts('recreating the build directory')
59+
Rake::Task["clean:#{BUILD_RUNNER}"].execute
60+
buildDir = props[:archive]
61+
rm_r buildDir if Dir.exists?(buildDir)
62+
rm_r RESULTS_DIR if Dir.exists?(RESULTS_DIR)
63+
mkdir_p buildDir
64+
mkdir_p RESULTS_DIR
65+
end
66+
67+
namespace :clean do
68+
msbuild :msbuild do |msb|
69+
clean_solution(msb)
70+
end
71+
xbuild :xbuild do |xb|
72+
clean_solution(xb)
73+
end
74+
75+
def clean_solution(command)
76+
command.targets :Clean
77+
command.solution = "src/#{ROOT_NAMESPACE}.sln"
78+
command.properties = {
79+
:configuration => COMPILE_TARGET,
80+
:platform => COMPILE_PLATFORM
81+
}
82+
end
83+
end
84+
85+
desc 'Prepares the working directory for a new build'
86+
task :clean do
87+
Rake::Task["clean:#{BUILD_RUNNER}"].execute
5488
buildDir = props[:archive]
5589
rm_r buildDir if Dir.exists?(buildDir)
5690
rm_r RESULTS_DIR if Dir.exists?(RESULTS_DIR)
@@ -59,23 +93,36 @@ task :clean do
5993
end
6094

6195
desc 'Compiles the app'
62-
task :compile => [:clean, :version] do
63-
MSBuildRunner.compile :compilemode => COMPILE_TARGET,
64-
:solutionfile => "src/#{ROOT_NAMESPACE}.sln",
65-
:clrversion => CLR_TOOLS_VERSION
66-
copyOutputFiles "src/#{ROOT_NAMESPACE}/bin/#{COMPILE_TARGET}", "*.{dll,pdb}", props[:archive]
96+
task :compile do
97+
Rake::Task["compile:#{BUILD_RUNNER}"].execute
6798
end
6899

69-
desc 'Runs unit tests'
70-
task :test do
71-
runner = NUnitRunner.new :compilemode => COMPILE_TARGET,
72-
:source => 'src',
73-
:platform => 'x86',
74-
:results => RESULTS_DIR
100+
namespace :compile do
101+
msbuild :msbuild do |msb|
102+
compile_solution(msb)
103+
end
104+
xbuild :xbuild do |xb|
105+
compile_solution(xb)
106+
end
107+
108+
def compile_solution(command)
109+
command.solution = "src/#{ROOT_NAMESPACE}.sln"
110+
command.properties = {
111+
:configuration => COMPILE_TARGET,
112+
:platform => COMPILE_PLATFORM
113+
}
114+
end
115+
end
116+
117+
task :test do |nunit|
118+
runner = Dir['**/nunit-console.exe'].first
119+
raise "nunit-console.exe not found" if runner.nil?
120+
assemblies = Dir["**/#{COMPILE_TARGET}/*.Tests.dll"].reject{|a|a =~ /\/obj\//}
75121

76-
runner.executeTests ['Fleck.Tests']
122+
sh "#{Platform.runtime(runner)} #{assemblies.join}"
77123
end
78124

79125
def copyOutputFiles(fromDir, filePattern, outDir)
80126
copy Dir[File.join(fromDir, filePattern)], outDir
81127
end
128+

VERSION.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_VERSION = "0.1.0"
1+
BUILD_VERSION = "0.1.0"

src/Fleck.sln

+5-14
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,35 @@ EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1414
Debug|Any CPU = Debug|Any CPU
15-
Debug|Mixed Platforms = Debug|Mixed Platforms
1615
Debug|x86 = Debug|x86
1716
Release|Any CPU = Release|Any CPU
18-
Release|Mixed Platforms = Release|Mixed Platforms
1917
Release|x86 = Release|x86
2018
EndGlobalSection
2119
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2220
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2321
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
25-
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
2622
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|x86.ActiveCfg = Debug|Any CPU
23+
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Debug|x86.Build.0 = Debug|Any CPU
2724
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|Any CPU.ActiveCfg = Release|Any CPU
2825
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|Any CPU.Build.0 = Release|Any CPU
29-
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
30-
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
3126
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|x86.ActiveCfg = Release|Any CPU
27+
{01AECC7B-C5FC-451C-8D3B-C400F0C9883C}.Release|x86.Build.0 = Release|Any CPU
3228
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|Any CPU.ActiveCfg = Debug|x86
3329
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|Any CPU.Build.0 = Debug|x86
34-
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
35-
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|Mixed Platforms.Build.0 = Debug|x86
3630
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|x86.ActiveCfg = Debug|x86
3731
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Debug|x86.Build.0 = Debug|x86
3832
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|Any CPU.ActiveCfg = Release|x86
39-
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|Mixed Platforms.ActiveCfg = Release|x86
40-
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|Mixed Platforms.Build.0 = Release|x86
33+
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|Any CPU.Build.0 = Release|x86
4134
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|x86.ActiveCfg = Release|x86
4235
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC}.Release|x86.Build.0 = Release|x86
4336
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4437
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
45-
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
46-
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
4738
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|x86.ActiveCfg = Debug|Any CPU
39+
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Debug|x86.Build.0 = Debug|Any CPU
4840
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
4941
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|Any CPU.Build.0 = Release|Any CPU
50-
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
51-
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
5242
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|x86.ActiveCfg = Release|Any CPU
43+
{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}.Release|x86.Build.0 = Release|Any CPU
5344
EndGlobalSection
5445
GlobalSection(NestedProjects) = preSolution
5546
{3D7680B4-0224-4F0C-B1F6-74FB7586EBDC} = {BDA01C02-E4AC-42BA-898A-ED4752F676EF}

support/platform.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
module Platform
22

3-
def self.is_nix
3+
def self.nix?
44
!RUBY_PLATFORM.match("linux|darwin").nil?
55
end
66

77
def self.runtime(cmd)
88
command = cmd
9-
if self.is_nix
9+
if self.nix?
1010
runtime = (CLR_TOOLS_VERSION || "v4.0.30319")
1111
command = "mono --runtime=#{runtime} #{cmd}"
1212
end
1313
command
1414
end
1515

1616
def self.switch(arg)
17-
sw = self.is_nix ? " -" : " /"
17+
sw = self.nix? ? " -" : " /"
1818
sw + arg
1919
end
2020

0 commit comments

Comments
 (0)