cxxproject 0.4.6 → 0.5.47
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +101 -54
- data/bin/cxx +4 -4
- data/lib/cxxproject/buildingblocks/binary_library.rb +32 -9
- data/lib/cxxproject/buildingblocks/building_block.rb +220 -74
- data/lib/cxxproject/buildingblocks/command_line.rb +70 -21
- data/lib/cxxproject/buildingblocks/custom_building_block.rb +33 -9
- data/lib/cxxproject/buildingblocks/executable.rb +228 -33
- data/lib/cxxproject/buildingblocks/has_dependencies_mixin.rb +69 -43
- data/lib/cxxproject/buildingblocks/has_includes_mixin.rb +20 -0
- data/lib/cxxproject/buildingblocks/has_libraries_mixin.rb +29 -30
- data/lib/cxxproject/buildingblocks/has_sources_mixin.rb +343 -64
- data/lib/cxxproject/buildingblocks/makefile.rb +142 -24
- data/lib/cxxproject/buildingblocks/module.rb +27 -6
- data/lib/cxxproject/buildingblocks/single_source.rb +26 -4
- data/lib/cxxproject/buildingblocks/source_library.rb +113 -20
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +40 -0
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +33 -0
- data/lib/cxxproject/errorparser/error_parser.rb +50 -0
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +29 -0
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +30 -0
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +29 -0
- data/lib/cxxproject/eval_context.rb +136 -0
- data/lib/cxxproject/ext/file.rb +71 -0
- data/lib/cxxproject/ext/filelist.rb +6 -0
- data/lib/cxxproject/ext/progressbar.rb +20 -0
- data/lib/cxxproject/ext/rake.rb +397 -0
- data/lib/cxxproject/{extensions/rake_listener_ext.rb → ext/rake_listener.rb} +18 -12
- data/lib/cxxproject/ext/stdout.rb +44 -0
- data/lib/cxxproject/ide_interface.rb +181 -0
- data/lib/cxxproject/toolchain/clang.rb +39 -0
- data/lib/cxxproject/toolchain/colorizing_formatter.rb +99 -0
- data/lib/cxxproject/toolchain/diab.rb +36 -33
- data/lib/cxxproject/toolchain/gcc.rb +16 -8
- data/lib/cxxproject/toolchain/provider.rb +112 -2
- data/lib/cxxproject/toolchain/ti.rb +50 -0
- data/lib/cxxproject/toolchain/toolchain.rb +38 -0
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +23 -0
- data/lib/cxxproject/torake.rb +181 -123
- data/lib/cxxproject/utils/cleanup.rb +20 -0
- data/lib/cxxproject/utils/console.rb +6 -0
- data/lib/cxxproject/utils/exit_helper.rb +40 -0
- data/lib/cxxproject/utils/graphstream.rb +154 -0
- data/lib/cxxproject/utils/optional.rb +16 -0
- data/lib/cxxproject/utils/printer.rb +50 -0
- data/lib/cxxproject/utils/process.rb +53 -0
- data/lib/cxxproject/utils/progress.rb +66 -0
- data/lib/cxxproject/utils/progress_helper.rb +77 -0
- data/lib/cxxproject/utils/rbcurse.rb +284 -0
- data/lib/cxxproject/utils/rbcurse_executable_ext.rb +14 -0
- data/lib/cxxproject/utils/rbcurse_progress.rb +71 -0
- data/lib/cxxproject/utils/rbcurse_tasktable.rb +51 -0
- data/lib/cxxproject/utils/stats.rb +60 -0
- data/lib/cxxproject/utils/ubigraph.rb +179 -188
- data/lib/cxxproject/utils/utils.rb +29 -25
- data/lib/cxxproject/version.rb +7 -0
- data/lib/cxxproject.rb +13 -7
- data/lib/tools/project_wizard.rb +66 -0
- data/spec/building_block_spec.rb +50 -6
- data/spec/{build_dependencies_spec.rb → cxxproject_2_rake_spec.rb} +82 -65
- data/spec/file_ext_spec.rb +30 -0
- data/spec/ide_interface_spec.rb +41 -0
- data/spec/object_dependency_spec.rb +83 -0
- data/spec/project_path_spec.rb +14 -16
- data/spec/rake_listener_ext_spec.rb +38 -5
- data/spec/spec_helper.rb +18 -0
- data/spec/testdata/basic/lib2/project.rb +1 -1
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
- data/spec/toolchain_spec.rb +29 -0
- metadata +91 -58
- data/lib/cxxproject/extensions/file_ext.rb +0 -47
- data/lib/cxxproject/extensions/rake_ext.rb +0 -158
- data/lib/cxxproject/extensions/stdout_ext.rb +0 -35
- data/lib/cxxproject/task_maker.rb +0 -418
- data/lib/cxxproject/testinstanceeval.rb +0 -65
- data/lib/cxxproject/toolchain/base.rb +0 -98
- data/lib/cxxproject/torake/compiler.rb +0 -10
- data/lib/cxxproject/torake/gcccompiler.rb +0 -7
- data/lib/cxxproject/torake/osxcompiler.rb +0 -7
- data/lib/cxxproject/utils/dot/building_block_graph_writer.rb +0 -19
- data/lib/cxxproject/utils/dot/graph_writer.rb +0 -53
- data/lib/cxxproject/utils/dot/task_graph_writer.rb +0 -34
- data/lib/tools/projectWizard.rb +0 -44
- data/spec/dir_spec.rb +0 -13
- /data/lib/cxxproject/{extensions/rake_dirty_ext.rb → ext/rake_dirty.rb} +0 -0
- /data/lib/cxxproject/{extensions/string_ext.rb → ext/string.rb} +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cxxproject/utils/utils'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
require 'cxxproject/errorparser/error_parser'
|
4
|
+
require 'cxxproject/errorparser/gcc_compiler_error_parser'
|
5
|
+
|
6
|
+
module Cxxproject
|
7
|
+
module Toolchain
|
8
|
+
gccCompilerErrorParser = GCCCompilerErrorParser.new
|
9
|
+
|
10
|
+
CLANG_CHAIN = Provider.add("CLANG")
|
11
|
+
|
12
|
+
CLANG_CHAIN[:COMPILER][:CPP].update({
|
13
|
+
:COMMAND => "llvm-g++",
|
14
|
+
:DEFINE_FLAG => "-D",
|
15
|
+
:OBJECT_FILE_FLAG => "-o",
|
16
|
+
:INCLUDE_PATH_FLAG => "-I",
|
17
|
+
:COMPILE_FLAGS => "-c ",
|
18
|
+
:DEP_FLAGS => "-MMD -MF ", # empty space at the end is important!
|
19
|
+
:ERROR_PARSER => gccCompilerErrorParser
|
20
|
+
})
|
21
|
+
|
22
|
+
CLANG_CHAIN[:COMPILER][:C] = Utils.deep_copy(CLANG_CHAIN[:COMPILER][:CPP])
|
23
|
+
CLANG_CHAIN[:COMPILER][:C][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:C][:SOURCE_FILE_ENDINGS]
|
24
|
+
CLANG_CHAIN[:COMPILER][:C][:COMMAND] = "llvm-gcc"
|
25
|
+
|
26
|
+
CLANG_CHAIN[:COMPILER][:ASM] = Utils.deep_copy(CLANG_CHAIN[:COMPILER][:C])
|
27
|
+
CLANG_CHAIN[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
28
|
+
|
29
|
+
CLANG_CHAIN[:ARCHIVER][:COMMAND] = "ar"
|
30
|
+
CLANG_CHAIN[:ARCHIVER][:ARCHIVE_FLAGS] = "r"
|
31
|
+
|
32
|
+
CLANG_CHAIN[:LINKER][:COMMAND] = "llvm-g++"
|
33
|
+
CLANG_CHAIN[:LINKER][:SCRIPT] = "-T"
|
34
|
+
CLANG_CHAIN[:LINKER][:USER_LIB_FLAG] = "-l:"
|
35
|
+
CLANG_CHAIN[:LINKER][:EXE_FLAG] = "-o"
|
36
|
+
CLANG_CHAIN[:LINKER][:LIB_FLAG] = "-l"
|
37
|
+
CLANG_CHAIN[:LINKER][:LIB_PATH_FLAG] = "-L"
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'cxxproject/utils/optional'
|
2
|
+
|
3
|
+
module Cxxproject
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
class ColorizingFormatter
|
7
|
+
class << self
|
8
|
+
attr_accessor :enabled
|
9
|
+
end
|
10
|
+
def enabled?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
define_colorizin_formatter = lambda do
|
16
|
+
require 'colored'
|
17
|
+
|
18
|
+
# simple class to colorize compiler output
|
19
|
+
# the class depends on the rainbow gem
|
20
|
+
class ColorizingFormatter
|
21
|
+
|
22
|
+
# colors are not instance vars due to caching the building blocks
|
23
|
+
def self.setColorScheme(scheme)
|
24
|
+
if scheme == :black
|
25
|
+
@@warning_color = :yellow
|
26
|
+
@@error_color = :red
|
27
|
+
@@info_color = :white
|
28
|
+
@@additional_info_color = :cyan
|
29
|
+
@@success_color = :green
|
30
|
+
elsif scheme == :white
|
31
|
+
@@warning_color = :magenta
|
32
|
+
@@error_color = :red
|
33
|
+
@@info_color = :black
|
34
|
+
@@additional_info_color = :blue
|
35
|
+
@@success_color = :green
|
36
|
+
end
|
37
|
+
end
|
38
|
+
ColorizingFormatter.setColorScheme(:black) # default
|
39
|
+
|
40
|
+
def printError(str)
|
41
|
+
[@@error_color,:bold].inject(str) {|m,x| m.send(x)}
|
42
|
+
end
|
43
|
+
|
44
|
+
def printWarning(str)
|
45
|
+
[@@warning_color,:bold].inject(str) {|m,x| m.send(x)}
|
46
|
+
end
|
47
|
+
|
48
|
+
def printInfo(str)
|
49
|
+
[@@info_color,:bold].inject(str) {|m,x| m.send(x)}
|
50
|
+
end
|
51
|
+
|
52
|
+
def printAdditionalInfo(str)
|
53
|
+
[@@additional_info_color,:bold].inject(str) {|m,x| m.send(x)}
|
54
|
+
end
|
55
|
+
|
56
|
+
def printSuccess(str)
|
57
|
+
[@@success_color,:bold].inject(str) {|m,x| m.send(x)}
|
58
|
+
end
|
59
|
+
|
60
|
+
# formats several lines of usually compiler output
|
61
|
+
def format(compiler_output, error_descs, error_parser)
|
62
|
+
return compiler_output if not enabled?
|
63
|
+
res = ""
|
64
|
+
begin
|
65
|
+
zipped = compiler_output.split($/).zip(error_descs)
|
66
|
+
zipped.each do |l,desc|
|
67
|
+
if desc.severity != 255
|
68
|
+
coloring = {}
|
69
|
+
if desc.severity == ErrorParser::SEVERITY_WARNING
|
70
|
+
res << printWarning(l)
|
71
|
+
elsif desc.severity == ErrorParser::SEVERITY_ERROR
|
72
|
+
res << printError(l)
|
73
|
+
else
|
74
|
+
res << printInfo(l)
|
75
|
+
end
|
76
|
+
else
|
77
|
+
res << l
|
78
|
+
end
|
79
|
+
res << "\n"
|
80
|
+
end
|
81
|
+
rescue Exception => e
|
82
|
+
puts "Error while parsing compiler output: #{e}"
|
83
|
+
return compiler_output
|
84
|
+
end
|
85
|
+
res
|
86
|
+
end
|
87
|
+
|
88
|
+
# getter to access the static variable with an instance
|
89
|
+
def enabled?
|
90
|
+
return ColorizingFormatter.enabled
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
Utils.optional_package(define_colorizin_formatter, nil)
|
98
|
+
|
99
|
+
end
|
@@ -1,47 +1,50 @@
|
|
1
|
-
require 'cxxproject/toolchain/
|
1
|
+
require 'cxxproject/toolchain/provider'
|
2
2
|
require 'cxxproject/utils/utils'
|
3
|
+
require 'cxxproject/errorparser/diab_compiler_error_parser'
|
4
|
+
require 'cxxproject/errorparser/diab_linker_error_parser'
|
3
5
|
|
4
6
|
module Cxxproject
|
5
7
|
module Toolchain
|
6
8
|
|
7
|
-
|
9
|
+
DiabChain = Provider.add("Diab")
|
8
10
|
|
9
|
-
|
11
|
+
DiabChain[:COMPILER][:C].update({
|
10
12
|
:COMMAND => "dcc",
|
11
|
-
:FLAGS => "
|
13
|
+
:FLAGS => "",
|
12
14
|
:DEFINE_FLAG => "-D",
|
13
|
-
:OBJECT_FILE_FLAG => "-o",
|
15
|
+
:OBJECT_FILE_FLAG => "-o ",
|
14
16
|
:INCLUDE_PATH_FLAG => "-I",
|
15
17
|
:COMPILE_FLAGS => "-c",
|
16
|
-
:DEP_FLAGS => "-Xmake-dependency=6 -Xmake-dependency-savefile="
|
18
|
+
:DEP_FLAGS => "-Xmake-dependency=6 -Xmake-dependency-savefile=",
|
19
|
+
:DEP_FLAGS_SPACE => false
|
17
20
|
})
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
22
|
+
DiabChain[:COMPILER][:CPP] = Utils.deep_copy(DiabChain[:COMPILER][:C])
|
23
|
+
DiabChain[:COMPILER][:CPP][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:CPP][:SOURCE_FILE_ENDINGS]
|
24
|
+
|
25
|
+
DiabChain[:COMPILER][:ASM] = Utils.deep_copy(DiabChain[:COMPILER][:C])
|
26
|
+
DiabChain[:COMPILER][:ASM][:COMMAND] = "das"
|
27
|
+
DiabChain[:COMPILER][:ASM][:COMPILE_FLAGS] = ""
|
28
|
+
DiabChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
29
|
+
|
30
|
+
DiabChain[:ARCHIVER][:COMMAND] = "dar"
|
31
|
+
DiabChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-rc"
|
32
|
+
|
33
|
+
DiabChain[:LINKER][:COMMAND] = "dcc"
|
34
|
+
DiabChain[:LINKER][:SCRIPT] = "-Wm"
|
35
|
+
DiabChain[:LINKER][:USER_LIB_FLAG] = "-l:"
|
36
|
+
DiabChain[:LINKER][:EXE_FLAG] = "-o"
|
37
|
+
DiabChain[:LINKER][:LIB_FLAG] = "-l"
|
38
|
+
DiabChain[:LINKER][:LIB_PATH_FLAG] = "-L"
|
39
|
+
DiabChain[:LINKER][:MAP_FILE_FLAG] = "-Wl,-m6" # no map file if this string is empty, otherwise -Wl,-m6>abc.map
|
40
|
+
DiabChain[:LINKER][:OUTPUT_ENDING] = ".elf"
|
41
|
+
|
42
|
+
diabCompilerErrorParser = DiabCompilerErrorParser.new
|
43
|
+
DiabChain[:COMPILER][:C][:ERROR_PARSER] = diabCompilerErrorParser
|
44
|
+
DiabChain[:COMPILER][:CPP][:ERROR_PARSER] = diabCompilerErrorParser
|
45
|
+
DiabChain[:COMPILER][:ASM][:ERROR_PARSER] = diabCompilerErrorParser
|
46
|
+
DiabChain[:ARCHIVER][:ERROR_PARSER] = diabCompilerErrorParser
|
47
|
+
DiabChain[:LINKER][:ERROR_PARSER] = DiabLinkerErrorParser.new
|
48
|
+
|
46
49
|
end
|
47
50
|
end
|
@@ -1,18 +1,22 @@
|
|
1
|
-
require 'cxxproject/toolchain/base'
|
2
1
|
require 'cxxproject/utils/utils'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
require 'cxxproject/errorparser/error_parser'
|
4
|
+
require 'cxxproject/errorparser/gcc_compiler_error_parser'
|
5
|
+
require 'cxxproject/errorparser/gcc_linker_error_parser'
|
3
6
|
|
4
7
|
module Cxxproject
|
5
8
|
module Toolchain
|
6
|
-
|
9
|
+
|
7
10
|
GCCChain = Provider.add("GCC")
|
8
11
|
|
9
12
|
GCCChain[:COMPILER][:CPP].update({
|
10
13
|
:COMMAND => "g++",
|
11
14
|
:DEFINE_FLAG => "-D",
|
12
|
-
:OBJECT_FILE_FLAG => "-o",
|
15
|
+
:OBJECT_FILE_FLAG => "-o ",
|
13
16
|
:INCLUDE_PATH_FLAG => "-I",
|
14
17
|
:COMPILE_FLAGS => "-c ",
|
15
|
-
:DEP_FLAGS => "-MMD -MF
|
18
|
+
:DEP_FLAGS => "-MMD -MF",
|
19
|
+
:DEP_FLAGS_SPACE => true
|
16
20
|
})
|
17
21
|
|
18
22
|
GCCChain[:COMPILER][:C] = Utils.deep_copy(GCCChain[:COMPILER][:CPP])
|
@@ -23,7 +27,7 @@ module Cxxproject
|
|
23
27
|
GCCChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
24
28
|
|
25
29
|
GCCChain[:ARCHIVER][:COMMAND] = "ar"
|
26
|
-
GCCChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-
|
30
|
+
GCCChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-rc"
|
27
31
|
|
28
32
|
GCCChain[:LINKER][:COMMAND] = "g++"
|
29
33
|
GCCChain[:LINKER][:SCRIPT] = "-T"
|
@@ -31,9 +35,13 @@ module Cxxproject
|
|
31
35
|
GCCChain[:LINKER][:EXE_FLAG] = "-o"
|
32
36
|
GCCChain[:LINKER][:LIB_FLAG] = "-l"
|
33
37
|
GCCChain[:LINKER][:LIB_PATH_FLAG] = "-L"
|
34
|
-
GCCChain[:LINKER][:FLAGS] = "-all_load"
|
35
|
-
GCCChain[:LINKER][:LIB_PREFIX_FLAGS] = "-Wl,--whole-archive"
|
36
|
-
GCCChain[:LINKER][:LIB_POSTFIX_FLAGS] = "-Wl,--no-whole-archive"
|
37
38
|
|
39
|
+
gccCompilerErrorParser = GCCCompilerErrorParser.new
|
40
|
+
GCCChain[:COMPILER][:C][:ERROR_PARSER] = gccCompilerErrorParser
|
41
|
+
GCCChain[:COMPILER][:CPP][:ERROR_PARSER] = gccCompilerErrorParser
|
42
|
+
GCCChain[:COMPILER][:ASM][:ERROR_PARSER] = gccCompilerErrorParser
|
43
|
+
GCCChain[:ARCHIVER][:ERROR_PARSER] = gccCompilerErrorParser
|
44
|
+
GCCChain[:LINKER][:ERROR_PARSER] = GCCLinkerErrorParser.new
|
45
|
+
|
38
46
|
end
|
39
47
|
end
|
@@ -1,18 +1,128 @@
|
|
1
|
-
require 'cxxproject/toolchain/
|
2
|
-
require 'cxxproject/toolchain/gcc'
|
1
|
+
require 'cxxproject/toolchain/colorizing_formatter'
|
3
2
|
|
4
3
|
module Cxxproject
|
5
4
|
module Toolchain
|
6
5
|
|
7
6
|
class Provider
|
7
|
+
@@settings = {}
|
8
|
+
@@default = {
|
9
|
+
:COMPILER =>
|
10
|
+
{
|
11
|
+
:CPP => {
|
12
|
+
:COMMAND => "",
|
13
|
+
:DEFINE_FLAG => "",
|
14
|
+
:OBJECT_FILE_FLAG => "",
|
15
|
+
:INCLUDE_PATH_FLAG => "",
|
16
|
+
:COMPILE_FLAGS => "",
|
17
|
+
:DEFINES => [],
|
18
|
+
:FLAGS => "",
|
19
|
+
:SOURCE_FILE_ENDINGS => [".cxx", ".cpp", ".c++", ".cc", ".C"],
|
20
|
+
:DEP_FLAGS => "",
|
21
|
+
:DEP_FLAGS => true,
|
22
|
+
:ERROR_PARSER => nil
|
23
|
+
},
|
24
|
+
:C => {
|
25
|
+
:COMMAND => "",
|
26
|
+
:DEFINE_FLAG => "",
|
27
|
+
:OBJECT_FILE_FLAG => "",
|
28
|
+
:INCLUDE_PATH_FLAG => "",
|
29
|
+
:COMPILE_FLAGS => "",
|
30
|
+
:DEFINES => [],
|
31
|
+
:FLAGS => "",
|
32
|
+
:SOURCE_FILE_ENDINGS => [".c"],
|
33
|
+
:DEP_FLAGS => "",
|
34
|
+
:ERROR_PARSER => nil
|
35
|
+
},
|
36
|
+
:ASM => {
|
37
|
+
:COMMAND => "",
|
38
|
+
:DEFINE_FLAG => "",
|
39
|
+
:OBJECT_FILE_FLAG => "",
|
40
|
+
:INCLUDE_PATH_FLAG => "",
|
41
|
+
:COMPILE_FLAGS => "",
|
42
|
+
:DEFINES => [],
|
43
|
+
:FLAGS => "",
|
44
|
+
:SOURCE_FILE_ENDINGS => [".asm", ".s", ".S"],
|
45
|
+
:DEP_FLAGS => "",
|
46
|
+
:ERROR_PARSER => nil
|
47
|
+
}
|
48
|
+
},
|
49
|
+
|
50
|
+
:ARCHIVER =>
|
51
|
+
{
|
52
|
+
:COMMAND => "",
|
53
|
+
:ARCHIVE_FLAGS => "",
|
54
|
+
:FLAGS => "",
|
55
|
+
:ERROR_PARSER => nil
|
56
|
+
},
|
57
|
+
|
58
|
+
:LINKER =>
|
59
|
+
{
|
60
|
+
:COMMAND => "",
|
61
|
+
:MUST_FLAGS => "",
|
62
|
+
:SCRIPT => "",
|
63
|
+
:USER_LIB_FLAG => "",
|
64
|
+
:EXE_FLAG => "",
|
65
|
+
:LIB_FLAG => "",
|
66
|
+
:LIB_PATH_FLAG => "",
|
67
|
+
:LIB_PREFIX_FLAGS => "", # "-Wl,--whole-archive",
|
68
|
+
:LIB_POSTFIX_FLAGS => "", # "-Wl,--no-whole-archive",
|
69
|
+
:FLAGS => "",
|
70
|
+
:MAP_FILE_FLAG => "",
|
71
|
+
:OUTPUT_ENDING => ".exe", # or .elf
|
72
|
+
:ERROR_PARSER => nil
|
73
|
+
},
|
74
|
+
|
75
|
+
:MAKE =>
|
76
|
+
{
|
77
|
+
:COMMAND => "make",
|
78
|
+
:FLAGS => "-j",
|
79
|
+
:FILE_FLAG => "-f",
|
80
|
+
:DIR_FLAG => "-C",
|
81
|
+
:CLEAN => "clean"
|
82
|
+
},
|
83
|
+
|
84
|
+
:CONSOLE_HIGHLIGHTER => ColorizingFormatter.new
|
85
|
+
}
|
86
|
+
|
87
|
+
def self.add(name, basedOn = nil)
|
88
|
+
chain = Marshal.load(Marshal.dump(basedOn.nil? ? @@default : @@settings[basedOn]))
|
89
|
+
@@settings[name] = chain
|
90
|
+
chain
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.default
|
94
|
+
@@default
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.modify_cpp_compiler(based_on, h)
|
98
|
+
chain = Marshal.load(Marshal.dump(@@settings[based_on]))
|
99
|
+
chain[:COMPILER][:CPP].update(h)
|
100
|
+
chain
|
101
|
+
end
|
8
102
|
|
9
103
|
def self.[](name)
|
104
|
+
|
105
|
+
if name == "TI"
|
106
|
+
if not ENV['TI_HOME']
|
107
|
+
Printer.printError "Error: Please set TI_HOME"
|
108
|
+
ExitHelper.exit(1)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
10
112
|
return @@settings[name] if @@settings.include? name
|
11
113
|
nil
|
12
114
|
end
|
13
115
|
|
116
|
+
def self.list
|
117
|
+
return @@settings
|
118
|
+
end
|
14
119
|
|
15
120
|
end
|
16
121
|
|
17
122
|
end
|
18
123
|
end
|
124
|
+
|
125
|
+
require 'cxxproject/toolchain/diab'
|
126
|
+
require 'cxxproject/toolchain/gcc'
|
127
|
+
require 'cxxproject/toolchain/clang'
|
128
|
+
require 'cxxproject/toolchain/ti'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'cxxproject/utils/utils'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
require 'cxxproject/errorparser/error_parser'
|
4
|
+
require 'cxxproject/errorparser/ti_compiler_error_parser'
|
5
|
+
require 'cxxproject/errorparser/ti_linker_error_parser'
|
6
|
+
|
7
|
+
module Cxxproject
|
8
|
+
module Toolchain
|
9
|
+
|
10
|
+
TiChain = Provider.add("TI")
|
11
|
+
|
12
|
+
ti_home = ENV['TI_HOME']
|
13
|
+
|
14
|
+
TiChain[:COMPILER][:CPP].update({
|
15
|
+
:COMMAND => "#{ti_home}/ccsv5/tools/compiler/tms470/bin/cl470",
|
16
|
+
:FLAGS => "-mv7A8 -g --include_path=\"#{ti_home}/ccsv5/tools/compiler/tms470/include\" --diag_warning=225 -me --abi=eabi --code_state=32 --preproc_with_compile",
|
17
|
+
:DEFINE_FLAG => "--define=",
|
18
|
+
:OBJECT_FILE_FLAG => "--output_file=",
|
19
|
+
:INCLUDE_PATH_FLAG => "--include_path=",
|
20
|
+
:COMPILE_FLAGS => "-c ",
|
21
|
+
:DEP_FLAGS => "--preproc_dependency=",
|
22
|
+
:DEP_FLAGS_SPACE => false
|
23
|
+
})
|
24
|
+
|
25
|
+
TiChain[:COMPILER][:C] = Utils.deep_copy(TiChain[:COMPILER][:CPP])
|
26
|
+
TiChain[:COMPILER][:C][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:C][:SOURCE_FILE_ENDINGS]
|
27
|
+
|
28
|
+
TiChain[:COMPILER][:ASM] = Utils.deep_copy(TiChain[:COMPILER][:C])
|
29
|
+
TiChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
30
|
+
|
31
|
+
TiChain[:ARCHIVER][:COMMAND] = "#{ti_home}/ccsv5/tools/compiler/tms470/bin/ar470"
|
32
|
+
TiChain[:ARCHIVER][:ARCHIVE_FLAGS] = "r"
|
33
|
+
|
34
|
+
TiChain[:LINKER][:COMMAND] = "#{ti_home}/ccsv5/tools/compiler/tms470/bin/cl470"
|
35
|
+
TiChain[:LINKER][:FLAGS] = "-mv7A8 -g --diag_warning=225 -me --abi=eabi --code_state=32 -z --warn_sections -i\"#{ti_home}/ccsv5/tools/compiler/tms470/lib\" -i\"#{ti_home}/ccsv5/tools/compiler/tms470/include\""
|
36
|
+
TiChain[:LINKER][:MAP_FILE_FLAG] = '-m'
|
37
|
+
TiChain[:LINKER][:EXE_FLAG] = "-o"
|
38
|
+
TiChain[:LINKER][:LIB_PREFIX_FLAGS] = '-lDebug/configPkg/linker.cmd'
|
39
|
+
TiChain[:LINKER][:LIB_FLAG] = "-l"
|
40
|
+
TiChain[:LINKER][:LIB_PATH_FLAG] = "-i"
|
41
|
+
|
42
|
+
tiCompilerErrorParser = TICompilerErrorParser.new
|
43
|
+
TiChain[:COMPILER][:C][:ERROR_PARSER] = tiCompilerErrorParser
|
44
|
+
TiChain[:COMPILER][:CPP][:ERROR_PARSER] = tiCompilerErrorParser
|
45
|
+
TiChain[:COMPILER][:ASM][:ERROR_PARSER] = tiCompilerErrorParser
|
46
|
+
TiChain[:ARCHIVER][:ERROR_PARSER] = tiCompilerErrorParser
|
47
|
+
TiChain[:LINKER][:ERROR_PARSER] = TILinkerErrorParser.new
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
def method_missing(m, *args, &block)
|
5
|
+
if m.to_s =~ /(.*)=$/ # was assignment
|
6
|
+
self[$1] = args[0]
|
7
|
+
else
|
8
|
+
fetch(m.to_s, nil)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
def recursive_merge(h)
|
12
|
+
self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.recursive_merge(_new) else _new end }
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
class Toolchain
|
18
|
+
attr_reader :toolchain
|
19
|
+
def initialize(toolchain_file)
|
20
|
+
@toolchain = YAML::load(File.open(toolchain_file))
|
21
|
+
if @toolchain.base
|
22
|
+
@based_on = @toolchain.base
|
23
|
+
else
|
24
|
+
@based_on = "base"
|
25
|
+
end
|
26
|
+
basechain = YAML::load(File.open(File.join(File.dirname(__FILE__),"#{@based_on}.json")))
|
27
|
+
@toolchain = basechain.recursive_merge(@toolchain)
|
28
|
+
end
|
29
|
+
def method_missing(m, *args, &block)
|
30
|
+
if @toolchain[m.to_s]
|
31
|
+
self.class.send(:define_method, m) { @toolchain[m.to_s] }
|
32
|
+
@toolchain[m.to_s]
|
33
|
+
else
|
34
|
+
return super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'toolchain'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
Benchmark.bm do |x|
|
6
|
+
|
7
|
+
n = 1000
|
8
|
+
x.report("load Toolchain #{n}-times") do
|
9
|
+
n.times do
|
10
|
+
tc = Toolchain.new('gcc.json')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
tc = Toolchain.new('gcc.json')
|
15
|
+
n = 1000000
|
16
|
+
x.report("access fields as methods #{n}-times") do
|
17
|
+
n.times do
|
18
|
+
x = tc.compiler.c.source_file_endings
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|