Class: FubuRake::Solution

Inherits:
Object
  • Object
show all
Defined in:
lib/fuburake.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Solution

Returns a new instance of Solution.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/fuburake.rb', line 59

def initialize(&block)
  tasks = SolutionTasks.new
  block.call(tasks)

  @defaultTask = create_task(:default, "**Default**, compiles and runs tests")
  @ciTask = create_task(:ci,  "Target used for the CI server")
  @ciTask.enhance [:default]
  
  options = tasks.options
  options ||= {}
  
  tc_build_number = ENV["BUILD_NUMBER"]
  build_revision = tc_build_number || Time.new.strftime('5%H%M')
  asm_version = BUILD_VERSION + ".0"
  @build_number = "#{BUILD_VERSION}.#{build_revision}"
  
  # SAMPLE: fuburake-options
  @options = {
	:compilemode => ENV['config'].nil? ? "Debug" : ENV['config'],
	:clrversion => 'v4.0.30319',
	:platform => 'x86',
	:unit_test_list_file => 'TESTS.txt',
	:unit_test_projects => [],
	:build_number => @build_number,
	:asm_version => asm_version,
	:tc_build_number => tc_build_number,
	:build_revision => build_revision,
	:source => 'src'}.merge(options)
  # ENDSAMPLE
	
  @compilemode = @options[:compilemode]
	
  tasks.clean ||= []
  tasks.defaults ||= []
  tasks.ci_steps ||= []
  tasks.precompile ||= []
  

  enable_docs tasks
  FubuRake::AssemblyInfo.create tasks, @options
  FubuRake::Ripple.create tasks, @options
  make_clean tasks
  FubuRake::MSBuild.create_task tasks, @options
  FubuRake::NUnit.create_task tasks, @options

  add_dependency :compile, [:clean, :version, 'ripple:restore', 'docs:bottle']

  Rake::Task[:compile].enhance(tasks.precompile)
  add_dependency :unit_test, :compile
  add_dependency :default, [:compile, :unit_test]
  add_dependency :default, :unit_test
  Rake::Task[:default].enhance tasks.defaults
  Rake::Task[:ci].enhance tasks.ci_steps
  add_dependency :ci, tasks.ci_steps
  add_dependency :ci, ["ripple:history", "ripple:package"]

  tasks.compilations ||= []
  tasks.compilations.each do |c|
	c.create @options
  end
  
  
  
  if tasks.bottles.empty? && tasks.bottles_enabled
	Dir.glob('**/.package-manifest').each do |f|
	   dir = File.dirname(f)
	   project = dir.split('/').last
	   if project.index('.Docs') == nil
	     proj_file = "#{dir}/#{project}.csproj"
		 if File.exists?(proj_file)
	       tasks.bottles << FubuRake::AssemblyBottle.new(project)
	     end
	   end

	end
  end
  
  if !tasks.bottles.empty?
	tasks.bottles.each do |c|
	  c.create @options
	end
  end
end

Instance Attribute Details

#build_numberObject

Returns the value of attribute build_number.



57
58
59
# File 'lib/fuburake.rb', line 57

def build_number
  @build_number
end

#compilemodeObject

Returns the value of attribute compilemode.



57
58
59
# File 'lib/fuburake.rb', line 57

def compilemode
  @compilemode
end

#optionsObject

Returns the value of attribute options.



57
58
59
# File 'lib/fuburake.rb', line 57

def options
  @options
end

Instance Method Details

#add_dependency(from, to) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/fuburake.rb', line 143

def add_dependency(from, to)
  if to.kind_of?(Array)
    to.each do |dep|
	  add_dependency from, dep
	end
  end

  if !Rake::Task.task_defined?(from)
    return
  end
  
  if !Rake::Task.task_defined?(to)
    return
  end 
  
  Rake::Task[from].enhance [to]
end

#create_task(name, description) ⇒ Object



161
162
163
164
165
166
167
168
# File 'lib/fuburake.rb', line 161

def create_task(name, description)
  task = Rake::Task.define_task name do
  
  end
  task.add_description description
  
  return task
end

#enable_docs(tasks) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/fuburake.rb', line 183

def enable_docs(tasks)
  if tasks.fubudocs_enabled
	if Platform.is_nix
		Dir.glob('**/*.Docs.csproj').each do |f|
			tasks.assembly_bottle File.basename(f, ".csproj")
		end
	else
		require_relative 'fubudocs'
	end
  
	
  end
end

#make_clean(tasks) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/fuburake.rb', line 170

def make_clean(tasks)
  if tasks.clean.any?
    @cleanTask = Rake::Task.define_task :clean do
	  tasks.clean.each do |dir|
		cleanDirectory dir
	  end
	end
  
	@cleanTask.add_description "Prepares the working directory for a new build"
  end
end