Skip to content

Commit

Permalink
initial import from the storyteller/two branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Oct 24, 2012
1 parent e4c2acd commit 3578255
Show file tree
Hide file tree
Showing 1,868 changed files with 205,834 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
build
obj
bin
deploy
results
deploy/*
*.cache
*.zip
*.lnk
source/CommonAssemblyInfo.cs
_ReSharper.*
*.csproj.user
*.resharper.user
*.resharper
*.suo
docs/samples
docs/output
publish.bat
source/Examples/Examples-results
TestResult.xml
samples/Grammars-results
StoryTeller.1*
*ReSharper*
demo/*
source/StoryTeller/CommonAssemblyInfo.cs
src/packages
src/CommonAssemblyInfo.cs
artifacts

src/StoryTeller.sln.DotSettings.user
src/StoryTeller/StoryTeller.csproj.DotSettings.user
*.DotSettings.user
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "buildsupport"]
path = buildsupport
url = git://github.com/DarthFubuMVC/buildsupport.git
148 changes: 148 additions & 0 deletions BuildUtils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
require 'erb'

class NUnitRunner
include FileTest

def initialize(paths)
@sourceDir = paths.fetch(:source, 'source')
@resultsDir = paths.fetch(:results, 'results')
@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.exe /nologo /nothread'
end

def executeTests(assemblies, additionalCommandLine='')
Dir.mkdir @resultsDir unless exists?(@resultsDir)

assemblies.each do |assem|
file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{@compileTarget}/#{assem}.dll")
sh "#{@nunitExe} #{file} #{additionalCommandLine}"
end
end
end

class MSBuildRunner
def self.compile(attributes)
compileTarget = attributes.fetch(:compilemode, 'debug')
solutionFile = attributes[:solutionfile]

attributes[:projFile] = solutionFile;
attributes[:properties] = ["Configuration=#{compileTarget}"];
attributes[:extraSwitches] = ["maxcpucount:2", "v:m", "t:rebuild"]

self.runProjFile(attributes);
end

def self.runProjFile(attributes)
version = attributes.fetch(:clrversion, 'v4.0.30319')
compileTarget = attributes.fetch(:compilemode, 'debug')
projFile = attributes[:projFile]

frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
msbuildFile = File.join(frameworkDir, 'msbuild.exe')

properties = attributes.fetch(:properties, [])

switchesValue = ""

properties.each do |prop|
switchesValue += " /property:#{prop}"
end

extraSwitches = attributes.fetch(:extraSwitches, [])

extraSwitches.each do |switch|
switchesValue += " /#{switch}"
end

targets = attributes.fetch(:targets, [])
targetsValue = ""
targets.each do |target|
targetsValue += " /t:#{target}"
end

sh "#{msbuildFile} #{projFile} #{targetsValue} #{switchesValue}"
end
end

class DocuRunner
def self.document(attributes)
assemblies = attributes.fetch(:assemblies, [])
output = attributes[:output]
templates = attributes[:templates]

outputArg = (output.nil?) ? '' : "--output=#{output}"
templatesArg = (templates.nil?) ? '' : "--templates=#{templates}"

sh "tools\\docu\\docu.exe #{assemblies.join(' ')} #{outputArg} #{templatesArg}" unless assemblies.empty?
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', 'v4.0.30319')
aspNetCompiler = File.join(frameworkDir, 'aspnet_compiler.exe')

sh "#{aspNetCompiler} -nologo -p #{webPhysDir} -v #{webVirDir}"
end
end

class AsmInfoBuilder
def initialize(buildnumber, properties)
@properties = properties;

@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
11 changes: 11 additions & 0 deletions InstallGems.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@ECHO *** Installing Rake
@call gem install rake --no-rdoc --no-ri

@ECHO *** Installing RubyZip
@call gem install rubyzip --no-rdoc --no-ri

@ECHO *** Installing Albacore (build support tools)
@call gem install albacore --no-rdoc --no-ri

@ECHO *** Installing Zip
@call gem install zip --no-rdoc --no-ri
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2007-2011 Jeremy D. Miller

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
111 changes: 111 additions & 0 deletions RakeFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
COMPILE_TARGET = ENV['config'].nil? ? "release" : ENV['config']

include FileTest
require 'albacore'
load "VERSION.txt"

RESULTS_DIR = "results"
PRODUCT = "Storyteller"
COPYRIGHT = 'Copyright 2009-2011 Jeremy D. Miller, et al. All rights reserved.';
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs';
CLR_TOOLS_VERSION = "v4.0.30319"

buildsupportfiles = Dir["#{File.dirname(__FILE__)}/buildsupport/*.rb"]

if( ! buildsupportfiles.any? )
# no buildsupport, let's go get it for them.
sh 'git submodule update --init' unless buildsupportfiles.any?
buildsupportfiles = Dir["#{File.dirname(__FILE__)}/buildsupport/*.rb"]
end

# nope, we still don't have buildsupport. Something went wrong.
raise "Run `git submodule update --init` to populate your buildsupport folder." unless buildsupportfiles.any?

buildsupportfiles.each { |ext| load ext }


tc_build_number = ENV["BUILD_NUMBER"]
build_revision = tc_build_number || Time.new.strftime('5%H%M')
build_number = "#{BUILD_VERSION}.#{build_revision}"
BUILD_NUMBER = build_number


props = { :stage => File.expand_path("build"), :stage35 => File.expand_path("build35"), :artifacts => File.expand_path("artifacts") }

desc "**Default**, compiles and runs tests"
task :default => [:compile, :ilrepack, :unit_test]
#task :default => [:compile, :unit_test, :stage, "fx35:compile", "fx35:unit_test", "fx35:stage"]
task :ci => [:update_all_dependencies, :default, :history, :package]

desc "Update the version information for the build"
assemblyinfo :version do |asm|
asm_version = build_number

begin
commit = `git log -1 --pretty=format:%H`
rescue
commit = "git unavailable"
end
puts "##teamcity[buildNumber '#{build_number}']" unless tc_build_number.nil?
puts "Version: #{build_number}" if tc_build_number.nil?
asm.trademark = commit
asm.product_name = PRODUCT
asm.description = build_number
asm.version = asm_version
asm.file_version = build_number
asm.custom_attributes :AssemblyInformationalVersion => asm_version
asm.copyright = COPYRIGHT
asm.output_file = COMMON_ASSEMBLY_INFO
end

desc "Prepares the working directory for a new build"
task :clean => [:update_buildsupport] do

FileUtils.rm_rf props[:stage]
FileUtils.rm_rf props[:stage35]
# work around nasty latency issue where folder still exists for a short while after it is removed
waitfor { !exists?(props[:stage]) }
Dir.mkdir props[:stage]
waitfor { !exists?(props[:stage35]) }
Dir.mkdir props[:stage35]

Dir.mkdir props[:artifacts] unless exists?(props[:artifacts])

end

def waitfor(&block)
checks = 0
until block.call || checks >10
sleep 0.5
checks += 1
end
raise 'waitfor timeout expired' if checks > 10
end

desc "Compiles the app"
msbuild :compile => [:restore_if_missing, :clean, :version] do |msb|
msb.command = File.join(ENV['windir'], 'Microsoft.NET', 'Framework', CLR_TOOLS_VERSION, 'MSBuild.exe')
msb.properties :configuration => COMPILE_TARGET
msb.solution = "src/Storyteller.sln"
msb.targets :Rebuild
msb.log_level = :verbose
end

desc "Runs unit tests"
task :unit_test => :compile do
runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :source => 'src', :platform => 'x86'

# don't feel like dealing w/ STA stuff this morning , 'StoryTeller.UserInterface.Testing'
runner.executeTests ['StoryTeller.Testing']
end

desc "Merge newtonsoft assembly into the main StoryTeller project"
task :ilrepack do
merge_newtonsoft("src/StoryTeller/bin/#{COMPILE_TARGET}", 'StoryTeller.dll')
end

def merge_newtonsoft(dir, assembly)
output = File.join(dir, assembly)
packer = ILRepack.new :out => output, :lib => dir
packer.merge :lib => dir, :refs => [assembly, 'Newtonsoft.Json.dll']
end
1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BUILD_VERSION = "2.0.0"
1 change: 1 addition & 0 deletions buildsupport
Submodule buildsupport added at c33667
Loading

0 comments on commit 3578255

Please sign in to comment.