rake_embedded 0.1.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 +9 -0
- data/.travis.yml +14 -0
- data/Gemfile +5 -0
- data/LICENSE +621 -0
- data/README.md +150 -0
- data/Rakefile +2 -0
- data/machine_conf/8051/8051.rb +23 -0
- data/machine_conf/8051/C8051FXXX.rb +22 -0
- data/machine_conf/8051/nrf24le1_24.rb +25 -0
- data/machine_conf/8051/nrf24le1_32.rb +24 -0
- data/machine_conf/8051/nrf24le1_48.rb +24 -0
- data/machine_conf/arm/arm.rb +24 -0
- data/machine_conf/arm/stm32f1.rb +24 -0
- data/machine_conf/arm/stm32f3.rb +28 -0
- data/machine_conf/arm/stm32f4.rb +28 -0
- data/machine_conf/avr/atmega168.rb +24 -0
- data/machine_conf/avr/avr.rb +25 -0
- data/machine_conf/mips/PIC32.rb +24 -0
- data/machine_conf/mips/pic32mx2.rb +24 -0
- data/machine_conf/mips/pic32mz2048.rb +24 -0
- data/machine_conf/native/linux.rb +24 -0
- data/machine_conf/native/native.rb +24 -0
- data/rake_embedded/version.rb +3 -0
- data/rake_embedded.gemspec +28 -0
- data/rem +34 -0
- data/rem.png +0 -0
- data/rem_core.rb +446 -0
- data/rem_path.rb +23 -0
- data/scripts/build_functions/package_build_functions.rb +121 -0
- data/scripts/compile_tasks/common/gcc_LinkPrepare.rb +35 -0
- data/scripts/compile_tasks/common/sdcc_LinkPrepare.rb +30 -0
- data/scripts/compile_tasks/gcc_tasks/DefaultTasks.rb +77 -0
- data/scripts/compile_tasks/make_tasks/MakeTasks.rb +86 -0
- data/scripts/compile_tasks/sdcc_tasks/DefaultTasks.rb +80 -0
- data/scripts/dependency_functions/dependency_graph.rb +68 -0
- data/scripts/dependency_functions/dependency_tasks.rb +67 -0
- data/scripts/download_tasks/DefaultTasks.rb +44 -0
- data/scripts/global_config/config_helper/check_env.rb +57 -0
- data/scripts/global_config/config_helper/config.rb +27 -0
- data/scripts/global_config/global_config.rb +230 -0
- data/scripts/misc/helper.rb +122 -0
- data/scripts/misc/helper_string_parse.rb +40 -0
- data/scripts/misc/print_functions.rb +53 -0
- data/scripts/package.rb +343 -0
- data/scripts/patch_tasks/DefaultTasks.rb +33 -0
- data/scripts/prepare_tasks/DefaultTasks.rb +74 -0
- data/scripts/recipe_handling/recipes.rb +151 -0
- data/scripts/remfile_functions/remfile_gen.rb +39 -0
- data/shell_scripts/check_deps.sh +214 -0
- data/shell_scripts/comment_unused_functions_cppcheck.sh +44 -0
- data/shell_scripts/find_func_and_comment.sh +61 -0
- data/tests/docker/dockerfile_debian_8.dockertest +18 -0
- data/tests/docker/dockerfile_ubuntu_14_04.dockertest +20 -0
- data/tests/run_all_rem_tests.sh +26 -0
- data/tests/run_docker_test.sh +5 -0
- data/tests/run_docker_tests.sh +26 -0
- data/tests/tests/TEST_append_features.sh +15 -0
- data/tests/tests/TEST_build_test_project.sh +28 -0
- data/tests/tests/TEST_check_deps_test_project.sh +16 -0
- data/tests/tests/TEST_remove_unused_functions.sh +17 -0
- metadata +149 -0
data/scripts/package.rb
ADDED
@@ -0,0 +1,343 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
|
4
|
+
|
5
|
+
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
|
6
|
+
|
7
|
+
REM is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
REM is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with REM. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
require_relative "build_functions/package_build_functions"
|
22
|
+
require_relative "misc/helper_string_parse"
|
23
|
+
|
24
|
+
# # This is used for packages to temporarily store the package info in a global variable
|
25
|
+
# # this is just used for easier handling when defining recipes
|
26
|
+
$global_sw_package
|
27
|
+
def sw_package; return $global_sw_package; end
|
28
|
+
def sw_package_set(pkg); $global_sw_package = pkg; end
|
29
|
+
|
30
|
+
class PackageUri
|
31
|
+
public
|
32
|
+
attr_reader :uri
|
33
|
+
attr_reader :uri_type
|
34
|
+
attr_reader :uri_src_rev
|
35
|
+
|
36
|
+
def initialize(init_val)
|
37
|
+
@uri = init_val
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_uri
|
41
|
+
# set uri type:
|
42
|
+
tmp_uri_arr = uri
|
43
|
+
@uri = uri.split(";")[0]
|
44
|
+
if((@uri_type = parse_string(tmp_uri_arr, "type=")) == "undefined")
|
45
|
+
@uri_type = get_extension_from_uri(uri)
|
46
|
+
end
|
47
|
+
@uri_src_rev = parse_string(tmp_uri_arr, "src_rev=")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
module PackageDescriptor
|
53
|
+
public
|
54
|
+
# package name
|
55
|
+
attr_reader :name
|
56
|
+
# unique hash of the package
|
57
|
+
attr_reader :unique_hash
|
58
|
+
|
59
|
+
# base_dir: recipe file location
|
60
|
+
attr_reader :base_dir
|
61
|
+
# pkg_dl_dir: download location
|
62
|
+
attr_reader :pkg_dl_dir
|
63
|
+
# pkg_dl_state_file: download state file location
|
64
|
+
attr_reader :pkg_dl_state_file
|
65
|
+
# pkg_build_dir: build directory
|
66
|
+
attr_reader :pkg_build_dir
|
67
|
+
# pkg_deploy_dir: output binary deploy directory
|
68
|
+
attr_reader :pkg_deploy_dir
|
69
|
+
# pkg_state_dir: package build state directory
|
70
|
+
attr_reader :pkg_state_dir
|
71
|
+
|
72
|
+
attr_reader :version
|
73
|
+
|
74
|
+
attr_reader :srcs
|
75
|
+
attr_reader :incdirs
|
76
|
+
attr_reader :patches
|
77
|
+
attr_reader :deps
|
78
|
+
attr_reader :defs
|
79
|
+
|
80
|
+
attr_reader :uri
|
81
|
+
|
82
|
+
attr_reader :arch
|
83
|
+
attr_reader :mach
|
84
|
+
attr_reader :global_defines
|
85
|
+
attr_reader :global_linker_flags
|
86
|
+
attr_reader :linker_script
|
87
|
+
|
88
|
+
attr_reader :instance_var_to_reset
|
89
|
+
|
90
|
+
# pkg_work_dir: work directory
|
91
|
+
attr_reader :pkg_work_dir
|
92
|
+
|
93
|
+
# specific package data - not really used at the moment, but it is intended to
|
94
|
+
# be used for build tasks other than the DefaultTasks - please see below:
|
95
|
+
# At the moment the this class is only extended by default tasks
|
96
|
+
attr_reader :download_specific_data
|
97
|
+
attr_reader :prepare_specific_data
|
98
|
+
attr_reader :patch_specific_data
|
99
|
+
attr_reader :build_specific_data
|
100
|
+
|
101
|
+
### SETTERS ###
|
102
|
+
|
103
|
+
# No ARRAY values
|
104
|
+
def set_name(name)
|
105
|
+
@name = name
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_unique_hash(hash)
|
109
|
+
@unique_hash = hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# ARRAY values - (only the first one is used)
|
113
|
+
def set_uri(uri)
|
114
|
+
tmp_str = string_strip(uri).strip
|
115
|
+
(@uri = []).concat([PackageUri.new(tmp_str)])
|
116
|
+
end
|
117
|
+
|
118
|
+
def set_work_dir(workdir_str)
|
119
|
+
tmp_str = string_strip(workdir_str).strip
|
120
|
+
(@pkg_work_dir = []).concat(string_strip_to_array("#{pkg_build_dir}/#{tmp_str}"))
|
121
|
+
end
|
122
|
+
|
123
|
+
def set_arch(arch)
|
124
|
+
(@arch = []).concat(string_strip_to_array(arch))
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_mach(mach)
|
128
|
+
(@mach = []).concat(string_strip_to_array(mach))
|
129
|
+
end
|
130
|
+
|
131
|
+
def set_version(version)
|
132
|
+
(@version = []).concat(string_strip_to_array(version))
|
133
|
+
end
|
134
|
+
|
135
|
+
def set_linker_script(script)
|
136
|
+
(@linker_script = []).concat(string_strip_to_array(script))
|
137
|
+
end
|
138
|
+
|
139
|
+
def set_build_specific_data(data)
|
140
|
+
(@build_specific_data = []).concat([data])
|
141
|
+
end
|
142
|
+
|
143
|
+
# full ARRAY values
|
144
|
+
def set_src(src)
|
145
|
+
(@srcs ||= []).concat(string_strip_to_array(src))
|
146
|
+
end
|
147
|
+
|
148
|
+
def set_inc(inc)
|
149
|
+
(@incdirs ||= []).concat(string_strip_to_array(inc))
|
150
|
+
end
|
151
|
+
|
152
|
+
def set_patch(patch)
|
153
|
+
(@patches ||= []).concat(string_strip_to_array(patch))
|
154
|
+
end
|
155
|
+
|
156
|
+
def set_dep(dep)
|
157
|
+
(@deps ||= []).concat(string_strip_to_array(dep))
|
158
|
+
end
|
159
|
+
|
160
|
+
def set_def(define)
|
161
|
+
(@defs ||= []).concat(string_strip_to_array(define))
|
162
|
+
end
|
163
|
+
|
164
|
+
def set_global_define(define)
|
165
|
+
(@global_defines ||= []).concat(string_strip_to_array(define))
|
166
|
+
end
|
167
|
+
|
168
|
+
def set_global_linker_flags(flags)
|
169
|
+
(@global_linker_flags ||= []).concat(string_strip_to_array(flags))
|
170
|
+
end
|
171
|
+
|
172
|
+
def reset_var(var)
|
173
|
+
(@instance_var_to_reset ||= []).concat(string_strip_to_array(var))
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
### GETTERS ###
|
179
|
+
def get_package_state_file(which)
|
180
|
+
return "#{pkg_state_dir}/#{which}"
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns the name as array-list
|
184
|
+
def get_name_splitted
|
185
|
+
return name.split
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_pkg_work_dir
|
189
|
+
return pkg_work_dir[0].strip()
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns first arch entry in array list
|
193
|
+
def get_arch
|
194
|
+
return arch[0].strip()
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_mach
|
198
|
+
return mach[0].strip()
|
199
|
+
end
|
200
|
+
|
201
|
+
def get_build_specific_data
|
202
|
+
return build_specific_data[0]
|
203
|
+
end
|
204
|
+
|
205
|
+
private
|
206
|
+
### Private set methods
|
207
|
+
|
208
|
+
def default_setup_identifiers(recipe_file)
|
209
|
+
# Extract the name of the package from the recipe name
|
210
|
+
set_name(get_filename_without_extension_from_uri(recipe_file))
|
211
|
+
set_unique_hash("nohash")
|
212
|
+
|
213
|
+
(@base_dir||= []).push(get_dirname_from_uri(recipe_file))
|
214
|
+
end
|
215
|
+
|
216
|
+
def default_setup_settables()
|
217
|
+
@pkg_dl_dir = "#{global_config.get_dl_dir()}/#{name}_#{unique_hash}"
|
218
|
+
@pkg_dl_state_file = "#{global_config.get_dl_state_dir()}/#{name}_#{unique_hash}"
|
219
|
+
@pkg_deploy_dir = "#{global_config.get_deploy_dir()}/#{name}_#{unique_hash}"
|
220
|
+
@pkg_state_dir = "#{global_config.get_state_dir()}/#{name}_#{unique_hash}"
|
221
|
+
@pkg_build_dir = "#{global_config.get_build_dir()}/#{name}_#{unique_hash}"
|
222
|
+
@pkg_work_dir = [pkg_build_dir]
|
223
|
+
|
224
|
+
@version = set_version("noversion")
|
225
|
+
@srcs = []
|
226
|
+
@incdirs = []
|
227
|
+
@patches = []
|
228
|
+
@deps = []
|
229
|
+
@defs = []
|
230
|
+
|
231
|
+
@uri = [PackageUri.new("package.local")]
|
232
|
+
|
233
|
+
@arch = set_arch("generic")
|
234
|
+
@mach = set_mach("generic")
|
235
|
+
@global_defines = []
|
236
|
+
@global_linker_flags = []
|
237
|
+
@linker_script = set_linker_script("")
|
238
|
+
|
239
|
+
@instance_var_to_reset = []
|
240
|
+
|
241
|
+
@build_specific_data = set_build_specific_data(nil)
|
242
|
+
end
|
243
|
+
|
244
|
+
def set_download_done()
|
245
|
+
execute "touch #{pkg_dl_state_file}"
|
246
|
+
end
|
247
|
+
|
248
|
+
def set_state_done(which)
|
249
|
+
execute "touch #{pkg_state_dir}/#{which}"
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
class SoftwarePackage
|
255
|
+
include PackageDescriptor
|
256
|
+
|
257
|
+
public
|
258
|
+
# All sources prepared with root directory added
|
259
|
+
attr_reader :src_files_prepared
|
260
|
+
# All source-extensions replaced with the configured obj-extension
|
261
|
+
attr_reader :obj_files_prepared
|
262
|
+
attr_reader :inc_dirs_prepared
|
263
|
+
attr_reader :inc_dirs_depends_prepared
|
264
|
+
|
265
|
+
# Extend with various modules here
|
266
|
+
include PackageBuildFunctions
|
267
|
+
|
268
|
+
def initialize(recipe_file)
|
269
|
+
default_setup_identifiers(recipe_file)
|
270
|
+
default_setup_settables()
|
271
|
+
|
272
|
+
# OK, we are done with the default setup, now load the recipe file and setup internals
|
273
|
+
sw_package_set(self)
|
274
|
+
load "./#{recipe_file}"
|
275
|
+
|
276
|
+
# override the above defined function here, this way it is possible
|
277
|
+
# to use "sw_package." in the method context also (for e.g if custom build methods are used)
|
278
|
+
def sw_package; return self; end
|
279
|
+
|
280
|
+
@src_files_prepared = []
|
281
|
+
@obj_files_prepared = []
|
282
|
+
|
283
|
+
@inc_dirs_prepared = []
|
284
|
+
@inc_dirs_depends_prepared = []
|
285
|
+
|
286
|
+
@uri[0].parse_uri()
|
287
|
+
|
288
|
+
# Make sanity checks here:
|
289
|
+
check_duplicates_exit_with_error(deps, "deps in package #{name}")
|
290
|
+
check_duplicates_exit_with_error(srcs, "srcs in package #{name}")
|
291
|
+
end
|
292
|
+
|
293
|
+
def post_initialize
|
294
|
+
|
295
|
+
case "#{download_specific_data.class.name}"
|
296
|
+
when "NilClass"
|
297
|
+
extend DefaultDownload::DownloadPackage
|
298
|
+
else
|
299
|
+
print_abort("Package download_type #{download_specific_data.class.name} not known")
|
300
|
+
end
|
301
|
+
|
302
|
+
case "#{prepare_specific_data.class.name}"
|
303
|
+
when "NilClass"
|
304
|
+
extend DefaultPrepare::PreparePackageBuildDir
|
305
|
+
else
|
306
|
+
print_abort("Package download_type #{prepare_specific_data.class.name} not known")
|
307
|
+
end
|
308
|
+
|
309
|
+
case "#{patch_specific_data.class.name}"
|
310
|
+
when "NilClass"
|
311
|
+
extend DefaultPatch::Patch
|
312
|
+
else
|
313
|
+
print_abort("Package download_type #{patch_specific_data.class.name} not known")
|
314
|
+
end
|
315
|
+
|
316
|
+
case "#{build_specific_data[0].class.name}"
|
317
|
+
when "NilClass"
|
318
|
+
extend Default::Compile
|
319
|
+
extend Default::Link
|
320
|
+
extend Default::Image
|
321
|
+
when "MakeTasksDesc"
|
322
|
+
extend MakePkg::Compile
|
323
|
+
extend MakePkg::Link
|
324
|
+
extend MakePkg::Image
|
325
|
+
print_any_yellow("Using class #{build_specific_data[0].class.name} for package #{name}")
|
326
|
+
else
|
327
|
+
print_abort("Package build_type #{build_specific_data[0].class.name} not known")
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
class SoftwarePackageAppend
|
333
|
+
include PackageDescriptor
|
334
|
+
|
335
|
+
def initialize(recipe_file)
|
336
|
+
# Only setup the identifiers
|
337
|
+
default_setup_identifiers(recipe_file)
|
338
|
+
|
339
|
+
# OK, we are done with the default setup, now load the recipe file and setup internals
|
340
|
+
sw_package_set(self)
|
341
|
+
load "./#{recipe_file}"
|
342
|
+
end
|
343
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
|
4
|
+
|
5
|
+
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
|
6
|
+
|
7
|
+
REM is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
REM is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with REM. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
module DefaultPatch
|
22
|
+
module Patch
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def do_patch
|
27
|
+
main_working_dir = Rake.original_dir
|
28
|
+
patches.each do |e|
|
29
|
+
execute "patch -d #{get_pkg_work_dir} -i #{pkg_build_dir}/#{e} -p1 -t"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
|
4
|
+
|
5
|
+
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
|
6
|
+
|
7
|
+
REM is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
REM is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with REM. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
module DefaultPrepare
|
22
|
+
module PreparePackageBuildDir
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def prepare_copy
|
27
|
+
base_dir.each do |dir|
|
28
|
+
FileUtils.cp_r("#{dir}/.", pkg_build_dir, {:remove_destination => true, :verbose => false})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def prepare_clone_git
|
33
|
+
execute "git clone #{uri[0].uri} #{pkg_build_dir}"
|
34
|
+
if(uri[0].uri_src_rev != "undefined")
|
35
|
+
execute "git --git-dir=#{pkg_build_dir}/.git --work-tree=#{pkg_build_dir} checkout #{uri[0].uri_src_rev}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def prepare_checkout_svn
|
40
|
+
execute "svn co #{uri[0].uri} #{pkg_build_dir}"
|
41
|
+
if(uri[0].uri_src_rev != "undefined")
|
42
|
+
# TODO: add possibilty to checkout specific revision
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_zip
|
47
|
+
execute "unzip -qq #{pkg_dl_dir}/#{get_filename_from_uri(uri[0].uri)} -d #{pkg_build_dir}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def do_prepare_clean
|
51
|
+
FileUtils.rm_rf(pkg_build_dir)
|
52
|
+
end
|
53
|
+
|
54
|
+
def do_prepare_builddir
|
55
|
+
case uri[0].uri_type
|
56
|
+
when "local"
|
57
|
+
print_debug "LOCAL package"
|
58
|
+
when "zip"
|
59
|
+
print_debug "ZIP package"
|
60
|
+
prepare_zip()
|
61
|
+
when "git"
|
62
|
+
print_debug "GIT repo"
|
63
|
+
prepare_clone_git()
|
64
|
+
when "svn"
|
65
|
+
print_debug "SVN repo"
|
66
|
+
prepare_checkout_svn()
|
67
|
+
else
|
68
|
+
print_abort('No valid URI type!')
|
69
|
+
end
|
70
|
+
# files need to be copied in every case:
|
71
|
+
prepare_copy()
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
|
4
|
+
|
5
|
+
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
|
6
|
+
|
7
|
+
REM is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
REM is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with REM. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
def get_recipes(project_folders, recipe_file_ending)
|
22
|
+
project_folders = project_folders.split(",")
|
23
|
+
files = []
|
24
|
+
files = find_files_with_ending(project_folders, recipe_file_ending)
|
25
|
+
|
26
|
+
if files.empty?
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
|
30
|
+
print_debug("Found the following recipes:")
|
31
|
+
print_debug(files)
|
32
|
+
print_debug("")
|
33
|
+
|
34
|
+
return files
|
35
|
+
end
|
36
|
+
|
37
|
+
def prepare_recipes(recipes, append=false)
|
38
|
+
recipe_filenames = []
|
39
|
+
pkgs = []
|
40
|
+
|
41
|
+
print_debug "Searching for recipes..."
|
42
|
+
|
43
|
+
# Remove directory from all recipes - this is needed to check for duplicates
|
44
|
+
recipes.each {|e| recipe_filenames.push(get_filename_from_uri(e))}
|
45
|
+
|
46
|
+
check_duplicates_exit_with_error(recipe_filenames, "recipes")
|
47
|
+
|
48
|
+
recipes.each do |r|
|
49
|
+
|
50
|
+
print_debug "parsing recipe #{r}:"
|
51
|
+
|
52
|
+
# Parse and include submakefiles
|
53
|
+
if(append == true)
|
54
|
+
cur_pkg = SoftwarePackageAppend.new(r)
|
55
|
+
else
|
56
|
+
cur_pkg = SoftwarePackage.new(r)
|
57
|
+
end
|
58
|
+
|
59
|
+
pkgs.push(cur_pkg)
|
60
|
+
end
|
61
|
+
return pkgs
|
62
|
+
end
|
63
|
+
|
64
|
+
def merge_recipes_append(recipe_list, append_recipe_list)
|
65
|
+
append_recipe_list.each do |append_pkg|
|
66
|
+
tmp_pkg = pkg_get_ref_by_name(recipe_list, append_pkg.name)
|
67
|
+
|
68
|
+
if tmp_pkg == nil
|
69
|
+
print_any_yellow("Could not find matching base recipe for append recipe " + append_pkg.name)
|
70
|
+
else
|
71
|
+
print_any_yellow("Appending #{tmp_pkg.name}")
|
72
|
+
|
73
|
+
# Iterate through instance_var_to_reset and reset all instance variables listed in this array
|
74
|
+
vars_to_reset = append_pkg.instance_variable_get(:@instance_var_to_reset)
|
75
|
+
if nil!=vars_to_reset
|
76
|
+
vars_to_reset.each do |var|
|
77
|
+
print_any_cyan("Reset all in #{var}")
|
78
|
+
if tmp_pkg.instance_variable_get("@#{var}").nil?
|
79
|
+
print_abort("sw_package variable #{var} does not exist!")
|
80
|
+
else
|
81
|
+
print_any_cyan("Clearing #{var}, which was #{tmp_pkg.instance_variable_get("@#{var}")}")
|
82
|
+
tmp_pkg.instance_variable_get("@#{var}").clear
|
83
|
+
end
|
84
|
+
end
|
85
|
+
print_any_cyan("Clearing instance_var_to_reset which was #{append_pkg.instance_variable_get(:@instance_var_to_reset)}")
|
86
|
+
append_pkg.instance_variable_get(:@instance_var_to_reset).clear
|
87
|
+
end
|
88
|
+
|
89
|
+
# Now merge the append recipe instance variables with the base recipe
|
90
|
+
append_pkg.instance_variables.each do |var|
|
91
|
+
print_any_yellow("#{var} before appending: #{tmp_pkg.instance_variable_get("#{var}")}")
|
92
|
+
|
93
|
+
# At the moment only array types will get appended
|
94
|
+
if tmp_pkg.instance_variable_get(var).kind_of?(Array)
|
95
|
+
val_to_append = append_pkg.instance_variable_get(var)
|
96
|
+
tmp_pkg.instance_variable_get(var).concat(val_to_append)
|
97
|
+
print_any_yellow("Appending #{var} #{val_to_append} to recipe #{tmp_pkg.name}")
|
98
|
+
print_any_cyan("#{var} is now #{tmp_pkg.instance_variable_get("#{var}")}")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
print_any_yellow("Merging append recipes done.")
|
104
|
+
end
|
105
|
+
|
106
|
+
def filter_packages(pkg_list, current_arch_config, current_mach_config)
|
107
|
+
tmp_pkg_list = []
|
108
|
+
pkg_list.each_with_index do |cur_pkg, index|
|
109
|
+
# Filter out packages which do not match arch or mach config
|
110
|
+
arch_config = cur_pkg.get_arch()
|
111
|
+
mach_config = cur_pkg.get_mach()
|
112
|
+
|
113
|
+
if ( (arch_config == "generic") or
|
114
|
+
(arch_config == current_arch_config and mach_config == "generic") or
|
115
|
+
(arch_config == current_arch_config and mach_config == current_mach_config)
|
116
|
+
)
|
117
|
+
tmp_pkg_list.push(cur_pkg)
|
118
|
+
else
|
119
|
+
print_debug "ARCH Config #{arch_config} or MACH Config #{mach_config} does not match - current arch config: #{current_arch_config} - current mach config: #{current_mach_config}, skipping recipe: #{cur_pkg.name}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
pkg_list = tmp_pkg_list
|
124
|
+
|
125
|
+
print_debug("Now having the following recipes:")
|
126
|
+
pkg_list.each do | pkg |
|
127
|
+
print_debug(pkg.name)
|
128
|
+
end
|
129
|
+
|
130
|
+
return tmp_pkg_list
|
131
|
+
end
|
132
|
+
|
133
|
+
def pkg_get_ref_by_name(pkg_list, name, needed_by_info=nil)
|
134
|
+
|
135
|
+
# find via index:
|
136
|
+
#result = ref_list.index{ |item| item.name == name }
|
137
|
+
#return ref_list[result]
|
138
|
+
|
139
|
+
# find directly:
|
140
|
+
result = pkg_list.find{ |item| item.name == name }
|
141
|
+
|
142
|
+
if result == nil
|
143
|
+
if needed_by_info != nil
|
144
|
+
return print_abort("ERROR: No recipe found for package #{name}!" + " Needed by: " + needed_by_info)
|
145
|
+
else
|
146
|
+
return nil
|
147
|
+
end
|
148
|
+
else
|
149
|
+
return result
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
Copyright (C) 2016 Franz Flasch <franz.flasch@gmx.at>
|
4
|
+
|
5
|
+
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
|
6
|
+
|
7
|
+
REM is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
REM is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with REM. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
=end
|
20
|
+
|
21
|
+
require 'yaml'
|
22
|
+
require 'yaml/store'
|
23
|
+
|
24
|
+
def yaml_store(file, fieldname, data)
|
25
|
+
store = YAML::Store.new(file)
|
26
|
+
store.transaction do
|
27
|
+
store[fieldname] = data
|
28
|
+
#store["compile_sources"] = { "hello" => "world" }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def yaml_parse(file)
|
33
|
+
pkgs = []
|
34
|
+
data = YAML::load_file(file)
|
35
|
+
data['pkg'].each do |d|
|
36
|
+
pkgs.push(d)
|
37
|
+
end
|
38
|
+
return pkgs
|
39
|
+
end
|