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.
- 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/bake/options/showDoc.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
module Bake
|
|
2
|
-
class Doc
|
|
3
|
-
def self.show
|
|
4
|
-
|
|
5
|
-
link = File.expand_path(File.dirname(__FILE__)+"/../../../documentation/_build/html/index.html")
|
|
6
|
-
if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
|
7
|
-
system "start #{link}"
|
|
8
|
-
elsif RUBY_PLATFORM =~ /darwin/
|
|
9
|
-
system "open #{link}"
|
|
10
|
-
elsif RUBY_PLATFORM =~ /linux|bsd/
|
|
11
|
-
system "xdg-open #{link}"
|
|
12
|
-
else
|
|
13
|
-
puts "Please open #{link} manually in your browser."
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
ExitHelper.exit(0)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
module Bake
|
|
2
|
+
class Doc
|
|
3
|
+
def self.show
|
|
4
|
+
|
|
5
|
+
link = File.expand_path(File.dirname(__FILE__)+"/../../../documentation/_build/html/index.html")
|
|
6
|
+
if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
|
7
|
+
system "start #{link}"
|
|
8
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
|
9
|
+
system "open #{link}"
|
|
10
|
+
elsif RUBY_PLATFORM =~ /linux|bsd/
|
|
11
|
+
system "xdg-open #{link}"
|
|
12
|
+
else
|
|
13
|
+
puts "Please open #{link} manually in your browser."
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ExitHelper.exit(0)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module Bake
|
|
2
|
-
class License
|
|
3
|
-
def self.show
|
|
4
|
-
licenseFile = File.join(File.dirname(__FILE__), "../../../license.txt")
|
|
5
|
-
puts "\n" + File.read(licenseFile)
|
|
6
|
-
ExitHelper.exit(0)
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
end
|
|
1
|
+
module Bake
|
|
2
|
+
class License
|
|
3
|
+
def self.show
|
|
4
|
+
licenseFile = File.join(File.dirname(__FILE__), "../../../license.txt")
|
|
5
|
+
puts "\n" + File.read(licenseFile)
|
|
6
|
+
ExitHelper.exit(0)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
module Bake
|
|
2
|
-
class ToolchainInfo
|
|
3
|
-
|
|
4
|
-
def self.printHash(x, level)
|
|
5
|
-
x.each do |k,v|
|
|
6
|
-
if Hash === v
|
|
7
|
-
if level > 0
|
|
8
|
-
level.times {print " "}
|
|
9
|
-
else
|
|
10
|
-
print "\n"
|
|
11
|
-
end
|
|
12
|
-
puts k
|
|
13
|
-
printHash(v,level+1)
|
|
14
|
-
elsif Array === v or String === v
|
|
15
|
-
level.times {print " "}
|
|
16
|
-
print "\n" if (level == 0)
|
|
17
|
-
puts "#{k} = #{v}"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.showToolchain(x)
|
|
23
|
-
tcs = Bake::Toolchain::Provider[x]
|
|
24
|
-
if tcs.nil?
|
|
25
|
-
puts "Toolchain not available"
|
|
26
|
-
else
|
|
27
|
-
printHash(tcs, 0)
|
|
28
|
-
end
|
|
29
|
-
ExitHelper.exit(0)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def self.showToolchainList()
|
|
33
|
-
puts "Available toolchains:"
|
|
34
|
-
Bake::Toolchain::Provider.list.keys.each { |c| puts "* #{c}" }
|
|
35
|
-
ExitHelper.exit(0)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
1
|
+
module Bake
|
|
2
|
+
class ToolchainInfo
|
|
3
|
+
|
|
4
|
+
def self.printHash(x, level)
|
|
5
|
+
x.each do |k,v|
|
|
6
|
+
if Hash === v
|
|
7
|
+
if level > 0
|
|
8
|
+
level.times {print " "}
|
|
9
|
+
else
|
|
10
|
+
print "\n"
|
|
11
|
+
end
|
|
12
|
+
puts k
|
|
13
|
+
printHash(v,level+1)
|
|
14
|
+
elsif Array === v or String === v
|
|
15
|
+
level.times {print " "}
|
|
16
|
+
print "\n" if (level == 0)
|
|
17
|
+
puts "#{k} = #{v}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.showToolchain(x)
|
|
23
|
+
tcs = Bake::Toolchain::Provider[x]
|
|
24
|
+
if tcs.nil?
|
|
25
|
+
puts "Toolchain not available"
|
|
26
|
+
else
|
|
27
|
+
printHash(tcs, 0)
|
|
28
|
+
end
|
|
29
|
+
ExitHelper.exit(0)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.showToolchainList()
|
|
33
|
+
puts "Available toolchains:"
|
|
34
|
+
Bake::Toolchain::Provider.list.keys.each { |c| puts "* #{c}" }
|
|
35
|
+
ExitHelper.exit(0)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
39
|
end
|
data/lib/bake/options/usage.rb
CHANGED
|
@@ -1,69 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
puts "
|
|
16
|
-
puts "
|
|
17
|
-
puts "
|
|
18
|
-
puts "
|
|
19
|
-
puts "
|
|
20
|
-
puts "
|
|
21
|
-
puts "
|
|
22
|
-
puts "
|
|
23
|
-
puts "
|
|
24
|
-
puts "
|
|
25
|
-
puts "
|
|
26
|
-
puts " --
|
|
27
|
-
puts "
|
|
28
|
-
puts " --
|
|
29
|
-
puts " --
|
|
30
|
-
puts " -
|
|
31
|
-
puts "
|
|
32
|
-
puts " --
|
|
33
|
-
puts " --
|
|
34
|
-
puts " --
|
|
35
|
-
puts " --
|
|
36
|
-
puts "
|
|
37
|
-
puts " --
|
|
38
|
-
puts "
|
|
39
|
-
puts "
|
|
40
|
-
puts " --
|
|
41
|
-
puts " --
|
|
42
|
-
puts " --
|
|
43
|
-
puts " --
|
|
44
|
-
puts " --
|
|
45
|
-
|
|
46
|
-
puts " --
|
|
47
|
-
puts "
|
|
48
|
-
puts " --
|
|
49
|
-
puts " --
|
|
50
|
-
puts " --
|
|
51
|
-
|
|
52
|
-
puts ""
|
|
53
|
-
puts " --
|
|
54
|
-
puts " --
|
|
55
|
-
puts "
|
|
56
|
-
puts " --
|
|
57
|
-
puts ""
|
|
58
|
-
puts " --
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
puts "
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
require 'common/version'
|
|
2
|
+
|
|
3
|
+
module Bake
|
|
4
|
+
|
|
5
|
+
class Usage
|
|
6
|
+
|
|
7
|
+
def self.version
|
|
8
|
+
Bake::Version.printBakeVersion
|
|
9
|
+
ExitHelper.exit(0)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def self.show
|
|
14
|
+
Bake::Version.printBakeVersion
|
|
15
|
+
puts "\nUsage: bake [options]"
|
|
16
|
+
puts " [-b] <name> Config name of main project"
|
|
17
|
+
puts " -m <dir> Directory of main project (default is current directory)."
|
|
18
|
+
puts " -p <dir> Project to build/clean (default is main project)"
|
|
19
|
+
puts " -f <name> Build/Clean this file only."
|
|
20
|
+
puts " -c Clean the file/project."
|
|
21
|
+
puts " -a <scheme> Use ansi color sequences (console must-- support it). Possible values are 'white' and 'black'."
|
|
22
|
+
puts " -v<level> Verbose level from 0 to 3, whereas -v0 is less, -v1 is normal (default) and -v2 and -v3 are more verbose."
|
|
23
|
+
puts " -r Stop on first error."
|
|
24
|
+
puts " -w <root> Add a workspace root (can be used multiple times)."
|
|
25
|
+
puts " If no root is specified, the parent directory of the main project is added automatically."
|
|
26
|
+
puts " --list Lists all configs with a DefaultToolchain."
|
|
27
|
+
puts " --rebuild Clean before build."
|
|
28
|
+
puts " --clobber Clean the file/project (same as option -c) AND the bake cache files."
|
|
29
|
+
puts " --prepro Stop after preprocessor."
|
|
30
|
+
puts " --link-only Only link executables - doesn't update objects and archives or start PreSteps and PostSteps."
|
|
31
|
+
puts " Forces executables to be relinked."
|
|
32
|
+
puts " --compile-only Only the compile steps are executed, equivalent to -f '.'"
|
|
33
|
+
puts " --generate-doc Builds docu instead of compiling sources."
|
|
34
|
+
puts " --lint Performs Lint checks instead of compiling sources."
|
|
35
|
+
puts " --lint-min <num> If number of files in a project is too large for lint to handle, it is possible"
|
|
36
|
+
puts " to specify only a part of the file list to lint (default -1)."
|
|
37
|
+
puts " --lint-max <num> See above (default -1)."
|
|
38
|
+
puts " --ignore-cache Rereads the original meta files - usefull if workspace structure has been changed."
|
|
39
|
+
puts " -j <num> Set NUMBER of parallel compiled files (default is 8)."
|
|
40
|
+
puts " --socket <num> Set SOCKET for sending errors, receiving commands, etc. - used by e.g. Eclipse."
|
|
41
|
+
puts " --toolchain-info <name> Prints default values of a toolchain."
|
|
42
|
+
puts " --toolchain-names Prints available toolchains."
|
|
43
|
+
puts " --dot <filename> Creates a .dot file of the config dependencies."
|
|
44
|
+
puts " --do <name> Includes steps with this filter name (can be used multiple times)."
|
|
45
|
+
puts " 'PRE', 'POST', 'STARTUP' or 'EXIT' includes all according steps."
|
|
46
|
+
puts " --omit <name> Excludes steps with this filter name (can be used multiple times)."
|
|
47
|
+
puts " 'PRE', 'POST', 'STARTUP' or 'EXIT' excludes all according steps."
|
|
48
|
+
puts " --abs-paths Compiler prints absolute filename paths instead of relative paths."
|
|
49
|
+
puts " --no-autodir Disable auto completion of paths like in IncludeDir"
|
|
50
|
+
puts " --set <key>=<value> Sets a variable. Overwrites variables defined in Project.metas (can be used multiple times)."
|
|
51
|
+
puts " --adapt <name> Specifies an adapt project to manipulate the configs (can be used multiple times)"
|
|
52
|
+
puts " --incs-and-defs=json Prints includes and defines of all projects in json format"
|
|
53
|
+
puts " --incs-and-defs=bake Used by IDEs plugins"
|
|
54
|
+
puts " --conversion-info Prints infos for an external tool which converts bake configs for other build systems"
|
|
55
|
+
# puts " --bundle <dir> Bundles the output (experimental, description will follow)"
|
|
56
|
+
puts " --prebuild Does not build configs which are marked as 'prebuild', this feature is used for distributions."
|
|
57
|
+
puts " --compilation-db [<fn>] Writes compilation information into filename fn in json format, default for fn is compilation-db.json"
|
|
58
|
+
puts " --create exe|lib|custom Creates a project with exe, lib or custom template"
|
|
59
|
+
puts " --link-2-17 DEPRECATED: Using link order of libraries which was used until bake 2.17"
|
|
60
|
+
puts " --build_ DEPRECATED: build directories will be build_<name> instead of build/<name>"
|
|
61
|
+
|
|
62
|
+
puts ""
|
|
63
|
+
puts " --version Print version."
|
|
64
|
+
puts " --time Print elapsed time at the end."
|
|
65
|
+
puts " --doc Open documentation in browser"
|
|
66
|
+
puts " -h, --help Print this help."
|
|
67
|
+
puts " --license Print the license."
|
|
68
|
+
puts ""
|
|
69
|
+
puts " --debug Print out backtraces in some cases - used only for debugging bake."
|
|
70
|
+
ExitHelper.exit(0)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.bundle
|
|
74
|
+
puts "\nOption --bundle not supported anymore, please contact the author via github if still needed."
|
|
75
|
+
ExitHelper.exit(1)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
69
80
|
end
|
data/lib/bake/subst.rb
CHANGED
|
@@ -1,313 +1,313 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
|
|
3
|
-
module Bake
|
|
4
|
-
|
|
5
|
-
class Subst
|
|
6
|
-
|
|
7
|
-
# this is done lazy because usually there is no need to calculate that
|
|
8
|
-
def self.lazyPathes
|
|
9
|
-
return unless @@lazy
|
|
10
|
-
|
|
11
|
-
cppCmd = @@toolchain[:COMPILER][:CPP][:COMMAND]
|
|
12
|
-
cCmd = @@toolchain[:COMPILER][:C][:COMMAND]
|
|
13
|
-
asmCmd = @@toolchain[:COMPILER][:ASM][:COMMAND]
|
|
14
|
-
archiverCmd = @@toolchain[:ARCHIVER][:COMMAND]
|
|
15
|
-
linkerCmd = @@toolchain[:LINKER][:COMMAND]
|
|
16
|
-
|
|
17
|
-
if @@config.toolchain
|
|
18
|
-
linkerCmd = @@config.toolchain.linker.command if @@config.toolchain.linker and @@config.toolchain.linker.command != ""
|
|
19
|
-
archiverCmd = @@config.toolchain.archiver.command if @@config.toolchain.linker and @@config.toolchain.archiver.command != ""
|
|
20
|
-
@@config.toolchain.compiler.each do |c|
|
|
21
|
-
if c.command != ""
|
|
22
|
-
if c.ctype == :CPP
|
|
23
|
-
cppCmd = c.command
|
|
24
|
-
elsif c.ctype == :C
|
|
25
|
-
cCmd = c.command
|
|
26
|
-
elsif c.ctype == :ASM
|
|
27
|
-
asmCmd = c.command
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
@@cppExe = File.which(cppCmd)
|
|
34
|
-
@@cExe = File.which(cCmd)
|
|
35
|
-
@@asmExe = File.which(asmCmd)
|
|
36
|
-
@@archiverExe = File.which(archiverCmd)
|
|
37
|
-
@@linkerExe = File.which(linkerCmd)
|
|
38
|
-
|
|
39
|
-
@@lazy = false
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def self.itute(config, projName, isMainProj, toolchain, loadedConfig, configTcMap)
|
|
43
|
-
@@lazy = true
|
|
44
|
-
@@config = config
|
|
45
|
-
@@toolchain = toolchain
|
|
46
|
-
@@loadedConfig = loadedConfig
|
|
47
|
-
@@configTcMap = configTcMap
|
|
48
|
-
@@toolchainName = config.defaultToolchain.basedOn if isMainProj
|
|
49
|
-
|
|
50
|
-
@@configName = config.name
|
|
51
|
-
@@projDir = config.parent.get_project_dir
|
|
52
|
-
@@projName = projName
|
|
53
|
-
@@resolvedVars = 0
|
|
54
|
-
@@configFilename = config.file_name
|
|
55
|
-
|
|
56
|
-
@@artifactName = ""
|
|
57
|
-
if Metamodel::ExecutableConfig === config || Metamodel::LibraryConfig === config
|
|
58
|
-
if not config.artifactName.nil?
|
|
59
|
-
@@artifactName = config.artifactName.name
|
|
60
|
-
else
|
|
61
|
-
if Metamodel::ExecutableConfig === config
|
|
62
|
-
@@artifactName = projName+toolchain[:LINKER][:OUTPUT_ENDING]
|
|
63
|
-
elsif Metamodel::LibraryConfig === config
|
|
64
|
-
@@artifactName = "lib#{projName}.a"
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
if isMainProj
|
|
70
|
-
@@userVarMap = {}
|
|
71
|
-
else
|
|
72
|
-
@@userVarMap = @@userVarMapMain.clone
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
config.set.each do |s|
|
|
76
|
-
|
|
77
|
-
if (s.value != "" and s.cmd != "")
|
|
78
|
-
Bake.formatter.printError("value and cmd attributes must be used exclusively", s)
|
|
79
|
-
ExitHelper.exit(1)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if (s.value != "")
|
|
83
|
-
setName = substString(s.name, s)
|
|
84
|
-
if (setName.empty?)
|
|
85
|
-
Bake.formatter.printWarning("Name of variable must not be empty - variable will be ignored", s)
|
|
86
|
-
else
|
|
87
|
-
@@userVarMap[s.name] = substString(s.value, s)
|
|
88
|
-
ENV[s.name] = @@userVarMap[s.name] if s.env
|
|
89
|
-
end
|
|
90
|
-
else
|
|
91
|
-
cmd_result = false
|
|
92
|
-
consoleOutput = ""
|
|
93
|
-
begin
|
|
94
|
-
Dir.chdir(@@projDir) do
|
|
95
|
-
cmd = [substString(s.cmd, s)]
|
|
96
|
-
cmd_result, consoleOutput = ProcessHelper.run(cmd)
|
|
97
|
-
@@userVarMap[s.name] = consoleOutput.chomp
|
|
98
|
-
ENV[s.name] = @@userVarMap[s.name] if s.env
|
|
99
|
-
end
|
|
100
|
-
rescue Exception=>e
|
|
101
|
-
consoleOutput = e.message
|
|
102
|
-
end
|
|
103
|
-
if (cmd_result == false)
|
|
104
|
-
Bake.formatter.printWarning("Command not successful, variable #{s.name} will be set to \"\" (#{consoleOutput.chomp}).", s)
|
|
105
|
-
@@userVarMap[s.name] = ""
|
|
106
|
-
ENV[s.name] = "" if s.env
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
@@userVarMapMain = @@userVarMap.clone if isMainProj
|
|
113
|
-
|
|
114
|
-
3.times {
|
|
115
|
-
subst(config);
|
|
116
|
-
substToolchain(toolchain)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@@resolvedVars = 0
|
|
120
|
-
lastFoundInVar = -1
|
|
121
|
-
100.times do
|
|
122
|
-
subst(config)
|
|
123
|
-
break if @@resolvedVars == 0 or (@@resolvedVars >= lastFoundInVar and lastFoundInVar >= 0)
|
|
124
|
-
lastFoundInVar = @@resolvedVars
|
|
125
|
-
end
|
|
126
|
-
if (@@resolvedVars > 0)
|
|
127
|
-
Bake.formatter.printError("Cyclic variable substitution detected", config.file_name)
|
|
128
|
-
ExitHelper.exit(1)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def self.substString(str, elem=nil)
|
|
134
|
-
substStr = ""
|
|
135
|
-
posSubst = 0
|
|
136
|
-
while (true)
|
|
137
|
-
posStart = str.index("$(", posSubst)
|
|
138
|
-
break if posStart.nil?
|
|
139
|
-
posEnd = str.index(")", posStart)
|
|
140
|
-
break if posEnd.nil?
|
|
141
|
-
posStartSub = str.index("$(", posStart+1)
|
|
142
|
-
if (not posStartSub.nil? and posStartSub < posEnd) # = nested vars
|
|
143
|
-
newStr = str[0,posStartSub] + substString(str[posStartSub..posEnd],elem)
|
|
144
|
-
if (str.length + 1 > posEnd)
|
|
145
|
-
str = newStr + str[posEnd+1..-1]
|
|
146
|
-
else
|
|
147
|
-
str = newStr
|
|
148
|
-
end
|
|
149
|
-
next
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
substStr << str[posSubst..posStart-1] if posStart>0
|
|
153
|
-
|
|
154
|
-
@@resolvedVars += 1
|
|
155
|
-
var = str[posStart+2..posEnd-1]
|
|
156
|
-
|
|
157
|
-
splittedVar = var.split(",")
|
|
158
|
-
|
|
159
|
-
if Bake.options.vars.has_key?(var)
|
|
160
|
-
substStr << Bake.options.vars[var]
|
|
161
|
-
elsif @@userVarMap.has_key?(var)
|
|
162
|
-
substStr << @@userVarMap[var]
|
|
163
|
-
elsif var == "MainConfigName"
|
|
164
|
-
substStr << Bake.options.build_config
|
|
165
|
-
elsif var == "MainProjectName"
|
|
166
|
-
substStr << Bake.options.main_project_name
|
|
167
|
-
elsif var == "MainProjectDir"
|
|
168
|
-
substStr << Bake.options.main_dir
|
|
169
|
-
elsif var == "ConfigName"
|
|
170
|
-
substStr << @@configName
|
|
171
|
-
elsif var == "ToolchainName" and defined?@@toolchainName
|
|
172
|
-
substStr << @@toolchainName
|
|
173
|
-
elsif var == "ProjectName"
|
|
174
|
-
substStr << @@projName
|
|
175
|
-
elsif var == "ProjectDir"
|
|
176
|
-
substStr << @@projDir
|
|
177
|
-
elsif var == "OutputDir" or (splittedVar.length == 3 and splittedVar[0] == "OutputDir")
|
|
178
|
-
if (var == "OutputDir")
|
|
179
|
-
out_proj_name = @@projName
|
|
180
|
-
out_conf_name = @@configName
|
|
181
|
-
else
|
|
182
|
-
out_proj_name = splittedVar[1].strip
|
|
183
|
-
out_conf_name = splittedVar[2].strip
|
|
184
|
-
end
|
|
185
|
-
if @@loadedConfig.referencedConfigs.has_key?out_proj_name
|
|
186
|
-
configs = @@loadedConfig.referencedConfigs[out_proj_name]
|
|
187
|
-
config = configs.select {|c| c.name == out_conf_name }.first
|
|
188
|
-
if config
|
|
189
|
-
out_dir = nil
|
|
190
|
-
if (config.toolchain and config.toolchain.outputDir and config.toolchain.outputDir != "")
|
|
191
|
-
out_dir = config.toolchain.outputDir
|
|
192
|
-
else
|
|
193
|
-
out_dir = @@configTcMap[config][:OUTPUT_DIR]
|
|
194
|
-
end
|
|
195
|
-
if not out_dir
|
|
196
|
-
if out_proj_name == Bake.options.main_project_name and out_conf_name == Bake.options.build_config
|
|
197
|
-
out_dir = "build" + Bake.options.buildDirDelimiter + Bake.options.build_config
|
|
198
|
-
else
|
|
199
|
-
out_dir = "build" + Bake.options.buildDirDelimiter + out_conf_name + "_" + Bake.options.main_project_name + "_" + Bake.options.build_config
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
out_dir = substString(out_dir, elem)
|
|
203
|
-
if File.is_absolute?(out_dir)
|
|
204
|
-
substStr << out_dir
|
|
205
|
-
else
|
|
206
|
-
substStr << Pathname.new(File.rel_from_to_project(@@projDir,config.get_project_dir,true) + out_dir).cleanpath.to_s
|
|
207
|
-
end
|
|
208
|
-
else
|
|
209
|
-
if Bake.options.verbose > 0
|
|
210
|
-
msg = "Substitute variable '$(#{var})' with empty string, because config #{out_conf_name} not found for project #{out_proj_name}"
|
|
211
|
-
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
else
|
|
215
|
-
if Bake.options.verbose > 0
|
|
216
|
-
msg = "Substitute variable '$(#{var})' with empty string, because project #{out_proj_name} not found"
|
|
217
|
-
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
elsif splittedVar.length > 1 and splittedVar[0] == "OutputDir"
|
|
221
|
-
if Bake.options.verbose > 0
|
|
222
|
-
msg = "Substitute variable '$(#{var})' with empty string, because syntax of complex variable OutputDir is not $(OutputDir,<project name>,<config name>)"
|
|
223
|
-
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
224
|
-
end
|
|
225
|
-
elsif var == "Time"
|
|
226
|
-
substStr << Time.now.to_s
|
|
227
|
-
elsif var == "Hostname"
|
|
228
|
-
substStr << Socket.gethostname
|
|
229
|
-
elsif var == "ArtifactName"
|
|
230
|
-
substStr << @@artifactName
|
|
231
|
-
elsif var == "ArtifactNameBase"
|
|
232
|
-
substStr << @@artifactName.chomp(File.extname(@@artifactName))
|
|
233
|
-
elsif var == "CPPPath"
|
|
234
|
-
self.lazyPathes
|
|
235
|
-
substStr << @@cppExe
|
|
236
|
-
elsif var == "CPath"
|
|
237
|
-
self.lazyPathes
|
|
238
|
-
substStr << @@cExe
|
|
239
|
-
elsif var == "ASMPath"
|
|
240
|
-
self.lazyPathes
|
|
241
|
-
substStr << @@asmExe
|
|
242
|
-
elsif var == "ArchiverPath"
|
|
243
|
-
self.lazyPathes
|
|
244
|
-
substStr << @@archiverExe
|
|
245
|
-
elsif var == "LinkerPath"
|
|
246
|
-
self.lazyPathes
|
|
247
|
-
substStr << @@linkerExe
|
|
248
|
-
elsif var == "Roots"
|
|
249
|
-
substStr << "___ROOTS___"
|
|
250
|
-
elsif var == "/"
|
|
251
|
-
substStr << File::SEPARATOR
|
|
252
|
-
elsif var == ":"
|
|
253
|
-
substStr << File::PATH_SEPARATOR
|
|
254
|
-
elsif ENV[var]
|
|
255
|
-
substStr << ENV[var]
|
|
256
|
-
else
|
|
257
|
-
if Bake.options.verbose >= 2
|
|
258
|
-
msg = "Substitute variable '$(#{var})' with empty string"
|
|
259
|
-
if elem
|
|
260
|
-
Bake.formatter.printInfo(msg, elem)
|
|
261
|
-
else
|
|
262
|
-
Bake.formatter.printInfo(msg + " in the toolchain", @@config)
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
posSubst = posEnd + 1
|
|
268
|
-
end
|
|
269
|
-
substStr << str[posSubst..-1]
|
|
270
|
-
substStr
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def self.substToolchain(elem)
|
|
274
|
-
if Hash === elem
|
|
275
|
-
elem.each do |k, e|
|
|
276
|
-
if Hash === e or Array === e
|
|
277
|
-
substToolchain(e)
|
|
278
|
-
elsif String === e
|
|
279
|
-
elem[k] = substString(e)
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
elsif Array === elem
|
|
283
|
-
elem.each_with_index do |e, i|
|
|
284
|
-
if Hash === e or Array === e
|
|
285
|
-
substToolchain(e)
|
|
286
|
-
elsif String === e
|
|
287
|
-
elem[i] = substString(e)
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
def self.subst(elem)
|
|
294
|
-
elem.class.ecore.eAllAttributes_derived.each do |a|
|
|
295
|
-
next if a.name == "file_name" or a.name == "line_number"
|
|
296
|
-
return if Metamodel::Set === elem.class
|
|
297
|
-
return if Metamodel::DefaultToolchain === elem
|
|
298
|
-
return if Metamodel::Toolchain === elem.class
|
|
299
|
-
next if a.eType.name != "EString"
|
|
300
|
-
substStr = substString(elem.getGeneric(a.name), elem)
|
|
301
|
-
elem.setGeneric(a.name, substStr)
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
childsRefs = elem.class.ecore.eAllReferences.select{|r| r.containment}
|
|
305
|
-
childsRefs.each do |c|
|
|
306
|
-
elem.getGenericAsArray(c.name).each { |child| subst(child) }
|
|
307
|
-
end
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
end
|
|
313
|
-
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
module Bake
|
|
4
|
+
|
|
5
|
+
class Subst
|
|
6
|
+
|
|
7
|
+
# this is done lazy because usually there is no need to calculate that
|
|
8
|
+
def self.lazyPathes
|
|
9
|
+
return unless @@lazy
|
|
10
|
+
|
|
11
|
+
cppCmd = @@toolchain[:COMPILER][:CPP][:COMMAND]
|
|
12
|
+
cCmd = @@toolchain[:COMPILER][:C][:COMMAND]
|
|
13
|
+
asmCmd = @@toolchain[:COMPILER][:ASM][:COMMAND]
|
|
14
|
+
archiverCmd = @@toolchain[:ARCHIVER][:COMMAND]
|
|
15
|
+
linkerCmd = @@toolchain[:LINKER][:COMMAND]
|
|
16
|
+
|
|
17
|
+
if @@config.toolchain
|
|
18
|
+
linkerCmd = @@config.toolchain.linker.command if @@config.toolchain.linker and @@config.toolchain.linker.command != ""
|
|
19
|
+
archiverCmd = @@config.toolchain.archiver.command if @@config.toolchain.linker and @@config.toolchain.archiver.command != ""
|
|
20
|
+
@@config.toolchain.compiler.each do |c|
|
|
21
|
+
if c.command != ""
|
|
22
|
+
if c.ctype == :CPP
|
|
23
|
+
cppCmd = c.command
|
|
24
|
+
elsif c.ctype == :C
|
|
25
|
+
cCmd = c.command
|
|
26
|
+
elsif c.ctype == :ASM
|
|
27
|
+
asmCmd = c.command
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@@cppExe = File.which(cppCmd)
|
|
34
|
+
@@cExe = File.which(cCmd)
|
|
35
|
+
@@asmExe = File.which(asmCmd)
|
|
36
|
+
@@archiverExe = File.which(archiverCmd)
|
|
37
|
+
@@linkerExe = File.which(linkerCmd)
|
|
38
|
+
|
|
39
|
+
@@lazy = false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.itute(config, projName, isMainProj, toolchain, loadedConfig, configTcMap)
|
|
43
|
+
@@lazy = true
|
|
44
|
+
@@config = config
|
|
45
|
+
@@toolchain = toolchain
|
|
46
|
+
@@loadedConfig = loadedConfig
|
|
47
|
+
@@configTcMap = configTcMap
|
|
48
|
+
@@toolchainName = config.defaultToolchain.basedOn if isMainProj
|
|
49
|
+
|
|
50
|
+
@@configName = config.name
|
|
51
|
+
@@projDir = config.parent.get_project_dir
|
|
52
|
+
@@projName = projName
|
|
53
|
+
@@resolvedVars = 0
|
|
54
|
+
@@configFilename = config.file_name
|
|
55
|
+
|
|
56
|
+
@@artifactName = ""
|
|
57
|
+
if Metamodel::ExecutableConfig === config || Metamodel::LibraryConfig === config
|
|
58
|
+
if not config.artifactName.nil?
|
|
59
|
+
@@artifactName = config.artifactName.name
|
|
60
|
+
else
|
|
61
|
+
if Metamodel::ExecutableConfig === config
|
|
62
|
+
@@artifactName = projName+toolchain[:LINKER][:OUTPUT_ENDING]
|
|
63
|
+
elsif Metamodel::LibraryConfig === config
|
|
64
|
+
@@artifactName = "lib#{projName}.a"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if isMainProj
|
|
70
|
+
@@userVarMap = {}
|
|
71
|
+
else
|
|
72
|
+
@@userVarMap = @@userVarMapMain.clone
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
config.set.each do |s|
|
|
76
|
+
|
|
77
|
+
if (s.value != "" and s.cmd != "")
|
|
78
|
+
Bake.formatter.printError("value and cmd attributes must be used exclusively", s)
|
|
79
|
+
ExitHelper.exit(1)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if (s.value != "")
|
|
83
|
+
setName = substString(s.name, s)
|
|
84
|
+
if (setName.empty?)
|
|
85
|
+
Bake.formatter.printWarning("Name of variable must not be empty - variable will be ignored", s)
|
|
86
|
+
else
|
|
87
|
+
@@userVarMap[s.name] = substString(s.value, s)
|
|
88
|
+
ENV[s.name] = @@userVarMap[s.name] if s.env
|
|
89
|
+
end
|
|
90
|
+
else
|
|
91
|
+
cmd_result = false
|
|
92
|
+
consoleOutput = ""
|
|
93
|
+
begin
|
|
94
|
+
Dir.chdir(@@projDir) do
|
|
95
|
+
cmd = [substString(s.cmd, s)]
|
|
96
|
+
cmd_result, consoleOutput = ProcessHelper.run(cmd)
|
|
97
|
+
@@userVarMap[s.name] = consoleOutput.chomp
|
|
98
|
+
ENV[s.name] = @@userVarMap[s.name] if s.env
|
|
99
|
+
end
|
|
100
|
+
rescue Exception=>e
|
|
101
|
+
consoleOutput = e.message
|
|
102
|
+
end
|
|
103
|
+
if (cmd_result == false)
|
|
104
|
+
Bake.formatter.printWarning("Command not successful, variable #{s.name} will be set to \"\" (#{consoleOutput.chomp}).", s)
|
|
105
|
+
@@userVarMap[s.name] = ""
|
|
106
|
+
ENV[s.name] = "" if s.env
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
@@userVarMapMain = @@userVarMap.clone if isMainProj
|
|
113
|
+
|
|
114
|
+
3.times {
|
|
115
|
+
subst(config);
|
|
116
|
+
substToolchain(toolchain)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@@resolvedVars = 0
|
|
120
|
+
lastFoundInVar = -1
|
|
121
|
+
100.times do
|
|
122
|
+
subst(config)
|
|
123
|
+
break if @@resolvedVars == 0 or (@@resolvedVars >= lastFoundInVar and lastFoundInVar >= 0)
|
|
124
|
+
lastFoundInVar = @@resolvedVars
|
|
125
|
+
end
|
|
126
|
+
if (@@resolvedVars > 0)
|
|
127
|
+
Bake.formatter.printError("Cyclic variable substitution detected", config.file_name)
|
|
128
|
+
ExitHelper.exit(1)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def self.substString(str, elem=nil)
|
|
134
|
+
substStr = ""
|
|
135
|
+
posSubst = 0
|
|
136
|
+
while (true)
|
|
137
|
+
posStart = str.index("$(", posSubst)
|
|
138
|
+
break if posStart.nil?
|
|
139
|
+
posEnd = str.index(")", posStart)
|
|
140
|
+
break if posEnd.nil?
|
|
141
|
+
posStartSub = str.index("$(", posStart+1)
|
|
142
|
+
if (not posStartSub.nil? and posStartSub < posEnd) # = nested vars
|
|
143
|
+
newStr = str[0,posStartSub] + substString(str[posStartSub..posEnd],elem)
|
|
144
|
+
if (str.length + 1 > posEnd)
|
|
145
|
+
str = newStr + str[posEnd+1..-1]
|
|
146
|
+
else
|
|
147
|
+
str = newStr
|
|
148
|
+
end
|
|
149
|
+
next
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
substStr << str[posSubst..posStart-1] if posStart>0
|
|
153
|
+
|
|
154
|
+
@@resolvedVars += 1
|
|
155
|
+
var = str[posStart+2..posEnd-1]
|
|
156
|
+
|
|
157
|
+
splittedVar = var.split(",")
|
|
158
|
+
|
|
159
|
+
if Bake.options.vars.has_key?(var)
|
|
160
|
+
substStr << Bake.options.vars[var]
|
|
161
|
+
elsif @@userVarMap.has_key?(var)
|
|
162
|
+
substStr << @@userVarMap[var]
|
|
163
|
+
elsif var == "MainConfigName"
|
|
164
|
+
substStr << Bake.options.build_config
|
|
165
|
+
elsif var == "MainProjectName"
|
|
166
|
+
substStr << Bake.options.main_project_name
|
|
167
|
+
elsif var == "MainProjectDir"
|
|
168
|
+
substStr << Bake.options.main_dir
|
|
169
|
+
elsif var == "ConfigName"
|
|
170
|
+
substStr << @@configName
|
|
171
|
+
elsif var == "ToolchainName" and defined?@@toolchainName
|
|
172
|
+
substStr << @@toolchainName
|
|
173
|
+
elsif var == "ProjectName"
|
|
174
|
+
substStr << @@projName
|
|
175
|
+
elsif var == "ProjectDir"
|
|
176
|
+
substStr << @@projDir
|
|
177
|
+
elsif var == "OutputDir" or (splittedVar.length == 3 and splittedVar[0] == "OutputDir")
|
|
178
|
+
if (var == "OutputDir")
|
|
179
|
+
out_proj_name = @@projName
|
|
180
|
+
out_conf_name = @@configName
|
|
181
|
+
else
|
|
182
|
+
out_proj_name = splittedVar[1].strip
|
|
183
|
+
out_conf_name = splittedVar[2].strip
|
|
184
|
+
end
|
|
185
|
+
if @@loadedConfig.referencedConfigs.has_key?out_proj_name
|
|
186
|
+
configs = @@loadedConfig.referencedConfigs[out_proj_name]
|
|
187
|
+
config = configs.select {|c| c.name == out_conf_name }.first
|
|
188
|
+
if config
|
|
189
|
+
out_dir = nil
|
|
190
|
+
if (config.toolchain and config.toolchain.outputDir and config.toolchain.outputDir != "")
|
|
191
|
+
out_dir = config.toolchain.outputDir
|
|
192
|
+
else
|
|
193
|
+
out_dir = @@configTcMap[config][:OUTPUT_DIR]
|
|
194
|
+
end
|
|
195
|
+
if not out_dir
|
|
196
|
+
if out_proj_name == Bake.options.main_project_name and out_conf_name == Bake.options.build_config
|
|
197
|
+
out_dir = "build" + Bake.options.buildDirDelimiter + Bake.options.build_config
|
|
198
|
+
else
|
|
199
|
+
out_dir = "build" + Bake.options.buildDirDelimiter + out_conf_name + "_" + Bake.options.main_project_name + "_" + Bake.options.build_config
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
out_dir = substString(out_dir, elem)
|
|
203
|
+
if File.is_absolute?(out_dir)
|
|
204
|
+
substStr << out_dir
|
|
205
|
+
else
|
|
206
|
+
substStr << Pathname.new(File.rel_from_to_project(@@projDir,config.get_project_dir,true) + out_dir).cleanpath.to_s
|
|
207
|
+
end
|
|
208
|
+
else
|
|
209
|
+
if Bake.options.verbose > 0
|
|
210
|
+
msg = "Substitute variable '$(#{var})' with empty string, because config #{out_conf_name} not found for project #{out_proj_name}"
|
|
211
|
+
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
else
|
|
215
|
+
if Bake.options.verbose > 0
|
|
216
|
+
msg = "Substitute variable '$(#{var})' with empty string, because project #{out_proj_name} not found"
|
|
217
|
+
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
elsif splittedVar.length > 1 and splittedVar[0] == "OutputDir"
|
|
221
|
+
if Bake.options.verbose > 0
|
|
222
|
+
msg = "Substitute variable '$(#{var})' with empty string, because syntax of complex variable OutputDir is not $(OutputDir,<project name>,<config name>)"
|
|
223
|
+
Bake.formatter.printInfo(msg, elem ? elem : @@config)
|
|
224
|
+
end
|
|
225
|
+
elsif var == "Time"
|
|
226
|
+
substStr << Time.now.to_s
|
|
227
|
+
elsif var == "Hostname"
|
|
228
|
+
substStr << Socket.gethostname
|
|
229
|
+
elsif var == "ArtifactName"
|
|
230
|
+
substStr << @@artifactName
|
|
231
|
+
elsif var == "ArtifactNameBase"
|
|
232
|
+
substStr << @@artifactName.chomp(File.extname(@@artifactName))
|
|
233
|
+
elsif var == "CPPPath"
|
|
234
|
+
self.lazyPathes
|
|
235
|
+
substStr << @@cppExe
|
|
236
|
+
elsif var == "CPath"
|
|
237
|
+
self.lazyPathes
|
|
238
|
+
substStr << @@cExe
|
|
239
|
+
elsif var == "ASMPath"
|
|
240
|
+
self.lazyPathes
|
|
241
|
+
substStr << @@asmExe
|
|
242
|
+
elsif var == "ArchiverPath"
|
|
243
|
+
self.lazyPathes
|
|
244
|
+
substStr << @@archiverExe
|
|
245
|
+
elsif var == "LinkerPath"
|
|
246
|
+
self.lazyPathes
|
|
247
|
+
substStr << @@linkerExe
|
|
248
|
+
elsif var == "Roots"
|
|
249
|
+
substStr << "___ROOTS___"
|
|
250
|
+
elsif var == "/"
|
|
251
|
+
substStr << File::SEPARATOR
|
|
252
|
+
elsif var == ":"
|
|
253
|
+
substStr << File::PATH_SEPARATOR
|
|
254
|
+
elsif ENV[var]
|
|
255
|
+
substStr << ENV[var]
|
|
256
|
+
else
|
|
257
|
+
if Bake.options.verbose >= 2
|
|
258
|
+
msg = "Substitute variable '$(#{var})' with empty string"
|
|
259
|
+
if elem
|
|
260
|
+
Bake.formatter.printInfo(msg, elem)
|
|
261
|
+
else
|
|
262
|
+
Bake.formatter.printInfo(msg + " in the toolchain", @@config)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
posSubst = posEnd + 1
|
|
268
|
+
end
|
|
269
|
+
substStr << str[posSubst..-1]
|
|
270
|
+
substStr
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def self.substToolchain(elem)
|
|
274
|
+
if Hash === elem
|
|
275
|
+
elem.each do |k, e|
|
|
276
|
+
if Hash === e or Array === e
|
|
277
|
+
substToolchain(e)
|
|
278
|
+
elsif String === e
|
|
279
|
+
elem[k] = substString(e)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
elsif Array === elem
|
|
283
|
+
elem.each_with_index do |e, i|
|
|
284
|
+
if Hash === e or Array === e
|
|
285
|
+
substToolchain(e)
|
|
286
|
+
elsif String === e
|
|
287
|
+
elem[i] = substString(e)
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def self.subst(elem)
|
|
294
|
+
elem.class.ecore.eAllAttributes_derived.each do |a|
|
|
295
|
+
next if a.name == "file_name" or a.name == "line_number"
|
|
296
|
+
return if Metamodel::Set === elem.class
|
|
297
|
+
return if Metamodel::DefaultToolchain === elem
|
|
298
|
+
return if Metamodel::Toolchain === elem.class
|
|
299
|
+
next if a.eType.name != "EString"
|
|
300
|
+
substStr = substString(elem.getGeneric(a.name), elem)
|
|
301
|
+
elem.setGeneric(a.name, substStr)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
childsRefs = elem.class.ecore.eAllReferences.select{|r| r.containment}
|
|
305
|
+
childsRefs.each do |c|
|
|
306
|
+
elem.getGenericAsArray(c.name).each { |child| subst(child) }
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
end
|
|
313
|
+
|