bake-toolkit 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/bin/bakery CHANGED
@@ -18,32 +18,14 @@ require 'cxxproject/utils/printer'
18
18
  require 'tocxx'
19
19
  require "bakery/loader"
20
20
  require "bakery/options"
21
+ require "bakery/toBake"
22
+ require "bakery/buildPattern"
21
23
  require 'cxxproject/ext/stdout'
22
24
  require 'cxxproject/utils/cleanup'
23
25
 
24
26
  module Cxxproject
25
27
 
26
- class BuildPattern
27
- attr_reader :proj, :conf, :coll_p
28
- def initialize(proj, conf, coll_p)
29
- @proj = proj
30
- @conf = conf
31
- @coll_p = coll_p
32
- end
33
- def getId
34
- proj + "*******" + conf
35
- end
36
- def hash
37
- getId.hash
38
- end
39
- def eql?(comparee)
40
- self == comparee
41
- end
42
- def ==(comparee)
43
- self.getId == comparee.getId
44
- end
45
- end
46
-
28
+
47
29
  @options = BakeryOptions.new(ARGV)
48
30
  @options.parse_options
49
31
 
@@ -56,7 +38,7 @@ module Cxxproject
56
38
  end
57
39
 
58
40
 
59
- if @options.collection_name.nil?
41
+ if @options.collection_name.empty?
60
42
  puts "Please specify a collection name (with -b). Possible values are:"
61
43
  env.find(:class => BakeryModel::Collection).each { |e|
62
44
  puts "* " + e.name
@@ -64,76 +46,25 @@ module Cxxproject
64
46
  ExitHelper.exit(0)
65
47
  end
66
48
 
67
- cols = env.find(:class => BakeryModel::Collection, :name => @options.collection_name)
68
- if (cols.length == 0)
69
- Printer.printError "Collection #{@options.collection_name} not found in #{@options.collection_dir+"/Collection.meta"}"
70
- ExitHelper.exit(1)
71
- elsif (cols.length > 1)
72
- Printer.printError "Collection #{@options.collection_name} found more than once in #{@options.collection_dir+"/Collection.meta"}"
73
- ExitHelper.exit(1)
74
- end
75
49
 
76
- col = cols[0]
77
-
78
- col.project.each do |p|
79
- if p.name == ""
80
- Printer.printError "Error in #{@options.collection_dir+"/Collection.meta"} (line #{p.line_number}): Project name empty"
81
- ExitHelper.exit(1)
82
- end
83
- if p.config == ""
84
- Printer.printError "Error in #{@options.collection_dir+"/Collection.meta"} (line #{p.line_number}): Config name empty"
85
- ExitHelper.exit(1)
86
- end
87
- end
88
-
89
- toBuildPattern = []
90
- @options.roots.each do |r|
91
- col.project.each do |p|
92
- projs = Dir.glob(r+"/"+p.name+"/Project.meta")
93
- if projs.length == 0
94
- toBuildPattern << BuildPattern.new(nil, nil, p) # remember it for sorted info printout
50
+ def self.getCollections(env, name)
51
+ cols = env.find(:class => BakeryModel::Collection, :name => name)
52
+ @toBuild |= getBuildPattern(cols, name)
53
+ @colsAll |= cols
54
+ cols[0].collections.each do |cRef|
55
+ alreadyProcessed = false
56
+ @colsAll.each do |ca|
57
+ alreadyProcessed = true if ca.name == cRef.name
95
58
  end
96
- projs.each do |f|
97
- toBuildPattern << BuildPattern.new(f, "^"+p.config.gsub("*","(\\w*)")+"$", p)
98
- end
99
- end
100
- end
101
-
102
- toBuild = []
103
- toBuildPattern.each do |bp|
104
- next unless bp.proj
105
- contents = File.open(bp.proj, "r") {|io| io.read }
106
- contents.split("\n").each do |c|
107
- res = c.match("\\s*(Library|Executable|Custom){1}Config\\s*(\\w*)")
108
- if res
109
- if res[2].match(bp.conf) != nil
110
- toBuild << BuildPattern.new(bp.proj, res[2], nil)
111
- bp.coll_p.found
112
- end
113
- end
114
- end
115
- end
116
-
117
- toBuildPattern.each do |bp|
118
- Printer.printInfo "Info in #{@options.collection_dir+"/Collection.meta"} (line #{bp.coll_p.line_number}): No match for project #{bp.coll_p.name} with config #{bp.coll_p.config}" unless bp.coll_p.isFound
119
- end
120
-
121
- col.exclude.each do |p|
122
- p.name = "/"+p.name.gsub("*","(\\w*)")+"/Project.meta"
123
- p.config = "^"+p.config.gsub("*","(\\w*)")+"$"
124
- end
125
-
126
- toBuild.delete_if do |bp|
127
- exclude = false
128
- col.exclude.each do |p|
129
- exclude = true if (bp.proj.match(p.name) != nil and bp.conf.match(p.config) != nil)
59
+ getCollections(env, cRef.name) unless alreadyProcessed
130
60
  end
131
- exclude
132
- end
61
+ end
133
62
 
134
- toBuild.uniq!
63
+ @toBuild = []
64
+ @colsAll = []
65
+ getCollections(env, @options.collection_name)
135
66
 
136
- maxRuns = toBuild.length
67
+ maxRuns = @toBuild.length
137
68
  currentRun = 0
138
69
  failedRuns = 0
139
70
 
@@ -144,7 +75,7 @@ module Cxxproject
144
75
  excludeParam = true
145
76
  next
146
77
  end
147
- if excludeParam
78
+ if excludeParam or x == @options.collection_name
148
79
  excludeParam = false
149
80
  next
150
81
  end
@@ -161,7 +92,7 @@ module Cxxproject
161
92
 
162
93
  exitValue = 0
163
94
  abort = false
164
- toBuild.each do |bp|
95
+ @toBuild.each do |bp|
165
96
  currentRun += 1
166
97
  p = File.dirname(bp.proj)
167
98
  cmd = (["-m #{p} -b #{bp.conf}"] + passedParams).join(" ")
data/lib/bake/cache.rb CHANGED
@@ -25,6 +25,9 @@ module Cxxproject
25
25
 
26
26
  def initialize(pm_filename, config_name, options)
27
27
  @cacheFilename = File.dirname(pm_filename)+"/.bake/"+File.basename(pm_filename)+"."+sanitize_filename(config_name)+".cache"
28
+
29
+ CLOBBER.include(File.dirname(pm_filename)+"/.bake")
30
+
28
31
  FileUtils.mkdir_p(File.dirname(@cacheFilename))
29
32
  @options = options
30
33
  @defaultToolchain = nil
@@ -128,6 +131,11 @@ module Cxxproject
128
131
 
129
132
  if cache != nil
130
133
  Printer.printInfo "Info: cache is up-to-date, loading cached meta information" if @options.verbose
134
+
135
+ cache.files.each do |c|
136
+ CLOBBER.include(File.dirname(c)+"/.bake")
137
+ end
138
+
131
139
  return cache.project2config
132
140
  end
133
141
  return nil
@@ -152,6 +160,11 @@ module Cxxproject
152
160
  rescue
153
161
  end
154
162
  File.open(@cacheFilename, 'wb') {|file| file.write(bbdump) }
163
+
164
+ project_files.each do |f|
165
+ CLOBBER.include(File.dirname(f)+"/.bake")
166
+ end
167
+
155
168
  end
156
169
 
157
170
  end
data/lib/bake/options.rb CHANGED
@@ -8,7 +8,7 @@ module Cxxproject
8
8
  class Options < Parser
9
9
  attr_reader :build_config, :main_dir, :project, :filename, :eclipse_version, :alias_filename # String
10
10
  attr_reader :roots, :include_filter, :exclude_filter # String List
11
- attr_reader :clean, :rebuild, :single, :verbose, :nocache, :color, :show_includes, :linkOnly, :check_uninc, :printLess, :no_autodir # Boolean
11
+ attr_reader :clean, :rebuild, :single, :verbose, :nocache, :color, :show_includes, :linkOnly, :check_uninc, :printLess, :no_autodir, :clobber # Boolean
12
12
  attr_reader :threads, :socket # Fixnum
13
13
 
14
14
  def initialize(argv)
@@ -20,6 +20,7 @@ module Cxxproject
20
20
  @filename = nil
21
21
  @single = false
22
22
  @clean = false
23
+ @clobber = false
23
24
  @rebuild = false
24
25
  @verbose = false
25
26
  @nocache = false
@@ -57,6 +58,7 @@ module Cxxproject
57
58
  add_option(Option.new("-v1",false) { set_v(1) })
58
59
  add_option(Option.new("-v2",false) { set_v(2) })
59
60
 
61
+ add_option(Option.new("--clobber",false) { set_clobber })
60
62
  add_option(Option.new("--ignore_cache",false) { set_nocache })
61
63
  add_option(Option.new("--threads",true) { |x| set_threads(x) })
62
64
  add_option(Option.new("--socket",true) { |x| set_socket(x) })
@@ -89,9 +91,9 @@ module Cxxproject
89
91
  puts " -w <root> Add a workspace root (can be used multiple times)."
90
92
  puts " If no root is specified, the parent directory of the main project is added automatically."
91
93
  puts " --rebuild Clean before build."
94
+ puts " --clobber Clean the file/project (same as option -c) AND the bake cache files."
92
95
  puts " --prepro Stop after preprocessor."
93
96
  puts " --link_only Only link executable - doesn't update objects and archives or start PreSteps and PostSteps"
94
- puts " --print_less Some progression logs will be suppressed"
95
97
  puts " --ignore_cache Rereads the original meta files - usefull if workspace structure has been changed."
96
98
  puts " --check_uninc Checks for unnecessary includes (only done for successful project builds)."
97
99
  puts " --threads <num> Set NUMBER of parallel compiled files (default is 8)."
@@ -183,6 +185,10 @@ module Cxxproject
183
185
  def set_clean()
184
186
  @clean = true
185
187
  end
188
+ def set_clobber()
189
+ @clobber = true
190
+ set_clean
191
+ end
186
192
  def set_rebuild()
187
193
  @clean = true
188
194
  @rebuild = true
@@ -209,10 +215,13 @@ module Cxxproject
209
215
  if num == 0
210
216
  @printLess = true
211
217
  @verbose = false
218
+ Rake::application.options.silent = true
212
219
  elsif num == 1
220
+ Rake::application.options.silent = false
213
221
  @printLess = false
214
222
  @verbose = false
215
223
  elsif num == 2
224
+ Rake::application.options.silent = false
216
225
  @printLess = false
217
226
  @verbose = true
218
227
  end
data/lib/bake/version.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Cxxproject
2
2
  class Version
3
3
  def self.bake
4
- "1.0.11"
4
+ "1.0.12"
5
5
  end
6
6
  end
7
7
 
8
- expectedCxx = "0.5.63"
8
+ expectedCxx = "0.5.64"
9
9
  expectedRGen = "0.6.0"
10
10
  expectedRText = "0.2.0"
11
11
 
@@ -0,0 +1,24 @@
1
+ module Cxxproject
2
+
3
+ class BuildPattern
4
+ attr_reader :proj, :conf, :coll_p
5
+ def initialize(proj, conf, coll_p)
6
+ @proj = proj
7
+ @conf = conf
8
+ @coll_p = coll_p
9
+ end
10
+ def getId
11
+ proj + "*******" + conf
12
+ end
13
+ def hash
14
+ getId.hash
15
+ end
16
+ def eql?(comparee)
17
+ self == comparee
18
+ end
19
+ def ==(comparee)
20
+ self.getId == comparee.getId
21
+ end
22
+ end
23
+
24
+ end
@@ -24,10 +24,14 @@ module Cxxproject
24
24
  has_attr 'name', String, :defaultValueLiteral => ""
25
25
  has_attr 'config', String, :defaultValueLiteral => ""
26
26
  end
27
+ class SubCollection < ModelElement
28
+ has_attr 'name', String, :defaultValueLiteral => ""
29
+ end
27
30
  class Collection < ModelElement
28
31
  has_attr 'name', String, :defaultValueLiteral => ""
29
32
  contains_many 'project', Project, 'collection'
30
33
  contains_many 'exclude', Exclude, 'collection'
34
+ contains_many 'collections', SubCollection, 'collection'
31
35
  end
32
36
 
33
37
  module Project::ClassModule
@@ -13,7 +13,7 @@ module Cxxproject
13
13
  def initialize(argv)
14
14
  super(argv)
15
15
 
16
- @collection_name = nil
16
+ @collection_name = ""
17
17
  @collection_dir = nil
18
18
  @color = nil
19
19
  @error = false
@@ -21,7 +21,9 @@ module Cxxproject
21
21
  @socket = 0
22
22
  @def_root = nil
23
23
 
24
- add_option(Option.new("-b",true) { |x| set_collection_name(x) })
24
+ add_default(Proc.new{ |x| set_collection_name_default(x) })
25
+
26
+ add_option(Option.new("-b",true) { |x| set_collection_name(x) })
25
27
  add_option(Option.new("-m",true) { |x| set_collection_dir(x) })
26
28
  add_option(Option.new("-r",false) { set_error })
27
29
  add_option(Option.new("-a",true) { |x| set_color(x) })
@@ -31,8 +33,8 @@ module Cxxproject
31
33
  end
32
34
 
33
35
  def usage
34
- puts "\nUsage: bake [options]"
35
- puts " -b <name> Name of the collection to build."
36
+ puts "\nUsage: bake <name> [options]"
37
+ puts " [-b] <name> Name of the collection to build."
36
38
  puts " -m <dir> Directory containing the collection file (default is current directory)."
37
39
  puts " -r Stop on first error."
38
40
  puts " -a <scheme> Use ansi color sequences (console must support it). Possible values are 'white' and 'black'."
@@ -60,7 +62,18 @@ module Cxxproject
60
62
  end
61
63
  end
62
64
 
65
+ def set_collection_name_default(collection_name)
66
+ index = collection_name.index('-')
67
+ return false if (index != nil and index == 0)
68
+ set_collection_name(collection_name)
69
+ return true
70
+ end
71
+
63
72
  def set_collection_name(collection_name)
73
+ if not @collection_name.empty?
74
+ Printer.printError "Error: Cannot set collection name '#{collection_name}', because collection name is already set to '#{@collection_name}'"
75
+ ExitHelper.exit(1)
76
+ end
64
77
  @collection_name = collection_name
65
78
  end
66
79
 
@@ -0,0 +1,78 @@
1
+ require "bakery/buildPattern"
2
+
3
+ module Cxxproject
4
+
5
+ def self.getBuildPattern(cols, name)
6
+
7
+ if (cols.length == 0)
8
+ Printer.printError "Collection #{name} not found in #{@options.collection_dir+"/Collection.meta"}"
9
+ ExitHelper.exit(1)
10
+ elsif (cols.length > 1)
11
+ Printer.printError "Collection #{name} found more than once in #{@options.collection_dir+"/Collection.meta"}"
12
+ ExitHelper.exit(1)
13
+ end
14
+
15
+ col = cols[0]
16
+
17
+ col.project.each do |p|
18
+ if p.name == ""
19
+ Printer.printError "Error in #{@options.collection_dir+"/Collection.meta"} (line #{p.line_number}): Project name empty"
20
+ ExitHelper.exit(1)
21
+ end
22
+ if p.config == ""
23
+ Printer.printError "Error in #{@options.collection_dir+"/Collection.meta"} (line #{p.line_number}): Config name empty"
24
+ ExitHelper.exit(1)
25
+ end
26
+ end
27
+
28
+ toBuildPattern = []
29
+ @options.roots.each do |r|
30
+ col.project.each do |p|
31
+ projs = Dir.glob(r+"/"+p.name+"/Project.meta")
32
+ if projs.length == 0
33
+ toBuildPattern << BuildPattern.new(nil, nil, p) # remember it for sorted info printout
34
+ end
35
+ projs.each do |f|
36
+ toBuildPattern << BuildPattern.new(f, "^"+p.config.gsub("*","(\\w*)")+"$", p)
37
+ end
38
+ end
39
+ end
40
+
41
+ toBuild = []
42
+ toBuildPattern.each do |bp|
43
+ next unless bp.proj
44
+ contents = File.open(bp.proj, "r") {|io| io.read }
45
+ contents.split("\n").each do |c|
46
+ res = c.match("\\s*(Library|Executable|Custom){1}Config\\s*(\\w*)")
47
+ if res
48
+ if res[2].match(bp.conf) != nil
49
+ toBuild << BuildPattern.new(bp.proj, res[2], nil)
50
+ bp.coll_p.found
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ toBuildPattern.each do |bp|
57
+ Printer.printInfo "Info in #{@options.collection_dir+"/Collection.meta"} (line #{bp.coll_p.line_number}): No match for project #{bp.coll_p.name} with config #{bp.coll_p.config}" unless bp.coll_p.isFound
58
+ end
59
+
60
+ col.exclude.each do |p|
61
+ p.name = "/"+p.name.gsub("*","(\\w*)")+"/Project.meta"
62
+ p.config = "^"+p.config.gsub("*","(\\w*)")+"$"
63
+ end
64
+
65
+ toBuild.delete_if do |bp|
66
+ exclude = false
67
+ col.exclude.each do |p|
68
+ exclude = true if (bp.proj.match(p.name) != nil and bp.conf.match(p.config) != nil)
69
+ end
70
+ exclude
71
+ end
72
+
73
+ toBuild.uniq!
74
+
75
+ return toBuild
76
+ end
77
+
78
+ end
data/lib/option/parser.rb CHANGED
@@ -38,11 +38,10 @@ class Parser
38
38
  while pos < @argv.length do
39
39
  if not @options.include?@argv[pos]
40
40
  if @default
41
- if not @default.call(@argv[pos])
41
+ res = @default.call(@argv[pos])
42
+ if (not res and not ignoreInvalid)
42
43
  raise "Option #{@argv[pos]} unknown"
43
44
  end
44
- elsif not ignoreInvalid
45
- raise "Option #{@argv[pos]} unknown"
46
45
  end
47
46
  else
48
47
  option = @options[@argv[pos]]
data/lib/tocxx.rb CHANGED
@@ -812,18 +812,24 @@ module Cxxproject
812
812
  FileUtils.rm @parseBB.get_dep_file(object), :force => true
813
813
  end
814
814
  else
815
- cleanTask = Rake.application["clean"]
815
+ if @options.clobber
816
+ cleanTask = Rake.application[:clobber]
817
+ cleanType = "Clobber"
818
+ else
819
+ cleanTask = Rake.application[:clean]
820
+ cleanType = "Clean"
821
+ end
816
822
  cleanTask.invoke
817
823
  end
818
824
 
819
825
  if Rake.application.idei and Rake.application.idei.get_abort
820
- Printer.printError "\nClean aborted."
826
+ Printer.printError "\#{cleanType} aborted."
821
827
  return false
822
828
  elsif cleanTask != nil and cleanTask.failure
823
- Printer.printError "\nClean failed."
829
+ Printer.printError "\n#{cleanType} failed."
824
830
  return false
825
831
  elsif not @options.rebuild
826
- Printer.printSuccess "\nClean done."
832
+ Printer.printSuccess "\n#{cleanType} done."
827
833
  return true
828
834
  end
829
835
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bake-toolkit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.11
5
+ version: 1.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Schaal
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-04-04 00:00:00 Z
13
+ date: 2013-04-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cxxproject
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.5.63
23
+ version: 0.5.64
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
@@ -68,10 +68,12 @@ files:
68
68
  - lib/bake/subst.rb
69
69
  - lib/bake/util.rb
70
70
  - lib/bake/version.rb
71
+ - lib/bakery/buildPattern.rb
71
72
  - lib/bakery/loader.rb
72
73
  - lib/bakery/model/language.rb
73
74
  - lib/bakery/model/metamodel.rb
74
75
  - lib/bakery/options.rb
76
+ - lib/bakery/toBake.rb
75
77
  - lib/option/parser.rb
76
78
  - lib/tocxx.rb
77
79
  - lib/vs/options.rb