Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added build script for command-line build with Rake (install Ruby 1…
….86 or later, run InstallGems.bat) - Added support for building against NHib 2.0GA and NHib 2.1 trunk/latest/whatever - Including NUnit console runner git-svn-id: https://fluent-nhibernate.googlecode.com/svn/trunk@119 48f0ce17-cc52-0410-af8c-857c09b6549b
- Loading branch information
Showing
48 changed files
with
143,546 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
require 'erb' | ||
|
||
class NUnitRunner | ||
include FileTest | ||
|
||
def initialize(paths) | ||
@sourceDir = paths.fetch(:source, 'source') | ||
@resultsDir = paths.fetch(:results, 'results') | ||
@compilePlatform = paths.fetch(:platform, 'x86') | ||
@compileTarget = paths.fetch(:compilemode, 'debug') | ||
|
||
if ENV["teamcity.dotnet.nunitlauncher"] # check if we are running in TeamCity | ||
# We are not using the TeamCity nunit launcher. We use NUnit with the TeamCity NUnit Addin which needs tO be copied to our NUnit addins folder | ||
# http://blogs.jetbrains.com/teamcity/2008/07/28/unfolding-teamcity-addin-for-nunit-secrets/ | ||
# The teamcity.dotnet.nunitaddin environment variable is not available until TeamCity 4.0, so we hardcode it for now | ||
@teamCityAddinPath = ENV["teamcity.dotnet.nunitaddin"] ? ENV["teamcity.dotnet.nunitaddin"] : 'c:/TeamCity/buildAgent/plugins/dotnetPlugin/bin/JetBrains.TeamCity.NUnitAddin-NUnit' | ||
cp @teamCityAddinPath + '-2.4.7.dll', 'tools/nunit/addins' | ||
end | ||
|
||
@nunitExe = "tools/nunit/nunit-console#{(@compilePlatform.nil? ? '' : "-#{@compilePlatform}")}.exe /nothread" | ||
end | ||
|
||
def executeTests(assemblies) | ||
Dir.mkdir @resultsDir unless exists?(@resultsDir) | ||
|
||
assemblies.each do |assem| | ||
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{(@compilePlatform.nil? ? '' : "#{@compilePlatform}/")}#{@compileTarget}/#{assem}.dll") | ||
sh "#{@nunitExe} #{file}" | ||
end | ||
end | ||
end | ||
|
||
class MSBuildRunner | ||
def self.compile(attributes) | ||
version = attributes.fetch(:clrversion, 'v3.5') | ||
compileTarget = attributes.fetch(:compilemode, 'debug') | ||
solutionFile = attributes[:solutionfile] | ||
|
||
frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version) | ||
msbuildFile = File.join(frameworkDir, 'msbuild.exe') | ||
|
||
sh "#{msbuildFile} #{solutionFile} /maxcpucount /v:m /property:BuildInParallel=false /property:Configuration=#{compileTarget} /t:Rebuild" | ||
end | ||
end | ||
|
||
class AspNetCompilerRunner | ||
def self.compile(attributes) | ||
|
||
webPhysDir = attributes.fetch(:webPhysDir, '') | ||
webVirDir = attributes.fetch(:webVirDir, '') | ||
|
||
frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', 'v2.0.50727') | ||
aspNetCompiler = File.join(frameworkDir, 'aspnet_compiler.exe') | ||
|
||
sh "#{aspNetCompiler} -p #{webPhysDir} -v #{webVirDir}" | ||
end | ||
end | ||
|
||
class AsmInfoBuilder | ||
attr_reader :buildnumber | ||
|
||
def initialize(baseVersion, properties) | ||
@properties = properties; | ||
|
||
@buildnumber = baseVersion + (ENV["CCNetLabel"].nil? ? '0' : ENV["CCNetLabel"].to_s) | ||
@properties['Version'] = @properties['InformationalVersion'] = buildnumber; | ||
end | ||
|
||
|
||
|
||
def write(file) | ||
template = %q{ | ||
using System; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
<% @properties.each {|k, v| %> | ||
[assembly: Assembly<%=k%>Attribute("<%=v%>")] | ||
<% } %> | ||
}.gsub(/^ /, '') | ||
|
||
erb = ERB.new(template, 0, "%<>") | ||
|
||
File.open(file, 'w') do |file| | ||
file.puts erb.result(binding) | ||
end | ||
end | ||
end | ||
|
||
class InstallUtilRunner | ||
def installServices(services, parameters) | ||
services.each do |service| | ||
params = "" | ||
parameters.each_pair {|key, value| params = params + "/" + key + "=" + value + " "} | ||
sh "tools/installutil /i #{params} #{service}" | ||
end | ||
end | ||
|
||
def uninstallServices(services) | ||
services.each do |service| | ||
begin | ||
sh "tools/installutil /u #{service}" | ||
rescue Exception => e | ||
puts 'IGNORING ERROR: ' + e | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@ECHO *** Installing Rake | ||
@call gem install rake --include-dependencies | ||
|
||
@ECHO *** Installing ActiveRecord | ||
@call gem install activerecord --include-dependencies | ||
|
||
@ECHO *** Installing RubyZip | ||
@call gem install rubyzip --include-dependencies | ||
|
||
@ECHO *** Installing Rails | ||
@call gem install rails --include-dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
COMPILE_TARGET = "debug" | ||
require "BuildUtils.rb" | ||
|
||
include FileTest | ||
|
||
require 'rubygems' | ||
|
||
gem 'rubyzip' | ||
require 'zip/zip' | ||
require 'zip/zipfilesystem' | ||
|
||
RESULTS_DIR = "results" | ||
BUILD_NUMBER = "0.1.0." | ||
PRODUCT = "FluentNHibernate" | ||
COPYRIGHT = 'Copyright 2008 Jeremy D. Miller, James Gregory, Andrew Stewart, Paul Batum, Chad Myers et al. All rights reserved.'; | ||
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs'; | ||
CLR_VERSION = "v3.5" | ||
|
||
versionNumber = ENV["BUILD_NUMBER"].nil? ? 0 : ENV["BUILD_NUMBER"] | ||
|
||
props = { :archive => "build" } | ||
|
||
desc "Compiles, unit tests, generates the database, and then runs integration tests" | ||
task :all => [:default] | ||
|
||
desc "**Default**, compiles and runs tests" | ||
task :default => [:use_nhib_20, :compile, :unit_test] | ||
|
||
desc "Builds Fluent NHibernate against the NHibernate 2.1 libs (instead of the normal NHibernate 2.0GA" | ||
task :nhib21 =>[:use_nhib_21, :compile, :unit_test, :use_nhib_20] | ||
|
||
desc "Switches NHibernate dependencies to NHibernate 2.1" | ||
task :use_nhib_21 do | ||
switch_nhib_libs('nhib2.1') | ||
end | ||
|
||
desc "Switches NHibernate dependencies to NHibernate 2.0" | ||
task :use_nhib_20 do | ||
switch_nhib_libs('nhib2.0GA') | ||
end | ||
|
||
#### hidden task, don't call directly | ||
def switch_nhib_libs(nhib_lib_dir) | ||
puts "Switching NHibernate dependencies to #{nhib_lib_dir}" | ||
# clear the nhib dir | ||
Dir.foreach('tools/NHibernate') {|file| | ||
relFile = File.join('tools/NHibernate',file) | ||
File.delete(relFile) if File.file?(relFile) | ||
} | ||
|
||
# copy the source files over | ||
Dir.foreach("tools/NHibernate/#{nhib_lib_dir}"){|file| | ||
relFile = File.join("tools/NHibernate/#{nhib_lib_dir}",file) | ||
copy(relFile, 'tools/NHibernate') if File.file?(relFile) | ||
} | ||
end | ||
|
||
|
||
desc "Displays a list of tasks" | ||
task :help do | ||
taskHash = Hash[*(`rake.cmd -T`.split(/\n/).collect { |l| l.match(/rake (\S+)\s+\#\s(.+)/).to_a }.collect { |l| [l[1], l[2]] }).flatten] | ||
|
||
indent = " " | ||
|
||
puts "rake #{indent}#Runs the 'default' task" | ||
|
||
taskHash.each_pair do |key, value| | ||
if key.nil? | ||
next | ||
end | ||
puts "rake #{key}#{indent.slice(0, indent.length - key.length)}##{value}" | ||
end | ||
end | ||
|
||
desc "Update the version information for the build" | ||
task :version do | ||
builder = AsmInfoBuilder.new(BUILD_NUMBER, {'Product' => PRODUCT, 'Copyright' => COPYRIGHT}) | ||
buildNumber = builder.buildnumber | ||
puts "The build number is #{buildNumber}" | ||
builder.write COMMON_ASSEMBLY_INFO | ||
end | ||
|
||
desc "Prepares the working directory for a new build" | ||
task :clean do | ||
#TODO: do any other tasks required to clean/prepare the working directory | ||
Dir.mkdir props[:archive] unless exists?(props[:archive]) | ||
end | ||
|
||
desc "Compiles the app" | ||
task :compile => [:clean, :version] do | ||
MSBuildRunner.compile :compilemode => COMPILE_TARGET, :solutionfile => 'src/FluentNHibernate.sln', :clrversion => CLR_VERSION | ||
|
||
outDir = "src/FluentNHibernate/bin/#{COMPILE_TARGET}" | ||
|
||
Dir.glob(File.join(outDir, "*.{dll,pdb}")){|file| | ||
copy(file, props[:archive]) if File.file?(file) | ||
} | ||
end | ||
|
||
desc "Runs unit tests" | ||
task :unit_test => :compile do | ||
runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :source => 'src', :platform => 'x86' | ||
runner.executeTests ['FluentNHibernate.Testing'] | ||
end |
Oops, something went wrong.