bake-toolkit 2.50.0 → 2.51.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce5efe331210cc1e31546df0f648bf989d173ed5095cd3cd3ebf6e423941fe77
4
- data.tar.gz: 8b9e09c9436b098878e281d02159bb2371b53c1d03ab0e1893b2a282dd8646e7
3
+ metadata.gz: 7be514890067a494671fdac7dfae9504543d2bf1bc6670d27aeaac9f7175a1a4
4
+ data.tar.gz: c98fb5849e848f75ac62e7baa64a70c3fd43b1b48bb5c1cbe824e6ae78e7349b
5
5
  SHA512:
6
- metadata.gz: d07d87f5322ad4d941b4da672eeb34c2da3f2d3e310c110b584e30fe01486a793918e74090fdb1adb5aa1e3005e62ad923ecf65a5af49d4a085d3534047cdc22
7
- data.tar.gz: 4749a9fe550431e99305835df4c26b109e9145aef758f345f1fde3fd4823ec3c18c6b2e2e28d54da8519d0863aa16b607886b299053cc309383128fcb6956b5e
6
+ metadata.gz: f6fc7efce7b5c59dddcac4ab3269b0283be77205ddad4d186a88578366aa7da6dcc38b776d214580a0b5e12c9c298152fc51bcf8859ed8ef9e6eb1089a4f2e82
7
+ data.tar.gz: 6ca78e17679d93e286f23ea6f30ad73648bdb7f3fd6344551a610188e20ba9bda42e56b1ce29a5617a51c63409e40c5ab9f54cf58999086a604fef68ccec340b
data/bin/bake CHANGED
@@ -11,6 +11,8 @@ STDERR.sync = true
11
11
  require 'tocxx'
12
12
  require 'socket'
13
13
 
14
+ puts "Profiling #{Time.now - $timeStart}: ruby includes parsed..." if ARGV.include?("--profiling")
15
+
14
16
  module Bake
15
17
 
16
18
  earlyExit = nil
@@ -20,6 +22,7 @@ module Bake
20
22
  ExitHelper.exit(1)
21
23
  end
22
24
 
25
+ puts "Profiling #{Time.now - $timeStart}: parse options..." if ARGV.include?("--profiling")
23
26
  Bake.options = Options.new(ARGV)
24
27
  Bake.options.parse_options
25
28
 
@@ -48,6 +48,10 @@ module Bake
48
48
  Bake.formatter.printError("Allowed types are 'replace', 'remove', 'extend' and 'push_front'.",c)
49
49
  ExitHelper.exit(1)
50
50
  end
51
+ if not ["", "yes", "no", "all"].include?c.mergeInc
52
+ Bake.formatter.printError("Allowed modes are 'all', 'yes', 'no' and unset.",c)
53
+ ExitHelper.exit(1)
54
+ end
51
55
  end
52
56
  end
53
57
 
@@ -78,11 +78,9 @@ module Bake
78
78
  end
79
79
  end if config.respond_to?("includeDir")
80
80
 
81
- config.dependency.each do |d|
82
- if not ["front", "back", ""].include?d.inject
83
- Bake.formatter.printError("inject of Dependency must be 'front' or 'back'", d)
84
- ExitHelper.exit(1)
85
- end
81
+ if not ["", "yes", "no", "all"].include?config.mergeInc
82
+ Bake.formatter.printError("Allowed modes are 'all', 'yes', 'no' and unset.",config)
83
+ ExitHelper.exit(1)
86
84
  end
87
85
 
88
86
  end
@@ -29,19 +29,12 @@ module Bake
29
29
 
30
30
  levels = @@linker[:LINK_ONLY_DIRECT_DEPS] ? 1 : -1
31
31
  collect_recursive(block, levels)
32
-
33
- if Bake.options.oldLinkOrder
34
- if @@linker[:LIST_MODE] and not @@lib_path_set.empty?
35
- @@linker_libs_array << (@@linker[:LIB_PATH_FLAG] + @@lib_path_set.join(","));
36
- end
37
- else
38
- @@source_libraries.reverse!
39
- @@lib_path_set.reverse!
40
- if @@linker[:LIST_MODE] and not @@lib_path_set.empty?
41
- @@linker_libs_array.unshift (@@linker[:LIB_PATH_FLAG] + @@lib_path_set.join(","));
42
- end
43
- @@linker_libs_array.reverse!
32
+ @@source_libraries.reverse!
33
+ @@lib_path_set.reverse!
34
+ if @@linker[:LIST_MODE] and not @@lib_path_set.empty?
35
+ @@linker_libs_array.unshift (@@linker[:LIB_PATH_FLAG] + @@lib_path_set.join(","));
44
36
  end
37
+ @@linker_libs_array.reverse!
45
38
 
46
39
  return [@@source_libraries + @@withpath, @@linker_libs_array]
47
40
  end
@@ -49,7 +42,7 @@ module Bake
49
42
  def self.adaptPath(path, block, prefix)
50
43
  adaptedPath = path
51
44
  if not File.is_absolute?(path)
52
- prefix ||= File.rel_from_to_project(@@projectDir,block.projectDir)
45
+ prefix ||= File.rel_from_to_project(@@projectDir, block.projectDir)
53
46
  adaptedPath = prefix + path if prefix
54
47
  adaptedPath = Pathname.new(adaptedPath).cleanpath.to_s
55
48
  end
@@ -75,59 +68,50 @@ module Bake
75
68
 
76
69
  prefix = nil
77
70
 
78
- if Bake.options.oldLinkOrder
79
- addOwnLib(block)
80
- elems = block.lib_elements
81
- else
82
- elems = block.lib_elements.reverse
83
- end
84
-
85
- elems.each do |elem|
86
- case elem.type
87
- when LibElement::LIB
88
- @@linker_libs_array << "#{@@linker[:LIB_FLAG]}#{elem.value}"
89
- when LibElement::USERLIB
90
- @@linker_libs_array << "#{@@linker[:USER_LIB_FLAG]}#{elem.value}"
91
- when LibElement::LIB_WITH_PATH
92
- adaptedPath, prefix = adaptPath(elem.value, block, prefix)
93
- @@linker_libs_array << adaptedPath
94
- @@withpath << adaptedPath
95
- when LibElement::SEARCH_PATH
96
- adaptedPath, prefix = adaptPath(elem.value, block, prefix)
97
- lpf = "#{@@linker[:LIB_PATH_FLAG]}#{adaptedPath}"
98
-
99
- if not Bake.options.oldLinkOrder
71
+ if levels != 0
72
+ lib_elements = calcLibElements(block)
73
+ lib_elements += block.lib_elements unless block.lib_elements.nil?
74
+
75
+ lib_elements.reverse.each do |elem|
76
+ case elem.type
77
+ when LibElement::LIB
78
+ @@linker_libs_array << "#{@@linker[:LIB_FLAG]}#{elem.value}"
79
+ when LibElement::USERLIB
80
+ @@linker_libs_array << "#{@@linker[:USER_LIB_FLAG]}#{elem.value}"
81
+ when LibElement::LIB_WITH_PATH
82
+ adaptedPath, prefix = adaptPath(elem.value, block, prefix)
83
+ @@linker_libs_array << adaptedPath
84
+ @@withpath << adaptedPath
85
+ when LibElement::SEARCH_PATH
86
+ adaptedPath, prefix = adaptPath(elem.value, block, prefix)
87
+ lpf = "#{@@linker[:LIB_PATH_FLAG]}#{adaptedPath}"
88
+
100
89
  if not @@lib_path_set.include?adaptedPath
101
90
  @@lib_path_set << adaptedPath
102
91
  @@linker_libs_array << lpf if @@linker[:LIST_MODE] == false
103
92
  end
104
- end
105
-
106
- if not Bake.options.oldLinkOrder
93
+
107
94
  # must be moved to the end, so delete it...
108
95
  ind1 = @@lib_path_set.index(adaptedPath)
109
96
  ind2 = @@linker_libs_array.index(lpf)
110
97
  @@lib_path_set.delete_at(ind1) if not ind1.nil?
111
98
  @@linker_libs_array.delete_at(ind2) if not ind2.nil?
112
- end
113
-
114
- if (not Bake.options.oldLinkOrder) or (not @@lib_path_set.include?adaptedPath)
99
+
115
100
  # end place it at the end again
116
101
  @@lib_path_set << adaptedPath
117
102
  @@linker_libs_array << lpf if @@linker[:LIST_MODE] == false
118
- end
119
-
120
- when LibElement::DEPENDENCY
121
- if Blocks::ALL_BLOCKS.include?elem.value
122
- bb = Blocks::ALL_BLOCKS[elem.value]
123
- collect_recursive(bb, levels-1)
124
- else
125
- # TODO: warning or error?
103
+
104
+ when LibElement::DEPENDENCY
105
+ if Blocks::ALL_BLOCKS.include?elem.value
106
+ bb = Blocks::ALL_BLOCKS[elem.value]
107
+ collect_recursive(bb, levels-1)
108
+ else
109
+ # TODO: warning or error?
110
+ end
126
111
  end
127
112
  end
128
- end if levels != 0
129
-
130
- addOwnLib(block) if not Bake.options.oldLinkOrder
113
+ end
114
+ addOwnLib(block)
131
115
  end
132
116
 
133
117
 
@@ -135,7 +119,6 @@ module Bake
135
119
  lib_elements = [] # value = array pairs [type, name/path string]
136
120
 
137
121
  block.config.libStuff.each do |l|
138
-
139
122
  if (Metamodel::UserLibrary === l)
140
123
  ln = l.name
141
124
  ls = nil
@@ -39,6 +39,13 @@ module Bake
39
39
 
40
40
 
41
41
  def replace()
42
+ if Metamodel::BaseConfig_INTERNAL === @child &&
43
+ Metamodel::BaseConfig_INTERNAL === @parent
44
+ if @child.mergeInc != "" && @parent.mergeInc != "no"
45
+ @parent.mergeInc = @child.mergeInc
46
+ end
47
+ end
48
+
42
49
  @child.class.ecore.eAllReferences.each do |f|
43
50
  next unless @parent.class.ecore.eAllReferences.include?f
44
51
  next unless f.containment
@@ -78,6 +85,13 @@ module Bake
78
85
 
79
86
  def removeChilds(childElem, parentElem)
80
87
  return if childElem.nil? or parentElem.nil?
88
+
89
+ if Metamodel::BaseConfig_INTERNAL === childElem &&
90
+ Metamodel::BaseConfig_INTERNAL === parentElem
91
+ if childElem.mergeInc == parentElem.mergeInc
92
+ parentElem.mergeInc = ""
93
+ end
94
+ end
81
95
 
82
96
  childElem.class.ecore.eAllReferences.each do |f|
83
97
  next unless f.containment
@@ -128,6 +142,13 @@ module Bake
128
142
  end
129
143
 
130
144
  def extend(child, parent, push_front)
145
+ if Metamodel::BaseConfig_INTERNAL === child &&
146
+ Metamodel::BaseConfig_INTERNAL === parent
147
+ if child.mergeInc != "" && parent.mergeInc != "no"
148
+ parent.mergeInc = child.mergeInc
149
+ end
150
+ end
151
+
131
152
  (parent.class.ecore.eAllReferences & child.class.ecore.eAllReferences).each do |f|
132
153
  next unless f.containment
133
154
  parentData = parent.getGeneric(f.name)
@@ -148,6 +148,9 @@ module Bake
148
148
  class BaseElement < ModelElement
149
149
  end
150
150
 
151
+ class LibStuff < BaseElement
152
+ end
153
+
151
154
  class IncludeDir < BaseElement
152
155
  has_attr 'name', String, :defaultValueLiteral => ""
153
156
  has_attr 'infix', String, :defaultValueLiteral => ""
@@ -156,8 +159,7 @@ module Bake
156
159
  has_attr 'system', Boolean, :defaultValueLiteral => "false"
157
160
  end
158
161
 
159
- class LibStuff < BaseElement
160
- end
162
+
161
163
 
162
164
  class ExternalLibrary < LibStuff
163
165
  has_attr 'name', String, :defaultValueLiteral => ""
@@ -273,6 +275,7 @@ module Bake
273
275
  has_attr 'type', String, :defaultValueLiteral => ""
274
276
  has_attr 'project', String, :defaultValueLiteral => ""
275
277
  has_attr 'private', Boolean, :defaultValueLiteral => "false"
278
+ has_attr 'mergeInc', String, :defaultValueLiteral => ""
276
279
  contains_one 'description', Description, 'parent'
277
280
  contains_one 'startupSteps', StartupSteps, 'parent'
278
281
  contains_one 'preSteps', PreSteps, 'parent'
@@ -23,10 +23,22 @@ module Bake
23
23
 
24
24
  end
25
25
 
26
+ module Dependency::ClassModule
27
+ def setInjected
28
+ @injected = true
29
+ end
30
+ def injected?
31
+ @injected ||= false
32
+ end
33
+ end
34
+
26
35
  module BaseConfig_INTERNAL::ClassModule
27
36
  def qname
28
37
  @qname ||= parent.name + "," + name
29
38
  end
39
+ def depInc
40
+ baseElement.find_all { |l| Dependency === l || IncludeDir === l}
41
+ end
30
42
  def dependency
31
43
  baseElement.find_all { |l| Dependency === l }
32
44
  end
@@ -23,7 +23,7 @@ module Bake
23
23
  attr_reader :main_dir, :project, :filename, :main_project_name, :buildDirDelimiter, :dot, :cc2j_filename # String
24
24
  attr_reader :include_filter, :exclude_filter, :adapt # String List
25
25
  attr_reader :conversion_info, :stopOnFirstError, :clean, :rebuild, :show_includes, :show_includes_and_defines, :projectPaths, :qac, :dry, :syncedOutput, :debug_threads, :skipBuildingLine # Boolean
26
- attr_reader :linkOnly, :compileOnly, :no_autodir, :clobber, :docu, :debug, :prepro, :oldLinkOrder, :prebuild, :printTime, :json, :wparse, :caseSensitivityCheck, :fileCmd, :mergeInc # Boolean
26
+ attr_reader :linkOnly, :compileOnly, :no_autodir, :clobber, :docu, :debug, :prepro, :prebuild, :printTime, :json, :wparse, :caseSensitivityCheck, :fileCmd, :profiling # Boolean
27
27
  attr_reader :threads, :socket # Fixnum
28
28
  attr_reader :vars, :include_filter_args # map
29
29
  attr_reader :verbose
@@ -49,7 +49,6 @@ module Bake
49
49
  @prebuild = false
50
50
  @printTime = false
51
51
  @buildDirDelimiter = "/"
52
- @oldLinkOrder = false
53
52
  @conversion_info = false
54
53
  @envToolchain = false
55
54
  @analyze = false
@@ -86,10 +85,10 @@ module Bake
86
85
  @main_project_name = ""
87
86
  @adapt = []
88
87
  @syncedOutput = false
88
+ @profiling = false
89
89
  @diabCaseCheck = false
90
90
  @defines = []
91
91
  @fileCmd = false
92
- @mergeInc = false
93
92
 
94
93
  add_option(["-b", "" ], lambda { |x| set_build_config(x) })
95
94
  add_option(["-m" ], lambda { |x| @main_dir = x })
@@ -101,6 +100,7 @@ module Bake
101
100
  add_option(["-r" ], lambda { @stopOnFirstError = true })
102
101
  add_option(["-O" ], lambda { @syncedOutput = true })
103
102
  add_option(["--rebuild" ], lambda { @rebuild = true })
103
+ add_option(["--profiling" ], lambda { @profiling = true })
104
104
  add_option(["--prepro" ], lambda { @prepro = true })
105
105
  add_option(["--link-only", "--link_only" ], lambda { @linkOnly = true; })
106
106
  add_option(["--compile-only", "--compile_only" ], lambda { @compileOnly = true; })
@@ -124,7 +124,6 @@ module Bake
124
124
  add_option(["-nb" ], lambda { @skipBuildingLine = true })
125
125
  add_option(["--no-case-check" ], lambda { @caseSensitivityCheck = false })
126
126
  add_option(["--file-cmd" ], lambda { @fileCmd = true })
127
- add_option(["--merge-inc" ], lambda { @mergeInc = true })
128
127
  add_option(["--clobber" ], lambda { @clobber = true; @clean = true })
129
128
  add_option(["--ignore-cache", "--ignore_cache" ], lambda { @nocache = true })
130
129
  add_option(["-j", "--threads" ], lambda { |x, dummy1, dummy2| set_threads(x) })
@@ -159,7 +158,6 @@ module Bake
159
158
  add_option(["--version" ], lambda { Bake::Usage.version })
160
159
  add_option(["--list", "--show_configs" ], lambda { @showConfigs = true })
161
160
  add_option(["--compilation-db" ], lambda { |x,dummy| @cc2j_filename = (x ? x : "compile_commands.json" )})
162
- add_option(["--link-2-17", "--link_2_17" ], lambda { @oldLinkOrder = true })
163
161
  add_option(["--build_", ], lambda { @buildDirDelimiter = "_" })
164
162
 
165
163
  # deprecated and not replaced by new command
@@ -62,8 +62,7 @@ module Bake
62
62
  puts " --crc32 <string> Calulates the CRC32 of string (0x4C11DB7, init 0, final xor 0, input and result not reflected), used for Uid variable calculation"
63
63
  puts " --diab-case-check When compiling with DCC, this switches to the case check on Windows machines. No actual compilation is done."
64
64
  puts " --file-cmd Writes arguments into a file and hands it over the compiler/archiver/linker. Works only for supported compilers."
65
- puts " --merge-inc Merges includes together, so the compiler gets only one include directory."
66
- puts " --link-2-17 DEPRECATED: Using link order of libraries which was used until bake 2.17"
65
+ puts " --link-beta Improved linking, order of libs changed. Experimental."
67
66
  puts " --build_ DEPRECATED: build directories will be build_<name> instead of build/<name>"
68
67
  puts " --version Print version."
69
68
  puts " --time Print elapsed time at the end."
@@ -49,7 +49,7 @@ module Bake
49
49
 
50
50
  GCCChain[:ARCHIVER][:COMMAND] = "ar"
51
51
  GCCChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-rc"
52
- GCCChain[:ARCHIVER][:FILE_COMMAND] = "@"
52
+ GCCChain[:ARCHIVER][:FILE_COMMAND] = (Bake::Utils::OS.name == "Mac" ? "" : "@")
53
53
 
54
54
  GCCChain[:LINKER][:COMMAND] = "g++"
55
55
  GCCChain[:LINKER][:SCRIPT] = "-T"
@@ -20,7 +20,11 @@ module Bake
20
20
 
21
21
  def self.localFile(str)
22
22
  return true if (not is_valid?) || (not @@options.qacfilefilter)
23
- projects.any? { |fil| str.include?(fil+"/") and not str.include?(fil+"/test/") and not str.include?(fil+"/mock/") and not str.include?(fil+"/.qacdata/") }
23
+ projects.any? { |fil| str.include?(fil+"/") &&
24
+ !str.include?(fil+"/test/") &&
25
+ !str.include?(fil+"/mock/") &&
26
+ !str.include?(fil+"/.qacdata/") &&
27
+ !str.include?("/mergedIncludes") }
24
28
  end
25
29
 
26
30
  def self.writeFilter(filter)
@@ -22,8 +22,8 @@ module Bake
22
22
  @@delayed_result = true
23
23
  @@threads = []
24
24
 
25
- attr_reader :lib_elements, :projectDir, :library, :config, :projectName, :prebuild, :output_dir, :tcs
26
- attr_accessor :visited, :inDeps, :result
25
+ attr_reader :lib_elements, :projectDir, :library, :config, :projectName, :configName, :prebuild, :output_dir, :tcs
26
+ attr_accessor :visited, :inDeps, :result, :bes
27
27
 
28
28
  def startupSteps
29
29
  @startupSteps ||= []
@@ -52,7 +52,7 @@ module Bake
52
52
  def dependencies
53
53
  @dependencies ||= []
54
54
  end
55
-
55
+
56
56
  def childs
57
57
  @childs ||= []
58
58
  end
@@ -61,10 +61,6 @@ module Bake
61
61
  @parents ||= []
62
62
  end
63
63
 
64
- def depToBlock
65
- @depToBlock ||= {}
66
- end
67
-
68
64
  def set_library(library)
69
65
  @library = library
70
66
  end
@@ -81,8 +77,8 @@ module Bake
81
77
  @projectDir = config.get_project_dir
82
78
  @result = true
83
79
  @tcs = tcs
84
-
85
- @lib_elements = Bake::LibElements.calcLibElements(self)
80
+ @bes = []
81
+ @lib_elements = []
86
82
 
87
83
  calcOutputDir
88
84
  end
@@ -352,7 +348,6 @@ module Bake
352
348
  @config.writeEnvVars()
353
349
  Thread.current[:lastCommand] = nil
354
350
  allSteps = (preSteps + mainSteps + postSteps)
355
-
356
351
  # check if we have to delay the output (if the last step of this block is not in a thread)
357
352
  @outputStep = nil
358
353
  allSteps.each { |step| @outputStep = independent?(method, step) ? step : nil }
@@ -197,6 +197,14 @@ module Bake
197
197
  end
198
198
  args = cmd.drop(onlyCmd.length)
199
199
  argsFlat = args.join(' ')
200
+
201
+ splittedArgs = argsFlat.split("\"")
202
+ argsFlat = ""
203
+ splittedArgs.each_with_index do |s,i|
204
+ argsFlat << s
205
+ argsFlat << (i%2 == 0 ? "\"\\\"" : "\\\"\"") if i != splittedArgs.length - 1
206
+ end
207
+
200
208
  cmdFile = orgOut + ".file" + postfix
201
209
  cmdFileLong = File.expand_path(cmdFile, @projectDir)
202
210
  FileUtils.mkdir_p(File.dirname(cmdFileLong))
@@ -41,7 +41,6 @@ end
41
41
 
42
42
 
43
43
 
44
-
45
44
  module Bake
46
45
 
47
46
  module Blocks
@@ -60,10 +59,7 @@ module Bake
60
59
  @object_files = {}
61
60
  @system_includes = Set.new
62
61
 
63
- calcFileTcs
64
- calcIncludes
65
- calcDefines # not for files with changed tcs
66
- calcFlags # not for files with changed tcs
62
+
67
63
  end
68
64
 
69
65
  def get_object_file(source)
@@ -408,12 +404,18 @@ module Bake
408
404
  end
409
405
 
410
406
  def execute
411
- #Dir.chdir(@projectDir) do
412
-
407
+ return true if @config.files.empty?
408
+
413
409
  SyncOut.mutex.synchronize do
410
+ calcFileTcs
411
+ calcIncludes
412
+ calcDefines # not for files with changed tcs
413
+ calcFlags # not for files with changed tcs
414
414
  calcSources
415
415
  calcObjects
416
+ puts "Profiling #{Time.now - $timeStart}: prepareIncludes (#{@projectName+","+@config.name}) start..." if Bake.options.profiling
416
417
  prepareIncludes
418
+ puts "Profiling #{Time.now - $timeStart}: prepareIncludes (#{@projectName+","+@config.name}) stop..." if Bake.options.profiling
417
419
  end
418
420
 
419
421
  fileListBlock = Set.new if Bake.options.filelist
@@ -592,78 +594,124 @@ module Bake
592
594
  @source_files
593
595
  end
594
596
 
595
- def mapInclude(inc, orgBlock)
596
-
597
- if inc.name == "___ROOTS___"
598
- return Bake.options.roots.map { |r| File.rel_from_to_project(@projectDir,r.dir,false) }
599
- end
600
-
601
- i = orgBlock.convPath(inc,nil,true)
602
- if orgBlock != @block
603
- if not File.is_absolute?(i)
604
- i = File.rel_from_to_project(@projectDir,orgBlock.config.parent.get_project_dir) + i
605
- end
606
- end
607
-
608
- Pathname.new(i).cleanpath
609
- end
610
-
611
597
  def calcIncludesInternal(block)
598
+ # puts "#{block.projectName},#{block.configName} " + block.to_s
599
+ noDeps = @blocksRead.include?(block)
612
600
  @blocksRead << block
613
- block.config.baseElement.each do |be|
601
+ block.bes.each do |be|
614
602
  if Metamodel::IncludeDir === be
603
+ # puts "-- #{be.name}"
615
604
  if be.inherit == true || block == @block
616
- mappedInc = mapInclude(be, block)
617
- @include_list << mappedInc
618
- @system_includes << mappedInc if be.system
605
+ mappedInc = File.rel_from_to_project(@projectDir,be.name,false)
606
+ mappedInc = "." if mappedInc.empty?
607
+ if !@include_set.include?(mappedInc) # todo set!!
608
+ @include_list << mappedInc
609
+ @include_set << mappedInc
610
+ if !@include_merge.has_key?(mappedInc)
611
+ if be.parent.mergeInc == "no"
612
+ @include_merge[mappedInc] = false
613
+ elsif @config.mergeInc == "all"
614
+ @include_merge[mappedInc] = true
615
+ elsif @block.config != be.parent && @config.mergeInc == "yes"
616
+ @include_merge[mappedInc] = true
617
+ else
618
+ @include_merge[mappedInc] = false
619
+ end
620
+ end
621
+ @system_includes << mappedInc if be.system
622
+ end
619
623
  end
620
624
  elsif Metamodel::Dependency === be
621
- childBlock = block.depToBlock[be.name + "," + be.config]
622
- calcIncludesInternal(childBlock) if !@blocksRead.include?(childBlock)
625
+ if (!noDeps)
626
+ childBlock = Blocks::ALL_BLOCKS[be.name + "," + be.config]
627
+ if block.projectName == be.parent.parent.name &&
628
+ block.configName == be.parent.name
629
+ next if @blocksRead.include?(childBlock)
630
+ end
631
+ calcIncludesInternal(childBlock)
632
+ end
623
633
  end
624
634
  end
625
635
  end
626
636
 
627
637
  def calcIncludes
628
-
629
638
  @blocksRead = Set.new
639
+ @include_set = Set.new
630
640
  @include_list = []
641
+ @include_merge = {}
631
642
  @system_includes = Set.new
643
+
644
+ #puts @block.bes.length
645
+ #@block.bes.each {|b| puts "#{b.class}: #{b.name}, #{b.respond_to?(:config) ? b.config : ""}"}
646
+ #exit(1)
647
+
648
+
649
+
632
650
  calcIncludesInternal(@block) # includeDir and child dependencies with inherit: true
651
+ # exit(1)
652
+ @include_list = @include_list.flatten.uniq
653
+ end
633
654
 
634
- @block.getBlocks(:parents).each do |b|
635
- if b.config.respond_to?("includeDir")
636
- include_list_front = []
637
- b.config.includeDir.each do |inc|
638
- if inc.inject == "front" || inc.infix == "front"
639
- mappedInc = mapInclude(inc, b)
640
- include_list_front << mappedInc
641
- @system_includes << mappedInc if inc.system
642
- elsif inc.inject == "back" || inc.infix == "back"
643
- mappedInc = mapInclude(inc, b)
644
- @include_list << mappedInc
645
- @system_includes << mappedInc if inc.system
655
+ def prepareIncludes
656
+ mergeCounter = 0
657
+ inmerge = false
658
+ mdir = nil
659
+ include_list_new = []
660
+ filesToCopy = {}
661
+ destDirs = Set.new
662
+ merging = false
663
+ @include_list.reverse.each do |idir|
664
+ idirs = idir.to_s
665
+ idirs = File.expand_path(idirs, @projectDir) if !File.is_absolute?(idirs)
666
+ if @include_merge[idir]
667
+ if (!inmerge)
668
+ mergeCounter += 1
669
+ mdir = File.expand_path(@block.output_dir+"/mergedIncludes#{mergeCounter}", @projectDir)
670
+ FileUtils.rm_rf(mdir)
671
+ FileUtils.mkdir_p(mdir)
672
+ inmerge = true
673
+ end
674
+ if !merging
675
+ puts "Profiling #{Time.now - $timeStart}: glob..." if Bake.options.profiling
676
+ end
677
+ merging = true
678
+
679
+ toCopy = Dir.glob(idirs+"/**/*").
680
+ reject { |file| file.start_with?(idirs+"/build/") || file.start_with?(idirs+"/.") }.
681
+ select { |file| File.file?(file) && /^\.(h|i|cfg)/ === File.extname(file) }
682
+ toCopy.each do |t|
683
+ dest = mdir+t[idirs.length..-1]
684
+ destDirs << File.dirname(dest)
685
+ if filesToCopy.has_key?(t)
686
+ filesToCopy[t] << dest
687
+ else
688
+ filesToCopy[t] = [dest]
646
689
  end
647
690
  end
648
- @include_list = include_list_front + @include_list
691
+ include_list_new << (@block.output_dir+"/mergedIncludes#{mergeCounter}")
692
+ else
693
+ if (inmerge)
694
+ inmerge = false
695
+ end
696
+ include_list_new << idir
649
697
  end
650
698
  end
651
-
652
- @include_list = @include_list.flatten.uniq
653
-
654
- end
655
-
656
- def prepareIncludes
657
- if Bake.options.mergeInc
658
- mdir = File.expand_path(@block.output_dir+"/mergedIncludes", @projectDir)
659
- @include_list.each do |idir|
660
- FileUtils.mkdir_p(mdir)
661
- idir = idir.to_s
662
- idir = File.expand_path(idir, @projectDir) if !File.is_absolute?(idir)
663
- FileUtils.cp_r(Dir.glob(idir+"/*"), mdir)
699
+ if merging
700
+ sizeWarning = 100000
701
+ sum = filesToCopy.keys.inject(0) do |sum,t|
702
+ si = File.size(t)
703
+ puts "Size warning (>#{sizeWarning} byte): #{t} has #{si} byte" if si > sizeWarning and Bake.options.profiling
704
+ sum + si
664
705
  end
665
- @include_list = [@block.output_dir+"/mergedIncludes"]
666
- end
706
+ puts "Profiling #{Time.now - $timeStart}: copy #{sum} byte in #{filesToCopy.length} files..." if Bake.options.profiling
707
+ destDirs.each {|d| FileUtils.mkdir_p(d)}
708
+ filesToCopy.each do |t, dest|
709
+ dest.each do |d|
710
+ FileUtils.cp_r(t, d, :preserve => true)
711
+ end
712
+ end
713
+ end
714
+ @include_list = include_list_new.uniq.reverse
667
715
 
668
716
  @include_array = {}
669
717
  [:CPP, :C, :ASM].each do |type|