bake-toolkit 2.20.4 → 2.21.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.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile.rb +3 -3
  3. data/bin/bake +46 -46
  4. data/bin/bake-doc +11 -11
  5. data/bin/bakery +179 -179
  6. data/bin/createVSProjects +213 -213
  7. data/documentation/_build/html/_sources/changelog.txt +456 -451
  8. data/documentation/_build/html/_sources/commandline/commandline.txt +107 -107
  9. data/documentation/_build/html/_sources/concepts/build_hierarchy.txt +34 -34
  10. data/documentation/_build/html/_sources/concepts/concepts.txt +14 -14
  11. data/documentation/_build/html/_sources/concepts/inject.txt +65 -65
  12. data/documentation/_build/html/_sources/concepts/link_order.txt +91 -91
  13. data/documentation/_build/html/_sources/concepts/prebuild.txt +56 -56
  14. data/documentation/_build/html/_sources/concepts/the_main_project.txt +45 -45
  15. data/documentation/_build/html/_sources/concepts/the_project_meta_file.txt +72 -72
  16. data/documentation/_build/html/_sources/ide/eclipse/eclipse.txt +25 -25
  17. data/documentation/_build/html/_sources/ide/eclipse/how_to_convert_existing_cdt_workspace.txt +31 -31
  18. data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_new_project_in_eclipse.txt +18 -18
  19. data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_workspace_in_eclipse.txt +27 -27
  20. data/documentation/_build/html/_sources/ide/eclipse/how_to_debug_in_eclipse.txt +38 -38
  21. data/documentation/_build/html/_sources/ide/eclipse/how_to_install_eclipse_plugin.txt +44 -44
  22. data/documentation/_build/html/_sources/ide/eclipse/how_to_use_bake_in_eclipse.txt +86 -86
  23. data/documentation/_build/html/_sources/ide/ide_integrations.txt +8 -8
  24. data/documentation/_build/html/_sources/ide/vs/how_to_create_vs_projects.txt +15 -15
  25. data/documentation/_build/html/_sources/ide/vs/how_to_debug_in_vs.txt +35 -35
  26. data/documentation/_build/html/_sources/ide/vs/how_to_used_bake_in_vs.txt +35 -35
  27. data/documentation/_build/html/_sources/ide/vs/vs.txt +10 -10
  28. data/documentation/_build/html/_sources/ide/vs/vs_install.txt +43 -43
  29. data/documentation/_build/html/_sources/index.txt +33 -33
  30. data/documentation/_build/html/_sources/install/install_bake.txt +112 -112
  31. data/documentation/_build/html/_sources/internal.txt +50 -50
  32. data/documentation/_build/html/_sources/known_issues.txt +9 -9
  33. data/documentation/_build/html/_sources/license.txt +4 -4
  34. data/documentation/_build/html/_sources/performance/performance.txt +104 -104
  35. data/documentation/_build/html/_sources/quickstart/quickstart.txt +70 -70
  36. data/documentation/_build/html/_sources/syntax/adapt_configs.txt +143 -143
  37. data/documentation/_build/html/_sources/syntax/auto_adjustment.txt +43 -43
  38. data/documentation/_build/html/_sources/syntax/derive_configs.txt +93 -94
  39. data/documentation/_build/html/_sources/syntax/project_meta_syntax.txt +19 -19
  40. data/documentation/_build/html/_sources/syntax/syntax.txt +11 -11
  41. data/documentation/_build/html/_sources/syntax/variable_substitutions.txt +147 -147
  42. data/documentation/_build/html/_sources/tips_and_tricks/dot.txt +34 -34
  43. data/documentation/_build/html/_sources/tips_and_tricks/how_to_use_bake_with_cygwin.txt +62 -62
  44. data/documentation/_build/html/_sources/tips_and_tricks/static_code_analysis.txt +122 -122
  45. data/documentation/_build/html/_sources/tips_and_tricks/the_bakery.txt +72 -72
  46. data/documentation/_build/html/_sources/tips_and_tricks/the_clang.txt +43 -43
  47. data/documentation/_build/html/_sources/tips_and_tricks/tips_and_tricks.txt +34 -34
  48. data/documentation/_build/html/_sources/why_bake/why_bake.txt +40 -40
  49. data/documentation/_build/html/changelog.html +7 -0
  50. data/documentation/_build/html/commandline/commandline.html +2 -2
  51. data/documentation/_build/html/concepts/link_order.html +2 -2
  52. data/documentation/_build/html/concepts/prebuild.html +2 -2
  53. data/documentation/_build/html/index.html +4 -4
  54. data/documentation/_build/html/performance/performance.html +2 -2
  55. data/documentation/_build/html/searchindex.js +1 -1
  56. data/documentation/_build/html/syntax/adapt_configs.html +2 -2
  57. data/documentation/_build/html/syntax/syntax.html +2 -2
  58. data/documentation/_build/html/tips_and_tricks/the_clang.html +2 -2
  59. data/documentation/_build/html/why_bake/why_bake.html +2 -2
  60. data/lib/adapt/config/loader.rb +112 -112
  61. data/lib/bake/bundle.rb +158 -158
  62. data/lib/bake/cache.rb +179 -180
  63. data/lib/bake/config/checks.rb +68 -68
  64. data/lib/bake/config/loader.rb +363 -363
  65. data/lib/bake/libElement.rb +176 -176
  66. data/lib/bake/mergeConfig.rb +208 -208
  67. data/lib/bake/model/language.rb +45 -45
  68. data/lib/bake/model/loader.rb +99 -99
  69. data/lib/bake/model/metamodel.rb +307 -307
  70. data/lib/bake/model/metamodel_ext.rb +27 -27
  71. data/lib/bake/options/create.rb +95 -95
  72. data/lib/bake/options/options.rb +315 -310
  73. data/lib/bake/options/showDoc.rb +20 -20
  74. data/lib/bake/options/showLicense.rb +9 -9
  75. data/lib/bake/options/showToolchains.rb +38 -38
  76. data/lib/bake/options/usage.rb +79 -68
  77. data/lib/bake/subst.rb +313 -313
  78. data/lib/bake/toolchain/clang.rb +44 -44
  79. data/lib/bake/toolchain/clang_analyze.rb +31 -31
  80. data/lib/bake/toolchain/colorizing_formatter.rb +125 -125
  81. data/lib/bake/toolchain/diab.rb +53 -53
  82. data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -40
  83. data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -41
  84. data/lib/bake/toolchain/errorparser/error_parser.rb +71 -71
  85. data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -35
  86. data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -35
  87. data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -32
  88. data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -44
  89. data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -40
  90. data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -30
  91. data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -34
  92. data/lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb +63 -63
  93. data/lib/bake/toolchain/errorparser/msvc_linker_error_parser.rb +42 -42
  94. data/lib/bake/toolchain/errorparser/process_output.rb +2 -2
  95. data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -30
  96. data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -30
  97. data/lib/bake/toolchain/gcc.rb +49 -49
  98. data/lib/bake/toolchain/gcc_env.rb +55 -55
  99. data/lib/bake/toolchain/greenhills.rb +52 -52
  100. data/lib/bake/toolchain/keil.rb +53 -53
  101. data/lib/bake/toolchain/lint.rb +20 -20
  102. data/lib/bake/toolchain/msvc.rb +58 -58
  103. data/lib/bake/toolchain/provider.rb +146 -146
  104. data/lib/bake/toolchain/ti.rb +47 -47
  105. data/lib/bake/util.rb +149 -149
  106. data/lib/bakery/buildPattern.rb +24 -24
  107. data/lib/bakery/model/language.rb +22 -22
  108. data/lib/bakery/model/loader.rb +55 -55
  109. data/lib/bakery/model/metamodel.rb +48 -48
  110. data/lib/bakery/options/options.rb +87 -87
  111. data/lib/bakery/toBake.rb +81 -81
  112. data/lib/blocks/block.rb +324 -324
  113. data/lib/blocks/blockBase.rb +204 -204
  114. data/lib/blocks/commandLine.rb +38 -38
  115. data/lib/blocks/compile.rb +529 -528
  116. data/lib/blocks/convert.rb +41 -41
  117. data/lib/blocks/docu.rb +30 -30
  118. data/lib/blocks/executable.rb +174 -174
  119. data/lib/blocks/has_execute_command.rb +31 -31
  120. data/lib/blocks/library.rb +114 -114
  121. data/lib/blocks/lint.rb +56 -56
  122. data/lib/blocks/makefile.rb +100 -100
  123. data/lib/blocks/showIncludes.rb +140 -125
  124. data/lib/common/abortException.rb +4 -4
  125. data/lib/common/cleanup.rb +10 -10
  126. data/lib/common/exit_helper.rb +38 -38
  127. data/lib/common/ext/file.rb +88 -88
  128. data/lib/common/ext/rtext.rb +11 -11
  129. data/lib/common/ext/stdout.rb +45 -45
  130. data/lib/common/ide_interface.rb +194 -194
  131. data/lib/common/options/parser.rb +95 -85
  132. data/lib/common/process.rb +64 -64
  133. data/lib/common/utils.rb +52 -52
  134. data/lib/common/version.rb +31 -23
  135. data/lib/multithread/job.rb +44 -44
  136. data/lib/tocxx.rb +558 -555
  137. data/lib/vs/options.rb +69 -69
  138. data/license.txt +90 -90
  139. metadata +2 -2
@@ -1,159 +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
-
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
159
  end
@@ -1,180 +1,179 @@
1
- require 'common/exit_helper'
2
- require 'bake/toolchain/colorizing_formatter'
3
- require 'common/options/parser'
4
- require 'common/version'
5
- require 'adapt/config/loader'
6
-
7
- module Bake
8
-
9
- class Cache
10
- attr_accessor :referencedConfigs
11
- attr_accessor :files # project_files
12
- attr_accessor :cache_file
13
- attr_accessor :version
14
- attr_accessor :workspace_roots
15
- attr_accessor :include_filter
16
- attr_accessor :exclude_filter
17
- attr_accessor :no_autodir
18
- attr_accessor :build_config
19
- attr_accessor :adapt_filenames
20
- end
21
-
22
- class CacheAccess
23
- attr_reader :cacheFilename
24
-
25
- def initialize()
26
- if Bake.options.build_config == ""
27
- @cacheFilename = Bake.options.main_dir+"/.bake/Default.Project.meta.cache"
28
- else
29
- @cacheFilename = Bake.options.main_dir+"/.bake/Project.meta." + sanitize_filename(Bake.options.build_config) + ".cache"
30
- end
31
-
32
- FileUtils.mkdir_p(File.dirname(@cacheFilename))
33
- end
34
-
35
- def load_cache
36
- cache = nil
37
- begin
38
- allFiles = Dir.glob(File.dirname(@cacheFilename)+"/*.cache")
39
- if allFiles.include?(@cacheFilename)
40
- cacheTime = File.mtime(@cacheFilename)
41
- contents = File.open(@cacheFilename, "rb") {|io| io.read }
42
- cache = Marshal.load(contents)
43
-
44
- if cache.version != Version.number
45
- Bake.formatter.printInfo("Info: cache version ("+cache.version+") does not match to bake version ("+Version.number+"), reloading meta information")
46
- cache = nil
47
- end
48
-
49
- if cache != nil
50
- if cache.cache_file != @cacheFilename
51
- Bake.formatter.printInfo("Info: cache filename changed, reloading meta information")
52
- cache = nil
53
- end
54
- end
55
-
56
- if cache != nil
57
- cache.files.each do |c|
58
- if (not File.exists?(c))
59
- Bake.options.nocache = true
60
- Bake.formatter.printInfo("Info: cached meta file #{c} renamed or deleted, reloading meta information")
61
- cache = nil
62
- break
63
- end
64
- end
65
- end
66
-
67
- if cache != nil
68
- cache.referencedConfigs.each do |pname,configs|
69
- configs.each do |config|
70
- if not File.exists?(config.file_name)
71
- Bake.options.nocache = true
72
- Bake.formatter.printInfo("Info: cached meta file #{config.file_name} renamed or deleted, reloading meta information")
73
- cache = nil
74
- end
75
- end
76
- end
77
- end
78
-
79
- if cache != nil
80
- cache.files.each do |c|
81
- if File.mtime(c) > cacheTime + 1
82
- Bake.formatter.printInfo("Info: #{c} has been changed, reloading meta information")
83
- cache = nil
84
- break
85
- end
86
- end
87
- end
88
-
89
- if (cache != nil)
90
- if (not AdaptConfig.filenames.eql?(cache.adapt_filenames))
91
- Bake.formatter.printInfo("Info: adapt config filenames have been changed, reloading meta information")
92
- cache = nil
93
- end
94
- end
95
-
96
- if (cache != nil and not AdaptConfig.filenames.empty?)
97
- AdaptConfig.filenames.each do |f|
98
- adaptTime = File.mtime(f)
99
- if adaptTime > cacheTime + 1
100
- Bake.formatter.printInfo("Info: #{f} has been changed, reloading meta information")
101
- cache = nil
102
- end
103
- end
104
- end
105
-
106
- if cache != nil
107
- if cache.workspace_roots.length == Bake.options.roots.length
108
- cache.workspace_roots.each do |r|
109
- if not Bake.options.roots.include?r
110
- cache = nil
111
- break
112
- end
113
- end
114
- else
115
- cache = nil
116
- end
117
- Bake.formatter.printInfo("Info: specified roots differ from cached roots, reloading meta information") if cache.nil?
118
- end
119
-
120
- if cache != nil
121
- if (not Bake.options.include_filter.eql?(cache.include_filter)) or (not Bake.options.exclude_filter.eql?(cache.exclude_filter))
122
- cache = nil
123
- Bake.formatter.printInfo("Info: specified filters differ from cached filters, reloading meta information")
124
- end
125
- end
126
-
127
- if cache != nil
128
- if (not Bake.options.no_autodir.eql?(cache.no_autodir))
129
- cache = nil
130
- Bake.formatter.printInfo("Info: no_autodir option differs in cache, reloading meta information")
131
- end
132
- end
133
-
134
- else
135
- Bake.formatter.printInfo("Info: cache not found, reloading meta information")
136
- end
137
- rescue Exception => e
138
- Bake.formatter.printWarning("Warning: cache file corrupt, reloading meta information (cache might be written by an older bake version)")
139
- if Bake.options.debug
140
- puts e.message
141
- puts e.backtrace
142
- end
143
- cache = nil
144
- end
145
-
146
- if cache != nil
147
- Bake.formatter.printInfo("Info: cache is up-to-date, loading cached meta information") if Bake.options.verbose >= 3
148
- Bake.options.build_config = cache.build_config if Bake.options.build_config == ""
149
- return cache.referencedConfigs
150
- end
151
-
152
- return nil
153
- end
154
-
155
- def write_cache(project_files, referencedConfigs)
156
- cache = Cache.new
157
- cache.referencedConfigs = referencedConfigs
158
- cache.files = project_files
159
- cache.cache_file = @cacheFilename
160
- cache.version = Version.number
161
- cache.include_filter = Bake.options.include_filter
162
- cache.no_autodir = Bake.options.no_autodir
163
- cache.exclude_filter = Bake.options.exclude_filter
164
- cache.workspace_roots = Bake.options.roots
165
- cache.build_config = Bake.options.build_config
166
- cache.adapt_filenames = AdaptConfig.filenames
167
- bbdump = Marshal.dump(cache)
168
- begin
169
- File.delete(@cacheFilename)
170
- rescue
171
- end
172
- File.open(@cacheFilename, 'wb') {|file| file.write(bbdump) }
173
- Bake.options.nocache = false
174
- end
175
-
176
- end
177
-
178
-
179
- end
180
-
1
+ require 'common/exit_helper'
2
+ require 'bake/toolchain/colorizing_formatter'
3
+ require 'common/options/parser'
4
+ require 'common/version'
5
+ require 'adapt/config/loader'
6
+
7
+ module Bake
8
+
9
+ class Cache
10
+ attr_accessor :referencedConfigs
11
+ attr_accessor :files # project_files
12
+ attr_accessor :cache_file
13
+ attr_accessor :version
14
+ attr_accessor :workspace_roots
15
+ attr_accessor :include_filter
16
+ attr_accessor :exclude_filter
17
+ attr_accessor :no_autodir
18
+ attr_accessor :build_config
19
+ attr_accessor :adapt_filenames
20
+ end
21
+
22
+ class CacheAccess
23
+ attr_reader :cacheFilename
24
+
25
+ def initialize()
26
+ if Bake.options.build_config == ""
27
+ @cacheFilename = Bake.options.main_dir+"/.bake/Default.Project.meta.cache"
28
+ else
29
+ @cacheFilename = Bake.options.main_dir+"/.bake/Project.meta." + sanitize_filename(Bake.options.build_config) + ".cache"
30
+ end
31
+
32
+ FileUtils.mkdir_p(File.dirname(@cacheFilename))
33
+ end
34
+
35
+ def load_cache
36
+ cache = nil
37
+ begin
38
+ allFiles = Dir.glob(File.dirname(@cacheFilename)+"/*.cache")
39
+ if allFiles.include?(@cacheFilename)
40
+ cacheTime = File.mtime(@cacheFilename)
41
+ contents = File.open(@cacheFilename, "rb") {|io| io.read }
42
+ cache = Marshal.load(contents)
43
+
44
+ if cache.version != Version.number
45
+ Bake.formatter.printInfo("Info: cache version ("+cache.version+") does not match to bake version ("+Version.number+"), reloading meta information")
46
+ cache = nil
47
+ end
48
+
49
+ if cache != nil
50
+ if cache.cache_file != @cacheFilename
51
+ Bake.formatter.printInfo("Info: cache filename changed, reloading meta information")
52
+ cache = nil
53
+ end
54
+ end
55
+
56
+ if cache != nil
57
+ cache.files.each do |c|
58
+ if (not File.exists?(c))
59
+ Bake.options.nocache = true
60
+ Bake.formatter.printInfo("Info: cached meta file #{c} renamed or deleted, reloading meta information")
61
+ cache = nil
62
+ break
63
+ end
64
+ end
65
+ end
66
+
67
+ if cache != nil
68
+ cache.referencedConfigs.each do |pname,configs|
69
+ configs.each do |config|
70
+ if not File.exists?(config.file_name)
71
+ Bake.options.nocache = true
72
+ Bake.formatter.printInfo("Info: cached meta file #{config.file_name} renamed or deleted, reloading meta information")
73
+ cache = nil
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ if cache != nil
80
+ cache.files.each do |c|
81
+ if File.mtime(c) > cacheTime + 1
82
+ Bake.formatter.printInfo("Info: #{c} has been changed, reloading meta information")
83
+ cache = nil
84
+ break
85
+ end
86
+ end
87
+ end
88
+
89
+ if (cache != nil)
90
+ if (not AdaptConfig.filenames.eql?(cache.adapt_filenames))
91
+ Bake.formatter.printInfo("Info: adapt config filenames have been changed, reloading meta information")
92
+ cache = nil
93
+ end
94
+ end
95
+
96
+ if (cache != nil and not AdaptConfig.filenames.empty?)
97
+ AdaptConfig.filenames.each do |f|
98
+ adaptTime = File.mtime(f)
99
+ if adaptTime > cacheTime + 1
100
+ Bake.formatter.printInfo("Info: #{f} has been changed, reloading meta information")
101
+ cache = nil
102
+ end
103
+ end
104
+ end
105
+
106
+ if cache != nil
107
+ if cache.workspace_roots.length == Bake.options.roots.length
108
+ cache.workspace_roots.each do |r|
109
+ if not Bake.options.roots.include?r
110
+ cache = nil
111
+ break
112
+ end
113
+ end
114
+ else
115
+ cache = nil
116
+ end
117
+ Bake.formatter.printInfo("Info: specified roots differ from cached roots, reloading meta information") if cache.nil?
118
+ end
119
+
120
+ if cache != nil
121
+ if (not Bake.options.include_filter.eql?(cache.include_filter)) or (not Bake.options.exclude_filter.eql?(cache.exclude_filter))
122
+ cache = nil
123
+ Bake.formatter.printInfo("Info: specified filters differ from cached filters, reloading meta information")
124
+ end
125
+ end
126
+
127
+ if cache != nil
128
+ if (not Bake.options.no_autodir.eql?(cache.no_autodir))
129
+ cache = nil
130
+ Bake.formatter.printInfo("Info: no_autodir option differs in cache, reloading meta information")
131
+ end
132
+ end
133
+
134
+ else
135
+ Bake.formatter.printInfo("Info: cache not found, reloading meta information")
136
+ end
137
+ rescue Exception => e
138
+ Bake.formatter.printWarning("Warning: cache file corrupt, reloading meta information (cache might be written by an older bake version)")
139
+ if Bake.options.debug
140
+ puts e.message
141
+ puts e.backtrace
142
+ end
143
+ cache = nil
144
+ end
145
+
146
+ if cache != nil
147
+ Bake.formatter.printInfo("Info: cache is up-to-date, loading cached meta information") if Bake.options.verbose >= 3
148
+ Bake.options.build_config = cache.build_config if Bake.options.build_config == ""
149
+ return cache.referencedConfigs
150
+ end
151
+
152
+ return nil
153
+ end
154
+
155
+ def write_cache(project_files, referencedConfigs)
156
+ cache = Cache.new
157
+ cache.referencedConfigs = referencedConfigs
158
+ cache.files = project_files
159
+ cache.cache_file = @cacheFilename
160
+ cache.version = Version.number
161
+ cache.include_filter = Bake.options.include_filter
162
+ cache.no_autodir = Bake.options.no_autodir
163
+ cache.exclude_filter = Bake.options.exclude_filter
164
+ cache.workspace_roots = Bake.options.roots
165
+ cache.build_config = Bake.options.build_config
166
+ cache.adapt_filenames = AdaptConfig.filenames
167
+ bbdump = Marshal.dump(cache)
168
+ begin
169
+ File.delete(@cacheFilename)
170
+ rescue
171
+ end
172
+ File.open(@cacheFilename, 'wb') {|file| file.write(bbdump) }
173
+ Bake.options.nocache = false
174
+ end
175
+
176
+ end
177
+
178
+
179
+ end