bake-toolkit 2.20.4 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile.rb +3 -3
- data/bin/bake +46 -46
- data/bin/bake-doc +11 -11
- data/bin/bakery +179 -179
- data/bin/createVSProjects +213 -213
- data/documentation/_build/html/_sources/changelog.txt +456 -451
- data/documentation/_build/html/_sources/commandline/commandline.txt +107 -107
- data/documentation/_build/html/_sources/concepts/build_hierarchy.txt +34 -34
- data/documentation/_build/html/_sources/concepts/concepts.txt +14 -14
- data/documentation/_build/html/_sources/concepts/inject.txt +65 -65
- data/documentation/_build/html/_sources/concepts/link_order.txt +91 -91
- data/documentation/_build/html/_sources/concepts/prebuild.txt +56 -56
- data/documentation/_build/html/_sources/concepts/the_main_project.txt +45 -45
- data/documentation/_build/html/_sources/concepts/the_project_meta_file.txt +72 -72
- data/documentation/_build/html/_sources/ide/eclipse/eclipse.txt +25 -25
- data/documentation/_build/html/_sources/ide/eclipse/how_to_convert_existing_cdt_workspace.txt +31 -31
- data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_new_project_in_eclipse.txt +18 -18
- data/documentation/_build/html/_sources/ide/eclipse/how_to_create_a_workspace_in_eclipse.txt +27 -27
- data/documentation/_build/html/_sources/ide/eclipse/how_to_debug_in_eclipse.txt +38 -38
- data/documentation/_build/html/_sources/ide/eclipse/how_to_install_eclipse_plugin.txt +44 -44
- data/documentation/_build/html/_sources/ide/eclipse/how_to_use_bake_in_eclipse.txt +86 -86
- data/documentation/_build/html/_sources/ide/ide_integrations.txt +8 -8
- data/documentation/_build/html/_sources/ide/vs/how_to_create_vs_projects.txt +15 -15
- data/documentation/_build/html/_sources/ide/vs/how_to_debug_in_vs.txt +35 -35
- data/documentation/_build/html/_sources/ide/vs/how_to_used_bake_in_vs.txt +35 -35
- data/documentation/_build/html/_sources/ide/vs/vs.txt +10 -10
- data/documentation/_build/html/_sources/ide/vs/vs_install.txt +43 -43
- data/documentation/_build/html/_sources/index.txt +33 -33
- data/documentation/_build/html/_sources/install/install_bake.txt +112 -112
- data/documentation/_build/html/_sources/internal.txt +50 -50
- data/documentation/_build/html/_sources/known_issues.txt +9 -9
- data/documentation/_build/html/_sources/license.txt +4 -4
- data/documentation/_build/html/_sources/performance/performance.txt +104 -104
- data/documentation/_build/html/_sources/quickstart/quickstart.txt +70 -70
- data/documentation/_build/html/_sources/syntax/adapt_configs.txt +143 -143
- data/documentation/_build/html/_sources/syntax/auto_adjustment.txt +43 -43
- data/documentation/_build/html/_sources/syntax/derive_configs.txt +93 -94
- data/documentation/_build/html/_sources/syntax/project_meta_syntax.txt +19 -19
- data/documentation/_build/html/_sources/syntax/syntax.txt +11 -11
- data/documentation/_build/html/_sources/syntax/variable_substitutions.txt +147 -147
- data/documentation/_build/html/_sources/tips_and_tricks/dot.txt +34 -34
- data/documentation/_build/html/_sources/tips_and_tricks/how_to_use_bake_with_cygwin.txt +62 -62
- data/documentation/_build/html/_sources/tips_and_tricks/static_code_analysis.txt +122 -122
- data/documentation/_build/html/_sources/tips_and_tricks/the_bakery.txt +72 -72
- data/documentation/_build/html/_sources/tips_and_tricks/the_clang.txt +43 -43
- data/documentation/_build/html/_sources/tips_and_tricks/tips_and_tricks.txt +34 -34
- data/documentation/_build/html/_sources/why_bake/why_bake.txt +40 -40
- data/documentation/_build/html/changelog.html +7 -0
- data/documentation/_build/html/commandline/commandline.html +2 -2
- data/documentation/_build/html/concepts/link_order.html +2 -2
- data/documentation/_build/html/concepts/prebuild.html +2 -2
- data/documentation/_build/html/index.html +4 -4
- data/documentation/_build/html/performance/performance.html +2 -2
- data/documentation/_build/html/searchindex.js +1 -1
- data/documentation/_build/html/syntax/adapt_configs.html +2 -2
- data/documentation/_build/html/syntax/syntax.html +2 -2
- data/documentation/_build/html/tips_and_tricks/the_clang.html +2 -2
- data/documentation/_build/html/why_bake/why_bake.html +2 -2
- data/lib/adapt/config/loader.rb +112 -112
- data/lib/bake/bundle.rb +158 -158
- data/lib/bake/cache.rb +179 -180
- data/lib/bake/config/checks.rb +68 -68
- data/lib/bake/config/loader.rb +363 -363
- data/lib/bake/libElement.rb +176 -176
- data/lib/bake/mergeConfig.rb +208 -208
- data/lib/bake/model/language.rb +45 -45
- data/lib/bake/model/loader.rb +99 -99
- data/lib/bake/model/metamodel.rb +307 -307
- data/lib/bake/model/metamodel_ext.rb +27 -27
- data/lib/bake/options/create.rb +95 -95
- data/lib/bake/options/options.rb +315 -310
- data/lib/bake/options/showDoc.rb +20 -20
- data/lib/bake/options/showLicense.rb +9 -9
- data/lib/bake/options/showToolchains.rb +38 -38
- data/lib/bake/options/usage.rb +79 -68
- data/lib/bake/subst.rb +313 -313
- data/lib/bake/toolchain/clang.rb +44 -44
- data/lib/bake/toolchain/clang_analyze.rb +31 -31
- data/lib/bake/toolchain/colorizing_formatter.rb +125 -125
- data/lib/bake/toolchain/diab.rb +53 -53
- data/lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/diab_linker_error_parser.rb +41 -41
- data/lib/bake/toolchain/errorparser/error_parser.rb +71 -71
- data/lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb +35 -35
- data/lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb +35 -35
- data/lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb +32 -32
- data/lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb +44 -44
- data/lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb +40 -40
- data/lib/bake/toolchain/errorparser/keil_linker_error_parser.rb +30 -30
- data/lib/bake/toolchain/errorparser/lint_error_parser.rb +34 -34
- data/lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb +63 -63
- data/lib/bake/toolchain/errorparser/msvc_linker_error_parser.rb +42 -42
- data/lib/bake/toolchain/errorparser/process_output.rb +2 -2
- data/lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb +30 -30
- data/lib/bake/toolchain/errorparser/ti_linker_error_parser.rb +30 -30
- data/lib/bake/toolchain/gcc.rb +49 -49
- data/lib/bake/toolchain/gcc_env.rb +55 -55
- data/lib/bake/toolchain/greenhills.rb +52 -52
- data/lib/bake/toolchain/keil.rb +53 -53
- data/lib/bake/toolchain/lint.rb +20 -20
- data/lib/bake/toolchain/msvc.rb +58 -58
- data/lib/bake/toolchain/provider.rb +146 -146
- data/lib/bake/toolchain/ti.rb +47 -47
- data/lib/bake/util.rb +149 -149
- data/lib/bakery/buildPattern.rb +24 -24
- data/lib/bakery/model/language.rb +22 -22
- data/lib/bakery/model/loader.rb +55 -55
- data/lib/bakery/model/metamodel.rb +48 -48
- data/lib/bakery/options/options.rb +87 -87
- data/lib/bakery/toBake.rb +81 -81
- data/lib/blocks/block.rb +324 -324
- data/lib/blocks/blockBase.rb +204 -204
- data/lib/blocks/commandLine.rb +38 -38
- data/lib/blocks/compile.rb +529 -528
- data/lib/blocks/convert.rb +41 -41
- data/lib/blocks/docu.rb +30 -30
- data/lib/blocks/executable.rb +174 -174
- data/lib/blocks/has_execute_command.rb +31 -31
- data/lib/blocks/library.rb +114 -114
- data/lib/blocks/lint.rb +56 -56
- data/lib/blocks/makefile.rb +100 -100
- data/lib/blocks/showIncludes.rb +140 -125
- data/lib/common/abortException.rb +4 -4
- data/lib/common/cleanup.rb +10 -10
- data/lib/common/exit_helper.rb +38 -38
- data/lib/common/ext/file.rb +88 -88
- data/lib/common/ext/rtext.rb +11 -11
- data/lib/common/ext/stdout.rb +45 -45
- data/lib/common/ide_interface.rb +194 -194
- data/lib/common/options/parser.rb +95 -85
- data/lib/common/process.rb +64 -64
- data/lib/common/utils.rb +52 -52
- data/lib/common/version.rb +31 -23
- data/lib/multithread/job.rb +44 -44
- data/lib/tocxx.rb +558 -555
- data/lib/vs/options.rb +69 -69
- data/license.txt +90 -90
- metadata +2 -2
data/lib/blocks/convert.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require 'blocks/compile'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
|
5
|
-
module Blocks
|
6
|
-
|
7
|
-
class Convert < Compile
|
8
|
-
|
9
|
-
def initialize(block, config, referencedConfigs, tcs)
|
10
|
-
super(block, config, referencedConfigs, tcs)
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute
|
14
|
-
Dir.chdir(@projectDir) do
|
15
|
-
calcSources
|
16
|
-
|
17
|
-
puts "START_INFO"
|
18
|
-
puts " BAKE_PROJECTDIR"
|
19
|
-
puts " #{File.expand_path(@projectDir)}"
|
20
|
-
puts " BAKE_SOURCES"
|
21
|
-
@source_files.each { |s| puts " #{s}" }
|
22
|
-
puts " BAKE_INCLUDES"
|
23
|
-
@include_list.each { |s| puts " #{s}" }
|
24
|
-
puts " BAKE_DEFINES"
|
25
|
-
(@tcs[:COMPILER][:CPP][:DEFINES] + @tcs[:COMPILER][:C][:DEFINES] + @tcs[:COMPILER][:ASM][:DEFINES]).uniq.each { |s| puts " #{s}" }
|
26
|
-
puts " BAKE_DEPENDENCIES"
|
27
|
-
@block.childs.each { |dep| puts " #{dep.projectName}" }
|
28
|
-
puts " BAKE_DEPENDENCIES_FILTERED"
|
29
|
-
@block.childs.each { |dep| puts " #{dep.projectName}" unless @projectName == dep.projectName or dep.projectName == "gmock" or dep.projectName == "gtest" }
|
30
|
-
puts "END_INFO"
|
31
|
-
end
|
32
|
-
return true
|
33
|
-
end
|
34
|
-
|
35
|
-
def clean
|
36
|
-
# nothing to do here
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
1
|
+
require 'blocks/compile'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
|
5
|
+
module Blocks
|
6
|
+
|
7
|
+
class Convert < Compile
|
8
|
+
|
9
|
+
def initialize(block, config, referencedConfigs, tcs)
|
10
|
+
super(block, config, referencedConfigs, tcs)
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
Dir.chdir(@projectDir) do
|
15
|
+
calcSources
|
16
|
+
|
17
|
+
puts "START_INFO"
|
18
|
+
puts " BAKE_PROJECTDIR"
|
19
|
+
puts " #{File.expand_path(@projectDir)}"
|
20
|
+
puts " BAKE_SOURCES"
|
21
|
+
@source_files.each { |s| puts " #{s}" }
|
22
|
+
puts " BAKE_INCLUDES"
|
23
|
+
@include_list.each { |s| puts " #{s}" }
|
24
|
+
puts " BAKE_DEFINES"
|
25
|
+
(@tcs[:COMPILER][:CPP][:DEFINES] + @tcs[:COMPILER][:C][:DEFINES] + @tcs[:COMPILER][:ASM][:DEFINES]).uniq.each { |s| puts " #{s}" }
|
26
|
+
puts " BAKE_DEPENDENCIES"
|
27
|
+
@block.childs.each { |dep| puts " #{dep.projectName}" }
|
28
|
+
puts " BAKE_DEPENDENCIES_FILTERED"
|
29
|
+
@block.childs.each { |dep| puts " #{dep.projectName}" unless @projectName == dep.projectName or dep.projectName == "gmock" or dep.projectName == "gtest" }
|
30
|
+
puts "END_INFO"
|
31
|
+
end
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
|
35
|
+
def clean
|
36
|
+
# nothing to do here
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
42
|
end
|
data/lib/blocks/docu.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
require 'blocks/compile'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
module Blocks
|
5
|
-
class Docu
|
6
|
-
include HasExecuteCommand
|
7
|
-
|
8
|
-
def initialize(config, tcs)
|
9
|
-
@config = config # Bake::Metamodel::CommandLine
|
10
|
-
@commandLine = tcs[:DOCU]
|
11
|
-
@projectDir = config.get_project_dir
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute
|
15
|
-
if @commandLine.empty?
|
16
|
-
Bake.formatter.printInfo("No documentation command specified", @config)
|
17
|
-
else
|
18
|
-
return executeCommand(@commandLine)
|
19
|
-
end
|
20
|
-
return true
|
21
|
-
end
|
22
|
-
|
23
|
-
def clean
|
24
|
-
# nothing to do here
|
25
|
-
return true
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
require 'blocks/compile'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
module Blocks
|
5
|
+
class Docu
|
6
|
+
include HasExecuteCommand
|
7
|
+
|
8
|
+
def initialize(config, tcs)
|
9
|
+
@config = config # Bake::Metamodel::CommandLine
|
10
|
+
@commandLine = tcs[:DOCU]
|
11
|
+
@projectDir = config.get_project_dir
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
if @commandLine.empty?
|
16
|
+
Bake.formatter.printInfo("No documentation command specified", @config)
|
17
|
+
else
|
18
|
+
return executeCommand(@commandLine)
|
19
|
+
end
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
|
23
|
+
def clean
|
24
|
+
# nothing to do here
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/blocks/executable.rb
CHANGED
@@ -1,175 +1,175 @@
|
|
1
|
-
require 'blocks/blockBase'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
|
5
|
-
module Blocks
|
6
|
-
|
7
|
-
class Executable < BlockBase
|
8
|
-
|
9
|
-
def initialize(block, config, referencedConfigs, tcs, compileBlock)
|
10
|
-
super(block, config, referencedConfigs, tcs)
|
11
|
-
@compileBlock = compileBlock
|
12
|
-
|
13
|
-
calcArtifactName
|
14
|
-
calcMapFile
|
15
|
-
calcLinkerScript
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def calcLinkerScript
|
20
|
-
@linker_script = @config.linkerScript.nil? ? nil : @block.convPath(@config.linkerScript)
|
21
|
-
end
|
22
|
-
|
23
|
-
def calcArtifactName
|
24
|
-
if not @config.artifactName.nil? and @config.artifactName.name != ""
|
25
|
-
baseFilename = @config.artifactName.name
|
26
|
-
else
|
27
|
-
baseFilename = "#{@projectName}#{@tcs[:LINKER][:OUTPUT_ENDING]}"
|
28
|
-
end
|
29
|
-
@exe_name ||= File.join([@output_dir, baseFilename])
|
30
|
-
end
|
31
|
-
|
32
|
-
def calcCmdlineFile()
|
33
|
-
@exe_name + ".cmdline"
|
34
|
-
end
|
35
|
-
|
36
|
-
def calcMapFile
|
37
|
-
@mapfile = nil
|
38
|
-
if (not Bake.options.docu) and (not Bake.options.lint) and (not @config.mapFile.nil?)
|
39
|
-
if @config.mapFile.name == ""
|
40
|
-
@mapfile = @exe_name.chomp(File.extname(@exe_name)) + ".map"
|
41
|
-
else
|
42
|
-
@mapfile = @config.mapFile.name
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def ignore?
|
48
|
-
Bake.options.prepro
|
49
|
-
end
|
50
|
-
|
51
|
-
def needed?(libs)
|
52
|
-
return "because linkOnly was specified" if Bake.options.linkOnly
|
53
|
-
|
54
|
-
# exe
|
55
|
-
return "because executable does not exist" if not File.exists?(@exe_name)
|
56
|
-
|
57
|
-
eTime = File.mtime(@exe_name)
|
58
|
-
|
59
|
-
# linkerscript
|
60
|
-
if @linker_script
|
61
|
-
return "because linker script does not exist - will most probably result in an error" if not File.exists?(@linker_script)
|
62
|
-
return "because linker script is newer than executable" if eTime < File.mtime(@linker_script)
|
63
|
-
end
|
64
|
-
|
65
|
-
# sources
|
66
|
-
@compileBlock.objects.each do |obj|
|
67
|
-
return "because object #{obj} does not exist" if not File.exists?(obj)
|
68
|
-
return "because object #{obj} is newer than executable" if eTime < File.mtime(obj)
|
69
|
-
end
|
70
|
-
|
71
|
-
# libs
|
72
|
-
libs.each do |lib|
|
73
|
-
return "because library #{lib} does not exist" if not File.exists?(lib)
|
74
|
-
return "because library #{lib} is newer than executable" if eTime < File.mtime(lib)
|
75
|
-
end
|
76
|
-
false
|
77
|
-
end
|
78
|
-
|
79
|
-
def execute
|
80
|
-
Dir.chdir(@projectDir) do
|
81
|
-
childs = @block.getBlocks(:childs)
|
82
|
-
return false if childs.any? { |b| b.result == false }
|
83
|
-
|
84
|
-
allSources = []
|
85
|
-
(childs + [@block]).each do |b|
|
86
|
-
Dir.chdir(b.projectDir) do
|
87
|
-
b.getCompileBlocks.each do |c|
|
88
|
-
allSources += c.calcSources(true, true).map { |s| File.expand_path(s) }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
duplicateSources = allSources.group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first)
|
93
|
-
duplicateSources.each do |d|
|
94
|
-
Bake.formatter.printWarning("Source compiled more than once: #{d}")
|
95
|
-
end
|
96
|
-
|
97
|
-
libs, linker_libs_array = LibElements.calc_linker_lib_string(@block, @tcs)
|
98
|
-
|
99
|
-
cmdLineCheck = false
|
100
|
-
cmdLineFile = calcCmdlineFile()
|
101
|
-
|
102
|
-
return true if ignore?
|
103
|
-
reason = needed?(libs)
|
104
|
-
if not reason
|
105
|
-
cmdLineCheck = true
|
106
|
-
reason = config_changed?(cmdLineFile)
|
107
|
-
end
|
108
|
-
|
109
|
-
linker = @tcs[:LINKER]
|
110
|
-
|
111
|
-
cmd = Utils.flagSplit(linker[:COMMAND], false) # g++
|
112
|
-
cmd += linker[:MUST_FLAGS].split(" ")
|
113
|
-
cmd += Bake::Utils::flagSplit(linker[:FLAGS],true)
|
114
|
-
|
115
|
-
|
116
|
-
cmd << linker[:EXE_FLAG]
|
117
|
-
if linker[:EXE_FLAG_SPACE]
|
118
|
-
cmd << @exe_name
|
119
|
-
else
|
120
|
-
cmd[cmd.length-1] += @exe_name
|
121
|
-
end
|
122
|
-
|
123
|
-
cmd += @compileBlock.objects
|
124
|
-
cmd << linker[:SCRIPT] if @linker_script # -T
|
125
|
-
cmd << @linker_script if @linker_script # xy/xy.dld
|
126
|
-
cmd += linker[:MAP_FILE_FLAG].split(" ") if @mapfile # -Wl,-m6
|
127
|
-
if not linker[:MAP_FILE_PIPE] and @mapfile
|
128
|
-
cmd[cmd.length-1] << @mapfile
|
129
|
-
end
|
130
|
-
cmd += Bake::Utils::flagSplit(linker[:LIB_PREFIX_FLAGS],true) # "-Wl,--whole-archive "
|
131
|
-
cmd += linker_libs_array
|
132
|
-
cmd += Bake::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS],true) # "-Wl,--no-whole-archive "
|
133
|
-
|
134
|
-
mapfileStr = (@mapfile and linker[:MAP_FILE_PIPE]) ? " >#{@mapfile}" : ""
|
135
|
-
|
136
|
-
# pre print because linking can take much time
|
137
|
-
cmdLinePrint = cmd.dup
|
138
|
-
outPipe = (@mapfile and linker[:MAP_FILE_PIPE]) ? "#{@mapfile}" : nil
|
139
|
-
cmdLinePrint << "> #{outPipe}" if outPipe
|
140
|
-
|
141
|
-
if cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile)
|
142
|
-
success = true
|
143
|
-
else
|
144
|
-
ToCxx.linkBlock
|
145
|
-
|
146
|
-
BlockBase.prepareOutput(@exe_name)
|
147
|
-
|
148
|
-
printCmd(cmdLinePrint, "Linking #{@exe_name}", reason, false)
|
149
|
-
BlockBase.writeCmdLineFile(cmd, cmdLineFile)
|
150
|
-
success, consoleOutput = ProcessHelper.run(cmd, false, false, outPipe)
|
151
|
-
process_result(cmdLinePrint, consoleOutput, linker[:ERROR_PARSER], nil, reason, success)
|
152
|
-
|
153
|
-
check_config_file()
|
154
|
-
end
|
155
|
-
|
156
|
-
Bake::Bundle.instance.addBinary(@exe_name, @linker_script, isMainProject? ? @config : nil)
|
157
|
-
|
158
|
-
return success
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def clean
|
163
|
-
Dir.chdir(@projectDir) do
|
164
|
-
if File.exist?@output_dir
|
165
|
-
puts "Deleting folder #{@output_dir}" if Bake.options.verbose >= 2
|
166
|
-
FileUtils.rm_rf(@output_dir)
|
167
|
-
end
|
168
|
-
end unless Bake.options.filename
|
169
|
-
return true
|
170
|
-
end
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
1
|
+
require 'blocks/blockBase'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
|
5
|
+
module Blocks
|
6
|
+
|
7
|
+
class Executable < BlockBase
|
8
|
+
|
9
|
+
def initialize(block, config, referencedConfigs, tcs, compileBlock)
|
10
|
+
super(block, config, referencedConfigs, tcs)
|
11
|
+
@compileBlock = compileBlock
|
12
|
+
|
13
|
+
calcArtifactName
|
14
|
+
calcMapFile
|
15
|
+
calcLinkerScript
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
def calcLinkerScript
|
20
|
+
@linker_script = @config.linkerScript.nil? ? nil : @block.convPath(@config.linkerScript)
|
21
|
+
end
|
22
|
+
|
23
|
+
def calcArtifactName
|
24
|
+
if not @config.artifactName.nil? and @config.artifactName.name != ""
|
25
|
+
baseFilename = @config.artifactName.name
|
26
|
+
else
|
27
|
+
baseFilename = "#{@projectName}#{@tcs[:LINKER][:OUTPUT_ENDING]}"
|
28
|
+
end
|
29
|
+
@exe_name ||= File.join([@output_dir, baseFilename])
|
30
|
+
end
|
31
|
+
|
32
|
+
def calcCmdlineFile()
|
33
|
+
@exe_name + ".cmdline"
|
34
|
+
end
|
35
|
+
|
36
|
+
def calcMapFile
|
37
|
+
@mapfile = nil
|
38
|
+
if (not Bake.options.docu) and (not Bake.options.lint) and (not @config.mapFile.nil?)
|
39
|
+
if @config.mapFile.name == ""
|
40
|
+
@mapfile = @exe_name.chomp(File.extname(@exe_name)) + ".map"
|
41
|
+
else
|
42
|
+
@mapfile = @config.mapFile.name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def ignore?
|
48
|
+
Bake.options.prepro
|
49
|
+
end
|
50
|
+
|
51
|
+
def needed?(libs)
|
52
|
+
return "because linkOnly was specified" if Bake.options.linkOnly
|
53
|
+
|
54
|
+
# exe
|
55
|
+
return "because executable does not exist" if not File.exists?(@exe_name)
|
56
|
+
|
57
|
+
eTime = File.mtime(@exe_name)
|
58
|
+
|
59
|
+
# linkerscript
|
60
|
+
if @linker_script
|
61
|
+
return "because linker script does not exist - will most probably result in an error" if not File.exists?(@linker_script)
|
62
|
+
return "because linker script is newer than executable" if eTime < File.mtime(@linker_script)
|
63
|
+
end
|
64
|
+
|
65
|
+
# sources
|
66
|
+
@compileBlock.objects.each do |obj|
|
67
|
+
return "because object #{obj} does not exist" if not File.exists?(obj)
|
68
|
+
return "because object #{obj} is newer than executable" if eTime < File.mtime(obj)
|
69
|
+
end
|
70
|
+
|
71
|
+
# libs
|
72
|
+
libs.each do |lib|
|
73
|
+
return "because library #{lib} does not exist" if not File.exists?(lib)
|
74
|
+
return "because library #{lib} is newer than executable" if eTime < File.mtime(lib)
|
75
|
+
end
|
76
|
+
false
|
77
|
+
end
|
78
|
+
|
79
|
+
def execute
|
80
|
+
Dir.chdir(@projectDir) do
|
81
|
+
childs = @block.getBlocks(:childs)
|
82
|
+
return false if childs.any? { |b| b.result == false }
|
83
|
+
|
84
|
+
allSources = []
|
85
|
+
(childs + [@block]).each do |b|
|
86
|
+
Dir.chdir(b.projectDir) do
|
87
|
+
b.getCompileBlocks.each do |c|
|
88
|
+
allSources += c.calcSources(true, true).map { |s| File.expand_path(s) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
duplicateSources = allSources.group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first)
|
93
|
+
duplicateSources.each do |d|
|
94
|
+
Bake.formatter.printWarning("Source compiled more than once: #{d}")
|
95
|
+
end
|
96
|
+
|
97
|
+
libs, linker_libs_array = LibElements.calc_linker_lib_string(@block, @tcs)
|
98
|
+
|
99
|
+
cmdLineCheck = false
|
100
|
+
cmdLineFile = calcCmdlineFile()
|
101
|
+
|
102
|
+
return true if ignore?
|
103
|
+
reason = needed?(libs)
|
104
|
+
if not reason
|
105
|
+
cmdLineCheck = true
|
106
|
+
reason = config_changed?(cmdLineFile)
|
107
|
+
end
|
108
|
+
|
109
|
+
linker = @tcs[:LINKER]
|
110
|
+
|
111
|
+
cmd = Utils.flagSplit(linker[:COMMAND], false) # g++
|
112
|
+
cmd += linker[:MUST_FLAGS].split(" ")
|
113
|
+
cmd += Bake::Utils::flagSplit(linker[:FLAGS],true)
|
114
|
+
|
115
|
+
|
116
|
+
cmd << linker[:EXE_FLAG]
|
117
|
+
if linker[:EXE_FLAG_SPACE]
|
118
|
+
cmd << @exe_name
|
119
|
+
else
|
120
|
+
cmd[cmd.length-1] += @exe_name
|
121
|
+
end
|
122
|
+
|
123
|
+
cmd += @compileBlock.objects
|
124
|
+
cmd << linker[:SCRIPT] if @linker_script # -T
|
125
|
+
cmd << @linker_script if @linker_script # xy/xy.dld
|
126
|
+
cmd += linker[:MAP_FILE_FLAG].split(" ") if @mapfile # -Wl,-m6
|
127
|
+
if not linker[:MAP_FILE_PIPE] and @mapfile
|
128
|
+
cmd[cmd.length-1] << @mapfile
|
129
|
+
end
|
130
|
+
cmd += Bake::Utils::flagSplit(linker[:LIB_PREFIX_FLAGS],true) # "-Wl,--whole-archive "
|
131
|
+
cmd += linker_libs_array
|
132
|
+
cmd += Bake::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS],true) # "-Wl,--no-whole-archive "
|
133
|
+
|
134
|
+
mapfileStr = (@mapfile and linker[:MAP_FILE_PIPE]) ? " >#{@mapfile}" : ""
|
135
|
+
|
136
|
+
# pre print because linking can take much time
|
137
|
+
cmdLinePrint = cmd.dup
|
138
|
+
outPipe = (@mapfile and linker[:MAP_FILE_PIPE]) ? "#{@mapfile}" : nil
|
139
|
+
cmdLinePrint << "> #{outPipe}" if outPipe
|
140
|
+
|
141
|
+
if cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile)
|
142
|
+
success = true
|
143
|
+
else
|
144
|
+
ToCxx.linkBlock
|
145
|
+
|
146
|
+
BlockBase.prepareOutput(@exe_name)
|
147
|
+
|
148
|
+
printCmd(cmdLinePrint, "Linking #{@exe_name}", reason, false)
|
149
|
+
BlockBase.writeCmdLineFile(cmd, cmdLineFile)
|
150
|
+
success, consoleOutput = ProcessHelper.run(cmd, false, false, outPipe)
|
151
|
+
process_result(cmdLinePrint, consoleOutput, linker[:ERROR_PARSER], nil, reason, success)
|
152
|
+
|
153
|
+
check_config_file()
|
154
|
+
end
|
155
|
+
|
156
|
+
Bake::Bundle.instance.addBinary(@exe_name, @linker_script, isMainProject? ? @config : nil)
|
157
|
+
|
158
|
+
return success
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def clean
|
163
|
+
Dir.chdir(@projectDir) do
|
164
|
+
if File.exist?@output_dir
|
165
|
+
puts "Deleting folder #{@output_dir}" if Bake.options.verbose >= 2
|
166
|
+
FileUtils.rm_rf(@output_dir)
|
167
|
+
end
|
168
|
+
end unless Bake.options.filename
|
169
|
+
return true
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
175
|
end
|