cxxproject 0.6.1 → 0.6.2
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.
- data/lib/cxxproject/context.rb +23 -0
- data/lib/cxxproject/eval_context.rb +8 -28
- data/lib/cxxproject/plugin_context.rb +132 -0
- data/lib/cxxproject/toolchain/provider.rb +26 -6
- data/lib/cxxproject/torake.rb +40 -67
- data/lib/cxxproject/version.rb +1 -1
- data/lib/cxxproject.rb +5 -0
- data/spec/building_block_spec.rb +5 -4
- data/spec/cxxproject_2_rake_spec.rb +1 -1
- data/spec/object_dependency_spec.rb +4 -4
- data/spec/plugin_context_spec.rb +57 -0
- data/spec/project_path_spec.rb +1 -1
- data/spec/provider_spec.rb +39 -0
- data/spec/testdata/multiple_levels/libs/lib2/project.rb +1 -1
- data/spec/testdata/onlyOneHeader/Rakefile.rb +1 -1
- metadata +53 -60
- data/lib/cxxproject/errorparser/diab_compiler_error_parser.rb +0 -40
- data/lib/cxxproject/errorparser/diab_linker_error_parser.rb +0 -41
- data/lib/cxxproject/errorparser/gcc_compiler_error_parser.rb +0 -35
- data/lib/cxxproject/errorparser/gcc_linker_error_parser.rb +0 -35
- data/lib/cxxproject/errorparser/ti_compiler_error_parser.rb +0 -30
- data/lib/cxxproject/errorparser/ti_linker_error_parser.rb +0 -30
- data/lib/cxxproject/toolchain/clang.rb +0 -39
- data/lib/cxxproject/toolchain/diab.rb +0 -52
- data/lib/cxxproject/toolchain/gcc.rb +0 -48
- data/lib/cxxproject/toolchain/ti.rb +0 -50
- data/lib/cxxproject/toolchain/toolchain_benchmark.rb +0 -23
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module Cxxproject
|
3
|
+
module Context
|
4
|
+
|
5
|
+
def check_hash(hash,allowed)
|
6
|
+
hash.keys.map do |k|
|
7
|
+
error_string = ["error while evaluating \"#{@current_working_dir}/#{@current_project_file}\"",
|
8
|
+
"\"#{k}\" is not a valid specifier!",
|
9
|
+
"allowd specifiers: #{allowed}"].join($/)
|
10
|
+
raise error_string unless allowed.include?(k)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_as_array(hash, s)
|
15
|
+
res = hash[s]
|
16
|
+
if res.is_a?(Array)
|
17
|
+
return res
|
18
|
+
end
|
19
|
+
return [res]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cxxproject/context'
|
1
2
|
|
2
3
|
module Cxxproject
|
3
4
|
class BinaryLibs
|
@@ -13,13 +14,14 @@ module Cxxproject
|
|
13
14
|
end
|
14
15
|
|
15
16
|
class EvalContext
|
17
|
+
include Context
|
16
18
|
|
17
|
-
attr_accessor :
|
19
|
+
attr_accessor :all_blocks
|
18
20
|
|
19
21
|
# must be called to add building blocks
|
20
22
|
def cxx_configuration(&block)
|
21
|
-
@myblock = block
|
22
23
|
@all_blocks = []
|
24
|
+
block.call
|
23
25
|
end
|
24
26
|
|
25
27
|
def eval_project(project_text, project_file, pwd)
|
@@ -28,28 +30,6 @@ module Cxxproject
|
|
28
30
|
instance_eval(project_text)
|
29
31
|
end
|
30
32
|
|
31
|
-
def configuration(*args, &block)
|
32
|
-
name = args[0]
|
33
|
-
raise "no name given" unless name.is_a?(String) && !name.strip.empty?
|
34
|
-
instance_eval(&block)
|
35
|
-
end
|
36
|
-
|
37
|
-
def check_hash(hash,allowed)
|
38
|
-
hash.keys.map do |k|
|
39
|
-
error_string = ["error while evaluating \"#{@current_working_dir}/#{@current_project_file}\"",
|
40
|
-
"\"#{k}\" is not a valid specifier!"].join($/)
|
41
|
-
raise error_string unless allowed.include?(k)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def get_as_array(hash, s)
|
46
|
-
res = hash[s]
|
47
|
-
if res.is_a?(Array)
|
48
|
-
return res
|
49
|
-
end
|
50
|
-
return [res]
|
51
|
-
end
|
52
|
-
|
53
33
|
# specify an executable
|
54
34
|
# hash supports:
|
55
35
|
# * :sources
|
@@ -59,7 +39,7 @@ module Cxxproject
|
|
59
39
|
# * :output_dir
|
60
40
|
def exe(name, hash)
|
61
41
|
raise "not a hash" unless hash.is_a?(Hash)
|
62
|
-
check_hash
|
42
|
+
check_hash(hash,[:sources,:includes,:dependencies,:libpath,:output_dir])
|
63
43
|
bblock = Executable.new(name)
|
64
44
|
bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
|
65
45
|
bblock.set_includes(get_as_array(hash, :includes)) if hash.has_key?(:includes)
|
@@ -94,7 +74,7 @@ module Cxxproject
|
|
94
74
|
# * :output_dir
|
95
75
|
def source_lib(name, hash)
|
96
76
|
raise "not a hash" unless hash.is_a?(Hash)
|
97
|
-
check_hash
|
77
|
+
check_hash(hash,[:sources, :includes, :dependencies, :toolchain, :file_dependencies, :output_dir])
|
98
78
|
raise ":sources need to be defined" unless hash.has_key?(:sources)
|
99
79
|
bblock = SourceLibrary.new(name)
|
100
80
|
bblock.set_sources(hash[:sources])
|
@@ -122,7 +102,7 @@ module Cxxproject
|
|
122
102
|
|
123
103
|
def compile(name, hash)
|
124
104
|
raise "not a hash" unless hash.is_a?(Hash)
|
125
|
-
check_hash
|
105
|
+
check_hash(hash,[:sources,:includes])
|
126
106
|
bblock = SingleSource.new(name)
|
127
107
|
bblock.set_sources(hash[:sources]) if hash.has_key?(:sources)
|
128
108
|
bblock.set_includes(hash[:includes]) if hash.has_key?(:includes)
|
@@ -131,7 +111,7 @@ module Cxxproject
|
|
131
111
|
|
132
112
|
def custom(name, hash)
|
133
113
|
raise "not a hash" unless hash.is_a?(Hash)
|
134
|
-
check_hash
|
114
|
+
check_hash(hash,[:execute, :dependencies])
|
135
115
|
bblock = CustomBuildingBlock.new(name)
|
136
116
|
bblock.set_actions(hash[:execute]) if hash.has_key?(:execute)
|
137
117
|
if hash.has_key?(:dependencies)
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'cxxproject/context'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
|
4
|
+
module Cxxproject
|
5
|
+
# context in which plugins are evaluated
|
6
|
+
# a cxx_plugin is a gem that:
|
7
|
+
# - follows the naming convention cxxplugin_name
|
8
|
+
# - that has a plugin.rb file in lib and
|
9
|
+
# - that calls cxx_plugin
|
10
|
+
#
|
11
|
+
# the context contains
|
12
|
+
# - @cxxproject2rake
|
13
|
+
# - @building_blocks
|
14
|
+
# - @log
|
15
|
+
class PluginContext
|
16
|
+
include Context
|
17
|
+
|
18
|
+
def initialize(cxxproject2rake, building_blocks, log)
|
19
|
+
@cxxproject2rake = cxxproject2rake
|
20
|
+
@building_blocks = building_blocks
|
21
|
+
@log = log
|
22
|
+
end
|
23
|
+
|
24
|
+
# method for plugins to get the
|
25
|
+
# cxxproject2rake
|
26
|
+
# building_blocks
|
27
|
+
# log
|
28
|
+
def cxx_plugin(&blk)
|
29
|
+
blk.call(@cxxproject2rake, @building_blocks, @log)
|
30
|
+
end
|
31
|
+
|
32
|
+
# specify a toolchain
|
33
|
+
# hash supports:
|
34
|
+
# * :command
|
35
|
+
def toolchain(name, tc)
|
36
|
+
raise "not a tc" unless tc.is_a?(Hash)
|
37
|
+
check_hash(tc,Provider.default.keys)
|
38
|
+
check_compiler(tc[:COMPILER]) if tc[:COMPILER]
|
39
|
+
check_linker(tc[:LINKER]) if tc[:LINKER]
|
40
|
+
check_archiver(tc[:ARCHIVER]) if tc[:ARCHIVER]
|
41
|
+
PluginContext::expand(tc)
|
42
|
+
Provider.add(name)
|
43
|
+
Provider.merge(Provider[name], tc)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.expand(toolchain)
|
47
|
+
to_expand = nil
|
48
|
+
from = nil
|
49
|
+
while (needs_expansion(toolchain)) do
|
50
|
+
to_expand = find_toolchain_subhash(toolchain)
|
51
|
+
from = find_toolchain_element(toolchain,to_expand[:BASED_ON])
|
52
|
+
to_expand.delete(:BASED_ON)
|
53
|
+
Cxxproject::Toolchain::Provider.merge(to_expand,from,false)
|
54
|
+
end
|
55
|
+
return toolchain
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.needs_expansion(tc)
|
59
|
+
res = false
|
60
|
+
tc.each do |k,v|
|
61
|
+
if k == :BASED_ON
|
62
|
+
res = true
|
63
|
+
elsif v.is_a?(Hash)
|
64
|
+
res = needs_expansion(v)
|
65
|
+
end
|
66
|
+
if res
|
67
|
+
break
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return res
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.find_toolchain_subhash(tc)
|
74
|
+
res = []
|
75
|
+
loop = lambda do |res,tc|
|
76
|
+
tc.each do |k,v|
|
77
|
+
if(k == :BASED_ON)
|
78
|
+
res << tc
|
79
|
+
elsif v.is_a?(Hash)
|
80
|
+
loop.call(res,v)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
loop.call(res,tc)
|
85
|
+
return res[0] if res.length > 0
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def self.find_toolchain_element(tc,name)
|
90
|
+
res = []
|
91
|
+
loop = lambda do |res,tc,name|
|
92
|
+
tc.each do |k,v|
|
93
|
+
if k == name
|
94
|
+
res << v
|
95
|
+
elsif v.is_a?(Hash)
|
96
|
+
loop.call(res,v,name)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
loop.call(res,tc,name)
|
101
|
+
return res[0] if res.length > 0
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def check_compiler(hash)
|
106
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
107
|
+
check_hash(hash,Provider.default[:COMPILER].keys)
|
108
|
+
|
109
|
+
check_hash(hash[:CPP],Provider.default[:COMPILER][:CPP].keys << :BASED_ON) if hash[:CPP]
|
110
|
+
check_hash(hash[:C],Provider.default[:COMPILER][:C].keys << :BASED_ON) if hash[:C]
|
111
|
+
check_hash(hash[:ASM],Provider.default[:COMPILER][:ASM].keys << :BASED_ON) if hash[:ASM]
|
112
|
+
end
|
113
|
+
|
114
|
+
def check_linker(hash)
|
115
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
116
|
+
check_hash(hash,Provider.default[:LINKER].keys)
|
117
|
+
end
|
118
|
+
|
119
|
+
def check_archiver(hash)
|
120
|
+
raise "not a hash" unless hash.is_a?(Hash)
|
121
|
+
check_hash(hash,Provider.default[:ARCHIVER].keys)
|
122
|
+
end
|
123
|
+
|
124
|
+
# will use the content of the plugin.rb file and evaluate it
|
125
|
+
# this will in turn result in a call to cxx_plugin
|
126
|
+
def eval_plugin(plugin_text)
|
127
|
+
instance_eval(plugin_text)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
@@ -18,7 +18,7 @@ module Cxxproject
|
|
18
18
|
:FLAGS => "",
|
19
19
|
:SOURCE_FILE_ENDINGS => [".cxx", ".cpp", ".c++", ".cc", ".C"],
|
20
20
|
:DEP_FLAGS => "",
|
21
|
-
:
|
21
|
+
:DEP_FLAGS_SPACE => false,
|
22
22
|
:ERROR_PARSER => nil,
|
23
23
|
:PREPRO_FLAGS => ""
|
24
24
|
},
|
@@ -32,6 +32,7 @@ module Cxxproject
|
|
32
32
|
:FLAGS => "",
|
33
33
|
:SOURCE_FILE_ENDINGS => [".c"],
|
34
34
|
:DEP_FLAGS => "",
|
35
|
+
:DEP_FLAGS_SPACE => false,
|
35
36
|
:ERROR_PARSER => nil,
|
36
37
|
:PREPRO_FLAGS => ""
|
37
38
|
},
|
@@ -93,12 +94,35 @@ module Cxxproject
|
|
93
94
|
chain
|
94
95
|
end
|
95
96
|
|
97
|
+
# merge hashB into hashA
|
98
|
+
# recurse on sub-hash-structures
|
99
|
+
# elements present in hashA only will be taken from hashA
|
100
|
+
# elements present in hashB only will be taken from hashB
|
101
|
+
# elements present in both will be taken from hashB
|
102
|
+
#
|
103
|
+
def self.merge(hashA,hashB,overwrite=true)
|
104
|
+
missingKeys = hashB.keys - hashA.keys
|
105
|
+
missingKeys.each do |k|
|
106
|
+
hashA[k] = hashB[k]
|
107
|
+
end
|
108
|
+
hashA.each do |k,v|
|
109
|
+
if v.is_a? Hash
|
110
|
+
merge(v,hashB[k],overwrite) if hashB[k]
|
111
|
+
else
|
112
|
+
hashA[k] = hashB[k] if hashB[k] and overwrite
|
113
|
+
end
|
114
|
+
end
|
115
|
+
hashA
|
116
|
+
end
|
117
|
+
|
96
118
|
def self.default
|
97
119
|
@@default
|
98
120
|
end
|
99
121
|
|
100
122
|
def self.modify_cpp_compiler(based_on, h)
|
101
|
-
chain = Marshal.load(Marshal.dump(@@settings[based_on]))
|
123
|
+
# chain = Marshal.load(Marshal.dump(@@settings[based_on]))
|
124
|
+
chain = @@settings[based_on]
|
125
|
+
raise "unknown toolchain: #{based_on}" unless chain
|
102
126
|
chain[:COMPILER][:CPP].update(h)
|
103
127
|
chain
|
104
128
|
end
|
@@ -125,7 +149,3 @@ module Cxxproject
|
|
125
149
|
end
|
126
150
|
end
|
127
151
|
|
128
|
-
require 'cxxproject/toolchain/diab'
|
129
|
-
require 'cxxproject/toolchain/gcc'
|
130
|
-
require 'cxxproject/toolchain/clang'
|
131
|
-
require 'cxxproject/toolchain/ti'
|
data/lib/cxxproject/torake.rb
CHANGED
@@ -12,76 +12,35 @@ require 'cxxproject/buildingblocks/custom_building_block'
|
|
12
12
|
require 'cxxproject/buildingblocks/command_line'
|
13
13
|
require 'cxxproject/toolchain/colorizing_formatter'
|
14
14
|
require 'cxxproject/eval_context'
|
15
|
+
require 'cxxproject/plugin_context'
|
15
16
|
|
16
17
|
require 'rubygems'
|
17
18
|
|
18
19
|
module Cxxproject
|
19
20
|
|
20
|
-
# context in which plugins are evaluated
|
21
|
-
# a cxx_plugin is a gem that:
|
22
|
-
# - follows the naming convention cxxplugin_name
|
23
|
-
# - that has a plugin.rb file in lib and
|
24
|
-
# - that calls cxx_plugin
|
25
|
-
#
|
26
|
-
# the context contains
|
27
|
-
# - @cxxproject2rake
|
28
|
-
# - @building_blocks
|
29
|
-
# - @log
|
30
|
-
class PluginContext
|
31
|
-
def initialize(cxxproject2rake, building_blocks, log)
|
32
|
-
@cxxproject2rake = cxxproject2rake
|
33
|
-
@building_blocks = building_blocks
|
34
|
-
@log = log
|
35
|
-
end
|
36
|
-
def load_plugin(gem)
|
37
|
-
path = File.join(gem.full_gem_path, 'lib', 'plugin.rb')
|
38
|
-
content = File.read(path)
|
39
|
-
instance_eval(content)
|
40
|
-
end
|
41
|
-
|
42
|
-
# method for plugins to get the
|
43
|
-
# cxxproject2rake
|
44
|
-
# building_blocks
|
45
|
-
# log
|
46
|
-
def cxx_plugin(&blk)
|
47
|
-
blk.call(@cxxproject2rake, @building_blocks, @log)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
21
|
class CxxProject2Rake
|
52
22
|
attr_accessor :base, :all_tasks
|
53
|
-
def load_cxx_plugins
|
54
|
-
prefix = 'cxxproject_'
|
55
|
-
gems_to_load = Gem::Specification.find_all do |gem|
|
56
|
-
gem.name.index(prefix)
|
57
|
-
end
|
58
|
-
gems_to_load.each do |gem|
|
59
|
-
context = PluginContext.new(self, ALL_BUILDING_BLOCKS, @log)
|
60
|
-
context.load_plugin(gem)
|
61
|
-
end
|
62
|
-
end
|
63
23
|
|
64
|
-
def initialize(projects, build_dir,
|
24
|
+
def initialize(projects, build_dir, toolchain_name, base='.')
|
25
|
+
load_cxx_plugins
|
26
|
+
toolchain = Provider[toolchain_name]
|
27
|
+
raise "no provider with name \"#{toolchain_name}\" found" unless toolchain
|
65
28
|
@base = base
|
66
29
|
cd(@base, :verbose => false) do
|
67
30
|
@projects = projects.to_a
|
68
31
|
end
|
69
|
-
@build_dir = build_dir
|
70
|
-
@toolchain = toolchain
|
71
|
-
@rel_projects = @projects#.map { |p| File.join(@base, p) }
|
72
32
|
|
73
33
|
# TODO: this should be cleaned up somehow...
|
74
|
-
if Utils::OS.linux?
|
75
|
-
|
76
|
-
|
77
|
-
end
|
34
|
+
# if Utils::OS.linux?
|
35
|
+
# toolchain[:LINKER][:LIB_PREFIX_FLAGS] = "-Wl,--whole-archive"
|
36
|
+
# toolchain[:LINKER][:LIB_POSTFIX_FLAGS] = "-Wl,--no-whole-archive"
|
37
|
+
# end
|
78
38
|
|
79
39
|
Rake::application.deriveIncludes = true
|
80
40
|
|
81
|
-
initialize_logging
|
82
|
-
@all_tasks = instantiate_tasks
|
41
|
+
initialize_logging(build_dir)
|
42
|
+
@all_tasks = instantiate_tasks(toolchain, build_dir)
|
83
43
|
|
84
|
-
load_cxx_plugins
|
85
44
|
|
86
45
|
create_generic_tasks
|
87
46
|
create_console_colorization
|
@@ -91,11 +50,33 @@ module Cxxproject
|
|
91
50
|
create_console_task
|
92
51
|
end
|
93
52
|
|
53
|
+
def load_cxx_plugins
|
54
|
+
prefix = 'cxxproject_'
|
55
|
+
gems_to_load = Gem::Specification.find_all do |gem|
|
56
|
+
gem.name.index(prefix)
|
57
|
+
end
|
58
|
+
context = PluginContext.new(self, ALL_BUILDING_BLOCKS, @log)
|
59
|
+
gems_to_load.each do |gem|
|
60
|
+
load_plugin(gem, context)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_plugin(gem, pluginContext)
|
65
|
+
begin
|
66
|
+
path = File.join(gem.full_gem_path, 'lib', 'plugin.rb')
|
67
|
+
content = File.read(path)
|
68
|
+
pluginContext.eval_plugin(content)
|
69
|
+
rescue Exception => e
|
70
|
+
puts "problems with gem #{gem} in dir: #{path}: #{e}"
|
71
|
+
raise e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
94
75
|
def create_console_task
|
95
76
|
require 'cxxproject/utils/console'
|
96
77
|
end
|
97
78
|
|
98
|
-
def initialize_logging
|
79
|
+
def initialize_logging(build_dir)
|
99
80
|
@log = Logger.new(STDOUT)
|
100
81
|
@log.formatter = proc { |severity, datetime, progname, msg|
|
101
82
|
"#{severity}: #{msg}\n"
|
@@ -106,7 +87,7 @@ module Cxxproject
|
|
106
87
|
@log.level = Logger::ERROR
|
107
88
|
@log.level = Logger::INFO if RakeFileUtils.verbose == true
|
108
89
|
@log.level = Logger::DEBUG if Rake::application.options.trace
|
109
|
-
@log.debug "initializing for build_dir: \"#{
|
90
|
+
@log.debug "initializing for build_dir: \"#{build_dir}\", base: \"#{@base}\""
|
110
91
|
end
|
111
92
|
def describe_clean_task
|
112
93
|
Rake::Task[:clean].add_description('clean')
|
@@ -176,7 +157,7 @@ module Cxxproject
|
|
176
157
|
end
|
177
158
|
end
|
178
159
|
|
179
|
-
def instantiate_tasks
|
160
|
+
def instantiate_tasks(toolchain, build_dir)
|
180
161
|
check_for_project_configs
|
181
162
|
|
182
163
|
if @log.debug?
|
@@ -185,7 +166,7 @@ module Cxxproject
|
|
185
166
|
end
|
186
167
|
register_projects()
|
187
168
|
ALL_BUILDING_BLOCKS.values.each do |block|
|
188
|
-
prepare_block(block)
|
169
|
+
prepare_block(block, toolchain, build_dir)
|
189
170
|
end
|
190
171
|
ALL_BUILDING_BLOCKS.values.inject([]) do |memo,block|
|
191
172
|
@log.debug "creating tasks for block: #{block.name}/taskname: #{block.get_task_name} (#{block})"
|
@@ -201,9 +182,9 @@ module Cxxproject
|
|
201
182
|
end
|
202
183
|
end
|
203
184
|
|
204
|
-
def prepare_block(block)
|
205
|
-
block.set_tcs(
|
206
|
-
block.set_output_dir(Dir.pwd + "/" +
|
185
|
+
def prepare_block(block, toolchain, build_dir)
|
186
|
+
block.set_tcs(toolchain) unless block.has_tcs?
|
187
|
+
block.set_output_dir(Dir.pwd + "/" + build_dir)
|
207
188
|
block.complete_init()
|
208
189
|
end
|
209
190
|
|
@@ -228,13 +209,6 @@ module Cxxproject
|
|
228
209
|
puts "problems with #{File.join(b, project_file)} in dir: #{Dir.pwd}"
|
229
210
|
raise e
|
230
211
|
end
|
231
|
-
begin
|
232
|
-
loadContext.myblock.call()
|
233
|
-
rescue Exception => e
|
234
|
-
error_string = "error while evaluating \"#{Dir.pwd}/#{project_file}\""
|
235
|
-
puts error_string
|
236
|
-
raise e
|
237
|
-
end
|
238
212
|
|
239
213
|
loadContext.all_blocks.each do |block|
|
240
214
|
block.
|
@@ -248,7 +222,6 @@ module Cxxproject
|
|
248
222
|
def define_project_info_task
|
249
223
|
desc "shows your defined projects"
|
250
224
|
task :project_info do
|
251
|
-
p "ProjectBase: #{@base}"
|
252
225
|
ALL_BUILDING_BLOCKS.each_value do |bb|
|
253
226
|
pp bb
|
254
227
|
end
|
data/lib/cxxproject/version.rb
CHANGED
data/lib/cxxproject.rb
CHANGED
@@ -17,7 +17,12 @@ require 'cxxproject/utils/rbcurse'
|
|
17
17
|
require 'cxxproject/utils/progress'
|
18
18
|
require 'cxxproject/utils/rbcurse'
|
19
19
|
require 'cxxproject/utils/stats'
|
20
|
+
require 'cxxproject/version'
|
20
21
|
|
21
22
|
include Cxxproject::Toolchain
|
22
23
|
CxxProject2Rake = Cxxproject::CxxProject2Rake
|
23
24
|
BinaryLibs = Cxxproject::BinaryLibs
|
25
|
+
|
26
|
+
def version_info
|
27
|
+
Cxxproject::Version.cxxproject
|
28
|
+
end
|
data/spec/building_block_spec.rb
CHANGED
@@ -38,9 +38,10 @@ describe Cxxproject::BuildingBlock do
|
|
38
38
|
lib2 = Cxxproject::SourceLibrary.new('lib2').set_sources(['test.cc']).set_output_dir('build2')
|
39
39
|
lib2.set_project_dir(File.join(Dir.pwd, 'lib2'))
|
40
40
|
|
41
|
-
cxx = CxxProject2Rake.new([], 'build',
|
42
|
-
|
43
|
-
cxx.prepare_block(
|
41
|
+
cxx = CxxProject2Rake.new([], 'build', "clang")
|
42
|
+
|
43
|
+
cxx.prepare_block(lib1, Provider["clang"], "build")
|
44
|
+
cxx.prepare_block(lib2, Provider["clang"], "build")
|
44
45
|
|
45
46
|
lib1.complete_output_dir.should eq(File.join(Dir.pwd, 'build'))
|
46
47
|
lib2.complete_output_dir.should eq(File.join(Dir.pwd, 'lib2', 'build2'))
|
@@ -49,7 +50,7 @@ describe Cxxproject::BuildingBlock do
|
|
49
50
|
it 'should raise exception if building block cannot be resolved' do
|
50
51
|
expect do
|
51
52
|
lib1 = Cxxproject::SourceLibrary.new('1').set_dependencies(['unresolved'])
|
52
|
-
cxx = CxxProject2Rake.new([], 'build',
|
53
|
+
cxx = CxxProject2Rake.new([], 'build', "clang")
|
53
54
|
end.to raise_exception(RuntimeError, 'Error: while reading config file for 1: dependent building block "unresolved" was specified but not found!')
|
54
55
|
end
|
55
56
|
|
@@ -17,7 +17,7 @@ describe Rake::Task do
|
|
17
17
|
file 'test.cc' => 'compiler'
|
18
18
|
File.delete('test.cc') if File.exists?('test.cc')
|
19
19
|
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
20
|
-
cxx = CxxProject2Rake.new([], 'build',
|
20
|
+
cxx = CxxProject2Rake.new([], 'build', "clang")
|
21
21
|
|
22
22
|
task = Rake::application['lib:testlib']
|
23
23
|
task.invoke
|
@@ -35,7 +35,7 @@ describe Rake::Task do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
38
|
-
CxxProject2Rake.new([], 'build',
|
38
|
+
CxxProject2Rake.new([], 'build', "clang")
|
39
39
|
|
40
40
|
task = Rake::application['lib:testlib']
|
41
41
|
task.invoke
|
@@ -48,7 +48,7 @@ describe Rake::Task do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
51
|
-
CxxProject2Rake.new([], 'build',
|
51
|
+
CxxProject2Rake.new([], 'build', "clang")
|
52
52
|
|
53
53
|
task = Rake::application['build/libs/libtestlib.a']
|
54
54
|
task.invoke
|
@@ -69,7 +69,7 @@ describe Rake::Task do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
sl = Cxxproject::SourceLibrary.new('testlib').set_sources(['test.cc']).set_project_dir(".")
|
72
|
-
CxxProject2Rake.new([], 'build',
|
72
|
+
CxxProject2Rake.new([], 'build', "clang")
|
73
73
|
|
74
74
|
task = Rake::application['build/libs/libtestlib.a']
|
75
75
|
task.invoke
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'cxxproject/plugin_context'
|
2
|
+
|
3
|
+
|
4
|
+
describe Cxxproject::PluginContext do
|
5
|
+
it "should copy cpp settings to c settings" do
|
6
|
+
toolchain = {:COMPILER => {
|
7
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
8
|
+
:C => { :BASED_ON => :CPP, :COMMAND => "clang" }
|
9
|
+
}}
|
10
|
+
expected = {:COMPILER => {
|
11
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
12
|
+
:C => { :DEFINE_FLAG => "-D", :COMMAND => "clang" }
|
13
|
+
}}
|
14
|
+
Cxxproject::PluginContext.expand(toolchain).should == expected
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should fully resolve all :BASED_ON sections" do
|
18
|
+
toolchain = {:COMPILER => {
|
19
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
20
|
+
:C => { :BASED_ON => :CPP, :COMMAND => "clang" },
|
21
|
+
:ASM => { :BASED_ON => :C }
|
22
|
+
}}
|
23
|
+
expected = {:COMPILER => {
|
24
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
25
|
+
:C => { :DEFINE_FLAG => "-D", :COMMAND => "clang" },
|
26
|
+
:ASM => { :DEFINE_FLAG => "-D", :COMMAND => "clang" }
|
27
|
+
}}
|
28
|
+
Cxxproject::PluginContext.expand(toolchain).should == expected
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should find out if extension is needed" do
|
32
|
+
toolchain = {:COMPILER => {
|
33
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
34
|
+
:C => { :BASED_ON => :CPP, :COMMAND => "clang" } }}
|
35
|
+
toolchain2 = {:COMPILER => {
|
36
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
37
|
+
:C => { :COMMAND => "clang" } }}
|
38
|
+
Cxxproject::PluginContext.needs_expansion(toolchain).should == true
|
39
|
+
Cxxproject::PluginContext.needs_expansion(toolchain2).should == false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should find a toolchain to expand" do
|
43
|
+
toolchain = {:COMPILER => {
|
44
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
45
|
+
:C => { :BASED_ON => :CPP, :COMMAND => "clang" }
|
46
|
+
}}
|
47
|
+
Cxxproject::PluginContext.find_toolchain_subhash(toolchain).should == toolchain[:COMPILER][:C]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should find a toolchain element by name" do
|
51
|
+
toolchain = {:COMPILER => {
|
52
|
+
:CPP => { :DEFINE_FLAG => "-D", :COMMAND => "clang++" },
|
53
|
+
:C => { :BASED_ON => :CPP, :COMMAND => "clang" }
|
54
|
+
}}
|
55
|
+
Cxxproject::PluginContext.find_toolchain_element(toolchain, :CPP).should == toolchain[:COMPILER][:CPP]
|
56
|
+
end
|
57
|
+
end
|
data/spec/project_path_spec.rb
CHANGED
@@ -18,7 +18,7 @@ describe CxxProject2Rake do
|
|
18
18
|
cd base do # have to be relative to base
|
19
19
|
project_configs = Dir.glob('**/project.rb')
|
20
20
|
end
|
21
|
-
CxxProject2Rake.new(project_configs, outputdir,
|
21
|
+
CxxProject2Rake.new(project_configs, outputdir, "clang", base)
|
22
22
|
end
|
23
23
|
|
24
24
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'cxxproject/toolchain/provider'
|
3
|
+
|
4
|
+
describe Cxxproject::Toolchain::Provider do
|
5
|
+
|
6
|
+
it 'should merge without overwrite' do
|
7
|
+
cpp = { :DEFINE_FLAG => "-D", :COMMAND => "clang++" }
|
8
|
+
c = { :COMMAND => "clang" }
|
9
|
+
expected = { :DEFINE_FLAG => "-D", :COMMAND => "clang" }
|
10
|
+
Cxxproject::Toolchain::Provider.merge(c, cpp, false).should == expected
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should merge two simple hashes' do
|
14
|
+
hashA = { :a => 1, :b => 2 }
|
15
|
+
hashB = { :a => 3, :c => 2 }
|
16
|
+
merged = Cxxproject::Toolchain::Provider.merge(hashA, hashB)
|
17
|
+
merged.should == { :a => 3, :b => 2, :c => 2 }
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should merge nested hashes' do
|
21
|
+
hashA = { :n => { :a => 1, :b => 2 }}
|
22
|
+
hashB = { :n => { :a => 3, :c => 2 }}
|
23
|
+
merged = Cxxproject::Toolchain::Provider.merge(hashA, hashB)
|
24
|
+
merged.should == { :n => { :a => 3, :b => 2, :c => 2 }}
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should merge multiple level nested hashes' do
|
28
|
+
hashA = {:COMPILER => {
|
29
|
+
:CPP => {:COMMAND => "",:DEFINE_FLAG => "",:SOURCE_FILE_ENDINGS => [".cxx", ".cpp", ".c++", ".cc", ".C"]}}}
|
30
|
+
hashB = {:COMPILER =>
|
31
|
+
{:CPP => { :COMMAND => "clang++", :SOURCE_FILE_ENDINGS => [".cxx", ".cpp"]}}}
|
32
|
+
merged = Cxxproject::Toolchain::Provider.merge(hashA, hashB)
|
33
|
+
expected = {:COMPILER =>
|
34
|
+
{:CPP => { :COMMAND => "clang++", :DEFINE_FLAG => "", :SOURCE_FILE_ENDINGS => [".cxx", ".cpp"]}}}
|
35
|
+
merged.should == expected
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cxxproject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- oliver mueller
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: highline
|
@@ -54,85 +54,78 @@ extensions: []
|
|
54
54
|
extra_rdoc_files: []
|
55
55
|
|
56
56
|
files:
|
57
|
-
- lib/cxxproject
|
58
|
-
- lib/
|
59
|
-
- lib/cxxproject/
|
60
|
-
- lib/cxxproject/errorparser/diab_compiler_error_parser.rb
|
61
|
-
- lib/cxxproject/errorparser/gcc_compiler_error_parser.rb
|
62
|
-
- lib/cxxproject/errorparser/ti_compiler_error_parser.rb
|
57
|
+
- lib/cxxproject.rb
|
58
|
+
- lib/tools/project_wizard.rb
|
59
|
+
- lib/cxxproject/context.rb
|
63
60
|
- lib/cxxproject/errorparser/error_parser.rb
|
64
|
-
- lib/cxxproject/utils/optional.rb
|
65
|
-
- lib/cxxproject/utils/cleanup.rb
|
66
|
-
- lib/cxxproject/utils/exit_helper.rb
|
67
|
-
- lib/cxxproject/utils/rbcurse_progress.rb
|
68
|
-
- lib/cxxproject/utils/process.rb
|
69
|
-
- lib/cxxproject/utils/ubigraph.rb
|
70
|
-
- lib/cxxproject/utils/printer.rb
|
71
|
-
- lib/cxxproject/utils/stats.rb
|
72
|
-
- lib/cxxproject/utils/rbcurse.rb
|
73
|
-
- lib/cxxproject/utils/progress_helper.rb
|
74
|
-
- lib/cxxproject/utils/rbcurse_executable_ext.rb
|
75
|
-
- lib/cxxproject/utils/utils.rb
|
76
|
-
- lib/cxxproject/utils/rbcurse_tasktable.rb
|
77
|
-
- lib/cxxproject/utils/console.rb
|
78
|
-
- lib/cxxproject/utils/progress.rb
|
79
|
-
- lib/cxxproject/utils/graphstream.rb
|
80
|
-
- lib/cxxproject/toolchain/toolchain_benchmark.rb
|
81
|
-
- lib/cxxproject/toolchain/diab.rb
|
82
|
-
- lib/cxxproject/toolchain/gcc.rb
|
83
|
-
- lib/cxxproject/toolchain/provider.rb
|
84
|
-
- lib/cxxproject/toolchain/clang.rb
|
85
|
-
- lib/cxxproject/toolchain/ti.rb
|
86
|
-
- lib/cxxproject/toolchain/colorizing_formatter.rb
|
87
|
-
- lib/cxxproject/toolchain/toolchain.rb
|
88
61
|
- lib/cxxproject/version.rb
|
62
|
+
- lib/cxxproject/torake.rb
|
63
|
+
- lib/cxxproject/plugin_context.rb
|
89
64
|
- lib/cxxproject/ide_interface.rb
|
90
|
-
- lib/cxxproject/ext/
|
65
|
+
- lib/cxxproject/ext/file.rb
|
66
|
+
- lib/cxxproject/ext/rake_dirty.rb
|
91
67
|
- lib/cxxproject/ext/filelist.rb
|
92
68
|
- lib/cxxproject/ext/string.rb
|
69
|
+
- lib/cxxproject/ext/rake_listener.rb
|
70
|
+
- lib/cxxproject/ext/stdout.rb
|
93
71
|
- lib/cxxproject/ext/rake.rb
|
94
72
|
- lib/cxxproject/ext/progressbar.rb
|
95
|
-
- lib/cxxproject/ext/stdout.rb
|
96
|
-
- lib/cxxproject/ext/rake_dirty.rb
|
97
|
-
- lib/cxxproject/ext/file.rb
|
98
|
-
- lib/cxxproject/torake.rb
|
99
|
-
- lib/cxxproject/buildingblocks/building_block.rb
|
100
73
|
- lib/cxxproject/buildingblocks/has_libraries_mixin.rb
|
101
|
-
- lib/cxxproject/buildingblocks/
|
102
|
-
- lib/cxxproject/buildingblocks/makefile.rb
|
74
|
+
- lib/cxxproject/buildingblocks/executable.rb
|
103
75
|
- lib/cxxproject/buildingblocks/has_includes_mixin.rb
|
104
|
-
- lib/cxxproject/buildingblocks/
|
76
|
+
- lib/cxxproject/buildingblocks/has_dependencies_mixin.rb
|
77
|
+
- lib/cxxproject/buildingblocks/custom_building_block.rb
|
105
78
|
- lib/cxxproject/buildingblocks/binary_library.rb
|
106
|
-
- lib/cxxproject/buildingblocks/executable.rb
|
107
79
|
- lib/cxxproject/buildingblocks/module.rb
|
108
|
-
- lib/cxxproject/buildingblocks/
|
109
|
-
- lib/cxxproject/buildingblocks/has_dependencies_mixin.rb
|
80
|
+
- lib/cxxproject/buildingblocks/building_block.rb
|
110
81
|
- lib/cxxproject/buildingblocks/source_library.rb
|
82
|
+
- lib/cxxproject/buildingblocks/single_source.rb
|
83
|
+
- lib/cxxproject/buildingblocks/makefile.rb
|
111
84
|
- lib/cxxproject/buildingblocks/command_line.rb
|
85
|
+
- lib/cxxproject/buildingblocks/has_sources_mixin.rb
|
86
|
+
- lib/cxxproject/utils/rbcurse_progress.rb
|
87
|
+
- lib/cxxproject/utils/ubigraph.rb
|
88
|
+
- lib/cxxproject/utils/graphstream.rb
|
89
|
+
- lib/cxxproject/utils/progress.rb
|
90
|
+
- lib/cxxproject/utils/stats.rb
|
91
|
+
- lib/cxxproject/utils/utils.rb
|
92
|
+
- lib/cxxproject/utils/optional.rb
|
93
|
+
- lib/cxxproject/utils/console.rb
|
94
|
+
- lib/cxxproject/utils/progress_helper.rb
|
95
|
+
- lib/cxxproject/utils/exit_helper.rb
|
96
|
+
- lib/cxxproject/utils/cleanup.rb
|
97
|
+
- lib/cxxproject/utils/rbcurse_tasktable.rb
|
98
|
+
- lib/cxxproject/utils/rbcurse_executable_ext.rb
|
99
|
+
- lib/cxxproject/utils/rbcurse.rb
|
100
|
+
- lib/cxxproject/utils/printer.rb
|
101
|
+
- lib/cxxproject/utils/process.rb
|
102
|
+
- lib/cxxproject/toolchain/provider.rb
|
103
|
+
- lib/cxxproject/toolchain/toolchain.rb
|
104
|
+
- lib/cxxproject/toolchain/colorizing_formatter.rb
|
112
105
|
- lib/cxxproject/eval_context.rb
|
113
|
-
- lib/tools/project_wizard.rb
|
114
|
-
- lib/cxxproject.rb
|
115
106
|
- Rakefile.rb
|
116
|
-
- spec/string_spec.rb
|
117
|
-
- spec/project_path_spec.rb
|
118
|
-
- spec/ide_interface_spec.rb
|
119
|
-
- spec/spec_helper.rb
|
120
|
-
- spec/object_dependency_spec.rb
|
121
|
-
- spec/building_block_spec.rb
|
122
|
-
- spec/file_ext_spec.rb
|
123
|
-
- spec/testdata/basic/exe12/project.rb
|
124
|
-
- spec/testdata/basic/lib1/project.rb
|
125
|
-
- spec/testdata/basic/lib2/project.rb
|
126
107
|
- spec/testdata/onlyOneHeader/Rakefile.rb
|
127
108
|
- spec/testdata/onlyOneHeader/project.rb
|
109
|
+
- spec/testdata/basic/lib1/project.rb
|
110
|
+
- spec/testdata/basic/lib2/project.rb
|
111
|
+
- spec/testdata/basic/exe12/project.rb
|
112
|
+
- spec/testdata/multiple_levels/mainproject/basic/project.rb
|
128
113
|
- spec/testdata/multiple_levels/libs/lib1/project.rb
|
129
114
|
- spec/testdata/multiple_levels/libs/lib2/project.rb
|
130
|
-
- spec/
|
115
|
+
- spec/string_spec.rb
|
131
116
|
- spec/cxxproject_2_rake_spec.rb
|
132
|
-
- spec/
|
117
|
+
- spec/provider_spec.rb
|
118
|
+
- spec/project_path_spec.rb
|
119
|
+
- spec/building_block_spec.rb
|
120
|
+
- spec/plugin_context_spec.rb
|
121
|
+
- spec/file_ext_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/ide_interface_spec.rb
|
124
|
+
- spec/object_dependency_spec.rb
|
133
125
|
- spec/rake_listener_ext_spec.rb
|
134
|
-
-
|
126
|
+
- spec/toolchain_spec.rb
|
135
127
|
- lib/tools/project.rb.template
|
128
|
+
- lib/tools/Rakefile.rb.template
|
136
129
|
- bin/cxx
|
137
130
|
homepage: https://github.com/marcmo/cxxproject
|
138
131
|
licenses: []
|
@@ -147,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
140
|
requirements:
|
148
141
|
- - ">="
|
149
142
|
- !ruby/object:Gem::Version
|
150
|
-
hash:
|
143
|
+
hash: 3389425425970571321
|
151
144
|
segments:
|
152
145
|
- 0
|
153
146
|
version: "0"
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class DiabCompilerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
@error_expression_start = /\"(.+)\", line ([0-9]+): (?!included)(catastrophic |fatal )*([A-Za-z]+)[:]* (.+)/
|
8
|
-
@error_expression_end = /^[ \t]*\^/ # well, it may end without "^"... in this case the error will last the next one starts or console text ends
|
9
|
-
end
|
10
|
-
|
11
|
-
def scan_lines(consoleOutput, proj_dir)
|
12
|
-
res = []
|
13
|
-
error_severity = 255
|
14
|
-
consoleOutputFullnames = ""
|
15
|
-
consoleOutput.each_line do |l|
|
16
|
-
d = ErrorDesc.new
|
17
|
-
lstripped = l.rstrip
|
18
|
-
scan_res = lstripped.scan(@error_expression_start)
|
19
|
-
if scan_res.length == 0
|
20
|
-
d.severity = error_severity
|
21
|
-
d.message = lstripped
|
22
|
-
if lstripped.scan(@error_expression_end).length > 0
|
23
|
-
error_severity = 255
|
24
|
-
end
|
25
|
-
else
|
26
|
-
d.file_name = File.expand_path(scan_res[0][0])
|
27
|
-
d.line_number = scan_res[0][1].to_i
|
28
|
-
d.message = scan_res[0][4]
|
29
|
-
d.severity = get_severity(scan_res[0][3])
|
30
|
-
error_severity = d.severity
|
31
|
-
l.gsub!(scan_res[0][0],d.file_name)
|
32
|
-
end
|
33
|
-
res << d
|
34
|
-
consoleOutputFullnames << l
|
35
|
-
end
|
36
|
-
[res, consoleOutputFullnames]
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class DiabLinkerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
@error_expression = /dld: ([A-Za-z]+): (.+)/
|
8
|
-
@error_expression_linkerscript = /dld: \"([^\"]+)\", line ([0-9]+): (.+)/
|
9
|
-
end
|
10
|
-
|
11
|
-
def scan_lines(consoleOutput, proj_dir)
|
12
|
-
res = []
|
13
|
-
error_severity = 255
|
14
|
-
consoleOutput.each_line do |l|
|
15
|
-
l.rstrip!
|
16
|
-
d = ErrorDesc.new
|
17
|
-
scan_res = l.scan(@error_expression)
|
18
|
-
scan_res2 = l.scan(@error_expression_linkerscript)
|
19
|
-
if scan_res.length == 0 and scan_res2.length == 0 # msg will end with the beginning of the next message
|
20
|
-
d.severity = error_severity
|
21
|
-
d.message = l
|
22
|
-
elsif scan_res.length > 0
|
23
|
-
d.file_name = proj_dir
|
24
|
-
d.line_number = 0
|
25
|
-
d.message = scan_res[0][1]
|
26
|
-
d.severity = get_severity(scan_res[0][0])
|
27
|
-
error_severity = d.severity
|
28
|
-
else
|
29
|
-
d.file_name = proj_dir+"/"+scan_res2[0][0]
|
30
|
-
d.line_number = scan_res2[0][1].to_i
|
31
|
-
d.message = scan_res2[0][2]
|
32
|
-
d.severity = SEVERITY_ERROR
|
33
|
-
error_severity = d.severity
|
34
|
-
end
|
35
|
-
res << d
|
36
|
-
end
|
37
|
-
[res, consoleOutput]
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class GCCCompilerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
@error_expression = /([^:]+):([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z\._]+): (.+)/
|
8
|
-
end
|
9
|
-
|
10
|
-
def scan_lines(consoleOutput, proj_dir)
|
11
|
-
res = []
|
12
|
-
consoleOutputFullnames = ""
|
13
|
-
consoleOutput.each_line do |l|
|
14
|
-
d = ErrorDesc.new
|
15
|
-
scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
|
16
|
-
if scan_res.length > 0
|
17
|
-
d.file_name = File.expand_path(scan_res[0][0])
|
18
|
-
d.line_number = scan_res[0][1].to_i
|
19
|
-
d.message = scan_res[0][4]
|
20
|
-
if (scan_res[0][3].include?".")
|
21
|
-
d.severity = SEVERITY_ERROR
|
22
|
-
d.message = scan_res[0][3] + ": " + d.message
|
23
|
-
else
|
24
|
-
d.severity = get_severity(scan_res[0][3])
|
25
|
-
end
|
26
|
-
l.gsub!(scan_res[0][0],d.file_name)
|
27
|
-
end
|
28
|
-
res << d
|
29
|
-
consoleOutputFullnames << l
|
30
|
-
end
|
31
|
-
[res, consoleOutputFullnames]
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class GCCLinkerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
# todo: is every line an error?
|
8
|
-
# todo: some linker errors look like simple text, dunno how to parse properly...
|
9
|
-
# @error_expression1 = /(.*:\(\..*\)): (.*)/ # e.g. /c/Tool/Temp/ccAlar4R.o:x.cpp:(.text+0x17): undefined reference to `_a'
|
10
|
-
# @error_expression2 = /(.*):([0-9]+): (.*)/ # e.g. /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:roodi.yml.a:1: syntax error
|
11
|
-
end
|
12
|
-
|
13
|
-
def scan_lines(consoleOutput, proj_dir)
|
14
|
-
res = []
|
15
|
-
consoleOutput.each_line do |l|
|
16
|
-
l.rstrip!
|
17
|
-
d = ErrorDesc.new
|
18
|
-
d.file_name = proj_dir
|
19
|
-
d.line_number = 0
|
20
|
-
d.message = l
|
21
|
-
if l.length == 0
|
22
|
-
d.severity = SEVERITY_OK
|
23
|
-
elsif l.include?" Warning:"
|
24
|
-
d.severity = SEVERITY_WARNING
|
25
|
-
else
|
26
|
-
d.severity = SEVERITY_ERROR
|
27
|
-
end
|
28
|
-
res << d
|
29
|
-
end
|
30
|
-
[res, consoleOutput]
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class TICompilerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
@error_expression = /\"([^,^\"]+)\", line ([0-9]+)[:0-9]* (catastrophic |fatal )*([A-Za-z]+): (.+)/
|
8
|
-
end
|
9
|
-
|
10
|
-
def scan_lines(consoleOutput, proj_dir)
|
11
|
-
res = []
|
12
|
-
consoleOutputFullnames = ""
|
13
|
-
consoleOutput.each_line do |l|
|
14
|
-
d = ErrorDesc.new
|
15
|
-
scan_res = l.gsub(/\r\n?/, "").scan(@error_expression)
|
16
|
-
if scan_res.length > 0
|
17
|
-
d.file_name = File.expand_path(scan_res[0][0])
|
18
|
-
d.line_number = scan_res[0][1].to_i
|
19
|
-
d.message = scan_res[0][4]
|
20
|
-
d.severity = get_severity(scan_res[0][3])
|
21
|
-
l.gsub!(scan_res[0][0],d.file_name)
|
22
|
-
end
|
23
|
-
res << d
|
24
|
-
consoleOutputFullnames << l
|
25
|
-
end
|
26
|
-
[res, consoleOutputFullnames]
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'cxxproject/errorparser/error_parser'
|
2
|
-
|
3
|
-
module Cxxproject
|
4
|
-
class TILinkerErrorParser < ErrorParser
|
5
|
-
|
6
|
-
def initialize()
|
7
|
-
# todo: is every line an error?
|
8
|
-
# todo: some linker errors look like simple text, dunno how to parse properly...
|
9
|
-
# @error_expression1 = /(.*:\(\..*\)): (.*)/ # e.g. /c/Tool/Temp/ccAlar4R.o:x.cpp:(.text+0x17): undefined reference to `_a'
|
10
|
-
# @error_expression2 = /(.*):([0-9]+): (.*)/ # e.g. /usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld:roodi.yml.a:1: syntax error
|
11
|
-
end
|
12
|
-
|
13
|
-
def scan_lines(consoleOutput, proj_dir)
|
14
|
-
res = []
|
15
|
-
consoleOutput.each_line do |l|
|
16
|
-
l.rstrip!
|
17
|
-
d = ErrorDesc.new
|
18
|
-
if l != "<Linking>" then
|
19
|
-
d.file_name = proj_dir
|
20
|
-
d.line_number = 0
|
21
|
-
d.message = l
|
22
|
-
d.severity = SEVERITY_ERROR
|
23
|
-
end
|
24
|
-
res << d
|
25
|
-
end
|
26
|
-
[res, consoleOutput]
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
@@ -1,39 +0,0 @@
|
|
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
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'cxxproject/toolchain/provider'
|
2
|
-
require 'cxxproject/utils/utils'
|
3
|
-
require 'cxxproject/errorparser/diab_compiler_error_parser'
|
4
|
-
require 'cxxproject/errorparser/diab_linker_error_parser'
|
5
|
-
|
6
|
-
module Cxxproject
|
7
|
-
module Toolchain
|
8
|
-
|
9
|
-
DiabChain = Provider.add("Diab")
|
10
|
-
|
11
|
-
DiabChain[:COMPILER][:C].update({
|
12
|
-
:COMMAND => "dcc",
|
13
|
-
:FLAGS => "",
|
14
|
-
:DEFINE_FLAG => "-D",
|
15
|
-
:OBJECT_FILE_FLAG => "-o ",
|
16
|
-
:INCLUDE_PATH_FLAG => "-I",
|
17
|
-
:COMPILE_FLAGS => "-c",
|
18
|
-
:DEP_FLAGS => "-Xmake-dependency=6 -Xmake-dependency-savefile=",
|
19
|
-
:DEP_FLAGS_SPACE => false,
|
20
|
-
:PREPRO_FLAGS => "-P"
|
21
|
-
})
|
22
|
-
|
23
|
-
DiabChain[:COMPILER][:CPP] = Utils.deep_copy(DiabChain[:COMPILER][:C])
|
24
|
-
DiabChain[:COMPILER][:CPP][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:CPP][:SOURCE_FILE_ENDINGS]
|
25
|
-
|
26
|
-
DiabChain[:COMPILER][:ASM] = Utils.deep_copy(DiabChain[:COMPILER][:C])
|
27
|
-
DiabChain[:COMPILER][:ASM][:COMMAND] = "das"
|
28
|
-
DiabChain[:COMPILER][:ASM][:COMPILE_FLAGS] = ""
|
29
|
-
DiabChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
30
|
-
DiabChain[:COMPILER][:ASM][:PREPRO_FLAGS] = ""
|
31
|
-
|
32
|
-
DiabChain[:ARCHIVER][:COMMAND] = "dar"
|
33
|
-
DiabChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-rc"
|
34
|
-
|
35
|
-
DiabChain[:LINKER][:COMMAND] = "dcc"
|
36
|
-
DiabChain[:LINKER][:SCRIPT] = "-Wm"
|
37
|
-
DiabChain[:LINKER][:USER_LIB_FLAG] = "-l:"
|
38
|
-
DiabChain[:LINKER][:EXE_FLAG] = "-o"
|
39
|
-
DiabChain[:LINKER][:LIB_FLAG] = "-l"
|
40
|
-
DiabChain[:LINKER][:LIB_PATH_FLAG] = "-L"
|
41
|
-
DiabChain[:LINKER][:MAP_FILE_FLAG] = "-Wl,-m6" # no map file if this string is empty, otherwise -Wl,-m6>abc.map
|
42
|
-
DiabChain[:LINKER][:OUTPUT_ENDING] = ".elf"
|
43
|
-
|
44
|
-
diabCompilerErrorParser = DiabCompilerErrorParser.new
|
45
|
-
DiabChain[:COMPILER][:C][:ERROR_PARSER] = diabCompilerErrorParser
|
46
|
-
DiabChain[:COMPILER][:CPP][:ERROR_PARSER] = diabCompilerErrorParser
|
47
|
-
DiabChain[:COMPILER][:ASM][:ERROR_PARSER] = diabCompilerErrorParser
|
48
|
-
DiabChain[:ARCHIVER][:ERROR_PARSER] = diabCompilerErrorParser
|
49
|
-
DiabChain[:LINKER][:ERROR_PARSER] = DiabLinkerErrorParser.new
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
@@ -1,48 +0,0 @@
|
|
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'
|
6
|
-
|
7
|
-
module Cxxproject
|
8
|
-
module Toolchain
|
9
|
-
|
10
|
-
GCCChain = Provider.add("GCC")
|
11
|
-
|
12
|
-
GCCChain[:COMPILER][:CPP].update({
|
13
|
-
:COMMAND => "g++",
|
14
|
-
:DEFINE_FLAG => "-D",
|
15
|
-
:OBJECT_FILE_FLAG => "-o ",
|
16
|
-
:INCLUDE_PATH_FLAG => "-I",
|
17
|
-
:COMPILE_FLAGS => "-c ",
|
18
|
-
:DEP_FLAGS => "-MMD -MF",
|
19
|
-
:DEP_FLAGS_SPACE => true,
|
20
|
-
:PREPRO_FLAGS => "-E -P"
|
21
|
-
})
|
22
|
-
|
23
|
-
GCCChain[:COMPILER][:C] = Utils.deep_copy(GCCChain[:COMPILER][:CPP])
|
24
|
-
GCCChain[:COMPILER][:C][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:C][:SOURCE_FILE_ENDINGS]
|
25
|
-
GCCChain[:COMPILER][:C][:COMMAND] = "gcc"
|
26
|
-
|
27
|
-
GCCChain[:COMPILER][:ASM] = Utils.deep_copy(GCCChain[:COMPILER][:C])
|
28
|
-
GCCChain[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS] = Provider.default[:COMPILER][:ASM][:SOURCE_FILE_ENDINGS]
|
29
|
-
|
30
|
-
GCCChain[:ARCHIVER][:COMMAND] = "ar"
|
31
|
-
GCCChain[:ARCHIVER][:ARCHIVE_FLAGS] = "-rc"
|
32
|
-
|
33
|
-
GCCChain[:LINKER][:COMMAND] = "g++"
|
34
|
-
GCCChain[:LINKER][:SCRIPT] = "-T"
|
35
|
-
GCCChain[:LINKER][:USER_LIB_FLAG] = "-l:"
|
36
|
-
GCCChain[:LINKER][:EXE_FLAG] = "-o"
|
37
|
-
GCCChain[:LINKER][:LIB_FLAG] = "-l"
|
38
|
-
GCCChain[:LINKER][:LIB_PATH_FLAG] = "-L"
|
39
|
-
|
40
|
-
gccCompilerErrorParser = GCCCompilerErrorParser.new
|
41
|
-
GCCChain[:COMPILER][:C][:ERROR_PARSER] = gccCompilerErrorParser
|
42
|
-
GCCChain[:COMPILER][:CPP][:ERROR_PARSER] = gccCompilerErrorParser
|
43
|
-
GCCChain[:COMPILER][:ASM][:ERROR_PARSER] = gccCompilerErrorParser
|
44
|
-
GCCChain[:ARCHIVER][:ERROR_PARSER] = gccCompilerErrorParser
|
45
|
-
GCCChain[:LINKER][:ERROR_PARSER] = GCCLinkerErrorParser.new
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
@@ -1,50 +0,0 @@
|
|
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
|
@@ -1,23 +0,0 @@
|
|
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
|
-
|