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.



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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/fuburake.rb', line 77

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 => ENV['platform'].nil? ? "" : ENV['platform'],
		: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',
		:nuget_publish_folder => 'artifacts',
		:nuget_publish_url => nil,
		:nuget_api_key => ENV['api_key']
		}.merge(options)
	# ENDSAMPLE

	@compilemode = @options[:compilemode]

	tasks.clean ||= []
	tasks.defaults ||= []
	tasks.ci_steps ||= []
	tasks.precompile ||= []
	tasks.doc_exports ||= []

	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.assembly_bottle File.basename(project)
				end
			end
		end
	end

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

	tasks.doc_exports.each do |opts|
		opts[:version] = @build_number

		docs = FubuDocs.new(opts)

		doc_task_name = docs.export_tasks
		if opts[:include_in_ci]
			add_dependency :ci, doc_task_name
		end
	end
	
end

Instance Attribute Details

#build_numberObject

Returns the value of attribute build_number.



75
76
77
# File 'lib/fuburake.rb', line 75

def build_number
  @build_number
end

#compilemodeObject

Returns the value of attribute compilemode.



75
76
77
# File 'lib/fuburake.rb', line 75

def compilemode
  @compilemode
end

#optionsObject

Returns the value of attribute options.



75
76
77
# File 'lib/fuburake.rb', line 75

def options
  @options
end

Instance Method Details

#create_task(name, description) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/fuburake.rb', line 176

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

	end
	task.add_description description

	return task
end

#dump_html(options) ⇒ Object



210
211
212
213
214
# File 'lib/fuburake.rb', line 210

def dump_html(options)
	options[:version] = @build_number
	docs = FubuDocs.new(options)
	docs.dump_task
end

#enable_docs(tasks) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/fuburake.rb', line 198

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



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

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