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
@@ -0,0 +1,77 @@
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 "../common/gcc_LinkPrepare"
22
+
23
+ module Default
24
+ module Compile
25
+ private
26
+ def do_compile_clean
27
+ end
28
+
29
+ def do_compile
30
+ print_debug "hey I am the Default compile function"
31
+
32
+ print_debug "IncDirsDependsPrepared: #{inc_dirs_depends_prepared}"
33
+ print_debug "IncDirsPrepared: #{inc_dirs_prepared}"
34
+ print_debug "SrcFilesPrepared: #{src_files_prepared}"
35
+
36
+ inc_dirs_string = inc_dirs_depends_prepared.map { |element| "-I #{element} " }.join("")
37
+ inc_dirs_string << inc_dirs_prepared.map { |element| "-I #{element} " }.join("")
38
+
39
+ defines_string = defs.map { |element| "-D#{element} " }.join("")
40
+ defines_string << "#{global_config.get_defines()}"
41
+
42
+ src_files_prepared.each_with_index do |src, obj|
43
+ execute "#{global_config.get_compiler} #{defines_string} #{global_config.get_compile_flags} #{inc_dirs_string} -c #{src} -o #{obj_files_prepared[obj]}"
44
+ end
45
+ end
46
+ end
47
+
48
+ module Link
49
+ private
50
+ def do_link_clean
51
+ end
52
+
53
+ include CommonLinkTasks
54
+
55
+ def do_link(objs)
56
+ print_debug "hey I am the Default link function"
57
+ print_debug "Objects to link: #{objs}"
58
+ objs_string = objs.join(" ")
59
+ execute "#{global_config.get_compiler} #{objs_string} #{global_config.get_link_flags} -Wl,-Map=#{pkg_deploy_dir}/#{name}.map -o #{pkg_deploy_dir}/#{name}.elf"
60
+ end
61
+ end
62
+
63
+ module Image
64
+ private
65
+ def do_make_bin
66
+ execute "#{global_config.get_obj_cp} #{global_config.get_obj_copy_flags} -S -O binary #{pkg_deploy_dir}/#{name}.elf #{pkg_deploy_dir}/#{name}.bin"
67
+ end
68
+
69
+ def do_make_hex
70
+ execute "#{global_config.get_obj_cp} #{global_config.get_obj_copy_flags} -S -O ihex #{pkg_deploy_dir}/#{name}.elf #{pkg_deploy_dir}/#{name}.hex"
71
+ end
72
+
73
+ def do_make_srec
74
+ execute "#{global_config.get_obj_cp} #{global_config.get_obj_copy_flags} -S -O srec #{pkg_deploy_dir}/#{name}.elf #{pkg_deploy_dir}/#{name}.srec"
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,86 @@
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 "../common/#{global_config.compiler}_LinkPrepare"
22
+
23
+ class MakeTasksDesc
24
+
25
+ attr_reader :compile_clean_command
26
+ attr_reader :compile_command
27
+ attr_reader :link_command
28
+ attr_reader :image_command
29
+
30
+ def initialize()
31
+ @compile_clean_command = ""
32
+ @compile_command = ""
33
+ @link_command = ""
34
+ @image_command = ""
35
+ end
36
+
37
+ def set_compile_clean_command(command)
38
+ @compile_clean_command = command
39
+ end
40
+ def set_compile_command(command)
41
+ @compile_command = command
42
+ end
43
+ def set_link_command(command)
44
+ @link_command = command
45
+ end
46
+ def set_image_command(command)
47
+ @image_command = command
48
+ end
49
+ end
50
+
51
+ module MakePkg
52
+ module Compile
53
+ private
54
+ def do_compile_clean
55
+ execute get_build_specific_data.compile_clean_command
56
+ end
57
+
58
+ def do_compile
59
+ print_debug "hey I am the Make compile function"
60
+ execute get_build_specific_data.compile_command
61
+ end
62
+ end
63
+
64
+ module Link
65
+ private
66
+ def do_link_clean
67
+ end
68
+
69
+ include CommonLinkTasks
70
+
71
+ def do_link(objs)
72
+ print_debug "Not implemented"
73
+ end
74
+ end
75
+
76
+ module Image
77
+ private
78
+ def do_make_bin
79
+ print_debug "Not implemented"
80
+ end
81
+
82
+ def do_make_hex
83
+ print_debug "Not implemented"
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,80 @@
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 "../common/sdcc_LinkPrepare"
22
+
23
+ module Default
24
+ module Compile
25
+ private
26
+ def do_compile_clean
27
+ FileUtils.rm_rf("#{pkg_state_dir}/compile")
28
+ end
29
+
30
+ def do_compile
31
+ print_debug "hey I am the SDCC compile function"
32
+
33
+ print_debug "IncDirs: #{incdirs}"
34
+ print_debug "IncDirsPrepared: #{inc_dirs_prepared}"
35
+ print_debug "SrcFilesPrepared: #{src_files_prepared}"
36
+
37
+ inc_dirs_string = inc_dirs_depends_prepared.map { |element| "-I #{element} " }.join("")
38
+ inc_dirs_string << inc_dirs_prepared.map { |element| "-I #{element} " }.join("")
39
+
40
+ defines_string = defs.map { |element| "-D#{element} " }.join("")
41
+ defines_string << "#{global_config.get_defines()}"
42
+
43
+ src_files_prepared.each_with_index do |src, obj|
44
+ execute "#{global_config.get_compiler} #{defines_string} #{global_config.get_compile_flags()} #{inc_dirs_string} -c #{src} -o #{obj_files_prepared[obj]}"
45
+ end
46
+ end
47
+ end
48
+
49
+ module Link
50
+ private
51
+ def do_link_clean
52
+ FileUtils.rm_rf("#{pkg_state_dir}/link")
53
+ end
54
+
55
+ def do_prepare_link_string
56
+ return ""
57
+ end
58
+
59
+ def do_link(objs)
60
+ print_debug "hey I am the Default link function"
61
+ print_debug "Objects to link: #{objs}"
62
+ objs_string = ""
63
+ objs.each do |e|
64
+ objs_string << "#{e} "
65
+ end
66
+
67
+ execute "#{global_config.get_compiler} #{global_config.get_link_flags()} #{objs_string} -o #{pkg_deploy_dir}/#{name}.ihx"
68
+ #set_state_done("link")
69
+ end
70
+ end
71
+
72
+ module Image
73
+ private
74
+ def do_make_bin
75
+ end
76
+
77
+ def do_make_hex
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,68 @@
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
+ begin
22
+ $dep_graph_support = 1
23
+ require 'ruby-graphviz'
24
+ rescue LoadError
25
+ $dep_graph_support = 0
26
+ end
27
+
28
+ class DependencyGraph
29
+ attr_reader :dependency_graph
30
+ attr_reader :node_list
31
+ attr_reader :node_list_str
32
+ attr_reader :filename
33
+
34
+ def initialize(output_filename)
35
+ if($dep_graph_support == 0)
36
+ print_abort("No support for ruby-graphviz, please install with gem install ruby-graphviz")
37
+ end
38
+ @dependency_graph = GraphViz.new( :G, :type => :digraph )
39
+ @node_list = []
40
+ @node_list_str = []
41
+ @filename = output_filename
42
+ end
43
+
44
+ def get_node_by_name(name)
45
+ result = node_list_str.index(name)
46
+ if result == nil
47
+ return print_abort("ERROR: No node found for package #{name}!")
48
+ else
49
+ return node_list[result]
50
+ end
51
+ end
52
+
53
+ def add_node(name)
54
+ @node_list.push(dependency_graph.add_nodes(name))
55
+ @node_list_str.push(name)
56
+ end
57
+
58
+ def add_dep(base_node, dependency)
59
+ node = get_node_by_name(base_node)
60
+ dep = get_node_by_name(dependency)
61
+
62
+ dependency_graph.add_edges(node, dep)
63
+ end
64
+
65
+ def draw()
66
+ dependency_graph.output( :png => "#{filename}.png")
67
+ end
68
+ end
@@ -0,0 +1,67 @@
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
+ NON_FILE_TASK = 0
22
+ FILE_TASK = 1
23
+
24
+ def package_add_non_file_task_dep(package_list, dependency_list, which, pkg_name)
25
+ dep_str_array = []
26
+ dependency_list.each do |dep|
27
+ dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_name)
28
+ dep_str_array.push("package:#{dep_ref.name}:#{which}")
29
+ end
30
+ return dep_str_array
31
+ end
32
+
33
+ def package_add_file_task_dep(package_list, dependency_list, which, pkg_name)
34
+ dep_str_array = []
35
+ dependency_list.each do |dep|
36
+ dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_name)
37
+ case which
38
+ when "download"
39
+ dep_str_array.push("#{dep_ref.pkg_dl_state_file}")
40
+ else
41
+ dep_str_array.push("#{dep_ref.get_package_state_file("#{which}")}")
42
+ end
43
+ end
44
+ return dep_str_array
45
+ end
46
+
47
+ # Generates a list of dependencies
48
+ # input has to be composed like this
49
+ # package_list - list of package references
50
+ # task_list - [ pkg.deps_array, "compile", pkg.get_name_splitted, "prepare"] # Every second entry is the dependency array, Every second+1 entry is the "which" entry
51
+ # file_task - specifies if the output dependencies shall be file tasks or non file tasks
52
+ def package_add_common_task_dep_list(package_list, task_list, file_task, pkg_name)
53
+ dep_str_array = []
54
+ # At first get the number of tasks
55
+ task_count = ((task_list.length/2)-1)
56
+ (0..task_count).step(1) do |i|
57
+ # Every second entry is the dependency list
58
+ deps_array = task_list[(i*2)]
59
+ which = task_list[(i*2)+1]
60
+ if(file_task == 1)
61
+ dep_str_array.concat(package_add_file_task_dep(package_list, deps_array, which, pkg_name))
62
+ else
63
+ dep_str_array.concat(package_add_non_file_task_dep(package_list, deps_array, which, pkg_name))
64
+ end
65
+ end
66
+ return dep_str_array
67
+ end
@@ -0,0 +1,44 @@
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 DefaultDownload
22
+ module DownloadPackage
23
+
24
+ private
25
+
26
+ def download_zip
27
+ execute "wget -c #{uri[0].uri} -P #{pkg_dl_dir}"
28
+ end
29
+
30
+ def do_download_clean
31
+ FileUtils.rm_rf("#{pkg_dl_dir}")
32
+ end
33
+
34
+ def do_download
35
+ case uri[0].uri_type
36
+ when "zip"
37
+ print_debug "Zip package"
38
+ download_zip()
39
+ else
40
+ print_debug('No zip package, falling through...')
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,57 @@
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 'pathname'
22
+
23
+ def set_input_env(var)
24
+ if ENV[var].nil? || ENV[var].empty?
25
+ abort ("#{var} not set!")
26
+ end
27
+ return ENV[var]
28
+ end
29
+
30
+
31
+ def set_input_env_default(var, default_val)
32
+ if ENV[var].nil? || ENV[var].empty?
33
+ puts ("#{var} not set, using #{default_val}")
34
+ return default_val
35
+ else
36
+ return ENV[var]
37
+ end
38
+ end
39
+
40
+ def set_workdir(input_keyword, default_val)
41
+ tmp_path = set_input_env_default(input_keyword, default_val)
42
+
43
+ if (Pathname.new tmp_path).absolute?
44
+ return "#{tmp_path}"
45
+ else
46
+ return "#{Rake.original_dir}/#{tmp_path}"
47
+ end
48
+ end
49
+
50
+
51
+ # Check for environment variables
52
+ ARCH = set_input_env("ARCH")
53
+ MACH = set_input_env("MACH")
54
+ PROJECT_FOLDER = set_input_env("PROJECT_FOLDER")
55
+ WORKDIR = set_workdir("WORKDIR", "rem_workdir")
56
+ VERBOSE = set_input_env_default("VERBOSE", "0")
57
+ SIMPLECOV = set_input_env_default("SIMPLECOV", "0")
@@ -0,0 +1,27 @@
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
+ BASE_DIR = "#{WORKDIR}/#{ARCH}_#{MACH}"
22
+ BUILD_DIR = "#{BASE_DIR}/build"
23
+ DEPLOY_DIR = "#{BASE_DIR}/deploy"
24
+ STATE_DIR = "#{BASE_DIR}/state"
25
+
26
+ DL_DIR = "#{WORKDIR}/download/packages"
27
+ DL_STATE_DIR = "#{WORKDIR}/download/state"