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.



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
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
# File 'lib/fuburake.rb', line 72

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'}.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.bottles << FubuRake::AssemblyBottle.new(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.



70
71
72
# File 'lib/fuburake.rb', line 70

def build_number
  @build_number
end

#compilemodeObject

Returns the value of attribute compilemode.



70
71
72
# File 'lib/fuburake.rb', line 70

def compilemode
  @compilemode
end

#optionsObject

Returns the value of attribute options.



70
71
72
# File 'lib/fuburake.rb', line 70

def options
  @options
end

Instance Method Details

#add_dependency(from, to) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/fuburake.rb', line 169

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



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

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

#dump_html(options) ⇒ Object



223
224
225
226
227
# File 'lib/fuburake.rb', line 223

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

#enable_docs(tasks) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/fuburake.rb', line 209

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



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

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