Permalink
Browse files

- 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...
1 parent 4bf948a commit 00bf2193c20f65c1c9dedcba791345487cdd1596 @chadmyers chadmyers committed Oct 15, 2008
Showing with 143,546 additions and 4 deletions.
  1. +1 −0 Build.bat
  2. +112 −0 BuildUtils.rb
  3. +11 −0 InstallGems.bat
  4. +104 −0 RakeFile
  5. +591 −0 TestResult.xml
  6. +5 −3 src/FluentNHibernate.Framework/SessionSource.cs
  7. +1 −1 src/FluentNHibernate.Testing/DomainModel/Mapping/ClassMapXmlCreationTester.cs
  8. BIN tools/NHibernate/nhib2.0GA/Castle.Core.dll
  9. +3,049 −0 tools/NHibernate/nhib2.0GA/Castle.Core.xml
  10. +13 −0 tools/NHibernate/nhib2.0GA/Castle.DynamicProxy.license.txt
  11. BIN tools/NHibernate/nhib2.0GA/Castle.DynamicProxy2.dll
  12. +635 −0 tools/NHibernate/nhib2.0GA/Castle.DynamicProxy2.xml
  13. BIN tools/NHibernate/nhib2.0GA/Iesi.Collections.Test.dll
  14. BIN tools/NHibernate/nhib2.0GA/Iesi.Collections.dll
  15. +9 −0 tools/NHibernate/nhib2.0GA/Iesi.Collections.license.txt
  16. +1,887 −0 tools/NHibernate/nhib2.0GA/Iesi.Collections.xml
  17. BIN tools/NHibernate/nhib2.0GA/NHibernate.Linq.dll
  18. BIN tools/NHibernate/nhib2.0GA/NHibernate.dll
  19. +460 −0 tools/NHibernate/nhib2.0GA/NHibernate.license.txt
  20. +36,640 −0 tools/NHibernate/nhib2.0GA/NHibernate.xml
  21. BIN tools/NHibernate/nhib2.0GA/log4net.dll
  22. +201 −0 tools/NHibernate/nhib2.0GA/log4net.license.txt
  23. +28,655 −0 tools/NHibernate/nhib2.0GA/log4net.xml
  24. BIN tools/NHibernate/nhib2.1/Castle.Core.dll
  25. +3,049 −0 tools/NHibernate/nhib2.1/Castle.Core.xml
  26. +13 −0 tools/NHibernate/nhib2.1/Castle.DynamicProxy.license.txt
  27. BIN tools/NHibernate/nhib2.1/Castle.DynamicProxy2.dll
  28. +635 −0 tools/NHibernate/nhib2.1/Castle.DynamicProxy2.xml
  29. BIN tools/NHibernate/nhib2.1/Iesi.Collections.dll
  30. +9 −0 tools/NHibernate/nhib2.1/Iesi.Collections.license.txt
  31. BIN tools/NHibernate/nhib2.1/Iesi.Collections.pdb
  32. +1,887 −0 tools/NHibernate/nhib2.1/Iesi.Collections.xml
  33. BIN tools/NHibernate/nhib2.1/NHibernate.Linq.dll
  34. BIN tools/NHibernate/nhib2.1/NHibernate.Linq.pdb
  35. BIN tools/NHibernate/nhib2.1/NHibernate.dll
  36. BIN tools/NHibernate/nhib2.1/NHibernate.pdb
  37. +36,484 −0 tools/NHibernate/nhib2.1/NHibernate.xml
  38. BIN tools/NHibernate/nhib2.1/log4net.dll
  39. +201 −0 tools/NHibernate/nhib2.1/log4net.license.txt
  40. +28,655 −0 tools/NHibernate/nhib2.1/log4net.xml
  41. BIN tools/nunit/nunit-console-runner.dll
  42. BIN tools/nunit/nunit-console-x86.exe
  43. +118 −0 tools/nunit/nunit-console-x86.exe.config
  44. BIN tools/nunit/nunit-console.exe
  45. +121 −0 tools/nunit/nunit-console.exe.config
  46. BIN tools/nunit/nunit.core.dll
  47. BIN tools/nunit/nunit.core.interfaces.dll
  48. BIN tools/nunit/nunit.util.dll
View
@@ -0,0 +1 @@
+rake
View
@@ -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
+
+
+
View
@@ -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
View
104 RakeFile
@@ -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.

0 comments on commit 00bf219

Please sign in to comment.