bake-toolkit 2.65.0 → 2.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,177 +1,179 @@
1
- require_relative 'metamodel'
2
- require_relative 'language'
3
- require_relative '../../common/version'
4
-
5
- require 'rgen/environment'
6
- require 'rgen/fragment/dump_file_cache'
7
- require 'rgen/fragment/fragmented_model'
8
- require 'rgen/util/file_cache_map'
9
-
10
- require 'rtext/default_loader'
11
-
12
- require_relative '../../common/ext/rgen'
13
- require_relative '../../common/exit_helper'
14
- require_relative '../toolchain/colorizing_formatter'
15
- require_relative '../options/options'
16
-
17
- module Bake
18
-
19
- class Loader
20
-
21
- attr_reader :model
22
-
23
- def initialize
24
- @env = RGen::Environment.new
25
-
26
- fcm = RGen::Util::FileCacheMap.new(".bake", ".cache")
27
- fcm.version_info = Version.number
28
-
29
- if !Bake.options.dry
30
- @DumpFileCache = RGen::Fragment::DumpFileCache.new(fcm)
31
- else
32
- @DumpFileCache = nil
33
- end
34
-
35
- @model = RGen::Fragment::FragmentedModel.new(:env => @env)
36
-
37
- @globalFilterStrMap = {
38
- Bake::Metamodel::StartupSteps => "STARTUP",
39
- Bake::Metamodel::PreSteps => "PRE",
40
- Bake::Metamodel::PostSteps => "POST",
41
- Bake::Metamodel::ExitSteps => "EXIT",
42
- Bake::Metamodel::CleanSteps => "CLEAN"
43
- }
44
- end
45
-
46
- def load_internal(filename, silent = false)
47
- silent = false if Bake.options.debug
48
- loader = RText::DefaultLoader.new(
49
- Bake::Language,
50
- @model,
51
- :file_provider => proc { [filename] },
52
- :cache => @DumpFileCache)
53
- loader.load(:before_load => proc {|fragment, kind|
54
- case kind
55
- when :load_update_cache
56
- if Bake.options.verbose >= 3
57
- puts "Loading and caching #{fragment.location}" unless silent
58
- else
59
- puts "Loading #{fragment.location}" unless silent
60
- end
61
- when :load_cached
62
- if Bake.options.verbose >= 3
63
- puts "Loading cached #{fragment.location}" unless silent
64
- else
65
- puts "Loading #{fragment.location}" unless silent
66
- end
67
- when :load
68
- puts "Loading #{fragment.location}" unless silent
69
- else
70
- Bake.formatter.printError("Error: Could not load #{fragment.location}")
71
- ExitHelper.exit(1)
72
- end
73
- })
74
-
75
- if !Bake.options.dry
76
- Utils.gitIgnore(File.dirname(filename)+"/.bake")
77
- end
78
-
79
- frag = @model.fragments[0]
80
- @model.remove_fragment(frag)
81
- frag
82
- end
83
-
84
- def filterElement?(elem)
85
- return false if Bake::Metamodel::Project === elem
86
-
87
- # 1st prio: explicit single filter
88
- if elem.filter != ""
89
- return true if Bake.options.exclude_filter.include?elem.filter
90
- return false if Bake.options.include_filter.include?elem.filter
91
- end
92
-
93
- # 2nd prio: explicit global filter
94
- if defined?(elem.parent)
95
- globalFilterStr = @globalFilterStrMap[elem.parent.class]
96
- if (globalFilterStr)
97
- return true if Bake.options.exclude_filter.include?globalFilterStr
98
- return false if Bake.options.include_filter.include?globalFilterStr
99
- end
100
- end
101
-
102
- # 3nd prio: default
103
- return true if elem.default == "off"
104
- false
105
- end
106
-
107
- def applyFilterOnArray(a)
108
- toRemove = []
109
- a.each do |elem|
110
- if filterElement?(elem)
111
- toRemove << elem
112
- else
113
- applyFilterOnElement(elem)
114
- end
115
- end
116
- toRemove.each { |r| r.parent = nil }
117
- end
118
-
119
- def applyFilterOnElement(elem)
120
- return if elem.nil?
121
- elem.class.ecore.eAllReferences.each do |f|
122
- next unless f.containment
123
- begin
124
- childData = elem.getGeneric(f.name)
125
- rescue Exception => ex
126
- next
127
- end
128
- next if childData.nil?
129
- if (Array === childData)
130
- applyFilterOnArray(childData)
131
- elsif Metamodel::ModelElement === childData
132
- if filterElement?(childData)
133
- childData.parent = nil
134
- else
135
- applyFilterOnElement(childData)
136
- end
137
- end
138
- end
139
- end
140
-
141
- def load(filename)
142
- sumErrors = 0
143
-
144
- if not File.exists?filename
145
- Bake.formatter.printError("Error: #{filename} does not exist")
146
- ExitHelper.exit(1)
147
- end
148
-
149
- frag = nil
150
- if not Bake.options.nocache
151
- frag = load_internal(filename) # regular load
152
- frag = nil if frag.root_elements.length > 0 and filename != frag.root_elements[0].file_name
153
- end
154
-
155
- if frag.nil?
156
- def @DumpFileCache.load(fragment)
157
- :invalid
158
- end
159
- frag = load_internal(filename, !Bake.options.nocache)
160
- end
161
-
162
- frag.data[:problems].each do |p|
163
- Bake.formatter.printError(p.message, p.file, p.line)
164
- end
165
-
166
- if frag.data[:problems].length > 0
167
- ExitHelper.exit(1)
168
- end
169
-
170
- applyFilterOnArray(frag.root_elements)
171
-
172
- return frag
173
-
174
- end
175
-
176
- end
1
+ require_relative 'metamodel'
2
+ require_relative 'language'
3
+ require_relative '../../common/version'
4
+
5
+ require 'rgen/environment'
6
+ require 'rgen/fragment/dump_file_cache'
7
+ require 'rgen/fragment/fragmented_model'
8
+ require 'rgen/util/file_cache_map'
9
+
10
+ require 'rtext/default_loader'
11
+
12
+ require_relative '../../common/ext/rgen'
13
+ require_relative '../../common/exit_helper'
14
+ require_relative '../toolchain/colorizing_formatter'
15
+ require_relative '../options/options'
16
+
17
+ module Bake
18
+
19
+ class Loader
20
+
21
+ attr_reader :model
22
+
23
+ def initialize
24
+ @env = RGen::Environment.new
25
+
26
+ fcm = RGen::Util::FileCacheMap.new(".bake", ".cache")
27
+ fcm.version_info = Version.number
28
+
29
+ if !Bake.options.dry
30
+ @DumpFileCache = RGen::Fragment::DumpFileCache.new(fcm)
31
+ else
32
+ @DumpFileCache = nil
33
+ end
34
+
35
+ @model = RGen::Fragment::FragmentedModel.new(:env => @env)
36
+
37
+ @globalFilterStrMap = {
38
+ Bake::Metamodel::StartupSteps => "STARTUP",
39
+ Bake::Metamodel::PreSteps => "PRE",
40
+ Bake::Metamodel::PostSteps => "POST",
41
+ Bake::Metamodel::ExitSteps => "EXIT",
42
+ Bake::Metamodel::CleanSteps => "CLEAN"
43
+ }
44
+ end
45
+
46
+ def load_internal(filename, silent = false)
47
+ silent = false if Bake.options.debug
48
+ loader = RText::DefaultLoader.new(
49
+ Bake::Language,
50
+ @model,
51
+ :file_provider => proc { [filename] },
52
+ :cache => @DumpFileCache)
53
+ loader.load(:before_load => proc {|fragment, kind|
54
+ case kind
55
+ when :load_update_cache
56
+ if Bake.options.verbose >= 3
57
+ puts "Loading and caching #{fragment.location}" unless silent
58
+ else
59
+ puts "Loading #{fragment.location}" unless silent
60
+ end
61
+ when :load_cached
62
+ if Bake.options.verbose >= 3
63
+ puts "Loading cached #{fragment.location}" unless silent
64
+ else
65
+ puts "Loading #{fragment.location}" unless silent
66
+ end
67
+ when :load
68
+ puts "Loading #{fragment.location}" unless silent
69
+ else
70
+ Bake.formatter.printError("Error: Could not load #{fragment.location}")
71
+ ExitHelper.exit(1)
72
+ end
73
+ })
74
+
75
+ if !Bake.options.dry
76
+ Utils.gitIgnore(File.dirname(filename)+"/.bake")
77
+ end
78
+
79
+ frag = @model.fragments[0]
80
+ @model.remove_fragment(frag)
81
+ frag
82
+ end
83
+
84
+ def filterElement?(elem)
85
+ return false if Bake::Metamodel::Project === elem
86
+
87
+ # 1st prio: explicit single filter
88
+ if elem.filter != ""
89
+ return true if Bake.options.exclude_filter.include?elem.filter
90
+ return false if Bake.options.include_filter.include?elem.filter
91
+ end
92
+
93
+ # 2nd prio: explicit global filter
94
+ if defined?(elem.parent)
95
+ globalFilterStr = @globalFilterStrMap[elem.parent.class]
96
+ if (globalFilterStr)
97
+ return true if Bake.options.exclude_filter.include?globalFilterStr
98
+ return false if Bake.options.include_filter.include?globalFilterStr
99
+ end
100
+ end
101
+
102
+ # 3nd prio: default
103
+ return true if elem.default == "off"
104
+ false
105
+ end
106
+
107
+ def applyFilterOnArray(a)
108
+ toRemove = []
109
+ a.each do |elem|
110
+ if filterElement?(elem)
111
+ toRemove << elem
112
+ else
113
+ applyFilterOnElement(elem)
114
+ end
115
+ end
116
+ toRemove.each { |r| r.parent = nil if r.respond_to?(:parent=) }
117
+ return toRemove
118
+ end
119
+
120
+ def applyFilterOnElement(elem)
121
+ return if elem.nil?
122
+ elem.class.ecore.eAllReferences.each do |f|
123
+ next unless f.containment
124
+ begin
125
+ childData = elem.getGeneric(f.name)
126
+ rescue Exception => ex
127
+ next
128
+ end
129
+ next if childData.nil?
130
+ if (Array === childData)
131
+ applyFilterOnArray(childData)
132
+ elsif Metamodel::ModelElement === childData
133
+ if filterElement?(childData)
134
+ childData.parent = nil
135
+ else
136
+ applyFilterOnElement(childData)
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ def load(filename)
143
+ sumErrors = 0
144
+
145
+ if not File.exists?filename
146
+ Bake.formatter.printError("Error: #{filename} does not exist")
147
+ ExitHelper.exit(1)
148
+ end
149
+
150
+ frag = nil
151
+ if not Bake.options.nocache
152
+ frag = load_internal(filename) # regular load
153
+ frag = nil if frag.root_elements.length > 0 and filename != frag.root_elements[0].file_name
154
+ end
155
+
156
+ if frag.nil?
157
+ def @DumpFileCache.load(fragment)
158
+ :invalid
159
+ end
160
+ frag = load_internal(filename, !Bake.options.nocache)
161
+ end
162
+
163
+ frag.data[:problems].each do |p|
164
+ Bake.formatter.printError(p.message, p.file, p.line)
165
+ end
166
+
167
+ if frag.data[:problems].length > 0
168
+ ExitHelper.exit(1)
169
+ end
170
+
171
+ tor = applyFilterOnArray(frag.root_elements)
172
+ frag.root_elements.delete_if {|re| tor.include?(re)}
173
+
174
+ return frag
175
+
176
+ end
177
+
178
+ end
177
179
  end
@@ -14,16 +14,10 @@ module Bake
14
14
  annotation :details => {'internal' => 'true'}
15
15
  end
16
16
  module ClassModule
17
+ attr_accessor :file_name, :org_file_name
17
18
  def fragment_ref=(fref)
18
- @fname = fref.fragment.location
19
- end
20
-
21
- def file_name
22
- @fname
23
- end
24
-
25
- def file_name=(name)
26
- @fname = name
19
+ @file_name = fref.fragment.location
20
+ @org_file_name = fref.fragment.location
27
21
  end
28
22
  end
29
23
  end
@@ -103,6 +97,7 @@ module Bake
103
97
  class DefaultToolchain < ModelElement
104
98
  has_attr 'basedOn', String, :defaultValueLiteral => ""
105
99
  has_attr 'outputDir', String, :defaultValueLiteral => ""
100
+ has_attr 'outputDirPostfix', String, :defaultValueLiteral => ""
106
101
  has_attr 'eclipseOrder', Boolean, :defaultValueLiteral => "false"
107
102
  has_attr 'keepObjFileEndings', Boolean, :defaultValueLiteral => "false"
108
103
  contains_many 'compiler', Compiler, 'parent'
@@ -115,6 +110,7 @@ module Bake
115
110
 
116
111
  class Toolchain < ModelElement
117
112
  has_attr 'outputDir', String, :defaultValueLiteral => ""
113
+ has_attr 'outputDirPostfix', String, :defaultValueLiteral => ""
118
114
  contains_many 'compiler', Compiler, 'parent'
119
115
  contains_one 'archiver', Archiver, 'parent'
120
116
  contains_one 'linker', Linker, 'parent'
@@ -201,13 +197,16 @@ module Bake
201
197
  contains_many 'except', Except, 'parent'
202
198
  end
203
199
 
204
- class Step < ModelElement
205
- has_attr 'name', String, :defaultValueLiteral => ""
200
+ class StepBase < ModelElement
206
201
  has_attr 'echo', String, :defaultValueLiteral => "on"
207
202
  has_attr 'independent', Boolean, :defaultValueLiteral => "false"
208
203
  has_many_attr 'validExitCodes', Integer
209
204
  end
210
205
 
206
+ class Step < StepBase
207
+ has_attr 'name', String, :defaultValueLiteral => ""
208
+ end
209
+
211
210
  class Makefile < Step
212
211
  has_attr 'lib', String, :defaultValueLiteral => ""
213
212
  has_attr 'target', String, :defaultValueLiteral => ""
@@ -238,27 +237,28 @@ module Bake
238
237
  has_attr 'name', String, :defaultValueLiteral => "0.0"
239
238
  end
240
239
 
241
- class CommandLine < Step
240
+ class CommandLine < StepBase
241
+ has_many_attr 'name', String, :defaultValueLiteral => ""
242
242
  end
243
243
 
244
244
  class PreSteps < ModelElement
245
- contains_many 'step', Step, 'parent'
245
+ contains_many 'step', StepBase, 'parent'
246
246
  end
247
247
 
248
248
  class PostSteps < ModelElement
249
- contains_many 'step', Step, 'parent'
249
+ contains_many 'step', StepBase, 'parent'
250
250
  end
251
251
 
252
252
  class ExitSteps < ModelElement
253
- contains_many 'step', Step, 'parent'
253
+ contains_many 'step', StepBase, 'parent'
254
254
  end
255
255
 
256
256
  class CleanSteps < ModelElement
257
- contains_many 'step', Step, 'parent'
257
+ contains_many 'step', StepBase, 'parent'
258
258
  end
259
259
 
260
260
  class StartupSteps < ModelElement
261
- contains_many 'step', Step, 'parent'
261
+ contains_many 'step', StepBase, 'parent'
262
262
  end
263
263
 
264
264
  class LinkerScript < ModelElement
@@ -348,7 +348,7 @@ module Bake
348
348
  end
349
349
 
350
350
  class CustomConfig < BaseConfig_INTERNAL
351
- contains_one 'step', Step, 'parent'
351
+ contains_one 'step', StepBase, 'parent'
352
352
  module ClassModule
353
353
  def color
354
354
  "red"