albacore 2.0.0.rc.2 → 2.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.email = 'henrik@haf.se'
12
12
  s.homepage = 'http://albacorebuild.net'
13
13
  s.summary = 'Dolphin-safe and awesome Mono and .Net Rake-tasks'
14
+ s.license = 'MIT'
14
15
  s.description = <<-EOF
15
16
  Easily build your .Net or Mono project using this collection of Rake tasks.
16
17
  Albacore assist you in creating nugets, managing nugets, building your projects,
@@ -1,3 +1,6 @@
1
1
  require 'albacore/version'
2
2
  require 'albacore/albacore_module'
3
3
  require 'albacore/dsl'
4
+
5
+ module Albacore
6
+ end
@@ -52,6 +52,12 @@ module Albacore
52
52
  end
53
53
  end
54
54
 
55
+ # Gets whether we're running under Windows.
56
+ #
57
+ def windows?
58
+ ::Rake::Win32.windows?
59
+ end
60
+
55
61
  Albacore.log_level = Logger::DEBUG if ENV["DEBUG"]
56
62
  end
57
63
  end
@@ -57,6 +57,9 @@ end})
57
57
  # gets or sets the description of this package
58
58
  nuspec_field :description
59
59
 
60
+ # gets or sets the summary of this package
61
+ nuspec_field :summary
62
+
60
63
  # gets or sets the language that this package has been built with
61
64
  nuspec_field :language
62
65
 
@@ -301,9 +304,12 @@ end})
301
304
  # Options:
302
305
  # - symbols
303
306
  # - dotnet_version
307
+ # Specifies the version to use for constructing the nuspec's lib folder
304
308
  # - known_projects
305
309
  # - configuration
306
310
  # - project_dependencies
311
+ # Specifies whether to follow the project dependencies. See nuget_model_spec.rb
312
+ # for examples of usage of this property.
307
313
  # - nuget_dependencies
308
314
  def self.from_xxproj proj, *opts
309
315
  opts = Map.options(opts || {}).
@@ -373,8 +379,8 @@ end})
373
379
  package.files.each do |file|
374
380
  file_path = File.expand_path file.src, proj.proj_path_base
375
381
  unless File.exists? file_path
382
+ info "while building nuspec for proj: #{proj.name}, file: #{file_path} => #{file.target} not found, removing from nuspec [nuget model: package]"
376
383
  package.remove_file file.src
377
- info "while building nuspec for proj: #{proj.name}, file: #{file.src} => #{file.target} not found, removing from nuspec [nuget model: package]"
378
384
  trace { "files: #{package.files.map { |f| f.src }.inspect} [nuget model: package]" }
379
385
  end
380
386
  end
@@ -18,6 +18,7 @@ module Albacore
18
18
  # the file name to write the assembly info to
19
19
  attr_path_accessor :file_path
20
20
 
21
+ # the namespace to output into the version file
21
22
  attr_writer :namespace
22
23
 
23
24
 
@@ -34,11 +35,12 @@ module Albacore
34
35
 
35
36
  def opts
36
37
  raise Error, "#file_path is not set" unless (file_path or out)
38
+ ns = @namespace || '' # defaults to empty namespace if not set.
37
39
  lang = lang_for file_path
38
40
  m = Map.new attributes: @attributes,
39
- namespace: @namespace,
41
+ namespace: ns,
40
42
  file_path: @file_path,
41
- language: lang
43
+ language: lang
42
44
  m[:out] = @out if @out
43
45
  m
44
46
  end
@@ -55,6 +57,7 @@ module Albacore
55
57
  end
56
58
  end
57
59
  class Task
60
+ include Logging
58
61
  def initialize opts
59
62
  @opts = opts
60
63
  end
@@ -62,8 +65,12 @@ module Albacore
62
65
  lang = @opts.get :language
63
66
  ns = @opts.get :namespace
64
67
  attrs = @opts.get :attributes
65
- out = @opts.get(:out) { File.open(@opts.get(:file_path), 'w') }
66
- ::Albacore::Asmver::FileGenerator.new(lang, ns, @opts).generate(attrs)
68
+ out = @opts.get :out do
69
+ trace { "asmver being written at '#{@opts.get :file_path}' [asmver-task #execute]" }
70
+ File.open(@opts.get(:file_path), 'w')
71
+ end
72
+ ::Albacore::Asmver::FileGenerator.new(lang, ns, @opts).generate out, attrs
73
+ trace { "asmver was written at '#{@opts.get :file_path}' [asmver-task #execute]" }
67
74
  ensure
68
75
  out.close if out
69
76
  end
@@ -1,8 +1,11 @@
1
1
  require 'albacore/task_types/asmver/engine'
2
+ require 'albacore/logging'
2
3
  require 'map'
3
4
 
4
5
  module Albacore::Asmver
5
6
  class FileGenerator
7
+ include ::Albacore::Logging
8
+
6
9
  DEFAULT_USINGS = %w|
7
10
  System.Reflection
8
11
  System.Runtime.CompilerServices
@@ -13,33 +16,37 @@ System.Runtime.InteropServices|
13
16
  raise ArgumentError, 'ns is nil' unless ns
14
17
  @engine = engine
15
18
  @ns = ns
16
- @opts = Map.new(opts)
19
+ @opts = Map.new opts
17
20
  end
18
21
 
19
- def generate attrs = {}
22
+ def generate out, attrs = {}
23
+ trace { "generating file with attributes: #{attrs} [file_generator #generate]" }
24
+
20
25
  # https://github.com/ahoward/map/blob/master/test/map_test.rb#L374
21
26
  attrs = Map.new attrs
22
- s = @opts.get(:out) { StringIO.new }
23
27
 
24
28
  # write the attributes in the namespace
25
- @engine.build_namespace @ns, s do
29
+ @engine.build_namespace @ns, out do
26
30
  # after namespace My.Ns.Here
27
- s << "\n"
31
+ out << "\n"
28
32
 
29
33
  # open all namespaces to use .Net attributes
30
34
  @opts.get(:usings) { DEFAULT_USINGS }.each do |ns|
31
- s << @engine.build_using_statement(ns)
32
- s << "\n"
35
+ out << @engine.build_using_statement(ns)
36
+ out << "\n"
33
37
  end
34
38
 
39
+ warn { 'no attributes have been given to [file_generator #generate]' } if attrs.empty?
40
+
35
41
  # write all attributes
36
42
  attrs.each do |name, data|
37
- s << @engine.build_attribute(name, data)
38
- s << "\n"
43
+ trace { "building attribute #{name}: '#{data}' [file_generator #generate]" }
44
+ out << @engine.build_attribute(name, data)
45
+ out << "\n"
39
46
  end
40
47
  end
41
48
 
42
- s.string
49
+ nil
43
50
  end
44
51
  end
45
52
  end
@@ -1,192 +1,196 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'rake'
4
- require 'albacore/paths'
5
- require 'albacore/cmd_config'
6
- require 'albacore/cross_platform_cmd'
7
- require 'albacore/logging'
8
- require 'albacore/facts'
9
-
10
- module Albacore
11
- module Build
12
- class Cmd
13
- include CrossPlatformCmd
14
- def initialize work_dir, executable, parameters
15
- @work_dir = work_dir
16
- @executable = executable
17
- @parameters = (parameters === Array) ? parameters : parameters.to_a
18
- end
19
- def execute
20
- system @executable, @parameters, :work_dir => @work_dir
21
- end
22
- end
23
-
24
- # The configuration class for xbuild and msbuild. MSDN docs at: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx
25
- class Config
26
- include CmdConfig
27
- self.extend ConfigDSL
28
- include Logging
29
-
30
- # TODO: move towards #opts() for all task types rather than
31
- # reading these public properties.
32
-
33
- # this is the target of the compilation with MsBuild/XBuild
34
- attr_reader :target
35
-
36
- # any properties you want to set
37
- attr_accessor :properties
38
-
39
- def initialize
40
- @parameters = Set.new
41
-
42
- w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }
43
-
44
- @exe = w.call( "msbuild" ) ||
45
- w.call( "xbuild" ) ||
46
- heuristic_executable
47
-
48
- debug { "build using '#{@exe}'" }
49
- set_logging 'minimal'
50
- end
51
-
52
- # this is the solution file to build (or the project files themselves)
53
- attr_path_accessor :sln, :file do |val|
54
- @parameters.add val
55
- end
56
-
57
- # Call for each target that you want to add, or pass an array or
58
- # strings. Only unique targets will be passed to MsBuild.
59
- #
60
- # From MSDN:
61
- #
62
- # "Build the specified targets in the project. Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:
63
- # /target:Resources;Compile
64
- # If you specify any targets by using this switch, they are run instead of any targets in the DefaultTargets attribute in the project file. For more information, see Target Build Order (http://msdn.microsoft.com/en-us/library/vstudio/ee216359.aspx) and How to: Specify Which Target to Build First (http://msdn.microsoft.com/en-us/library/vstudio/ms171463.aspx).
65
- # A target is a group of tasks. For more information, see MSBuild Targets (http://msdn.microsoft.com/en-us/library/vstudio/ms171462.aspx)."
66
- #
67
- # t :: the array or string target to add to the list of tarets to build
68
- attr_path_accessor :target do |t|
69
- update_array_prop "target", method(:make_target), :targets, t
70
- end
71
-
72
- # Allows you to add properties to MsBuild; example:
73
- #
74
- # b.prop 'WarningLevel', 2
75
- # b.prop 'BuildVersion', '3.5.0'
76
- #
77
- # From MSDN:
78
- #
79
- # "Set or override the specified project-level properties, where name is the property name and value is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:
80
- # /property:WarningLevel=2;OutputDir=bin\Debug"
81
- #
82
- # The properties will be automatically converted to the correct syntax
83
- def prop k, v
84
- @properties ||= Hash.new
85
- @parameters.delete "/property:#{make_props}" if @properties.any?
86
- @properties[k] = v
87
- @parameters.add "/property:#{make_props}"
88
- end
89
-
90
- # Specifies the amount of information to display in the build log.
91
- # Each logger displays events based on the verbosity level that you set for that logger.
92
- # You can specify the following verbosity levels: q[uiet], m[inimal],
93
- # n[ormal], d[etailed], and diag[nostic].
94
- attr_path_accessor :logging do |mode|
95
- set_logging mode
96
- end
97
-
98
- # Specifies the number of parallel worker processes to build with
99
- # Defaults to the number of logical cores
100
- attr_path_accessor :cores do |num|
101
- @parameters.add "/maxcpucount:#{num}"
102
- end
103
-
104
- # Pass the parameters that you specify to the console logger, which displays build information in the console window. You can specify the following parameters:
105
- # * PerformanceSummary. Show the time that’s spent in tasks, targets, and projects.
106
- # * Summary. Show the error and warning summary at the end.
107
- # * NoSummary. Don't show the error and warning summary at the end.
108
- # * ErrorsOnly. Show only errors.
109
- # * WarningsOnly. Show only warnings.
110
- # * NoItemAndPropertyList. Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.
111
- # * ShowCommandLine. Show TaskCommandLineEvent messages.
112
- # * ShowTimestamp. Show the timestamp as a prefix to any message.
113
- # * ShowEventId. Show the event ID for each started event, finished event, and message.
114
- # * ForceNoAlign. Don't align the text to the size of the console buffer.
115
- # * DisableConsoleColor. Use the default console colors for all logging messages.
116
- # * DisableMPLogging. Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
117
- # * EnableMPLogging. Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.
118
- # * Verbosity. Override the /verbosity setting for this logger.
119
- def clp param
120
- update_array_prop "consoleloggerparameters", method(:make_clp), :clp, param
121
- end
122
-
123
- # Set logging verbosity to quiet
124
- def be_quiet
125
- logging = "quiet"
126
- end
127
-
128
- # Don't display the startup banner or the copyright message.
129
- def nologo
130
- @parameters.add "/nologo"
131
- end
132
-
133
- private
134
- def set_logging mode
135
- modes = %w{quiet minimal normal detailed diagnostic}.collect{ |m| "/verbosity:#{m}" }
136
- @parameters.subtract modes
137
- @parameters.add "/verbosity:#{mode}"
138
- end
139
-
140
- def update_array_prop prop_name, callable_prop_val, field_sym, value
141
- field = :"@#{field_sym}"
142
- # @targets ||= []
143
- instance_variable_set field, [] unless instance_variable_defined? field
144
- # parameters.delete "/target:#{make_target}" if @targets.any?
145
- @parameters.delete "/#{prop_name}:#{callable_prop_val.call}" if
146
- instance_variable_get(field).any?
147
- if value.respond_to? 'each'
148
- value.each { |v| instance_variable_get(field) << v }
149
- else
150
- instance_variable_get(field) << value
151
- end
152
- instance_variable_get(field).uniq!
153
- # @parameters.add "/target:#{make_target}"
154
- @parameters.add "/#{prop_name}:#{callable_prop_val.call}"
155
- end
156
-
157
- def make_target
158
- @targets.join(';')
159
- end
160
-
161
- def make_props
162
- @properties.collect { |k, v|
163
- "#{k}=#{v}"
164
- }.join(';')
165
- end
166
-
167
- def make_clp
168
- @clp.join(';')
169
- end
170
-
171
- def heuristic_executable
172
- if ::Rake::Win32.windows?
173
- trace 'build tasktype finding msbuild.exe'
174
- %w{v4.0.30319 v4.0 v3.5 v2.0}.collect { |fw_ver|
175
- msb = File.join ENV['WINDIR'], 'Microsoft.NET', 'Framework', fw_ver, 'msbuild.exe'
176
- CrossPlatformCmd.which(msb) ? msb : nil
177
- }.first
178
- else
179
- nil
180
- end
181
- end
182
- end
183
- class Task
184
- def initialize command_line
185
- @command_line = command_line
186
- end
187
- def execute
188
- @command_line.execute
189
- end
190
- end
191
- end
192
- end
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'rake'
4
+ require 'albacore/paths'
5
+ require 'albacore/cmd_config'
6
+ require 'albacore/cross_platform_cmd'
7
+ require 'albacore/logging'
8
+ require 'albacore/facts'
9
+
10
+ module Albacore
11
+ module Build
12
+ class Cmd
13
+ include CrossPlatformCmd
14
+ def initialize work_dir, executable, parameters
15
+ @work_dir = work_dir
16
+ @executable = executable
17
+ @parameters = (parameters === Array) ? parameters : parameters.to_a
18
+ end
19
+ def execute
20
+ system @executable, @parameters, :work_dir => @work_dir
21
+ end
22
+ end
23
+
24
+ # The configuration class for xbuild and msbuild. MSDN docs at: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx
25
+ class Config
26
+ include CmdConfig
27
+ self.extend ConfigDSL
28
+ include Logging
29
+
30
+ # TODO: move towards #opts() for all task types rather than
31
+ # reading these public properties.
32
+
33
+ # this is the target of the compilation with MsBuild/XBuild
34
+ attr_reader :target
35
+
36
+ # any properties you want to set
37
+ attr_accessor :properties
38
+
39
+ def initialize
40
+ @parameters = Set.new
41
+
42
+ w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }
43
+
44
+ @exe = w.call( "msbuild" ) ||
45
+ w.call( "xbuild" ) ||
46
+ heuristic_executable
47
+
48
+ debug { "build using '#{@exe}'" }
49
+ set_logging (ENV['DEBUG'] ?
50
+ (ENV['VERBOSE'] ?
51
+ 'detailed' :
52
+ 'normal') :
53
+ 'minimal')
54
+ end
55
+
56
+ # this is the solution file to build (or the project files themselves)
57
+ attr_path_accessor :sln, :file do |val|
58
+ @parameters.add val
59
+ end
60
+
61
+ # Call for each target that you want to add, or pass an array or
62
+ # strings. Only unique targets will be passed to MsBuild.
63
+ #
64
+ # From MSDN:
65
+ #
66
+ # "Build the specified targets in the project. Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:
67
+ # /target:Resources;Compile
68
+ # If you specify any targets by using this switch, they are run instead of any targets in the DefaultTargets attribute in the project file. For more information, see Target Build Order (http://msdn.microsoft.com/en-us/library/vstudio/ee216359.aspx) and How to: Specify Which Target to Build First (http://msdn.microsoft.com/en-us/library/vstudio/ms171463.aspx).
69
+ # A target is a group of tasks. For more information, see MSBuild Targets (http://msdn.microsoft.com/en-us/library/vstudio/ms171462.aspx)."
70
+ #
71
+ # t :: the array or string target to add to the list of tarets to build
72
+ attr_path_accessor :target do |t|
73
+ update_array_prop "target", method(:make_target), :targets, t
74
+ end
75
+
76
+ # Allows you to add properties to MsBuild; example:
77
+ #
78
+ # b.prop 'WarningLevel', 2
79
+ # b.prop 'BuildVersion', '3.5.0'
80
+ #
81
+ # From MSDN:
82
+ #
83
+ # "Set or override the specified project-level properties, where name is the property name and value is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:
84
+ # /property:WarningLevel=2;OutputDir=bin\Debug"
85
+ #
86
+ # The properties will be automatically converted to the correct syntax
87
+ def prop k, v
88
+ @properties ||= Hash.new
89
+ @parameters.delete "/property:#{make_props}" if @properties.any?
90
+ @properties[k] = v
91
+ @parameters.add "/property:#{make_props}"
92
+ end
93
+
94
+ # Specifies the amount of information to display in the build log.
95
+ # Each logger displays events based on the verbosity level that you set for that logger.
96
+ # You can specify the following verbosity levels: q[uiet], m[inimal],
97
+ # n[ormal], d[etailed], and diag[nostic].
98
+ attr_path_accessor :logging do |mode|
99
+ set_logging mode
100
+ end
101
+
102
+ # Specifies the number of parallel worker processes to build with
103
+ # Defaults to the number of logical cores
104
+ attr_path_accessor :cores do |num|
105
+ @parameters.add "/maxcpucount:#{num}"
106
+ end
107
+
108
+ # Pass the parameters that you specify to the console logger, which displays build information in the console window. You can specify the following parameters:
109
+ # * PerformanceSummary. Show the time that’s spent in tasks, targets, and projects.
110
+ # * Summary. Show the error and warning summary at the end.
111
+ # * NoSummary. Don't show the error and warning summary at the end.
112
+ # * ErrorsOnly. Show only errors.
113
+ # * WarningsOnly. Show only warnings.
114
+ # * NoItemAndPropertyList. Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.
115
+ # * ShowCommandLine. Show TaskCommandLineEvent messages.
116
+ # * ShowTimestamp. Show the timestamp as a prefix to any message.
117
+ # * ShowEventId. Show the event ID for each started event, finished event, and message.
118
+ # * ForceNoAlign. Don't align the text to the size of the console buffer.
119
+ # * DisableConsoleColor. Use the default console colors for all logging messages.
120
+ # * DisableMPLogging. Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
121
+ # * EnableMPLogging. Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.
122
+ # * Verbosity. Override the /verbosity setting for this logger.
123
+ def clp param
124
+ update_array_prop "consoleloggerparameters", method(:make_clp), :clp, param
125
+ end
126
+
127
+ # Set logging verbosity to quiet
128
+ def be_quiet
129
+ logging = "quiet"
130
+ end
131
+
132
+ # Don't display the startup banner or the copyright message.
133
+ def nologo
134
+ @parameters.add "/nologo"
135
+ end
136
+
137
+ private
138
+ def set_logging mode
139
+ modes = %w{quiet minimal normal detailed diagnostic}.collect{ |m| "/verbosity:#{m}" }
140
+ @parameters.subtract modes
141
+ @parameters.add "/verbosity:#{mode}"
142
+ end
143
+
144
+ def update_array_prop prop_name, callable_prop_val, field_sym, value
145
+ field = :"@#{field_sym}"
146
+ # @targets ||= []
147
+ instance_variable_set field, [] unless instance_variable_defined? field
148
+ # parameters.delete "/target:#{make_target}" if @targets.any?
149
+ @parameters.delete "/#{prop_name}:#{callable_prop_val.call}" if
150
+ instance_variable_get(field).any?
151
+ if value.respond_to? 'each'
152
+ value.each { |v| instance_variable_get(field) << v }
153
+ else
154
+ instance_variable_get(field) << value
155
+ end
156
+ instance_variable_get(field).uniq!
157
+ # @parameters.add "/target:#{make_target}"
158
+ @parameters.add "/#{prop_name}:#{callable_prop_val.call}"
159
+ end
160
+
161
+ def make_target
162
+ @targets.join(';')
163
+ end
164
+
165
+ def make_props
166
+ @properties.collect { |k, v|
167
+ "#{k}=#{v}"
168
+ }.join(';')
169
+ end
170
+
171
+ def make_clp
172
+ @clp.join(';')
173
+ end
174
+
175
+ def heuristic_executable
176
+ if ::Rake::Win32.windows?
177
+ trace 'build tasktype finding msbuild.exe'
178
+ %w{v4.0.30319 v4.0 v3.5 v2.0}.collect { |fw_ver|
179
+ msb = File.join ENV['WINDIR'], 'Microsoft.NET', 'Framework', fw_ver, 'msbuild.exe'
180
+ CrossPlatformCmd.which(msb) ? msb : nil
181
+ }.first
182
+ else
183
+ nil
184
+ end
185
+ end
186
+ end
187
+ class Task
188
+ def initialize command_line
189
+ @command_line = command_line
190
+ end
191
+ def execute
192
+ @command_line.execute
193
+ end
194
+ end
195
+ end
196
+ end