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.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +14 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE +621 -0
  6. data/README.md +150 -0
  7. data/Rakefile +2 -0
  8. data/machine_conf/8051/8051.rb +23 -0
  9. data/machine_conf/8051/C8051FXXX.rb +22 -0
  10. data/machine_conf/8051/nrf24le1_24.rb +25 -0
  11. data/machine_conf/8051/nrf24le1_32.rb +24 -0
  12. data/machine_conf/8051/nrf24le1_48.rb +24 -0
  13. data/machine_conf/arm/arm.rb +24 -0
  14. data/machine_conf/arm/stm32f1.rb +24 -0
  15. data/machine_conf/arm/stm32f3.rb +28 -0
  16. data/machine_conf/arm/stm32f4.rb +28 -0
  17. data/machine_conf/avr/atmega168.rb +24 -0
  18. data/machine_conf/avr/avr.rb +25 -0
  19. data/machine_conf/mips/PIC32.rb +24 -0
  20. data/machine_conf/mips/pic32mx2.rb +24 -0
  21. data/machine_conf/mips/pic32mz2048.rb +24 -0
  22. data/machine_conf/native/linux.rb +24 -0
  23. data/machine_conf/native/native.rb +24 -0
  24. data/rake_embedded/version.rb +3 -0
  25. data/rake_embedded.gemspec +28 -0
  26. data/rem +34 -0
  27. data/rem.png +0 -0
  28. data/rem_core.rb +446 -0
  29. data/rem_path.rb +23 -0
  30. data/scripts/build_functions/package_build_functions.rb +121 -0
  31. data/scripts/compile_tasks/common/gcc_LinkPrepare.rb +35 -0
  32. data/scripts/compile_tasks/common/sdcc_LinkPrepare.rb +30 -0
  33. data/scripts/compile_tasks/gcc_tasks/DefaultTasks.rb +77 -0
  34. data/scripts/compile_tasks/make_tasks/MakeTasks.rb +86 -0
  35. data/scripts/compile_tasks/sdcc_tasks/DefaultTasks.rb +80 -0
  36. data/scripts/dependency_functions/dependency_graph.rb +68 -0
  37. data/scripts/dependency_functions/dependency_tasks.rb +67 -0
  38. data/scripts/download_tasks/DefaultTasks.rb +44 -0
  39. data/scripts/global_config/config_helper/check_env.rb +57 -0
  40. data/scripts/global_config/config_helper/config.rb +27 -0
  41. data/scripts/global_config/global_config.rb +230 -0
  42. data/scripts/misc/helper.rb +122 -0
  43. data/scripts/misc/helper_string_parse.rb +40 -0
  44. data/scripts/misc/print_functions.rb +53 -0
  45. data/scripts/package.rb +343 -0
  46. data/scripts/patch_tasks/DefaultTasks.rb +33 -0
  47. data/scripts/prepare_tasks/DefaultTasks.rb +74 -0
  48. data/scripts/recipe_handling/recipes.rb +151 -0
  49. data/scripts/remfile_functions/remfile_gen.rb +39 -0
  50. data/shell_scripts/check_deps.sh +214 -0
  51. data/shell_scripts/comment_unused_functions_cppcheck.sh +44 -0
  52. data/shell_scripts/find_func_and_comment.sh +61 -0
  53. data/tests/docker/dockerfile_debian_8.dockertest +18 -0
  54. data/tests/docker/dockerfile_ubuntu_14_04.dockertest +20 -0
  55. data/tests/run_all_rem_tests.sh +26 -0
  56. data/tests/run_docker_test.sh +5 -0
  57. data/tests/run_docker_tests.sh +26 -0
  58. data/tests/tests/TEST_append_features.sh +15 -0
  59. data/tests/tests/TEST_build_test_project.sh +28 -0
  60. data/tests/tests/TEST_check_deps_test_project.sh +16 -0
  61. data/tests/tests/TEST_remove_unused_functions.sh +17 -0
  62. metadata +149 -0
data/rem_core.rb ADDED
@@ -0,0 +1,446 @@
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
+ # Global Config
22
+ require_relative "scripts/global_config/global_config"
23
+
24
+ if(SIMPLECOV == "1")
25
+ require 'simplecov'
26
+ SimpleCov.command_name "rem codecoverage"
27
+ SimpleCov.start
28
+ end
29
+
30
+ # Machine and compiler specific
31
+ require_relative "machine_conf/#{global_config.arch}/#{global_config.mach}"
32
+ require_relative "scripts/compile_tasks/#{global_config.compiler}_tasks/DefaultTasks"
33
+ require_relative "scripts/compile_tasks/make_tasks/MakeTasks"
34
+
35
+ # Prepare and Patch tasks:
36
+ require_relative "scripts/download_tasks/DefaultTasks"
37
+ require_relative "scripts/prepare_tasks/DefaultTasks"
38
+ require_relative "scripts/patch_tasks/DefaultTasks"
39
+
40
+ # Generic
41
+ require_relative "scripts/misc/helper"
42
+ require_relative "scripts/misc/print_functions"
43
+ require_relative "scripts/package"
44
+ require_relative "scripts/dependency_functions/dependency_tasks"
45
+ require_relative "scripts/dependency_functions/dependency_graph"
46
+ require_relative "scripts/remfile_functions/remfile_gen"
47
+ require_relative "scripts/recipe_handling/recipes"
48
+
49
+ require "find"
50
+ require "fileutils"
51
+ require 'digest'
52
+
53
+ def create_workdir
54
+ FileUtils.mkdir_p(BUILD_DIR)
55
+ FileUtils.mkdir_p(DL_DIR)
56
+ FileUtils.mkdir_p(DL_STATE_DIR)
57
+ end
58
+
59
+ # Main:
60
+ namespace :package do
61
+
62
+ # 'global' variables used across tasks:
63
+ global_package_list = []
64
+ global_dep_chain = []
65
+
66
+ # At first set the main rakefile base directory
67
+ global_config.set_rakefile_dir(File.dirname(__FILE__))
68
+
69
+ # Check if a rem_file was already generated
70
+ if File.exist?(global_config.get_remfile())
71
+ temp_pkgs = yaml_parse(global_config.get_remfile())
72
+ # We need to extend all build functions here, as they're not
73
+ # restored when loading the yaml file
74
+ temp_pkgs.each { |pkg| pkg.post_initialize() }
75
+ else
76
+ print_debug("Parsing recipes...")
77
+ rem_recipes = get_recipes("#{global_config.get_project_folder()}", "rem")
78
+ if rem_recipes == nil
79
+ print_abort ("No recipes found!")
80
+ end
81
+
82
+ temp_pkgs = prepare_recipes(rem_recipes)
83
+
84
+ remappend_recipes = get_recipes("#{global_config.get_project_folder()}", "remappend")
85
+ if remappend_recipes != nil
86
+ temp_pkgs_append = prepare_recipes(remappend_recipes, true)
87
+ merge_recipes_append(temp_pkgs, temp_pkgs_append)
88
+ end
89
+
90
+ temp_pkgs = filter_packages(temp_pkgs, "#{global_config.arch}", "#{global_config.mach}")
91
+ temp_pkgs.each { |pkg| pkg.post_initialize() }
92
+ end
93
+
94
+ global_package_list = temp_pkgs
95
+
96
+ global_package_list.each do |pkg|
97
+
98
+ namespace :"#{pkg.name}" do
99
+
100
+ task :get_dep_chain => package_add_non_file_task_dep(global_package_list, pkg.deps, "get_dep_chain", pkg.name) do
101
+ global_dep_chain.push("#{pkg.name}")
102
+ end
103
+
104
+ desc "depends_chain_print"
105
+ task :depends_chain_print => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "get_dep_chain", pkg.name) do
106
+ print_any_green "DEPENDENCY-CHAIN:"
107
+ global_dep_chain.each do |dep|
108
+ dep_ref = pkg_get_ref_by_name(global_package_list, dep, pkg.name)
109
+ tmp_string = ""
110
+ dep_ref.deps.each do |e|
111
+ tmp_string << "#{e} "
112
+ end
113
+ if tmp_string.to_s == ""
114
+ print_any_green("#{dep_ref.name}")
115
+ else
116
+ print_any_green("#{dep_ref.name} --> " + tmp_string)
117
+ end
118
+ end
119
+ end
120
+
121
+ desc "depends_chain_graph"
122
+ task :depends_chain_graph => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "get_dep_chain", pkg.name) do
123
+ print_any_green("Generating dependency graph for #{pkg.name}")
124
+ dep_graph = DependencyGraph.new(pkg.name)
125
+ global_dep_chain.each do |dep|
126
+ dep_ref = pkg_get_ref_by_name(global_package_list, dep, pkg.name)
127
+ dep_graph.add_node("#{dep_ref.name}")
128
+
129
+ dep_ref.deps.each do |e|
130
+ dep_graph.add_dep("#{dep_ref.name}", "#{e}")
131
+ end
132
+ end
133
+ dep_graph.draw()
134
+ end
135
+
136
+ desc "depends_chain_print_version_hash"
137
+ task :depends_chain_print_version_hash, [:what] => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "get_dep_chain", pkg.name) do |t, args|
138
+ # Do some verbose output
139
+ version_string = ""
140
+ hash = 0
141
+ global_dep_chain.each do |dep|
142
+ dep_ref = pkg_get_ref_by_name(global_package_list, dep, pkg.name)
143
+ version_string << "#{dep_ref.version[0]}"
144
+ end
145
+ case args[:what]
146
+ when "md5"
147
+ hash = Digest::MD5.hexdigest(version_string)
148
+ when "sha1"
149
+ hash = Digest::SHA1.hexdigest(version_string)
150
+ else
151
+ print_abort("Invalid argument #{args[:what]}, please specify [md5] or [sha1]")
152
+ end
153
+ print_any_green(hash)
154
+ end
155
+
156
+
157
+
158
+ def create_remfile_generate_file_task(pkg_ref, package_list, remfile, dep_chain)
159
+ Rake::Task["package:create_workdir"].invoke()
160
+ file remfile do
161
+ dep_ref_array = []
162
+ dep_chain.each do |dep|
163
+ dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name)
164
+ dep_ref_array.push(dep_ref)
165
+ print_any_green("Writing #{dep_ref.name}")
166
+ end
167
+ yaml_store(remfile, "pkg", dep_ref_array)
168
+ end
169
+ end
170
+
171
+ desc "remfile_generate"
172
+ task :remfile_generate => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "get_dep_chain", pkg.name) do
173
+ create_remfile_generate_file_task(pkg, global_package_list, global_config.get_remfile(), global_dep_chain)
174
+ Rake::Task["#{global_config.get_remfile()}"].invoke()
175
+ end
176
+
177
+
178
+
179
+ def create_download_file_task(pkg_ref, package_list, tasks_common)
180
+
181
+ # As this is the first task in the chain create work directories here:
182
+ Rake::Task["package:create_workdir"].invoke()
183
+
184
+ file "#{pkg_ref.pkg_dl_state_file}" do
185
+ print_any_green "Downloading #{pkg_ref.name}..."
186
+ pkg_ref.download()
187
+ end
188
+ end
189
+
190
+ desc "download"
191
+ task :download do
192
+ print_debug("download: #{pkg.name}")
193
+ create_download_file_task(pkg, global_package_list, 0)
194
+ Rake::Task["#{pkg.pkg_dl_state_file}"].invoke()
195
+ end
196
+
197
+
198
+
199
+ prepare_tasks_common = [ pkg.get_name_splitted, "download" ]
200
+ def create_prepare_file_task(pkg_ref, package_list, tasks_common)
201
+
202
+ pkg_prepare_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name)
203
+
204
+ # Add source file dependencies and include folders
205
+ # This is quite hacky, but the best solution so far:
206
+ if pkg_ref.uri[0].uri_type == "local"
207
+ pkg_ref.srcs.each do |e|
208
+ found = 0
209
+ pkg_ref.base_dir.each do |dir|
210
+ if File.exist?("#{dir}/#{e}")
211
+ pkg_prepare_list.push("#{dir}/#{e}")
212
+ found = 1
213
+ break
214
+ end
215
+ end
216
+ if found != 1
217
+ print_abort("Could not find file #{e} in the following dirs #{pkg_ref.base_dir}")
218
+ end
219
+ end
220
+
221
+ # At first find all *.h files:
222
+ header_files = []
223
+ pkg_ref.incdirs.each do |e|
224
+ found = 0
225
+ pkg_ref.base_dir.each do |dir|
226
+ if File.exist?("#{dir}/#{e}")
227
+ header_files.concat(find_files_with_ending("#{dir}/#{e}", "h"))
228
+ found = 1
229
+ break
230
+ end
231
+ end
232
+ if found != 1
233
+ print_abort("Could not find path #{e} in the following dirs #{pkg_ref.base_dir}")
234
+ end
235
+ end
236
+ pkg_prepare_list.concat(header_files)
237
+ end
238
+
239
+ file "#{pkg_ref.get_package_state_file("prepare")}" => pkg_prepare_list do
240
+ print_any_green "Preparing #{pkg_ref.name}..."
241
+ pkg_ref.prepare_package_state_dir()
242
+ pkg_ref.prepare()
243
+ print_debug "#{pkg_ref.name} prepare list: #{pkg_prepare_list}"
244
+ end
245
+ end
246
+
247
+ desc "prepare"
248
+ task :prepare => package_add_common_task_dep_list(global_package_list, prepare_tasks_common, NON_FILE_TASK, pkg.name) do
249
+ print_debug("prepare: #{pkg.name}")
250
+ create_prepare_file_task(pkg, global_package_list, prepare_tasks_common)
251
+ Rake::Task["#{pkg.get_package_state_file("prepare")}"].invoke()
252
+ end
253
+
254
+
255
+
256
+ compile_tasks_common = [ pkg.deps, "compile", pkg.get_name_splitted, "prepare" ]
257
+ def create_compile_file_task(pkg_ref, package_list, tasks_common)
258
+
259
+ pkg_compile_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name)
260
+
261
+ # Prepare include directories of the dependencies
262
+ dep_inc_array = []
263
+ pkg_ref.deps.each do |dep|
264
+ dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name)
265
+ dep_inc_array.concat(dep_ref.inc_dirs_prepared)
266
+ end
267
+
268
+ pkg_ref.set_dependency_incdirs(dep_inc_array)
269
+ pkg_ref.incdir_prepare()
270
+ pkg_ref.compile_and_link_prepare()
271
+
272
+ # Check for updated header or c files
273
+ header_files = []
274
+ pkg_ref.incdirs.each do |e|
275
+ header_files.concat(find_files_with_ending("#{pkg_ref.get_pkg_work_dir}/#{e}", "h"))
276
+ end
277
+ pkg_compile_list.concat(header_files)
278
+
279
+ c_files = pkg_ref.srcs.map { |element| "#{pkg_ref.get_pkg_work_dir}/#{element}" }
280
+ pkg_compile_list.concat(c_files)
281
+
282
+ desc "#{pkg_ref.get_package_state_file("compile")}"
283
+ file "#{pkg_ref.get_package_state_file("compile")}" => pkg_compile_list do
284
+ print_any_green "Compiling #{pkg_ref.name}..."
285
+ pkg_ref.compile()
286
+ end
287
+ end
288
+
289
+ # The compile task is kind of special, because we need to set all global defines
290
+ # of the dependency chain before we start with any of the upcoming compile tasks.
291
+ # It's a pity that it's not possible to integrate this in create_compile_file_task(),
292
+ # however I haven't found any other solution to this problem yet.
293
+ task :compile_globals_prepare => package_add_non_file_task_dep(global_package_list, pkg.deps, "compile_globals_prepare", pkg.name) do
294
+ # set global defines
295
+ pkg.global_defines.each do |e|
296
+ global_config.set_define("#{e}")
297
+ end
298
+ end
299
+
300
+ desc "compile"
301
+ task :compile => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "compile_globals_prepare", pkg.name) +
302
+ package_add_common_task_dep_list(global_package_list, compile_tasks_common, NON_FILE_TASK, pkg.name) do
303
+ print_debug("compile: #{pkg.name}")
304
+ create_compile_file_task(pkg, global_package_list, compile_tasks_common)
305
+ Rake::Task["#{pkg.get_package_state_file("compile")}"].invoke()
306
+ end
307
+
308
+
309
+
310
+ link_tasks_common = [ pkg.get_name_splitted, "compile" ]
311
+ def create_link_file_task(pkg_ref, package_list, tasks_common, dep_chain)
312
+ pkg_link_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name)
313
+
314
+ # Prepare include directories of the dependencies
315
+ dep_obj_array = []
316
+ dep_chain.each do |dep|
317
+ dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name)
318
+ dep_ref.compile_and_link_prepare()
319
+ dep_obj_array.concat(dep_ref.obj_files_prepared)
320
+
321
+ # Set global linker flags here, as the linker task does not have any other paralell
322
+ # executed tasks it is possible to set the linker flags here, locally.
323
+ global_config.set_link_flag(dep_ref.get_prepared_link_string())
324
+ end
325
+
326
+ desc "#{pkg_ref.get_package_state_file("link")}"
327
+ file "#{pkg_ref.get_package_state_file("link")}" => pkg_link_list do
328
+ print_any_green "Linking #{pkg_ref.name}..."
329
+ pkg_ref.prepare_package_deploy_dir()
330
+ pkg_ref.link(dep_obj_array)
331
+ end
332
+ end
333
+
334
+ desc "link"
335
+ task :link => package_add_common_task_dep_list(global_package_list, link_tasks_common, NON_FILE_TASK, pkg.name) +
336
+ package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "get_dep_chain", pkg.name) do
337
+ print_debug("link: #{pkg.name}")
338
+ create_link_file_task(pkg, global_package_list, link_tasks_common, global_dep_chain)
339
+ Rake::Task["#{pkg.get_package_state_file("link")}"].invoke()
340
+ end
341
+
342
+
343
+
344
+ desc "Do #{pkg.name} image"
345
+ task :image, [:what] => package_add_non_file_task_dep(global_package_list, pkg.get_name_splitted, "link", pkg.name) do |t, args|
346
+ print_any_green "Making image #{pkg.name}..."
347
+ pkg.make_image("#{args[:what]}")
348
+ end
349
+
350
+
351
+
352
+ desc "Do #{pkg.name} clean"
353
+ task :clean, [:what] do |t, args|
354
+ print_any_green "Cleaning #{pkg.name}..."
355
+ case args[:what]
356
+ when "download"
357
+ pkg.clean_download()
358
+ when "prepare"
359
+ pkg.clean_prepare()
360
+ when "compile"
361
+ pkg.clean_compile()
362
+ when "link"
363
+ pkg.clean_link()
364
+ when "all"
365
+ pkg.cleanall()
366
+ else
367
+ print_abort("Invalid argument #{args[:what]}")
368
+ end
369
+ end
370
+
371
+
372
+
373
+ desc "Do #{pkg.name} check dependency chain"
374
+ task :check_deps, [:what, :compile_link, :base_pkg] do |t, args|
375
+ if !args.what
376
+ print_abort("No package for removal given!")
377
+ end
378
+
379
+ if !args.base_pkg
380
+ print_abort("No base package given!")
381
+ end
382
+
383
+ # Prepare globals like global defines to be sure we are using the correct setup
384
+ Rake::Task["package:#{args[:base_pkg]}:compile_globals_prepare"].invoke()
385
+
386
+ pkg_to_remove = args[:what]
387
+ print_any_green "Building #{pkg.name} without dep #{pkg_to_remove}"
388
+
389
+ if !pkg.deps.include? pkg_to_remove
390
+ print_abort "Package #{pkg_to_remove} not in list!"
391
+ end
392
+
393
+ # Now remove one dep, and build again, to check compile step
394
+ print_any_green "Deps before #{pkg.deps}"
395
+ pkg.deps.delete(pkg_to_remove)
396
+ print_any_green "Deps after #{pkg.deps}"
397
+
398
+ if args[:compile_link] == "compile"
399
+ # Remove the task from the prerequisite list:
400
+ Rake::Task["package:#{pkg.name}:compile"].prerequisites.delete("package:#{pkg_to_remove}:compile")
401
+ Rake::Task["package:#{pkg.name}:compile"].invoke()
402
+ elsif args[:compile_link] == "link"
403
+
404
+ Rake::Task["package:#{pkg.name}:get_dep_chain"].invoke()
405
+
406
+ # Now remove the one package from the dep list:
407
+ print_any_green "Deps before #{global_dep_chain}"
408
+ global_dep_chain.delete(pkg_to_remove)
409
+ print_any_green "Deps after #{global_dep_chain}"
410
+ Rake::Task["package:#{pkg.name}:link"].invoke()
411
+ else
412
+ print_abort "Please specify if link or compile command!"
413
+ end
414
+ end
415
+
416
+ end
417
+ end
418
+
419
+
420
+
421
+ task :create_workdir do
422
+ print_debug("Preparing work directories...")
423
+ create_workdir()
424
+ end
425
+
426
+ task :remfile_clean do
427
+ print_debug("Deleting #{global_config.get_remfile()}")
428
+ FileUtils.rm_f(global_config.get_remfile())
429
+ end
430
+
431
+ task :dirclean do
432
+ print_debug("Deleting basedir #{BASE_DIR}")
433
+ FileUtils.rm_rf("#{BASE_DIR}")
434
+ end
435
+
436
+ desc "List available packages"
437
+ task :list_packages do |t, args|
438
+ print_debug ""
439
+ print_debug "Following software packages are available for this architecture: "
440
+ global_package_list.each do |pkg|
441
+ print_debug "#{pkg.name}"
442
+ print_debug "\t\t\t#{pkg.version[0]}"
443
+ print_debug ""
444
+ end
445
+ end
446
+ end
data/rem_path.rb ADDED
@@ -0,0 +1,23 @@
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
+ def get_rem_path()
22
+ File.expand_path(File.dirname(__FILE__))
23
+ end
@@ -0,0 +1,121 @@
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
+ module PackageBuildFunctions
22
+
23
+ def download
24
+ do_download()
25
+ set_download_done()
26
+ end
27
+
28
+ def prepare_package_state_dir
29
+ FileUtils.mkdir_p(pkg_state_dir)
30
+ end
31
+
32
+ def prepare_package_build_dir
33
+ FileUtils.mkdir_p(pkg_build_dir)
34
+ end
35
+
36
+ def prepare_package_deploy_dir
37
+ FileUtils.mkdir_p(pkg_deploy_dir)
38
+ end
39
+
40
+ def prepare
41
+ do_prepare_builddir()
42
+ do_patch()
43
+ set_state_done("prepare")
44
+ end
45
+
46
+ def set_dependency_incdirs(inc_dep_array)
47
+ inc_dirs_depends_prepared.concat(inc_dep_array)
48
+ end
49
+
50
+ def incdir_prepare()
51
+ @inc_dirs_prepared = incdirs.map { |e| "#{get_pkg_work_dir}/#{e}" }
52
+ end
53
+
54
+ def compile_and_link_prepare
55
+ if src_files_prepared.empty?
56
+ @src_files_prepared = srcs.map { |e| "#{get_pkg_work_dir}/#{e}" }
57
+ @obj_files_prepared = srcs.map { |e| "#{get_pkg_work_dir}/#{get_uri_without_extension(e)}.#{global_config.get_obj_extension}" }
58
+ end
59
+ end
60
+
61
+ def compile
62
+ print_debug "Compiling package #{name}..."
63
+ do_compile()
64
+ set_state_done("compile")
65
+ end
66
+
67
+ def get_prepared_link_string
68
+ return do_prepare_link_string
69
+ end
70
+
71
+ def link(objs)
72
+ print_debug "Linking package #{name}..."
73
+ do_link(objs)
74
+ set_state_done("link")
75
+ end
76
+
77
+ def make_image(which)
78
+ case which
79
+ when "bin"
80
+ do_make_bin()
81
+ when "hex"
82
+ do_make_hex()
83
+ when "srec"
84
+ do_make_srec()
85
+ else
86
+ abort("Invalid image argument!")
87
+ end
88
+ end
89
+
90
+ def clean_download
91
+ print_debug "cleaning download package #{name}"
92
+ do_download_clean()
93
+ FileUtils.rm_rf("#{pkg_dl_state_dir}")
94
+ end
95
+
96
+ def clean_prepare
97
+ print_debug "cleaning prepare package #{name}"
98
+ do_prepare_clean()
99
+ FileUtils.rm_rf("#{pkg_state_dir}/prepare")
100
+ end
101
+
102
+ def clean_compile
103
+ print_debug "cleaning compile package #{name}"
104
+ do_compile_clean()
105
+ FileUtils.rm_rf("#{pkg_state_dir}/compile")
106
+ end
107
+
108
+ def clean_link
109
+ print_debug "cleaning link package #{name}"
110
+ do_link_clean()
111
+ FileUtils.rm_rf("#{pkg_state_dir}/link")
112
+ end
113
+
114
+ def cleanall
115
+ print_debug "cleaning all for package #{name}"
116
+ clean_link()
117
+ clean_compile()
118
+ clean_prepare()
119
+ clean_download()
120
+ end
121
+ end
@@ -0,0 +1,35 @@
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
+ module CommonLinkTasks
22
+ def do_prepare_link_string
23
+ tmp_str = ""
24
+ global_linker_flags.each do |e|
25
+ tmp_str.concat("#{e} ")
26
+ end
27
+
28
+ # Set linker script
29
+ unless linker_script[0].to_s.strip.empty?
30
+ tmp_str.concat("-T #{pkg_build_dir}/#{linker_script[0]} ")
31
+ end
32
+
33
+ return tmp_str
34
+ end
35
+ end
@@ -0,0 +1,30 @@
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
+ module CommonLinkTasks
22
+ def do_prepare_link_string
23
+ tmp_str = ""
24
+ global_linker_flags.each do |e|
25
+ tmp_str.concat("#{e} ")
26
+ end
27
+
28
+ return tmp_str
29
+ end
30
+ end