rakeoe 0.0.9 → 0.0.10
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/rakeoe/app.rb +20 -17
- data/lib/rakeoe/binary_base.rb +52 -34
- data/lib/rakeoe/config.rb +3 -1
- data/lib/rakeoe/lib.rb +12 -7
- data/lib/rakeoe/prj_file_cache.rb +162 -6
- data/lib/rakeoe/toolchain.rb +71 -7
- data/lib/rakeoe/version.rb +1 -1
- data/lib/rakeoe.rb +1 -1
- data/rakeoe.gemspec +3 -1
- metadata +3 -3
data/lib/rakeoe/app.rb
CHANGED
@@ -38,6 +38,7 @@ module RakeOE
|
|
38
38
|
@app_main_dep = @app_main_obj.map {|obj| obj.ext('.d')}
|
39
39
|
@app_lib_objs = objs - @app_main_obj
|
40
40
|
@app_lib_deps = @app_lib_objs.map {|obj| obj.ext('.d')}
|
41
|
+
@prj_libs = search_libs(settings)
|
41
42
|
end
|
42
43
|
|
43
44
|
|
@@ -54,20 +55,20 @@ module RakeOE
|
|
54
55
|
|
55
56
|
binary_targets = paths_of_local_libs() + @app_main_dep + @app_main_obj
|
56
57
|
|
58
|
+
prj_libs = search_libs(settings)
|
59
|
+
linked_libs = prj_libs[:all]
|
60
|
+
|
57
61
|
# This is only necessary if we have more than a single app main file
|
58
62
|
if @app_lib_objs.any?
|
59
|
-
create_app_lib_rules(binary_targets)
|
63
|
+
create_app_lib_rules(binary_targets, linked_libs)
|
60
64
|
end
|
61
65
|
|
62
|
-
prj_libs = search_libs(settings)
|
63
|
-
linked_libs = prj_libs[:all]
|
64
|
-
|
65
66
|
file binary => binary_targets do
|
66
67
|
tc.app(:libs => linked_libs,
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
:app => binary,
|
69
|
+
:objects => @app_main_obj,
|
70
|
+
:settings => @settings,
|
71
|
+
:includes => src_dirs)
|
71
72
|
end
|
72
73
|
|
73
74
|
if test_objs.any?
|
@@ -107,12 +108,13 @@ module RakeOE
|
|
107
108
|
CLOBBER.include('*.d', build_dir)
|
108
109
|
end
|
109
110
|
|
110
|
-
def create_app_lib_rules(binary_targets)
|
111
|
+
def create_app_lib_rules(binary_targets, libs)
|
111
112
|
app_lib_targets = @app_lib_deps + @app_lib_objs + [@settings['PRJ_FILE']]
|
112
113
|
file @app_lib => app_lib_targets do
|
113
114
|
tc.lib(:objects => @app_lib_objs,
|
114
|
-
|
115
|
-
|
115
|
+
:lib => @app_lib,
|
116
|
+
:libs => libs,
|
117
|
+
:settings => @settings)
|
116
118
|
end
|
117
119
|
|
118
120
|
# add this to the dependent targets of app binary
|
@@ -138,13 +140,14 @@ module RakeOE
|
|
138
140
|
# 'hidden' task just for building the test
|
139
141
|
task "#{name}_build" => test_binary
|
140
142
|
|
141
|
-
|
143
|
+
test_binary_dependencies = [@test_fw.binary_path] + binary_targets + test_deps + test_objs
|
144
|
+
file test_binary => test_binary_dependencies do
|
142
145
|
tc.test(:objects => test_objs + [@app_lib],
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
146
|
+
:test => test_binary,
|
147
|
+
:libs => linked_libs,
|
148
|
+
:framework => @test_fw.name,
|
149
|
+
:settings => @settings,
|
150
|
+
:includes => test_dirs)
|
148
151
|
end
|
149
152
|
CLEAN.include(test_binary, build_dir)
|
150
153
|
task :all => "#{name}"
|
data/lib/rakeoe/binary_base.rb
CHANGED
@@ -25,7 +25,8 @@ module RakeOE
|
|
25
25
|
#
|
26
26
|
def initialize(params)
|
27
27
|
check_params(params)
|
28
|
-
|
28
|
+
@@all_libs ||= (PrjFileCache.project_names('LIB') + PrjFileCache.project_names('SOLIB')).uniq
|
29
|
+
@@all_libs_and_deps ||= PrjFileCache.search_recursive(:names => @@all_libs, :attribute => 'ADD_LIBS')
|
29
30
|
@name = params[:name]
|
30
31
|
@settings = params[:settings]
|
31
32
|
@src_dir = @settings['PRJ_HOME']
|
@@ -274,14 +275,14 @@ module RakeOE
|
|
274
275
|
end
|
275
276
|
end
|
276
277
|
|
278
|
+
|
277
279
|
# Checks if projects build prerequisites are met.
|
278
280
|
#
|
279
281
|
# If at least one of the following criteria are met, the method returns false:
|
280
282
|
# * project variable PRJ_TYPE == "DISABLED"
|
281
283
|
# * project variable IGNORED_PLATFORMS contains build platform
|
282
|
-
# @return true if project can be
|
283
|
-
#
|
284
|
-
|
284
|
+
# @return true if project can be built on current platform
|
285
|
+
# @return false if project settings prohibit building
|
285
286
|
def project_can_build?
|
286
287
|
(settings['PRJ_TYPE'] != 'DISABLED') and (! tc.current_platform_any?(settings['IGNORED_PLATFORMS'].split))
|
287
288
|
end
|
@@ -440,53 +441,52 @@ module RakeOE
|
|
440
441
|
end
|
441
442
|
end
|
442
443
|
|
443
|
-
|
444
|
-
# Returns unique list of dependent libraries for given parameter.
|
445
|
-
#
|
446
|
-
# @param [Array] libs Libraries for using dependent libs
|
447
|
-
#
|
448
|
-
# @return [Set] All dependent libs
|
449
|
-
#
|
450
|
-
def all_lib_deps(libs)
|
451
|
-
@lib_type ||= PrjFileCache.entries_reversed(['LIB', 'SOLIB'])
|
452
|
-
@dependent_libs ||= Set.new
|
453
|
-
|
454
|
-
libs.each do |name|
|
455
|
-
if (@lib_cache.has_key?(name))
|
456
|
-
unless @dependent_libs.contain?(name)
|
457
|
-
@dependent_libs += all_lib_deps(PrjFileCache.get(@lib_type[name], name, 'ADD_LIBS'))
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
@dependent_libs
|
462
|
-
end
|
463
|
-
|
464
|
-
|
465
444
|
# Search dependent libraries as specified in ADD_LIBS setting
|
466
445
|
# of prj.rake file
|
467
446
|
#
|
468
447
|
# @param [String] settings The project settings definition
|
469
448
|
#
|
470
|
-
# @return [Hash]
|
471
|
-
# @option return [Array] :local
|
472
|
-
# @option return [Array] :
|
449
|
+
# @return [Hash] Containing the following components mapped to an array:
|
450
|
+
# @option return [Array] :local all local libs found by toolchain
|
451
|
+
# @option return [Array] :local_alibs local static libs found by toolchain
|
452
|
+
# @option return [Array] :local_solibs local shared libs found by toolchain
|
453
|
+
# @option return [Array] :all local + external libs
|
473
454
|
#
|
474
455
|
def search_libs(settings)
|
475
456
|
# get all libs specified in ADD_LIBS
|
476
|
-
|
457
|
+
search_libs = settings['ADD_LIBS'].split
|
458
|
+
our_lib_deps = []
|
459
|
+
search_libs.each do |lib|
|
460
|
+
our_lib_deps << lib
|
461
|
+
deps_of_lib = @@all_libs_and_deps[lib]
|
462
|
+
if deps_of_lib
|
463
|
+
our_lib_deps += deps_of_lib
|
464
|
+
end
|
465
|
+
end
|
466
|
+
our_lib_deps.uniq!
|
477
467
|
|
478
468
|
# match libs found by toolchain
|
479
|
-
|
480
|
-
|
469
|
+
solibs_local = []
|
470
|
+
alibs_local = []
|
471
|
+
our_lib_deps.each do |lib|
|
472
|
+
if PrjFileCache.contain?('LIB', lib)
|
473
|
+
alibs_local << lib
|
474
|
+
elsif PrjFileCache.contain?('SOLIB', lib)
|
475
|
+
solibs_local << lib
|
476
|
+
end
|
481
477
|
end
|
478
|
+
local_libs = (alibs_local + solibs_local) || []
|
482
479
|
|
483
480
|
# return value is a hash
|
484
481
|
{
|
485
|
-
:local
|
486
|
-
:
|
482
|
+
:local => local_libs,
|
483
|
+
:local_alibs => alibs_local,
|
484
|
+
:local_solibs => solibs_local,
|
485
|
+
:all => our_lib_deps
|
487
486
|
}
|
488
487
|
end
|
489
488
|
|
489
|
+
|
490
490
|
# Iterate over each local library and execute given block
|
491
491
|
#
|
492
492
|
# @param [Block] block The block that is executed
|
@@ -498,6 +498,24 @@ module RakeOE
|
|
498
498
|
end
|
499
499
|
end
|
500
500
|
|
501
|
+
|
502
|
+
#
|
503
|
+
# Returns absolute paths to given libraries, if they are local libraries
|
504
|
+
# of the current project.
|
505
|
+
#
|
506
|
+
def paths_of_libs(some_libs)
|
507
|
+
local_libs = Array.new
|
508
|
+
|
509
|
+
some_libs.each do |lib|
|
510
|
+
if PrjFileCache.contain?('LIB', lib)
|
511
|
+
local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.a"
|
512
|
+
elsif PrjFileCache.contain?('SOLIB', lib)
|
513
|
+
local_libs << "#{tc.settings['LIB_OUT']}/lib#{lib}.so"
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
local_libs
|
518
|
+
end
|
501
519
|
#
|
502
520
|
# Returns absolute paths to dependend local libraries, i.e. libraries
|
503
521
|
# of the current project.
|
data/lib/rakeoe/config.rb
CHANGED
@@ -95,7 +95,9 @@ module RakeOE
|
|
95
95
|
|
96
96
|
# Dumps configuration to stdout
|
97
97
|
def dump
|
98
|
-
puts '
|
98
|
+
puts '******************'
|
99
|
+
puts '* RakeOE::Config *'
|
100
|
+
puts '******************'
|
99
101
|
puts "Directories : #{@directories}"
|
100
102
|
puts "Suffixes : #{@suffixes}"
|
101
103
|
puts "Platform : #{@platform}"
|
data/lib/rakeoe/lib.rb
CHANGED
@@ -24,6 +24,9 @@ module RakeOE
|
|
24
24
|
|
25
25
|
|
26
26
|
# Create all rules and tasks for the lib
|
27
|
+
# XXX DS: we have to make a consistent step by step approach for each binary type
|
28
|
+
# XXX DS: something like: 1.) search library dependencies, 2.)build paths, 3.) create main rule,
|
29
|
+
# XXX DS: 4.) make test rules, 5, make additional rules (clean/all, ...) etc.
|
27
30
|
def create
|
28
31
|
unless project_can_build?
|
29
32
|
disable_build
|
@@ -32,10 +35,12 @@ module RakeOE
|
|
32
35
|
|
33
36
|
desc "Create #{name}"
|
34
37
|
|
38
|
+
prj_libs = search_libs(settings)
|
39
|
+
#puts "prj_libs for #{name}: #{prj_libs}"
|
35
40
|
task name => [binary]
|
36
|
-
|
37
|
-
file binary =>
|
38
|
-
|
41
|
+
dependency_paths = paths_of_local_libs + deps + objs
|
42
|
+
file binary => dependency_paths do
|
43
|
+
tc.test_all_files_exist?(dependency_paths)
|
39
44
|
tc.lib(:objects => objs,
|
40
45
|
:lib => binary,
|
41
46
|
:libs => prj_libs[:all],
|
@@ -43,7 +48,7 @@ module RakeOE
|
|
43
48
|
end
|
44
49
|
|
45
50
|
if test_objs.any? && (tc.config.test_fw.size > 0)
|
46
|
-
create_test_rules()
|
51
|
+
create_test_rules(:libs => prj_libs)
|
47
52
|
end
|
48
53
|
|
49
54
|
task name+'_clean' do
|
@@ -66,7 +71,7 @@ module RakeOE
|
|
66
71
|
|
67
72
|
|
68
73
|
# Create all rules and tasks
|
69
|
-
def create_test_rules
|
74
|
+
def create_test_rules(params)
|
70
75
|
namespace 'test' do
|
71
76
|
# Build the library and execute tests
|
72
77
|
desc "Test #{name}"
|
@@ -81,10 +86,10 @@ module RakeOE
|
|
81
86
|
|
82
87
|
# 'hidden' task just for building the test
|
83
88
|
task "#{name}_build" => test_binary
|
89
|
+
prj_libs = params[:libs]
|
84
90
|
|
85
91
|
# main rule for the test binary
|
86
|
-
file test_binary => [@test_fw.binary_path] + [binary] + test_deps + test_objs do
|
87
|
-
prj_libs = search_libs(settings)
|
92
|
+
file test_binary => [@test_fw.binary_path] + paths_of_local_libs + [binary] + test_deps + test_objs do
|
88
93
|
tc.test(:objects => test_objs,
|
89
94
|
:test => test_binary,
|
90
95
|
:libs => prj_libs[:all] + [name],
|
@@ -6,14 +6,25 @@ require 'rake'
|
|
6
6
|
module RakeOE
|
7
7
|
|
8
8
|
# Finds all project files and reads them into memory
|
9
|
-
# Maps
|
9
|
+
# Maps found entries to the following hash format:
|
10
|
+
#
|
11
|
+
# {"PRJ_TYPE1" => [{"NAME1"=>{"SETTING1" => "VALUE1", "SETTING2" => "VALUE2", ... },
|
12
|
+
# {"NAME2"=>{"SETTING1" => "VALUE1", "SETTING2" => "VALUE2", ... },
|
13
|
+
# ... ,
|
14
|
+
# ]
|
15
|
+
# {"PRJ_TYPE2" => [{"NAME100"=>{"SETTING1" => "VALUE1", "SETTING2" => "VALUE2", ... },
|
16
|
+
# {"NAME101"=>{"SETTING1" => "VALUE1", "SETTING2" => "VALUE2", ... },
|
17
|
+
# ... ,
|
18
|
+
# ]
|
19
|
+
# }
|
10
20
|
# XXX DS: IDEA: generate all runtime dependencies at the beginning for each prj,
|
11
21
|
# XXX DS: e.g. lib includes, source files, dependency files etc. and cache those as own variable in @prj_list
|
12
22
|
class PrjFileCache
|
13
23
|
|
14
|
-
attr_accessor :prj_list
|
24
|
+
class << self; attr_accessor :prj_list end
|
15
25
|
|
16
|
-
# Introduce hash of projects.
|
26
|
+
# Introduce class instance variable: hash of projects.
|
27
|
+
# Contains list of project with key 'PRJ_TYPE'
|
17
28
|
@prj_list = {}
|
18
29
|
|
19
30
|
#
|
@@ -59,6 +70,21 @@ module RakeOE
|
|
59
70
|
end
|
60
71
|
|
61
72
|
|
73
|
+
# Returns specific project library settings with given library names
|
74
|
+
#
|
75
|
+
# @param libs Name of libraries
|
76
|
+
#
|
77
|
+
def self.get_lib_entries(libs)
|
78
|
+
rv = {}
|
79
|
+
self.entries_reversed(['ALIB', 'SOLIB']).each_pair do |entries, prj_name|
|
80
|
+
if libs.include?(prj_name)
|
81
|
+
rv[prj_name] = entries
|
82
|
+
end
|
83
|
+
end
|
84
|
+
rv
|
85
|
+
end
|
86
|
+
|
87
|
+
|
62
88
|
# Returns specific value of a setting of the specified
|
63
89
|
# project
|
64
90
|
def self.get(prj_type, prj_name, setting)
|
@@ -67,6 +93,24 @@ module RakeOE
|
|
67
93
|
end
|
68
94
|
|
69
95
|
|
96
|
+
# Returns specific value of a setting of the specified
|
97
|
+
# project
|
98
|
+
def self.get_with_name(prj_name, setting)
|
99
|
+
projects = @prj_list.values.flatten
|
100
|
+
projects.each do |project|
|
101
|
+
values = project[prj_name]
|
102
|
+
if values
|
103
|
+
value = values[setting].split
|
104
|
+
if value
|
105
|
+
return value
|
106
|
+
else
|
107
|
+
return []
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
[]
|
112
|
+
end
|
113
|
+
|
70
114
|
# Do we know anything about prj_name ?
|
71
115
|
def self.contain?(prj_type, prj_name)
|
72
116
|
return false unless @prj_list.has_key?(prj_type)
|
@@ -87,13 +131,56 @@ module RakeOE
|
|
87
131
|
@prj_list[prj_type][prj_name]['PRJ_HOME']
|
88
132
|
end
|
89
133
|
|
90
|
-
|
134
|
+
# iterate over each project with given project type
|
91
135
|
def self.for_each(prj_type, &block)
|
92
136
|
return unless @prj_list.has_key?(prj_type)
|
93
137
|
@prj_list[prj_type].each_pair &block
|
94
138
|
end
|
95
139
|
|
96
140
|
|
141
|
+
#
|
142
|
+
# Recursive function that uses each value of the array given via
|
143
|
+
# parameter 'values' and uses parameter 'setting' for accessing the
|
144
|
+
# values for next recursion step until all values have been traversed
|
145
|
+
# in all projects
|
146
|
+
def self.deps_recursive(values, setting, visited=Set.new)
|
147
|
+
return visited if values.nil?
|
148
|
+
values.each do |val|
|
149
|
+
next if (visited.include?(val))
|
150
|
+
visited << val
|
151
|
+
next_values = PrjFileCache.get_with_name(val, setting)
|
152
|
+
deps_recursive(next_values, setting, visited)
|
153
|
+
end
|
154
|
+
visited
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
# Searches recursively for all projects with name and associate
|
159
|
+
# Dependency with given attribute
|
160
|
+
#
|
161
|
+
# Returns a hash of the following form:
|
162
|
+
# { 'name1' => ['name2', 'name3', ...],
|
163
|
+
# 'name2' => ['name1', 'name3', ...],
|
164
|
+
# 'name3' => ['name1', 'name5', ...],
|
165
|
+
# }
|
166
|
+
#
|
167
|
+
def self.search_recursive(params={})
|
168
|
+
attribute = params[:attribute]
|
169
|
+
names = params[:names]
|
170
|
+
rv = {}
|
171
|
+
@prj_list.values.flatten.each do |projects|
|
172
|
+
projects.each_pair do |prj_name, prj_attributes|
|
173
|
+
if (names.include?(prj_name))
|
174
|
+
attr_values = prj_attributes[attribute].split
|
175
|
+
dependencies = deps_recursive(attr_values, attribute)
|
176
|
+
rv[prj_name] = dependencies.to_a
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
rv
|
181
|
+
end
|
182
|
+
|
183
|
+
|
97
184
|
# Returns all entries for given project types as an array
|
98
185
|
# of reversed prj_name => prj_type mappings
|
99
186
|
#
|
@@ -103,13 +190,82 @@ module RakeOE
|
|
103
190
|
#
|
104
191
|
def self.entries_reversed(prj_types)
|
105
192
|
prj_types.each_with_object(Hash.new) do |prj_type, h|
|
106
|
-
h.merge!(@prj_list[prj_type].
|
193
|
+
h.merge!(@prj_list[prj_type].invert) if @prj_list.has_key?(prj_type)
|
107
194
|
end
|
108
195
|
end
|
109
196
|
|
197
|
+
|
198
|
+
#
|
199
|
+
# SEMANTIC METHODS, use specific attributes
|
200
|
+
#
|
201
|
+
|
202
|
+
|
203
|
+
# Checks if the project entries build prerequisites are met.
|
204
|
+
#
|
205
|
+
# If at least one of the following criteria are met, the method returns false:
|
206
|
+
# * project variable PRJ_TYPE == "DISABLED"
|
207
|
+
# * project variable IGNORED_PLATFORMS contains build platform
|
208
|
+
#
|
209
|
+
# @param entry The project name
|
210
|
+
# @param platform Current platform
|
211
|
+
#
|
212
|
+
# @return true if project can be built on current platform
|
213
|
+
# @return false if project settings prohibit building
|
214
|
+
#
|
215
|
+
def self.project_entry_buildable?(entry, platform)
|
216
|
+
(entry['IGNORED_PLATFORMS'].include?(platform)) &&
|
217
|
+
(entry['PRJ_TYPE'] != 'DISABLED')
|
218
|
+
end
|
219
|
+
|
220
|
+
=begin
|
221
|
+
# Checks if projects build prerequisites are met.
|
222
|
+
#
|
223
|
+
# If at least one of the following criteria are met, the method returns false:
|
224
|
+
# * project variable PRJ_TYPE == "DISABLED"
|
225
|
+
# * project variable IGNORED_PLATFORMS contains build platform
|
226
|
+
#
|
227
|
+
# @param prj_type The project type
|
228
|
+
# @param prj_name The project name
|
229
|
+
# @param platform Current platform
|
230
|
+
#
|
231
|
+
# @return true if project can be built on current platform
|
232
|
+
# @return false if project settings prohibit building
|
233
|
+
#
|
234
|
+
def self.project_can_build?(prj_type, prj_name, platform)
|
235
|
+
self.project_entry_buildable?(@prj_list[prj_type][prj_name], platform)
|
236
|
+
end
|
237
|
+
=end
|
238
|
+
|
239
|
+
# Joins all entries with keys that are appended with a regular expression that match
|
240
|
+
# the given match_string. Make them available via the base key name without the
|
241
|
+
# regular expression.
|
110
242
|
#
|
111
|
-
#
|
243
|
+
# @param a_string String to be matched against key in all kvr with appended regular expression
|
112
244
|
#
|
245
|
+
def self.join_regex_keys_for!(a_string)
|
246
|
+
@prj_list.each_pair do |prj_type, prj_names|
|
247
|
+
prj_names.each_pair do |prj_name, defs|
|
248
|
+
defs.each_pair do |property, value|
|
249
|
+
# split properties containing /../
|
250
|
+
base, key_regex = property.split(/\//)
|
251
|
+
if (key_regex)
|
252
|
+
if a_string.match(Regexp.new(key_regex))
|
253
|
+
if base.end_with?('_')
|
254
|
+
base_key = base.chop
|
255
|
+
else
|
256
|
+
base_key = base
|
257
|
+
end
|
258
|
+
|
259
|
+
# if base_key does not yet exist, create an empty string
|
260
|
+
@prj_list[prj_type][prj_name][base_key] ||= ''
|
261
|
+
@prj_list[prj_type][prj_name][base_key] += " #{@prj_list[prj_type][prj_name][property]}"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
113
269
|
|
114
270
|
# Returns exported include directories of a library project.
|
115
271
|
# If given name does not exist in local library projects, an empty array
|
data/lib/rakeoe/toolchain.rb
CHANGED
@@ -186,8 +186,7 @@ class Toolchain
|
|
186
186
|
|
187
187
|
# Set common build variables
|
188
188
|
#
|
189
|
-
|
190
|
-
def set_build_vars()
|
189
|
+
def set_build_vars
|
191
190
|
warning_flags = ' -W -Wall'
|
192
191
|
if 'release' == @config.release
|
193
192
|
optimization_flags = " #{@config.optimization_release} -DRELEASE"
|
@@ -289,6 +288,10 @@ class Toolchain
|
|
289
288
|
end
|
290
289
|
|
291
290
|
# Generates linker line from given library list.
|
291
|
+
# The linker line normally will be like -l<lib1> -l<lib2>, ...
|
292
|
+
#
|
293
|
+
# If a library has specific platform specific setting in the platform file
|
294
|
+
# with a specific -l<lib> alternative, this will be used instead.
|
292
295
|
#
|
293
296
|
# @param [Array] libs Libraries to be used for linker line
|
294
297
|
#
|
@@ -296,9 +299,10 @@ class Toolchain
|
|
296
299
|
#
|
297
300
|
def linker_line_for(libs)
|
298
301
|
return '' if (libs.nil? || libs.empty?)
|
302
|
+
|
299
303
|
libs.map do |lib|
|
300
304
|
settings = platform_settings_for(lib)
|
301
|
-
if settings[:LDFLAGS].nil?
|
305
|
+
if settings[:LDFLAGS].nil? || settings[:LDFLAGS].empty?
|
302
306
|
# automatic linker line if no platform specific LDFLAGS exist
|
303
307
|
"-l#{lib}"
|
304
308
|
else
|
@@ -308,11 +312,66 @@ class Toolchain
|
|
308
312
|
end.join(' ').strip
|
309
313
|
end
|
310
314
|
|
315
|
+
|
316
|
+
# Reduces the given list of libraries to bare minimum, i.e.
|
317
|
+
# the minimum needed for actual platform
|
318
|
+
#
|
319
|
+
# @libs list of libraries
|
320
|
+
#
|
321
|
+
# @return reduced list of libraries
|
322
|
+
#
|
323
|
+
def reduce_libs_to_bare_minimum(libs)
|
324
|
+
rv = libs.clone
|
325
|
+
lib_entries = RakeOE::PrjFileCache.get_lib_entries(libs)
|
326
|
+
lib_entries.each_pair do |lib, entry|
|
327
|
+
rv.delete(lib) unless RakeOE::PrjFileCache.project_entry_buildable?(entry, @target)
|
328
|
+
end
|
329
|
+
rv
|
330
|
+
end
|
331
|
+
|
332
|
+
|
333
|
+
# Return array of library prerequisites for given file
|
334
|
+
def libs_for_binary(a_binary, visited=[])
|
335
|
+
return [] if visited.include?(a_binary)
|
336
|
+
visited << a_binary
|
337
|
+
pre = Rake::Task[a_binary].prerequisites
|
338
|
+
rv = []
|
339
|
+
pre.each do |p|
|
340
|
+
|
341
|
+
next if (File.extname(p) != '.a') && (File.extname(p) != '.so')
|
342
|
+
next if p =~ /\-app\.a/
|
343
|
+
|
344
|
+
rv << File.basename(p).gsub(/(\.a|\.so|^lib)/, '')
|
345
|
+
rv += libs_for_binary(p, visited) # Recursive call
|
346
|
+
end
|
347
|
+
|
348
|
+
reduce_libs_to_bare_minimum(rv.uniq)
|
349
|
+
end
|
350
|
+
|
311
351
|
# Touches a file
|
312
352
|
def touch(file)
|
313
353
|
sh "#{@settings['TOUCH']} #{file}"
|
314
354
|
end
|
315
355
|
|
356
|
+
|
357
|
+
# Tests if all given files in given list exist
|
358
|
+
# @return true all file exist
|
359
|
+
# @return false not all file exist
|
360
|
+
def test_all_files_exist?(files)
|
361
|
+
files.each do |file|
|
362
|
+
raise "No such file: #{file}" unless File.exist?(file)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
def diagnose_buildability(projects)
|
367
|
+
projects.each do |project|
|
368
|
+
|
369
|
+
RakeOE::PrjFileCache.project_entry_buildable?(entry, platform)
|
370
|
+
end
|
371
|
+
|
372
|
+
end
|
373
|
+
|
374
|
+
|
316
375
|
# Returns platform specific settings of a resource (APP/LIB/SOLIB or external resource like e.g. an external library)
|
317
376
|
# as a hash with the keys CFLAGS, CXXFLAGS and LDFLAGS. The values are empty if no such resource settings exist inside
|
318
377
|
# the platform file. The resulting hash values can be used for platform specific compilation/linkage against the
|
@@ -419,7 +478,8 @@ class Toolchain
|
|
419
478
|
def lib(params = {})
|
420
479
|
ldflags = params[:settings]['ADD_LDFLAGS'] + ' ' + @settings['LDFLAGS']
|
421
480
|
objs = params[:objects].join(' ')
|
422
|
-
|
481
|
+
dep_libs = (params[:libs] + libs_for_binary(params[:lib])).uniq
|
482
|
+
libs = linker_line_for(dep_libs)
|
423
483
|
extension = File.extname(params[:lib])
|
424
484
|
|
425
485
|
case extension
|
@@ -448,7 +508,8 @@ class Toolchain
|
|
448
508
|
incs = compiler_incs_for(params[:includes])
|
449
509
|
ldflags = params[:settings]['ADD_LDFLAGS'] + ' ' + @settings['LDFLAGS']
|
450
510
|
objs = params[:objects].join(' ')
|
451
|
-
|
511
|
+
dep_libs = (params[:libs] + libs_for_binary(params[:app])).uniq
|
512
|
+
libs = linker_line_for(dep_libs)
|
452
513
|
|
453
514
|
sh "#{@settings['SIZE']} #{objs} >#{params[:app]}.size" if @settings['SIZE']
|
454
515
|
sh "#{@settings['CXX']} #{incs} #{objs} #{ldflags} #{libs} -o #{params[:app]} -Wl,-Map,#{params[:app]}.map"
|
@@ -470,13 +531,16 @@ class Toolchain
|
|
470
531
|
ldflags = params[:settings]['ADD_LDFLAGS'] + ' ' + @settings['LDFLAGS']
|
471
532
|
objs = params[:objects].join(' ')
|
472
533
|
test_fw = linker_line_for([params[:framework]])
|
473
|
-
|
534
|
+
dep_libs = (params[:libs] + libs_for_binary(params[:test])).uniq
|
535
|
+
libs = linker_line_for(dep_libs)
|
474
536
|
|
475
537
|
sh "#{@settings['CXX']} #{incs} #{objs} #{test_fw} #{ldflags} #{libs} -o #{params[:test]}"
|
476
538
|
end
|
477
539
|
|
478
540
|
def dump
|
479
|
-
|
541
|
+
puts '**************************'
|
542
|
+
puts '* Platform configuration *'
|
543
|
+
puts '**************************'
|
480
544
|
@kvr.dump
|
481
545
|
end
|
482
546
|
|
data/lib/rakeoe/version.rb
CHANGED
data/lib/rakeoe.rb
CHANGED
data/rakeoe.gemspec
CHANGED
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "rspec"
|
29
29
|
spec.add_development_dependency "factory_girl", "~> 4.0"
|
30
|
-
|
30
|
+
|
31
|
+
spec.required_ruby_version = '>= 1.9.2'
|
32
|
+
|
31
33
|
spec.add_dependency "rake"
|
32
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakeoe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
requirements:
|
146
146
|
- - ! '>='
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version:
|
148
|
+
version: 1.9.2
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|