bake-toolkit 2.15.0 → 2.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/_build/html/_sources/changelog.txt +5 -0
  3. data/documentation/_build/html/_sources/index.txt +1 -1
  4. data/documentation/_build/html/_sources/tips_and_tricks/bundle.txt +24 -0
  5. data/documentation/_build/html/_sources/tips_and_tricks/tips_and_tricks.txt +1 -0
  6. data/documentation/_build/html/changelog.html +10 -3
  7. data/documentation/_build/html/commandline/commandline.html +3 -3
  8. data/documentation/_build/html/concepts/build_hierarchy.html +3 -3
  9. data/documentation/_build/html/concepts/concepts.html +3 -3
  10. data/documentation/_build/html/concepts/the_main_project.html +3 -3
  11. data/documentation/_build/html/concepts/the_project_meta_file.html +3 -3
  12. data/documentation/_build/html/genindex.html +3 -3
  13. data/documentation/_build/html/ide/eclipse/eclipse.html +3 -3
  14. data/documentation/_build/html/ide/eclipse/how_to_convert_existing_cdt_workspace.html +3 -3
  15. data/documentation/_build/html/ide/eclipse/how_to_create_a_new_project_in_eclipse.html +3 -3
  16. data/documentation/_build/html/ide/eclipse/how_to_create_a_workspace_in_eclipse.html +3 -3
  17. data/documentation/_build/html/ide/eclipse/how_to_install_eclipse_plugin.html +3 -3
  18. data/documentation/_build/html/ide/eclipse/how_to_use_bake_in_eclipse.html +3 -3
  19. data/documentation/_build/html/ide/ide_integrations.html +3 -3
  20. data/documentation/_build/html/ide/vs/how_to_create_vs_projects.html +3 -3
  21. data/documentation/_build/html/ide/vs/how_to_debug_in_vs.html +3 -3
  22. data/documentation/_build/html/ide/vs/how_to_used_bake_in_vs.html +3 -3
  23. data/documentation/_build/html/ide/vs/vs.html +3 -3
  24. data/documentation/_build/html/ide/vs/vs_install.html +3 -3
  25. data/documentation/_build/html/index.html +7 -6
  26. data/documentation/_build/html/install/install_bake.html +3 -3
  27. data/documentation/_build/html/internal.html +3 -3
  28. data/documentation/_build/html/known_issues.html +3 -3
  29. data/documentation/_build/html/license.html +3 -3
  30. data/documentation/_build/html/performance/performance.html +5 -5
  31. data/documentation/_build/html/quickstart/quickstart.html +3 -3
  32. data/documentation/_build/html/search.html +3 -3
  33. data/documentation/_build/html/searchindex.js +1 -1
  34. data/documentation/_build/html/syntax/adapt_configs.html +3 -3
  35. data/documentation/_build/html/syntax/derive_configs.html +3 -3
  36. data/documentation/_build/html/syntax/project_meta_syntax.html +3 -3
  37. data/documentation/_build/html/syntax/syntax.html +3 -3
  38. data/documentation/_build/html/syntax/variable_substitutions.html +3 -3
  39. data/documentation/_build/html/tips_and_tricks/bundle.html +181 -0
  40. data/documentation/_build/html/tips_and_tricks/how_to_use_bake_with_cygwin.html +3 -3
  41. data/documentation/_build/html/tips_and_tricks/static_code_analysis.html +3 -3
  42. data/documentation/_build/html/tips_and_tricks/the_bakery.html +3 -3
  43. data/documentation/_build/html/tips_and_tricks/the_clang.html +5 -5
  44. data/documentation/_build/html/tips_and_tricks/tips_and_tricks.html +4 -3
  45. data/documentation/_build/html/why_bake/why_bake.html +5 -5
  46. data/lib/bake/bundle.rb +159 -0
  47. data/lib/bake/mergeConfig.rb +5 -5
  48. data/lib/bake/model/loader.rb +36 -24
  49. data/lib/bake/options/options.rb +12 -2
  50. data/lib/bake/options/usage.rb +2 -1
  51. data/lib/blocks/blockBase.rb +7 -1
  52. data/lib/blocks/compile.rb +17 -16
  53. data/lib/blocks/executable.rb +16 -12
  54. data/lib/blocks/library.rb +13 -9
  55. data/lib/common/ext/rtext.rb +11 -0
  56. data/lib/common/version.rb +1 -1
  57. metadata +6 -2
@@ -0,0 +1,159 @@
1
+ require 'fileutils'
2
+ require 'common/ext/rtext'
3
+
4
+
5
+ module Bake
6
+
7
+ class Bundle
8
+
9
+ def initialize()
10
+ cleanup()
11
+ end
12
+
13
+ def cleanup
14
+ @outputDir = nil
15
+ @result = true
16
+ @sources = []
17
+ @libs = []
18
+ @ls = nil
19
+ end
20
+
21
+ def self.instance
22
+ @@bundle ||= Bundle.new
23
+ end
24
+
25
+ def setOutputDir(dir)
26
+ @outputDir = dir
27
+ FileUtils.mkdir_p(@outputDir)
28
+ end
29
+
30
+ def addLib(lib, mainConfig)
31
+ return unless @outputDir
32
+ dir = @outputDir+"/lib"
33
+ FileUtils.mkdir_p(dir)
34
+ FileUtils.cp(lib, dir)
35
+ @libs << "lib/" + File.basename(lib) unless mainConfig
36
+ createProjectMeta(mainConfig)
37
+ end
38
+
39
+ def addBinary(exe, ls, mainConfig)
40
+ return unless @outputDir
41
+
42
+ dir = @outputDir+"/bin"
43
+ FileUtils.mkdir_p(dir)
44
+ FileUtils.cp(exe, dir)
45
+
46
+ if (ls and mainConfig)
47
+ lsDir = @outputDir+"/ls"
48
+ FileUtils.mkdir_p(lsDir)
49
+ FileUtils.cp(ls, lsDir)
50
+ @ls = "ls/" + File.basename(ls)
51
+ end
52
+
53
+ createProjectMeta(mainConfig)
54
+ end
55
+
56
+ def addSource(source, includeList, depFilename)
57
+ return unless @outputDir
58
+ if File.is_absolute?(source)
59
+ Bake.formatter.printWarning("Warning: '#{source}' is an absolute filename, this is not supported by bundle feature. File will be ignored.")
60
+ return
61
+ end
62
+ sdir = File.dirname(source)
63
+ dir = @outputDir
64
+ dir = dir + "/" + sdir unless sdir.empty?
65
+ FileUtils.mkdir_p(dir)
66
+ FileUtils.cp(source, dir)
67
+ @sources << source
68
+
69
+ addHeaders(makeAbsolute(includeList), parseDepFile(depFilename))
70
+ end
71
+
72
+ def addHeaders(absIncs, deps)
73
+ deps.each do |d|
74
+ absIncs.each do |a|
75
+ if d.start_with?a
76
+ filename = d[a.length+1..-1]
77
+ hdir = File.dirname(filename)
78
+ dir = @outputDir + "/inc"
79
+ dir = dir + "/" + hdir unless hdir.empty?
80
+ FileUtils.mkdir_p(dir)
81
+ FileUtils.cp(d, dir)
82
+ next
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ def makeAbsolute(includeList)
89
+ includeList.map { |x| File.expand_path(x) }
90
+ end
91
+
92
+ def parseDepFile(depFilename)
93
+ res = []
94
+ begin
95
+ File.readlines(depFilename).map{|line| line.strip}.each do |dep|
96
+ if File.exist?(dep)
97
+ res << File.expand_path(dep)
98
+ end
99
+ end
100
+ rescue Exception => ex
101
+ end
102
+ res
103
+ end
104
+
105
+ def createProjectMeta(mainConfig)
106
+ return unless mainConfig
107
+
108
+ project = Bake::Metamodel::Project.new
109
+ project.setDefault("bundle")
110
+ project.file_name = ""
111
+
112
+ config = mainConfig.class.new
113
+ config.setName("bundle")
114
+
115
+ project.setConfig([config])
116
+
117
+ sourceElements = @sources.map do |s|
118
+ source = Bake::Metamodel::Files.new
119
+ source.setName(s)
120
+ source
121
+ end
122
+ config.setFiles(sourceElements)
123
+
124
+ idir = Bake::Metamodel::IncludeDir.new
125
+ idir.setName("inc")
126
+ config.setIncludeDir([idir])
127
+
128
+ exLibs = @libs.map do |s|
129
+ lib = Bake::Metamodel::ExternalLibrary.new
130
+ lib.setName(s)
131
+ lib.setSearch(false)
132
+ lib
133
+ end
134
+ config.setLibStuff(exLibs)
135
+
136
+ if (mainConfig.toolchain)
137
+ config.setToolchain(Bake::MergeConfig.clone(mainConfig.toolchain))
138
+ end
139
+
140
+ if (mainConfig.defaultToolchain)
141
+ config.setDefaultToolchain(Bake::MergeConfig.clone(mainConfig.defaultToolchain))
142
+ end
143
+
144
+ if (@ls)
145
+ ls = Bake::Metamodel::LinkerScript.new
146
+ ls.setName(@ls)
147
+ config.setLinkerScript(ls)
148
+ end
149
+
150
+ s = StringIO.new
151
+ ser = RText::Serializer.new(Language)
152
+ ser.serialize(project, s)
153
+ File.write(@outputDir + "/Project.meta", s.string)
154
+
155
+ end
156
+
157
+ end
158
+
159
+ end
@@ -1,4 +1,4 @@
1
- require 'rtext/serializer'
1
+ require 'common/ext/rtext'
2
2
 
3
3
  module Bake
4
4
 
@@ -9,7 +9,7 @@ module Bake
9
9
  @parent = parent
10
10
  end
11
11
 
12
- def clone(obj)
12
+ def self.clone(obj)
13
13
  if obj.is_a?(Metamodel::ModelElement)
14
14
  cloneModelElement(obj)
15
15
  elsif Array === obj
@@ -19,7 +19,7 @@ module Bake
19
19
  end
20
20
  end
21
21
 
22
- def cloneModelElement(obj)
22
+ def self.cloneModelElement(obj)
23
23
  cpy = obj.class.new
24
24
  cpy.file_name = obj.file_name
25
25
  obj.class.ecore.eAllStructuralFeatures.each do |f|
@@ -184,11 +184,11 @@ module Bake
184
184
  elsif (type == :replace)
185
185
  replace
186
186
  elsif (type == :extend)
187
- c = clone(@child)
187
+ c = MergeConfig.clone(@child)
188
188
  extend(c, @parent)
189
189
  copyChildToParent(c, @parent)
190
190
  elsif (type == :merge)
191
- extend(@child, clone(@parent))
191
+ extend(@child, MergeConfig.clone(@parent))
192
192
  end
193
193
 
194
194
  if Bake.options.debug
@@ -28,20 +28,8 @@ module Bake
28
28
  @model = RGen::Fragment::FragmentedModel.new(:env => @env)
29
29
  end
30
30
 
31
- def load(filename)
32
- sumErrors = 0
33
-
34
- if Bake.options.nocache
35
- def @DumpFileCache.load(fragment)
36
- :invalid
37
- end
38
- end
39
-
40
- if not File.exists?filename
41
- Bake.formatter.printError("Error: #{filename} does not exist")
42
- ExitHelper.exit(1)
43
- end
44
-
31
+ def load_internal(filename, silent = false)
32
+ silent = false if Bake.options.debug
45
33
  loader = RText::DefaultLoader.new(
46
34
  Bake::Language,
47
35
  @model,
@@ -51,36 +39,60 @@ module Bake
51
39
  case kind
52
40
  when :load_update_cache
53
41
  if Bake.options.verbose >= 3
54
- puts "Loading and caching #{fragment.location}"
42
+ puts "Loading and caching #{fragment.location}" unless silent
55
43
  else
56
- puts "Loading #{fragment.location}"
44
+ puts "Loading #{fragment.location}" unless silent
57
45
  end
58
46
  when :load_cached
59
47
  if Bake.options.verbose >= 3
60
- puts "Loading cached #{fragment.location}"
48
+ puts "Loading cached #{fragment.location}" unless silent
61
49
  else
62
- puts "Loading #{fragment.location}"
50
+ puts "Loading #{fragment.location}" unless silent
63
51
  end
64
52
  when :load
65
- puts "Loading #{fragment.location}"
53
+ puts "Loading #{fragment.location}" unless silent
66
54
  else
67
55
  Bake.formatter.printError("Error: Could not load #{fragment.location}")
68
56
  ExitHelper.exit(1)
69
57
  end
70
58
  })
71
59
 
72
- f = @model.fragments[0]
73
- @model.remove_fragment(f)
60
+ frag = @model.fragments[0]
61
+ @model.remove_fragment(frag)
62
+ frag
63
+ end
64
+
65
+
66
+ def load(filename)
67
+ sumErrors = 0
68
+
69
+ if not File.exists?filename
70
+ Bake.formatter.printError("Error: #{filename} does not exist")
71
+ ExitHelper.exit(1)
72
+ end
73
+
74
+ frag = nil
75
+ if not Bake.options.nocache
76
+ frag = load_internal(filename) # regular load
77
+ frag = nil if frag.root_elements.length > 0 and filename != frag.root_elements[0].file_name
78
+ end
79
+
80
+ if frag.nil?
81
+ def @DumpFileCache.load(fragment)
82
+ :invalid
83
+ end
84
+ frag = load_internal(filename, !Bake.options.nocache)
85
+ end
74
86
 
75
- f.data[:problems].each do |p|
87
+ frag.data[:problems].each do |p|
76
88
  Bake.formatter.printError(p.message, p.file, p.line)
77
89
  end
78
90
 
79
- if f.data[:problems].length > 0
91
+ if frag.data[:problems].length > 0
80
92
  ExitHelper.exit(1)
81
93
  end
82
94
 
83
- return f
95
+ return frag
84
96
 
85
97
  end
86
98
 
@@ -6,6 +6,7 @@ require 'bake/options/showLicense'
6
6
  require 'bake/options/showDoc'
7
7
  require 'bake/options/usage'
8
8
  require 'bake/options/create'
9
+ require 'bake/bundle'
9
10
 
10
11
  module Bake
11
12
 
@@ -18,7 +19,7 @@ module Bake
18
19
 
19
20
  class Options < Parser
20
21
  attr_accessor :build_config, :nocache, :analyze, :eclipseOrder, :envToolchain
21
- attr_reader :main_dir, :project, :filename, :main_project_name, :cc2j_filename # String
22
+ attr_reader :main_dir, :project, :filename, :main_project_name, :cc2j_filename, :bundleDir # String
22
23
  attr_reader :roots, :include_filter, :exclude_filter, :adapt # String List
23
24
  attr_reader :conversion_info, :stopOnFirstError, :clean, :rebuild, :show_includes, :show_includes_and_defines, :linkOnly, :no_autodir, :clobber, :lint, :docu, :debug, :prepro # Boolean
24
25
  attr_reader :threads, :socket, :lint_min, :lint_max # Fixnum
@@ -67,6 +68,7 @@ module Bake
67
68
  @def_roots = []
68
69
  @main_project_name = ""
69
70
  @adapt = []
71
+ @bundleDir = nil
70
72
 
71
73
  add_option(["-b", "" ], lambda { |x| set_build_config(x) })
72
74
  add_option(["-m" ], lambda { |x| set_main_dir(x) })
@@ -101,13 +103,14 @@ module Bake
101
103
 
102
104
  add_option(["--clobber" ], lambda { @clobber = true; @clean = true })
103
105
  add_option(["--ignore-cache", "--ignore_cache" ], lambda { @nocache = true })
104
- add_option(["--threads" ], lambda { |x| set_threads(x) })
106
+ add_option(["-j", "--threads" ], lambda { |x| set_threads(x) })
105
107
  add_option(["--socket" ], lambda { |x| @socket = String === x ? x.to_i : x })
106
108
  add_option(["--toolchain-info", "--toolchain_info" ], lambda { |x| ToolchainInfo.showToolchain(x) })
107
109
  add_option(["--toolchain-names", "--toolchain_names" ], lambda { ToolchainInfo.showToolchainList })
108
110
  add_option(["--do", "--include_filter" ], lambda { |x| @include_filter << x })
109
111
  add_option(["--omit", "--exclude_filter" ], lambda { |x| @exclude_filter << x })
110
112
  add_option(["--abs-paths", "--show_abs_paths" ], lambda { @consoleOutput_fullnames = true })
113
+ add_option(["--bundle" ], lambda { |x| set_bundle_dir(x) })
111
114
 
112
115
  add_option(["-h", "--help" ], lambda { Bake::Usage.show })
113
116
 
@@ -128,6 +131,7 @@ module Bake
128
131
  end
129
132
 
130
133
  def parse_options()
134
+ Bake::Bundle.instance.cleanup()
131
135
  parse_internal(false)
132
136
  set_main_dir(Dir.pwd) if @main_dir.nil?
133
137
  @roots = @def_roots if @roots.length == 0
@@ -232,6 +236,12 @@ module Bake
232
236
  @def_roots = calc_def_roots(@main_dir)
233
237
  end
234
238
 
239
+ def set_bundle_dir(dir)
240
+ d = File.expand_path(dir.gsub(/[\\]/,'/'))
241
+ Bake::Bundle.instance.setOutputDir(d)
242
+ end
243
+
244
+
235
245
  def set_root(dir)
236
246
  check_valid_dir(dir)
237
247
  r = File.expand_path(dir.gsub(/[\\]/,'/'))
@@ -26,7 +26,7 @@ module Bake
26
26
  puts " to specify only a part of the file list to lint (default -1)."
27
27
  puts " --lint-max <num> See above (default -1)."
28
28
  puts " --ignore-cache Rereads the original meta files - usefull if workspace structure has been changed."
29
- puts " --threads <num> Set NUMBER of parallel compiled files (default is 8)."
29
+ puts " -j <num> Set NUMBER of parallel compiled files (default is 8)."
30
30
  puts " --socket <num> Set SOCKET for sending errors, receiving commands, etc. - used by e.g. Eclipse."
31
31
  puts " --toolchain-info <name> Prints default values of a toolchain."
32
32
  puts " --toolchain-names Prints available toolchains."
@@ -40,6 +40,7 @@ module Bake
40
40
  puts " --adapt <name> Specifies an adapt project to manipulate the configs (can be used multiple times)"
41
41
  puts " --incs-and-defs Used by IDEs plugins"
42
42
  puts " --conversion-info Prints infos for an external tool which converts bake configs for other build systems"
43
+ puts " --bundle <dir> Bundles the output (experimental, description will follow)"
43
44
  puts " --writeCC2J <name> Writes compiler command into a json file (experimental!)"
44
45
  puts " --create exe|lib|custom Creates a project with exe, lib or custom template"
45
46
  puts ""
@@ -1,3 +1,5 @@
1
+ require 'bake/bundle'
2
+
1
3
  module Bake
2
4
  module Blocks
3
5
 
@@ -89,11 +91,15 @@ module Bake
89
91
  end
90
92
  end
91
93
 
94
+ def isMainProject?
95
+ @projectName == Bake.options.main_project_name and @config.name == Bake.options.build_config
96
+ end
97
+
92
98
  def calcOutputDir
93
99
  if @tcs[:OUTPUT_DIR] != nil
94
100
  p = @block.convPath(@tcs[:OUTPUT_DIR])
95
101
  @output_dir = p
96
- elsif @projectName == Bake.options.main_project_name and @config.name == Bake.options.build_config
102
+ elsif isMainProject?
97
103
  @output_dir = "build_" + Bake.options.build_config
98
104
  else
99
105
  @output_dir = "build_" + @config.name + "_" + Bake.options.main_project_name + "_" + Bake.options.build_config
@@ -103,7 +103,7 @@ module Bake
103
103
 
104
104
  def compileFile(source)
105
105
  type = get_source_type(source)
106
- return true if type.nil?
106
+ return if type.nil?
107
107
 
108
108
  object = @object_files[source]
109
109
 
@@ -113,14 +113,12 @@ module Bake
113
113
  cmdLineCheck = false
114
114
  cmdLineFile = calcCmdlineFile(object)
115
115
 
116
- return true if ignore?(type)
116
+ return if ignore?(type)
117
117
  reason = needed?(source, object, type, dep_filename_conv)
118
118
  if not reason
119
119
  cmdLineCheck = true
120
- # currently this returns always != nil
121
120
  reason = config_changed?(cmdLineFile)
122
121
  end
123
- return true unless reason
124
122
 
125
123
  if @fileTcs.include?(source)
126
124
  compiler = @fileTcs[source][:COMPILER][type]
@@ -181,20 +179,23 @@ module Bake
181
179
  Blocks::CC2J << { :directory => @projectDir, :command => cmd, :file => source }
182
180
  end
183
181
 
184
- return true if cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile)
182
+ if not (cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile))
183
+ BlockBase.prepareOutput(object)
184
+ BlockBase.writeCmdLineFile(cmd, cmdLineFile)
185
+ success, consoleOutput = ProcessHelper.run(cmd, false, false)
186
+
187
+ outputType = Bake.options.analyze ? "Analyzing" : (Bake.options.prepro ? "Preprocessing" : "Compiling")
188
+ incList = process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "#{outputType} #{source}", reason, success)
189
+
190
+ if type != :ASM and not Bake.options.analyze and not Bake.options.prepro
191
+ incList = Compile.read_depfile(dep_filename, @projectDir, @tcs[:COMPILER][:DEP_FILE_SINGLE_LINE]) if incList.nil?
192
+ Compile.write_depfile(incList, dep_filename_conv)
193
+ end
194
+ check_config_file
195
+ end
185
196
 
186
- BlockBase.prepareOutput(object)
187
- BlockBase.writeCmdLineFile(cmd, cmdLineFile)
188
- success, consoleOutput = ProcessHelper.run(cmd, false, false)
197
+ Bake::Bundle.instance.addSource(source, @include_list, dep_filename_conv) if isMainProject?
189
198
 
190
- outputType = Bake.options.analyze ? "Analyzing" : (Bake.options.prepro ? "Preprocessing" : "Compiling")
191
- incList = process_result(cmd, consoleOutput, compiler[:ERROR_PARSER], "#{outputType} #{source}", reason, success)
192
-
193
- if type != :ASM and not Bake.options.analyze and not Bake.options.prepro
194
- incList = Compile.read_depfile(dep_filename, @projectDir, @tcs[:COMPILER][:DEP_FILE_SINGLE_LINE]) if incList.nil?
195
- Compile.write_depfile(incList, dep_filename_conv)
196
- end
197
- check_config_file
198
199
  end
199
200
 
200
201
  def self.read_depfile(dep_filename, projDir, singeLine)