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 +4 -4
- data/bin/bake +3 -0
- data/lib/adapt/config/loader.rb +4 -0
- data/lib/bake/config/checks.rb +3 -5
- data/lib/bake/libElement.rb +36 -53
- data/lib/bake/mergeConfig.rb +21 -0
- data/lib/bake/model/metamodel.rb +5 -2
- data/lib/bake/model/metamodel_ext.rb +12 -0
- data/lib/bake/options/options.rb +3 -5
- data/lib/bake/options/usage.rb +1 -2
- data/lib/bake/toolchain/gcc.rb +1 -1
- data/lib/bakeqac/filter.rb +5 -1
- data/lib/blocks/block.rb +5 -10
- data/lib/blocks/blockBase.rb +8 -0
- data/lib/blocks/compile.rb +106 -58
- data/lib/blocks/convert.rb +2 -2
- data/lib/blocks/executable.rb +13 -14
- data/lib/blocks/makefile.rb +138 -138
- data/lib/blocks/showIncludes.rb +145 -141
- data/lib/common/version.rb +1 -1
- data/lib/tocxx.rb +179 -45
- metadata +2 -2
data/lib/blocks/convert.rb
CHANGED
@@ -24,9 +24,9 @@ module Bake
|
|
24
24
|
puts " BAKE_DEFINES"
|
25
25
|
(@block.tcs[:COMPILER][:CPP][:DEFINES] + @block.tcs[:COMPILER][:C][:DEFINES] + @block.tcs[:COMPILER][:ASM][:DEFINES]).uniq.each { |s| puts " #{s}" }
|
26
26
|
puts " BAKE_DEPENDENCIES"
|
27
|
-
@block.
|
27
|
+
@block.dependencies.each { |dep| puts " #{dep.projectName}" }
|
28
28
|
puts " BAKE_DEPENDENCIES_FILTERED"
|
29
|
-
@block.
|
29
|
+
@block.dependencies.each { |dep| puts " #{dep.projectName}" unless @projectName == dep.projectName or dep.projectName == "gmock" or dep.projectName == "gtest" }
|
30
30
|
puts "END_INFO"
|
31
31
|
end
|
32
32
|
return true
|
data/lib/blocks/executable.rb
CHANGED
@@ -78,8 +78,9 @@ module Bake
|
|
78
78
|
|
79
79
|
def execute
|
80
80
|
Dir.chdir(@projectDir) do
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
subBlocks = @block.bes.select{|d| Metamodel::Dependency === d}.map { |d| ALL_BLOCKS["#{d.name},#{d.config}"] }
|
83
|
+
if subBlocks.any? { |d| d.result == false }
|
83
84
|
if Bake.options.stopOnFirstError
|
84
85
|
Blocks::Block.set_delayed_result
|
85
86
|
return true
|
@@ -89,13 +90,15 @@ module Bake
|
|
89
90
|
end
|
90
91
|
|
91
92
|
allSources = []
|
92
|
-
(
|
93
|
+
(subBlocks + [@block]).each do |b|
|
93
94
|
Dir.chdir(b.projectDir) do
|
94
95
|
b.getCompileBlocks.each do |c|
|
95
|
-
|
96
|
+
srcs = c.calcSources(true, true).map { |s| File.expand_path(s) }
|
97
|
+
allSources += srcs
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
101
|
+
|
99
102
|
duplicateSources = allSources.group_by{ |e| e }.select { |k, v| v.size > 1 }.map(&:first)
|
100
103
|
duplicateSources.each do |d|
|
101
104
|
Bake.formatter.printError("Source compiled more than once: #{d}")
|
@@ -146,19 +149,15 @@ module Bake
|
|
146
149
|
cmd += linker_libs_array
|
147
150
|
cmd += Bake::Utils::flagSplit(linker[:LIB_POSTFIX_FLAGS],true) # "-Wl,--no-whole-archive "
|
148
151
|
|
149
|
-
mapfileStr = (@mapfile and linker[:MAP_FILE_PIPE]) ? " >#{@mapfile}" : ""
|
150
|
-
|
151
152
|
realCmd = Bake.options.fileCmd ? calcFileCmd(cmd, onlyCmd, @exe_name, linker) : cmd
|
152
153
|
|
153
154
|
# pre print because linking can take much time
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
161
|
-
|
155
|
+
cmdLinePrint = Bake.options.fileCmd ? realCmd.dup : cmd.dup
|
156
|
+
|
157
|
+
# some mapfiles are printed in stdout
|
158
|
+
outPipe = (@mapfile and linker[:MAP_FILE_PIPE]) ? "#{@mapfile}" : nil
|
159
|
+
cmdLinePrint << "> #{outPipe}" if outPipe
|
160
|
+
|
162
161
|
if cmdLineCheck and BlockBase.isCmdLineEqual?(cmd, cmdLineFile)
|
163
162
|
success = true
|
164
163
|
else
|
data/lib/blocks/makefile.rb
CHANGED
@@ -1,138 +1,138 @@
|
|
1
|
-
require_relative 'has_execute_command'
|
2
|
-
|
3
|
-
module Bake
|
4
|
-
module Blocks
|
5
|
-
|
6
|
-
class Makefile
|
7
|
-
include HasExecuteCommand
|
8
|
-
|
9
|
-
MAKE_COMMAND = "make"
|
10
|
-
MAKE_FILE_FLAG = "-f"
|
11
|
-
MAKE_DIR_FLAG = "-C"
|
12
|
-
MAKE_CLEAN = "clean"
|
13
|
-
|
14
|
-
def initialize(config, referencedConfigs, block)
|
15
|
-
@config = config
|
16
|
-
@tcs = block.tcs
|
17
|
-
@projectDir = config.get_project_dir
|
18
|
-
@path_to = ""
|
19
|
-
@flags = adjustFlags("",config.flags) if config.flags
|
20
|
-
@makefile = config.name
|
21
|
-
@target = config.target != "" ? config.target : "all"
|
22
|
-
calcPathTo(referencedConfigs)
|
23
|
-
calcCommandLine
|
24
|
-
calcCleanLine
|
25
|
-
calcEnv
|
26
|
-
|
27
|
-
block.lib_elements << LibElement.new(LibElement::LIB_WITH_PATH, config.lib) if config.lib != ""
|
28
|
-
end
|
29
|
-
|
30
|
-
def calcEnv
|
31
|
-
@envs = {}
|
32
|
-
[:CPP, :C, :ASM].each do |type|
|
33
|
-
compiler = @tcs[:COMPILER][type]
|
34
|
-
defs = compiler[:DEFINES].map {|k| "#{compiler[:DEFINE_FLAG]}#{k}"}.join(" ")
|
35
|
-
args = [defs, compiler[:FLAGS]].reject(&:empty?).join(" ")
|
36
|
-
@envs["BAKE_#{type.to_s}_FLAGS"] = args
|
37
|
-
@envs["BAKE_#{type.to_s}_COMMAND"] = compiler[:COMMAND]
|
38
|
-
end
|
39
|
-
@envs["BAKE_AR_FLAGS"] = @tcs[:ARCHIVER][:FLAGS]
|
40
|
-
@envs["BAKE_LD_FLAGS"] = @tcs[:LINKER][:FLAGS]
|
41
|
-
@envs["BAKE_AR_COMMAND"] = @tcs[:ARCHIVER][:COMMAND]
|
42
|
-
@envs["BAKE_LD_COMMAND"] = @tcs[:LINKER][:COMMAND]
|
43
|
-
end
|
44
|
-
|
45
|
-
def fileAndDir
|
46
|
-
if @config.changeWorkingDir
|
47
|
-
return remove_empty_strings_and_join([
|
48
|
-
MAKE_DIR_FLAG, File.dirname(@makefile),
|
49
|
-
MAKE_FILE_FLAG, File.basename(@makefile)])
|
50
|
-
else
|
51
|
-
return remove_empty_strings_and_join([
|
52
|
-
MAKE_FILE_FLAG, @makefile])
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def calcCommandLine
|
57
|
-
@commandLine = remove_empty_strings_and_join([
|
58
|
-
MAKE_COMMAND, @target,
|
59
|
-
@flags,
|
60
|
-
fileAndDir,
|
61
|
-
@path_to])
|
62
|
-
end
|
63
|
-
|
64
|
-
def calcCleanLine
|
65
|
-
@cleanLine = remove_empty_strings_and_join([
|
66
|
-
MAKE_COMMAND, MAKE_CLEAN,
|
67
|
-
@flags,
|
68
|
-
fileAndDir,
|
69
|
-
@path_to])
|
70
|
-
end
|
71
|
-
|
72
|
-
def calcPathTo(referencedConfigs)
|
73
|
-
@path_to = ""
|
74
|
-
if @config.pathTo != ""
|
75
|
-
pathHash = {}
|
76
|
-
@config.pathTo.split(",").each do |p|
|
77
|
-
nameOfP = p.strip
|
78
|
-
dirOfP = nil
|
79
|
-
if referencedConfigs.include?nameOfP
|
80
|
-
dirOfP = referencedConfigs[nameOfP].first.get_project_dir
|
81
|
-
else
|
82
|
-
Bake.options.roots.each do |r|
|
83
|
-
absIncDir = r.dir+"/"+nameOfP
|
84
|
-
if File.exists?(absIncDir)
|
85
|
-
dirOfP = absIncDir
|
86
|
-
break
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
if dirOfP == nil
|
91
|
-
Bake.formatter.printError("Project '#{nameOfP}' not found", @config)
|
92
|
-
ExitHelper.exit(1)
|
93
|
-
end
|
94
|
-
pathHash[nameOfP] = File.rel_from_to_project(File.dirname(@projectDir),File.dirname(dirOfP))
|
95
|
-
end
|
96
|
-
path_to_array = []
|
97
|
-
pathHash.each { |k,v| path_to_array << "PATH_TO_#{k}=#{v}" }
|
98
|
-
@path_to = path_to_array.join(" ")
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
def run
|
104
|
-
return true if Bake.options.linkOnly
|
105
|
-
@envs.each { |k,v| ENV[k] = v }
|
106
|
-
return executeCommand(@commandLine, nil, @config.validExitCodes, @config.echo)
|
107
|
-
end
|
108
|
-
|
109
|
-
def execute
|
110
|
-
return run()
|
111
|
-
end
|
112
|
-
|
113
|
-
def startupStep
|
114
|
-
return run()
|
115
|
-
end
|
116
|
-
|
117
|
-
def exitStep
|
118
|
-
return run()
|
119
|
-
end
|
120
|
-
|
121
|
-
def do_clean
|
122
|
-
return true if Bake.options.linkOnly || @config.noClean
|
123
|
-
@envs.each { |k,v| ENV[k] = v }
|
124
|
-
return executeCommand(@cleanLine, "No rule to make target 'clean'.", @config.validExitCodes, @config.echo) unless Bake.options.filename
|
125
|
-
end
|
126
|
-
|
127
|
-
def clean
|
128
|
-
return do_clean()
|
129
|
-
end
|
130
|
-
|
131
|
-
def cleanStep
|
132
|
-
return do_clean()
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
1
|
+
require_relative 'has_execute_command'
|
2
|
+
|
3
|
+
module Bake
|
4
|
+
module Blocks
|
5
|
+
|
6
|
+
class Makefile
|
7
|
+
include HasExecuteCommand
|
8
|
+
|
9
|
+
MAKE_COMMAND = "make"
|
10
|
+
MAKE_FILE_FLAG = "-f"
|
11
|
+
MAKE_DIR_FLAG = "-C"
|
12
|
+
MAKE_CLEAN = "clean"
|
13
|
+
|
14
|
+
def initialize(config, referencedConfigs, block)
|
15
|
+
@config = config
|
16
|
+
@tcs = block.tcs
|
17
|
+
@projectDir = config.get_project_dir
|
18
|
+
@path_to = ""
|
19
|
+
@flags = adjustFlags("",config.flags) if config.flags
|
20
|
+
@makefile = config.name
|
21
|
+
@target = config.target != "" ? config.target : "all"
|
22
|
+
calcPathTo(referencedConfigs)
|
23
|
+
calcCommandLine
|
24
|
+
calcCleanLine
|
25
|
+
calcEnv
|
26
|
+
|
27
|
+
block.lib_elements << LibElement.new(LibElement::LIB_WITH_PATH, config.lib) if config.lib != ""
|
28
|
+
end
|
29
|
+
|
30
|
+
def calcEnv
|
31
|
+
@envs = {}
|
32
|
+
[:CPP, :C, :ASM].each do |type|
|
33
|
+
compiler = @tcs[:COMPILER][type]
|
34
|
+
defs = compiler[:DEFINES].map {|k| "#{compiler[:DEFINE_FLAG]}#{k}"}.join(" ")
|
35
|
+
args = [defs, compiler[:FLAGS]].reject(&:empty?).join(" ")
|
36
|
+
@envs["BAKE_#{type.to_s}_FLAGS"] = args
|
37
|
+
@envs["BAKE_#{type.to_s}_COMMAND"] = compiler[:COMMAND]
|
38
|
+
end
|
39
|
+
@envs["BAKE_AR_FLAGS"] = @tcs[:ARCHIVER][:FLAGS]
|
40
|
+
@envs["BAKE_LD_FLAGS"] = @tcs[:LINKER][:FLAGS]
|
41
|
+
@envs["BAKE_AR_COMMAND"] = @tcs[:ARCHIVER][:COMMAND]
|
42
|
+
@envs["BAKE_LD_COMMAND"] = @tcs[:LINKER][:COMMAND]
|
43
|
+
end
|
44
|
+
|
45
|
+
def fileAndDir
|
46
|
+
if @config.changeWorkingDir
|
47
|
+
return remove_empty_strings_and_join([
|
48
|
+
MAKE_DIR_FLAG, File.dirname(@makefile),
|
49
|
+
MAKE_FILE_FLAG, File.basename(@makefile)])
|
50
|
+
else
|
51
|
+
return remove_empty_strings_and_join([
|
52
|
+
MAKE_FILE_FLAG, @makefile])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def calcCommandLine
|
57
|
+
@commandLine = remove_empty_strings_and_join([
|
58
|
+
MAKE_COMMAND, @target,
|
59
|
+
@flags,
|
60
|
+
fileAndDir,
|
61
|
+
@path_to])
|
62
|
+
end
|
63
|
+
|
64
|
+
def calcCleanLine
|
65
|
+
@cleanLine = remove_empty_strings_and_join([
|
66
|
+
MAKE_COMMAND, MAKE_CLEAN,
|
67
|
+
@flags,
|
68
|
+
fileAndDir,
|
69
|
+
@path_to])
|
70
|
+
end
|
71
|
+
|
72
|
+
def calcPathTo(referencedConfigs)
|
73
|
+
@path_to = ""
|
74
|
+
if @config.pathTo != ""
|
75
|
+
pathHash = {}
|
76
|
+
@config.pathTo.split(",").each do |p|
|
77
|
+
nameOfP = p.strip
|
78
|
+
dirOfP = nil
|
79
|
+
if referencedConfigs.include?nameOfP
|
80
|
+
dirOfP = referencedConfigs[nameOfP].first.get_project_dir
|
81
|
+
else
|
82
|
+
Bake.options.roots.each do |r|
|
83
|
+
absIncDir = r.dir+"/"+nameOfP
|
84
|
+
if File.exists?(absIncDir)
|
85
|
+
dirOfP = absIncDir
|
86
|
+
break
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if dirOfP == nil
|
91
|
+
Bake.formatter.printError("Project '#{nameOfP}' not found", @config)
|
92
|
+
ExitHelper.exit(1)
|
93
|
+
end
|
94
|
+
pathHash[nameOfP] = File.rel_from_to_project(File.dirname(@projectDir),File.dirname(dirOfP))
|
95
|
+
end
|
96
|
+
path_to_array = []
|
97
|
+
pathHash.each { |k,v| path_to_array << "PATH_TO_#{k}=#{v}" }
|
98
|
+
@path_to = path_to_array.join(" ")
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
def run
|
104
|
+
return true if Bake.options.linkOnly
|
105
|
+
@envs.each { |k,v| ENV[k] = v }
|
106
|
+
return executeCommand(@commandLine, nil, @config.validExitCodes, @config.echo)
|
107
|
+
end
|
108
|
+
|
109
|
+
def execute
|
110
|
+
return run()
|
111
|
+
end
|
112
|
+
|
113
|
+
def startupStep
|
114
|
+
return run()
|
115
|
+
end
|
116
|
+
|
117
|
+
def exitStep
|
118
|
+
return run()
|
119
|
+
end
|
120
|
+
|
121
|
+
def do_clean
|
122
|
+
return true if Bake.options.linkOnly || @config.noClean
|
123
|
+
@envs.each { |k,v| ENV[k] = v }
|
124
|
+
return executeCommand(@cleanLine, "No rule to make target 'clean'.", @config.validExitCodes, @config.echo) unless Bake.options.filename
|
125
|
+
end
|
126
|
+
|
127
|
+
def clean
|
128
|
+
return do_clean()
|
129
|
+
end
|
130
|
+
|
131
|
+
def cleanStep
|
132
|
+
return do_clean()
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
data/lib/blocks/showIncludes.rb
CHANGED
@@ -1,141 +1,145 @@
|
|
1
|
-
module Bake
|
2
|
-
module Blocks
|
3
|
-
class Show
|
4
|
-
|
5
|
-
def self.secureShow
|
6
|
-
begin
|
7
|
-
yield
|
8
|
-
rescue Exception => e
|
9
|
-
if (not SystemExit === e)
|
10
|
-
puts e
|
11
|
-
puts e.backtrace
|
12
|
-
ExitHelper.exit(1)
|
13
|
-
else
|
14
|
-
raise e
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.includes
|
20
|
-
secureShow {
|
21
|
-
Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|
|
22
|
-
print projName
|
23
|
-
incs = []
|
24
|
-
blocks.each do |block|
|
25
|
-
if Bake.options.consoleOutput_fullnames
|
26
|
-
incs += block.include_list.map { |i| File.expand_path(i, block.projectDir) }
|
27
|
-
else
|
28
|
-
incs += block.include_list
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
incs.uniq.each { |inc| print "##{inc}" }
|
33
|
-
print "\n"
|
34
|
-
end
|
35
|
-
ExitHelper.exit(0) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.readInternalIncludes(mainConfig, mainBlock, mainTcs)
|
39
|
-
intIncs = []
|
40
|
-
iinc = mainConfig.defaultToolchain.internalIncludes
|
41
|
-
Dir.chdir(Bake.options.main_dir) do
|
42
|
-
if (iinc)
|
43
|
-
|
44
|
-
cppExe = File.which(mainTcs[:COMPILER][:CPP][:COMMAND])
|
45
|
-
cExe = File.which(mainTcs[:COMPILER][:C][:COMMAND])
|
46
|
-
asmExe = File.which(mainTcs[:COMPILER][:ASM][:COMMAND])
|
47
|
-
archiverExe = File.which(mainTcs[:ARCHIVER][:COMMAND])
|
48
|
-
linkerExe = File.which(mainTcs[:LINKER][:COMMAND])
|
49
|
-
|
50
|
-
iname = mainBlock.convPath(iinc)
|
51
|
-
if iname != ""
|
52
|
-
if not File.exists?(iname)
|
53
|
-
Bake.formatter.printError("InternalIncludes file #{iname} does not exist", iinc)
|
54
|
-
ExitHelper.exit(1)
|
55
|
-
end
|
56
|
-
IO.foreach(iname) do |x|
|
57
|
-
x.sub!("$(CPPPath)", cppExe)
|
58
|
-
x.sub!("$(CPath)", cExe)
|
59
|
-
x.sub!("$(ASMPath)", asmExe)
|
60
|
-
x.sub!("$(ArchiverPath)", archiverExe)
|
61
|
-
x.sub!("$(LinkerPath)", linkerExe)
|
62
|
-
add_line_if_no_comment(intIncs,x)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
return intIncs
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.readInternalDefines(mainConfig, mainBlock)
|
71
|
-
intDefs = {:CPP => [], :C => [], :ASM => []}
|
72
|
-
Dir.chdir(Bake.options.main_dir) do
|
73
|
-
mainConfig.defaultToolchain.compiler.each do |c|
|
74
|
-
if (c.internalDefines)
|
75
|
-
dname = mainBlock.convPath(c.internalDefines)
|
76
|
-
if dname != ""
|
77
|
-
if not File.exists?(dname)
|
78
|
-
Bake.formatter.printError("InternalDefines file #{dname} does not exist", c.internalDefines)
|
79
|
-
ExitHelper.exit(1)
|
80
|
-
end
|
81
|
-
IO.foreach(dname) {|x| add_line_if_no_comment(intDefs[c.ctype],x) }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
return intDefs
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.includesAndDefines(mainConfig, mainTcs)
|
90
|
-
secureShow {
|
91
|
-
mainBlock = Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]
|
92
|
-
|
93
|
-
intIncs = readInternalIncludes(mainConfig, mainBlock, mainTcs)
|
94
|
-
intDefs = readInternalDefines(mainConfig, mainBlock)
|
95
|
-
|
96
|
-
|
97
|
-
projs = {}
|
98
|
-
Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|
|
99
|
-
|
100
|
-
blockIncs = []
|
101
|
-
blockDefs = {:CPP => [], :C => [], :ASM => []}
|
102
|
-
blocks.each do |block|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
1
|
+
module Bake
|
2
|
+
module Blocks
|
3
|
+
class Show
|
4
|
+
|
5
|
+
def self.secureShow
|
6
|
+
begin
|
7
|
+
yield
|
8
|
+
rescue Exception => e
|
9
|
+
if (not SystemExit === e)
|
10
|
+
puts e
|
11
|
+
puts e.backtrace
|
12
|
+
ExitHelper.exit(1)
|
13
|
+
else
|
14
|
+
raise e
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.includes
|
20
|
+
secureShow {
|
21
|
+
Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|
|
22
|
+
print projName
|
23
|
+
incs = []
|
24
|
+
blocks.each do |block|
|
25
|
+
if Bake.options.consoleOutput_fullnames
|
26
|
+
incs += block.include_list.map { |i| File.expand_path(i, block.projectDir) }
|
27
|
+
else
|
28
|
+
incs += block.include_list
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
incs.uniq.each { |inc| print "##{inc}" }
|
33
|
+
print "\n"
|
34
|
+
end
|
35
|
+
ExitHelper.exit(0) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.readInternalIncludes(mainConfig, mainBlock, mainTcs)
|
39
|
+
intIncs = []
|
40
|
+
iinc = mainConfig.defaultToolchain.internalIncludes
|
41
|
+
Dir.chdir(Bake.options.main_dir) do
|
42
|
+
if (iinc)
|
43
|
+
|
44
|
+
cppExe = File.which(mainTcs[:COMPILER][:CPP][:COMMAND])
|
45
|
+
cExe = File.which(mainTcs[:COMPILER][:C][:COMMAND])
|
46
|
+
asmExe = File.which(mainTcs[:COMPILER][:ASM][:COMMAND])
|
47
|
+
archiverExe = File.which(mainTcs[:ARCHIVER][:COMMAND])
|
48
|
+
linkerExe = File.which(mainTcs[:LINKER][:COMMAND])
|
49
|
+
|
50
|
+
iname = mainBlock.convPath(iinc)
|
51
|
+
if iname != ""
|
52
|
+
if not File.exists?(iname)
|
53
|
+
Bake.formatter.printError("InternalIncludes file #{iname} does not exist", iinc)
|
54
|
+
ExitHelper.exit(1)
|
55
|
+
end
|
56
|
+
IO.foreach(iname) do |x|
|
57
|
+
x.sub!("$(CPPPath)", cppExe)
|
58
|
+
x.sub!("$(CPath)", cExe)
|
59
|
+
x.sub!("$(ASMPath)", asmExe)
|
60
|
+
x.sub!("$(ArchiverPath)", archiverExe)
|
61
|
+
x.sub!("$(LinkerPath)", linkerExe)
|
62
|
+
add_line_if_no_comment(intIncs,x)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
return intIncs
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.readInternalDefines(mainConfig, mainBlock)
|
71
|
+
intDefs = {:CPP => [], :C => [], :ASM => []}
|
72
|
+
Dir.chdir(Bake.options.main_dir) do
|
73
|
+
mainConfig.defaultToolchain.compiler.each do |c|
|
74
|
+
if (c.internalDefines)
|
75
|
+
dname = mainBlock.convPath(c.internalDefines)
|
76
|
+
if dname != ""
|
77
|
+
if not File.exists?(dname)
|
78
|
+
Bake.formatter.printError("InternalDefines file #{dname} does not exist", c.internalDefines)
|
79
|
+
ExitHelper.exit(1)
|
80
|
+
end
|
81
|
+
IO.foreach(dname) {|x| add_line_if_no_comment(intDefs[c.ctype],x) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
return intDefs
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.includesAndDefines(mainConfig, mainTcs)
|
90
|
+
secureShow {
|
91
|
+
mainBlock = Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]
|
92
|
+
|
93
|
+
intIncs = readInternalIncludes(mainConfig, mainBlock, mainTcs)
|
94
|
+
intDefs = readInternalDefines(mainConfig, mainBlock)
|
95
|
+
|
96
|
+
|
97
|
+
projs = {}
|
98
|
+
Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|
|
99
|
+
|
100
|
+
blockIncs = []
|
101
|
+
blockDefs = {:CPP => [], :C => [], :ASM => []}
|
102
|
+
blocks.each do |block|
|
103
|
+
block.calcFileTcs
|
104
|
+
block.calcIncludes
|
105
|
+
block.calcDefines
|
106
|
+
block.calcFlags
|
107
|
+
if Bake.options.consoleOutput_fullnames
|
108
|
+
blockIncs += block.include_list.map { |i| File.expand_path(i, block.projectDir) }
|
109
|
+
else
|
110
|
+
blockIncs += block.include_list
|
111
|
+
end
|
112
|
+
[:CPP, :C, :ASM].each { |type| blockDefs[type] += block.block.tcs[:COMPILER][type][:DEFINES] }
|
113
|
+
end
|
114
|
+
if Bake.options.json
|
115
|
+
projs[projName] =
|
116
|
+
{ :includes => (blockIncs + intIncs).uniq,
|
117
|
+
:cpp_defines => (blockDefs[:CPP] + intDefs[:CPP]).uniq + Bake.options.defines,
|
118
|
+
:c_defines => (blockDefs[:C] + intDefs[:C]).uniq + Bake.options.defines,
|
119
|
+
:asm_defines => (blockDefs[:ASM] + intDefs[:ASM]).uniq + Bake.options.defines,
|
120
|
+
:dir => blocks.first.projectDir
|
121
|
+
}
|
122
|
+
else
|
123
|
+
puts projName
|
124
|
+
puts " dir #{blocks.first.projectDir}"
|
125
|
+
puts " includes"
|
126
|
+
(blockIncs + intIncs).uniq.each { |i| puts " #{i}" }
|
127
|
+
[:CPP, :C, :ASM].each do |type|
|
128
|
+
puts " #{type} defines"
|
129
|
+
(blockDefs[type] + intDefs[type] + Bake.options.defines).uniq.each { |d| puts " #{d}" }
|
130
|
+
end
|
131
|
+
puts " done"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
if Bake.options.json
|
136
|
+
require "json"
|
137
|
+
puts JSON.pretty_generate(projs)
|
138
|
+
end
|
139
|
+
|
140
|
+
ExitHelper.exit(0) }
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|