rakeoe 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +674 -0
- data/README.md +234 -0
- data/Rakefile +1 -0
- data/lib/rakeoe/app.rb +158 -0
- data/lib/rakeoe/binary_base.rb +492 -0
- data/lib/rakeoe/config.rb +93 -0
- data/lib/rakeoe/defaults.rb +45 -0
- data/lib/rakeoe/key_value_reader.rb +165 -0
- data/lib/rakeoe/lib.rb +100 -0
- data/lib/rakeoe/prj_file_cache.rb +119 -0
- data/lib/rakeoe/qt_settings.rb +88 -0
- data/lib/rakeoe/test_framework.rb +40 -0
- data/lib/rakeoe/toolchain/environment-arm-none-eabi +47 -0
- data/lib/rakeoe/toolchain/environment-arm-none-eabi.Linux +46 -0
- data/lib/rakeoe/toolchain/environment-arm-none-eabi.osx +46 -0
- data/lib/rakeoe/toolchain/environment-arm-stm32f072-eabi.Linux +46 -0
- data/lib/rakeoe/toolchain/environment-arm-stm32f072-eabi.osx +46 -0
- data/lib/rakeoe/toolchain.rb +457 -0
- data/lib/rakeoe/version.rb +3 -0
- data/lib/rakeoe.rb +94 -0
- data/rakeoe.gemspec +30 -0
- metadata +129 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
export PATH="/Users/dschnell/install/gcc-arm-none-eabi-4_8-2013q4/bin/:$PATH"
|
2
|
+
export PKG_CONFIG_SYSROOT_DIR=
|
3
|
+
export PKG_CONFIG_PATH=
|
4
|
+
export CONFIG_SITE=
|
5
|
+
export CC="arm-none-eabi-gcc"
|
6
|
+
export CXX="arm-none-eabi-g++"
|
7
|
+
export CPP="arm-none-eabi-gcc -E"
|
8
|
+
export AS="arm-none-eabi-as"
|
9
|
+
export LD="arm-none-eabi-ld"
|
10
|
+
export GDB="arm-none-eabi-gdb"
|
11
|
+
export STRIP="arm-none-eabi-strip"
|
12
|
+
export RANLIB="arm-none-eabi-ranlib"
|
13
|
+
export OBJCOPY="arm-none-eabi-objcopy"
|
14
|
+
export OBJDUMP="arm-none-eabi-objdump"
|
15
|
+
export AR="arm-none-eabi-ar"
|
16
|
+
export NM="arm-none-eabi-nm"
|
17
|
+
export SIZE="arm-none-eabi-size"
|
18
|
+
export M4=
|
19
|
+
export TARGET_PREFIX=arm-none-eabi-
|
20
|
+
export CONFIGURE_FLAGS=
|
21
|
+
export CFLAGS=" -std=gnu99 -mcpu=cortex-m0 -mthumb -fomit-frame-pointer -fdata-sections -ffunction-sections -D__ASSEMBLY__ -DSTM32F072X -DSTM32F072"
|
22
|
+
export CXXFLAGS=" -mcpu=cortex-m0 -mthumb -fomit-frame-pointer -fdata-sections -ffunction-sections -D__ASSEMBLY__"
|
23
|
+
export LDFLAGS=' -mcpu=cortex-m0 -mthumb -g -nostartfiles -Wl,--gc-sections -Xlinker -Tlinker/stm32f072_linker.ld'
|
24
|
+
export CPPFLAGS=
|
25
|
+
export OECORE_NATIVE_SYSROOT=
|
26
|
+
export OECORE_TARGET_SYSROOT=
|
27
|
+
export OECORE_ACLOCAL_OPTS=
|
28
|
+
export OECORE_DISTRO_VERSION=
|
29
|
+
export OECORE_SDK_VERSION=
|
30
|
+
export OE_QMAKE_CFLAGS=
|
31
|
+
export OE_QMAKE_CXXFLAGS=
|
32
|
+
export OE_QMAKE_LDFLAGS=
|
33
|
+
export OE_QMAKE_CC=
|
34
|
+
export OE_QMAKE_CXX=
|
35
|
+
export OE_QMAKE_LINK=
|
36
|
+
export OE_QMAKE_AR=
|
37
|
+
export OE_QMAKE_LIBDIR_QT=
|
38
|
+
export OE_QMAKE_INCDIR_QT=
|
39
|
+
export OE_QMAKE_MOC=
|
40
|
+
export OE_QMAKE_UIC=
|
41
|
+
export OE_QMAKE_UIC3=
|
42
|
+
export OE_QMAKE_RCC=
|
43
|
+
export OE_QMAKE_QDBUSCPP2XML=
|
44
|
+
export OE_QMAKE_QDBUSXML2CPP=
|
45
|
+
export OE_QMAKE_QT_CONFIG=
|
46
|
+
export QMAKESPEC=
|
@@ -0,0 +1,457 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'rake/loaders/makefile'
|
5
|
+
require 'rakeoe/defaults'
|
6
|
+
require 'rakeoe/test_framework'
|
7
|
+
|
8
|
+
module RakeOE
|
9
|
+
|
10
|
+
#
|
11
|
+
# Toolchain specific key value reader
|
12
|
+
#
|
13
|
+
# @author Daniel Schnell
|
14
|
+
class Toolchain
|
15
|
+
attr_reader :qt, :settings, :target, :config
|
16
|
+
|
17
|
+
# Initializes object
|
18
|
+
#
|
19
|
+
# @param [RakeOE::Config] config Project wide configurations
|
20
|
+
#
|
21
|
+
def initialize(config)
|
22
|
+
@config = config
|
23
|
+
|
24
|
+
@kvr = KeyValueReader.new(config.platform)
|
25
|
+
@settings = @kvr.env
|
26
|
+
fixup_env
|
27
|
+
|
28
|
+
# save target platform of our compiler (gcc specific)
|
29
|
+
if RbConfig::CONFIG["host_os"] != "mingw32"
|
30
|
+
@target=`export PATH=#{@settings['PATH']} && #{@settings['CC']} -dumpmachine`.chop
|
31
|
+
else
|
32
|
+
@target=`PATH = #{@settings['PATH']} & #{@settings['CC']} -dumpmachine`.chop
|
33
|
+
end
|
34
|
+
|
35
|
+
@settings['TOUCH'] = 'touch'
|
36
|
+
# XXX DS: we should only instantiate @qt if we have any qt settings
|
37
|
+
@qt = QtSettings.new(self)
|
38
|
+
set_build_vars()
|
39
|
+
|
40
|
+
init_test_frameworks
|
41
|
+
sanity
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# Do some sanity checks
|
46
|
+
def sanity
|
47
|
+
# TODO DS: check if libs and apps directories exist
|
48
|
+
# TODO DS: check if test frameworks exist
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns the build directory
|
52
|
+
def build_dir
|
53
|
+
@config.directories[:build]
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
# Initializes definitions for test framework
|
58
|
+
# TODO: Add possibility to configure test framework specific CFLAGS/CXXFLAGS
|
59
|
+
def init_test_frameworks()
|
60
|
+
@@test_framework ||= Hash.new
|
61
|
+
|
62
|
+
config_empty_test_framework
|
63
|
+
|
64
|
+
if @config.test_fw.size > 0
|
65
|
+
if PrjFileCache.contain?('LIB', @config.test_fw)
|
66
|
+
@@test_framework[@config.test_fw] = TestFramework.new(:name => @config.test_fw,
|
67
|
+
:binary_path => "#{@settings['LIB_OUT']}/lib#{@config.test_fw}.a",
|
68
|
+
:include_dir => PrjFileCache.exported_lib_incs(@config.test_fw),
|
69
|
+
:cflags => '')
|
70
|
+
else
|
71
|
+
puts "WARNING: Configured test framework (#{@config.test_fw}) does not exist in project!"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Configures empty test framework
|
77
|
+
def config_empty_test_framework
|
78
|
+
@@test_framework[''] = TestFramework.new(:name => '',
|
79
|
+
:binary_path => '',
|
80
|
+
:include_dir => '',
|
81
|
+
:cflags => '')
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns default test framework or nil if none defined
|
86
|
+
def default_test_framework
|
87
|
+
test_framework(@config.test_fw) || test_framework('')
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns definitions of specific test framework or none if
|
91
|
+
# specified test framework doesn't exist
|
92
|
+
def test_framework(name)
|
93
|
+
@@test_framework[name]
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns list of all registered test framework names
|
97
|
+
def test_frameworks
|
98
|
+
@@test_framework.keys
|
99
|
+
end
|
100
|
+
|
101
|
+
# returns library project setting
|
102
|
+
def lib_setting(name, setting)
|
103
|
+
@libs.get(name, setting)
|
104
|
+
end
|
105
|
+
|
106
|
+
# returns app project setting
|
107
|
+
def app_setting(name, setting)
|
108
|
+
@apps.get(name, setting)
|
109
|
+
end
|
110
|
+
|
111
|
+
# returns c++ source extensions
|
112
|
+
def cpp_source_extensions
|
113
|
+
(@config.suffixes[:cplus_sources] + [@config.suffixes[:moc_source]]).uniq
|
114
|
+
end
|
115
|
+
|
116
|
+
# returns c source extensions
|
117
|
+
def c_source_extensions
|
118
|
+
@config.suffixes[:c_sources].uniq
|
119
|
+
end
|
120
|
+
|
121
|
+
# returns assembler source extensions
|
122
|
+
def as_source_extensions
|
123
|
+
@config.suffixes[:as_sources].uniq
|
124
|
+
end
|
125
|
+
|
126
|
+
# returns all source extensions
|
127
|
+
def source_extensions
|
128
|
+
cpp_source_extensions + c_source_extensions + as_source_extensions
|
129
|
+
end
|
130
|
+
|
131
|
+
# returns c++ header extensions
|
132
|
+
def cpp_header_extensions
|
133
|
+
(@config.suffixes[:cplus_headers] + [@config.suffixes[:moc_header]]).uniq
|
134
|
+
end
|
135
|
+
|
136
|
+
# returns c header extensions
|
137
|
+
def c_header_extensions
|
138
|
+
@config.suffixes[:c_headers].uniq
|
139
|
+
end
|
140
|
+
|
141
|
+
# returns moc header extensions
|
142
|
+
def moc_header_extension
|
143
|
+
@config.suffixes[:moc_header]
|
144
|
+
end
|
145
|
+
|
146
|
+
# returns c++ header extensions
|
147
|
+
def moc_source
|
148
|
+
@config.suffixes[:moc_source]
|
149
|
+
end
|
150
|
+
|
151
|
+
# Specific fixups for toolchain
|
152
|
+
def fixup_env
|
153
|
+
# set system PATH if no PATH defined
|
154
|
+
@settings['PATH'] ||= ENV['PATH']
|
155
|
+
|
156
|
+
# replace $PATH
|
157
|
+
@settings['PATH'] = @settings['PATH'].gsub('$PATH', ENV['PATH'])
|
158
|
+
|
159
|
+
# create ARCH
|
160
|
+
@settings['ARCH'] = "#{@settings['TARGET_PREFIX']}".chop
|
161
|
+
|
162
|
+
# remove optimizations, we set these explicitly
|
163
|
+
@settings['CXXFLAGS'] = "#{@settings['CXXFLAGS']} -DPROGRAM_VERSION=\\\"#{@config.sw_version}\\\"".gsub('-O2', '')
|
164
|
+
@settings['CFLAGS'] = "#{@settings['CFLAGS']} -DPROGRAM_VERSION=\\\"#{@config.sw_version}\\\"".gsub('-O2', '')
|
165
|
+
KeyValueReader.substitute_dollar_symbols!(@settings)
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# Set common build variables
|
170
|
+
#
|
171
|
+
# @param [String] release_mode Release mode used for the build, either 'release' or 'dbg'
|
172
|
+
def set_build_vars()
|
173
|
+
warning_flags = ' -W -Wall'
|
174
|
+
if 'release' == @config.release
|
175
|
+
optimization_flags = " #{@config.optimization_release} -DRELEASE"
|
176
|
+
else
|
177
|
+
optimization_flags = " #{@config.optimization_dbg} -g"
|
178
|
+
end
|
179
|
+
|
180
|
+
# we could make these also arrays of source directories ...
|
181
|
+
@settings['APP_SRC_DIR'] = 'src/app'
|
182
|
+
@settings['LIB_SRC_DIR'] = 'src/lib'
|
183
|
+
|
184
|
+
# derived settings
|
185
|
+
@settings['BUILD_DIR'] = "#{build_dir}/#{@target}/#{@config.release}"
|
186
|
+
@settings['LIB_OUT'] = "#{@settings['BUILD_DIR']}/libs"
|
187
|
+
@settings['APP_OUT'] = "#{@settings['BUILD_DIR']}/apps"
|
188
|
+
@settings['SYS_LFLAGS'] = "-L#{@settings['OECORE_TARGET_SYSROOT']}/lib -L#{@settings['OECORE_TARGET_SYSROOT']}/usr/lib"
|
189
|
+
|
190
|
+
# set LD_LIBRARY_PATH
|
191
|
+
@settings['LD_LIBRARY_PATH'] = @settings['LIB_OUT']
|
192
|
+
|
193
|
+
# standard settings
|
194
|
+
@settings['CXXFLAGS'] += warning_flags + optimization_flags + " #{@config.language_std_cpp}"
|
195
|
+
@settings['CFLAGS'] += warning_flags + optimization_flags + " #{@config.language_std_c}"
|
196
|
+
if @settings['PRJ_TYPE'] == 'SOLIB'
|
197
|
+
@settings['CXXFLAGS'] += ' -fPIC'
|
198
|
+
@settings['CFLAGS'] += ' -fPIC'
|
199
|
+
end
|
200
|
+
# !! don't change order of the following string components without care !!
|
201
|
+
@settings['LDFLAGS'] = @settings['LDFLAGS'] + " -L #{@settings['LIB_OUT']} #{@settings['SYS_LFLAGS']} -Wl,--no-as-needed -Wl,--start-group"
|
202
|
+
end
|
203
|
+
|
204
|
+
# Executes the command
|
205
|
+
def sh(cmd, silent: false)
|
206
|
+
if RbConfig::CONFIG["host_os"] != "mingw32"
|
207
|
+
full_cmd = "export PATH=#{@settings['PATH']} && #{cmd}"
|
208
|
+
else
|
209
|
+
full_cmd = "PATH = #{@settings['PATH']} & #{cmd}"
|
210
|
+
end
|
211
|
+
|
212
|
+
if silent
|
213
|
+
system full_cmd
|
214
|
+
else
|
215
|
+
Rake::sh full_cmd
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
# Removes list of given files
|
221
|
+
# @param [String] files List of files to be deleted
|
222
|
+
def rm(files)
|
223
|
+
if files
|
224
|
+
Rake::sh "rm -f #{files}" unless files.empty?
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
# Executes a given binary
|
230
|
+
#
|
231
|
+
# @param [String] binary Absolute path of the binary to be executed
|
232
|
+
#
|
233
|
+
def run(binary)
|
234
|
+
# compare ruby platform config and our target setting
|
235
|
+
if @target[RbConfig::CONFIG["target_cpu"]]
|
236
|
+
system "export LD_LIBRARY_PATH=#{@settings['LD_LIBRARY_PATH']} && #{binary}"
|
237
|
+
else
|
238
|
+
puts "Warning: Can't execute on this platform: #{binary}"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
# Executes a given test binary with test runner specific parameter(s)
|
243
|
+
#
|
244
|
+
# @param [String] binary Absolute path of the binary to be executed
|
245
|
+
#
|
246
|
+
def run_junit_test(binary)
|
247
|
+
# compare ruby platform config and our target setting
|
248
|
+
if @target[RbConfig::CONFIG["target_cpu"]]
|
249
|
+
system "export LD_LIBRARY_PATH=#{@settings['LD_LIBRARY_PATH']} && #{binary} -o junit"
|
250
|
+
else
|
251
|
+
puts "Warning: Can't execute test on this platform: #{binary}"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# Tests given list of platforms if any of those matches the current platform
|
256
|
+
def current_platform_any?(platforms)
|
257
|
+
([@target] & platforms).any?
|
258
|
+
end
|
259
|
+
|
260
|
+
# Generates compiler include line from given include path list
|
261
|
+
#
|
262
|
+
# @param [Array] paths Paths to be used for include file search
|
263
|
+
#
|
264
|
+
# @return [String] Compiler include line
|
265
|
+
#
|
266
|
+
def compiler_incs_for(paths)
|
267
|
+
paths.each_with_object('') {|path, str| str << " -I#{path}"}
|
268
|
+
end
|
269
|
+
|
270
|
+
# Generates linker line from given library list
|
271
|
+
#
|
272
|
+
# @param [Array] libs Libraries to be used for linker line
|
273
|
+
#
|
274
|
+
# @return [String] Linker line
|
275
|
+
#
|
276
|
+
def linker_line_for(libs)
|
277
|
+
libs.map { |lib| "-l#{lib}" }.join(' ').strip
|
278
|
+
end
|
279
|
+
|
280
|
+
# Touches a file
|
281
|
+
def touch(file)
|
282
|
+
sh "#{@settings['TOUCH']} #{file}"
|
283
|
+
end
|
284
|
+
|
285
|
+
# Returns platform specific settings of a resource (APP/LIB/SOLIB or external resource like e.g. an external library)
|
286
|
+
# as a hash with the keys CFLAGS, CXXFLAGS and LDFLAGS. The values are empty if no such resource settings exist inside
|
287
|
+
# the platform file. The resulting hash values can be used for platform specific compilation/linkage against the
|
288
|
+
# the resource.
|
289
|
+
#
|
290
|
+
# @param resource_name [String] name of resource
|
291
|
+
# @return [Hash] Hash of compilation/linkage flags or empty hash if no settings are defined
|
292
|
+
# The returned hash has the following format:
|
293
|
+
# { 'CFLAGS' => '...', 'CXXFLAGS' => '...', 'LDFLAGS' => '...'}
|
294
|
+
#
|
295
|
+
def res_platform_settings(resource_name)
|
296
|
+
return {} if resource_name.empty?
|
297
|
+
|
298
|
+
rv = Hash.new
|
299
|
+
rv['CFLAGS'] = @settings["#{resource_name}_CFLAGS"]
|
300
|
+
rv['CXXFLAGS'] = @settings["#{resource_name}_CXXFLAGS"]
|
301
|
+
rv['LDFLAGS'] = @settings["#{resource_name}_LDFLAGS"]
|
302
|
+
rv
|
303
|
+
end
|
304
|
+
|
305
|
+
# Creates compilation object
|
306
|
+
#
|
307
|
+
# @param [Hash] params
|
308
|
+
# @option params [String] :source source filename with path
|
309
|
+
# @option params [String] :object object filename path
|
310
|
+
# @option params [Hash] :settings project specific settings
|
311
|
+
# @option params [Array] :includes include paths used
|
312
|
+
#
|
313
|
+
def obj(params = {})
|
314
|
+
extension = File.extname(params[:source])
|
315
|
+
object = params[:object]
|
316
|
+
source = params[:source]
|
317
|
+
incs = compiler_incs_for(params[:includes]) + " #{@settings['LIB_INC']}"
|
318
|
+
=begin
|
319
|
+
puts
|
320
|
+
puts "incs for #{object}: #{incs}"
|
321
|
+
puts
|
322
|
+
puts "params[:includes]:#{params[:includes]}"
|
323
|
+
puts
|
324
|
+
=end
|
325
|
+
case
|
326
|
+
when cpp_source_extensions.include?(extension)
|
327
|
+
flags = @settings['CXXFLAGS'] + ' ' + params[:settings]['ADD_CXXFLAGS']
|
328
|
+
compiler = "#{@settings['CXX']} -x c++ "
|
329
|
+
when c_source_extensions.include?(extension)
|
330
|
+
flags = @settings['CFLAGS'] + ' ' + params[:settings]['ADD_CFLAGS']
|
331
|
+
compiler = "#{@settings['CC']} -x c "
|
332
|
+
when as_source_extensions.include?(extension)
|
333
|
+
flags = ''
|
334
|
+
compiler = "#{@settings['AS']}"
|
335
|
+
else
|
336
|
+
raise "unsupported source file extension (#{extension}) for creating object!"
|
337
|
+
end
|
338
|
+
sh "#{compiler} #{flags} #{incs} -c #{source} -o #{object}"
|
339
|
+
end
|
340
|
+
|
341
|
+
|
342
|
+
# Creates dependency
|
343
|
+
#
|
344
|
+
# @param [Hash] params
|
345
|
+
# @option params [String] :source source filename with path
|
346
|
+
# @option params [String] :dep dependency filename path
|
347
|
+
# @option params [Hash] :settings project specific settings
|
348
|
+
# @option params [Array] :includes include paths used
|
349
|
+
#
|
350
|
+
def dep(params = {})
|
351
|
+
extension = File.extname(params[:source])
|
352
|
+
dep = params[:dep]
|
353
|
+
source = params[:source]
|
354
|
+
incs = compiler_incs_for(params[:includes]) + " #{@settings['LIB_INC']}"
|
355
|
+
case
|
356
|
+
when cpp_source_extensions.include?(extension)
|
357
|
+
flags = @settings['CXXFLAGS'] + ' ' + params[:settings]['ADD_CXXFLAGS']
|
358
|
+
compiler = "#{@settings['CXX']} -x c++ "
|
359
|
+
when c_source_extensions.include?(extension)
|
360
|
+
flags = @settings['CFLAGS'] + ' ' + params[:settings]['ADD_CFLAGS']
|
361
|
+
compiler = "#{@settings['CC']} -x c "
|
362
|
+
when as_source_extensions.include?(extension)
|
363
|
+
flags = ''
|
364
|
+
compiler = "#{@settings['AS']}"
|
365
|
+
else
|
366
|
+
raise "unsupported source file extension (#{extension}) for creating dependency!"
|
367
|
+
end
|
368
|
+
sh "#{compiler} -MM #{flags} #{incs} -c #{source} -MT #{dep.ext('.o')} -MF #{dep}", silent: true
|
369
|
+
end
|
370
|
+
|
371
|
+
|
372
|
+
# Creates moc_ source file
|
373
|
+
#
|
374
|
+
# @param [Hash] params
|
375
|
+
# @option params [String] :source source filename with path
|
376
|
+
# @option params [String] :moc moc_XXX filename path
|
377
|
+
# @option params [Hash] :settings project specific settings
|
378
|
+
#
|
379
|
+
def moc(params = {})
|
380
|
+
moc_compiler = @settings['OE_QMAKE_MOC']
|
381
|
+
raise 'No Qt Toolchain set' if moc_compiler.empty?
|
382
|
+
sh "#{moc_compiler} -i -f#{File.basename(params[:source])} #{params[:source]} >#{params[:moc]}"
|
383
|
+
end
|
384
|
+
|
385
|
+
|
386
|
+
# Creates library
|
387
|
+
#
|
388
|
+
# @param [Hash] params
|
389
|
+
# @option params [Array] :objects object filename paths
|
390
|
+
# @option params [String] :lib library filename path
|
391
|
+
# @option params [Hash] :settings project specific settings
|
392
|
+
#
|
393
|
+
def lib(params = {})
|
394
|
+
ldflags = params[:settings]['ADD_LDFLAGS']
|
395
|
+
objs = params[:objects].join(' ')
|
396
|
+
extension = File.extname(params[:lib])
|
397
|
+
|
398
|
+
case extension
|
399
|
+
when ('.a')
|
400
|
+
# need to use 'touch' for correct timestamp, ar doesn't update the timestamp
|
401
|
+
# if archive hasn't changed
|
402
|
+
sh "#{@settings['AR']} curv #{params[:lib]} #{objs} && #{@settings['TOUCH']} #{params[:lib]}"
|
403
|
+
when '.so'
|
404
|
+
sh "#{@settings['CXX']} -shared #{ldflags} #{objs} -o #{params[:lib]}"
|
405
|
+
else
|
406
|
+
raise "unsupported library extension (#{extension})!"
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
|
411
|
+
# Creates application
|
412
|
+
#
|
413
|
+
# @param [Hash] params
|
414
|
+
# @option params [Array] :objects array of object file paths
|
415
|
+
# @option params [Array] :libs array of libraries that should be linked against
|
416
|
+
# @option params [String] :app application filename path
|
417
|
+
# @option params [Hash] :settings project specific settings
|
418
|
+
# @option params [Array] :includes include paths used
|
419
|
+
#
|
420
|
+
def app(params = {})
|
421
|
+
incs = compiler_incs_for(params[:includes])
|
422
|
+
ldflags = params[:settings]['ADD_LDFLAGS'] + ' ' + @settings['LDFLAGS']
|
423
|
+
objs = params[:objects].join(' ')
|
424
|
+
libs = linker_line_for(params[:libs])
|
425
|
+
|
426
|
+
sh "#{@settings['SIZE']} #{objs} >#{params[:app]}.size" if @settings['SIZE']
|
427
|
+
sh "#{@settings['CXX']} #{incs} #{objs} #{ldflags} #{libs} -o #{params[:app]} -Wl,-Map,#{params[:app]}.map"
|
428
|
+
sh "#{@settings['OBJCOPY']} -O binary #{params[:app]} #{params[:app]}.bin"
|
429
|
+
end
|
430
|
+
|
431
|
+
# Creates test
|
432
|
+
#
|
433
|
+
# @param [Hash] params
|
434
|
+
# @option params [Array] :objects array of object file paths
|
435
|
+
# @option params [Array] :libs array of libraries that should be linked against
|
436
|
+
# @option params [String] :framework test framework name
|
437
|
+
# @option params [String] :test test filename path
|
438
|
+
# @option params [Hash] :settings project specific settings
|
439
|
+
# @option params [Array] :includes include paths used
|
440
|
+
#
|
441
|
+
def test(params = {})
|
442
|
+
incs = compiler_incs_for(params[:includes])
|
443
|
+
ldflags = params[:settings]['ADD_LDFLAGS'] + ' ' + @settings['LDFLAGS']
|
444
|
+
objs = params[:objects].join(' ')
|
445
|
+
test_fw = linker_line_for([params[:framework]])
|
446
|
+
libs = linker_line_for(params[:libs])
|
447
|
+
|
448
|
+
sh "#{@settings['CXX']} #{incs} #{objs} #{test_fw} #{ldflags} #{libs} -o #{params[:test]}"
|
449
|
+
end
|
450
|
+
|
451
|
+
def dump
|
452
|
+
@kvr.dump
|
453
|
+
end
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
end
|
data/lib/rakeoe.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/dsl_definition'
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
require 'rakeoe/config'
|
7
|
+
require 'rakeoe/version'
|
8
|
+
require 'rakeoe/defaults'
|
9
|
+
require 'rakeoe/key_value_reader'
|
10
|
+
require 'rakeoe/toolchain'
|
11
|
+
require 'rakeoe/qt_settings'
|
12
|
+
require 'rakeoe/lib'
|
13
|
+
require 'rakeoe/app'
|
14
|
+
require 'rakeoe/prj_file_cache'
|
15
|
+
|
16
|
+
module RakeOE
|
17
|
+
|
18
|
+
include Rake::DSL # for #task, #desc, #namespace
|
19
|
+
|
20
|
+
# Initialize RakeOE project. Reads & parses all prj.rake files
|
21
|
+
# of given config.
|
22
|
+
#
|
23
|
+
# @param config [RakeOE::Config] Configuration as provided by project Rakefile
|
24
|
+
#
|
25
|
+
def init(config)
|
26
|
+
|
27
|
+
RakeOE::PrjFileCache.sweep_recursive(config.directories[:apps] + config.directories[:libs])
|
28
|
+
|
29
|
+
toolchain = RakeOE::Toolchain.new(config)
|
30
|
+
|
31
|
+
#
|
32
|
+
# Top level tasks
|
33
|
+
#
|
34
|
+
%w[lib app].each do |type|
|
35
|
+
namespace type do
|
36
|
+
# Introduce type:all
|
37
|
+
#
|
38
|
+
# All libs/apps will make themselves dependent on this task, so whenever you call
|
39
|
+
# 'rake lib:all' or 'rake app:all'
|
40
|
+
# all libs/apps will thus be generated automatically
|
41
|
+
desc "Create all #{type}s"
|
42
|
+
task :all
|
43
|
+
|
44
|
+
case type
|
45
|
+
when 'lib'
|
46
|
+
RakeOE::PrjFileCache.for_each('LIB') do |name, settings|
|
47
|
+
RakeOE::Lib.new(name, settings, toolchain).create
|
48
|
+
end
|
49
|
+
|
50
|
+
RakeOE::PrjFileCache.for_each('SOLIB') do |name, settings|
|
51
|
+
RakeOE::Lib.new(name, settings, toolchain).create
|
52
|
+
end
|
53
|
+
|
54
|
+
when 'app'
|
55
|
+
RakeOE::PrjFileCache.for_each('APP') do |name, settings|
|
56
|
+
RakeOE::App.new(name, settings, toolchain).create
|
57
|
+
end
|
58
|
+
else
|
59
|
+
raise "No such type #{type} supported"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Introduce type:test:all
|
63
|
+
#
|
64
|
+
# All tests in lib/app will make themselves dependent on this task, so whenever you call
|
65
|
+
# 'rake lib:test:all'
|
66
|
+
# all available library tests will be generated automatically before execution
|
67
|
+
namespace 'test' do
|
68
|
+
desc "Run all #{type} tests"
|
69
|
+
task :all
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'Dumps toolchain environment variables'
|
75
|
+
task :dump do
|
76
|
+
puts
|
77
|
+
config.dump
|
78
|
+
puts
|
79
|
+
toolchain.dump
|
80
|
+
puts
|
81
|
+
end
|
82
|
+
|
83
|
+
task :all => %w[lib:all app:all]
|
84
|
+
task :test => %w[lib:test:all app:test:all]
|
85
|
+
task :test_build => %w[lib:test:build app:test:build]
|
86
|
+
task :junit => %w[lib:test:junit app:test:junit]
|
87
|
+
task :default => :all
|
88
|
+
|
89
|
+
# kind of mrproper/realclean
|
90
|
+
CLOBBER.include('*.tmp', "#{config.directories[:build]}/*")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
include RakeOE
|
data/rakeoe.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rakeoe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rakeoe"
|
8
|
+
spec.version = RakeOE::VERSION
|
9
|
+
spec.authors = ["Daniel Schnell"]
|
10
|
+
spec.email = ["dschnell@skerpa.com"]
|
11
|
+
spec.description = %q{RakeOE : Rake Optimized for Embedded
|
12
|
+
A build system for test driven Embedded C/C++ Development based on Ruby Rake.
|
13
|
+
RakeOE is a build system for application development. It can parse OpenEmbedded/Yocto environment files.
|
14
|
+
In this way it knows how to cross compile in whatever target platform the cross compiler builds.
|
15
|
+
It uses automatically the appropriate include paths and libraries of the given platform.}
|
16
|
+
spec.summary = %q{RakeOE : Rake Optimized for Embedded. A build system for test driven Embedded C/C++ Development}
|
17
|
+
spec.homepage = "http://rakeoe.github.io/rakeoe/"
|
18
|
+
spec.license = "GPLv3"
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split($/)
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
|
29
|
+
spec.add_dependency "rake"
|
30
|
+
end
|