class Object
Constants
- ARCH
Check for environment variables
- BASE_DIR
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
- BUILD_DIR
- DEPLOY_DIR
- DL_DIR
- DL_STATE_DIR
- FILE_TASK
- MACH
- NON_FILE_TASK
Copyright (C) 2016 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
- PROJECT_FOLDER
- SIMPLECOV
- STATE_DIR
- VERBOSE
- WORKDIR
Public Instance Methods
# File scripts/misc/helper.rb, line 57 def check_duplicates_exit_with_error(array, list_name) # Now put warning if there are any duplicate recipes duplicates = get_duplicates_in_array(array) if duplicates.uniq.any? print_abort ("ERROR: Duplicates in #{list_name}, duplicates: #{duplicates.uniq}") end end
# File rem_core.rb, line 290 def create_compile_file_task(pkg_ref, package_list, tasks_common) pkg_compile_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name) # Prepare include directories of the dependencies dep_inc_array = [] pkg_ref.deps.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name) dep_inc_array.concat(dep_ref.inc_dirs_prepared) end pkg_ref.set_dependency_incdirs(dep_inc_array) pkg_ref.incdir_prepare() pkg_ref.compile_and_link_prepare() # Check for updated header or c files header_files = [] pkg_ref.incdirs.each do |e| header_files.concat(find_files_with_ending("#{pkg_ref.get_pkg_work_dir}/#{e}", "h")) end pkg_compile_list.concat(header_files) c_files = pkg_ref.srcs.map { |element| "#{pkg_ref.get_pkg_work_dir}/#{element}" } pkg_compile_list.concat(c_files) desc "#{pkg_ref.get_package_state_file("compile")}" file "#{pkg_ref.get_package_state_file("compile")}" => pkg_compile_list do print_any_green "Compiling #{pkg_ref.name}..." pkg_ref.compile() end end
# File rem_core.rb, line 212 def create_download_file_task(pkg_ref, package_list, tasks_common) # As this is the first task in the chain create work directories here: Rake::Task["package:create_workdir"].invoke() file "#{pkg_ref.pkg_dl_state_file}" do print_any_green "Downloading #{pkg_ref.name}..." pkg_ref.download() end end
# File rem_core.rb, line 344 def create_link_file_task(pkg_ref, package_list, tasks_common, dep_chain) pkg_link_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name) # Prepare include directories of the dependencies dep_obj_array = [] dep_chain.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name) dep_ref.compile_and_link_prepare() dep_obj_array.concat(dep_ref.obj_files_prepared) # Set global linker flags here, as the linker task does not have any other paralell # executed tasks it is possible to set the linker flags here, locally. global_config.set_link_flag(dep_ref.get_prepared_link_string()) end desc "#{pkg_ref.get_package_state_file("link")}" file "#{pkg_ref.get_package_state_file("link")}" => pkg_link_list do print_any_green "Linking #{pkg_ref.name}..." pkg_ref.prepare_package_deploy_dir() pkg_ref.link(dep_obj_array) end end
# File rem_core.rb, line 233 def create_prepare_file_task(pkg_ref, package_list, tasks_common) pkg_prepare_list = package_add_common_task_dep_list(package_list, tasks_common, FILE_TASK, pkg_ref.name) # Add source file dependencies and include folders # This is quite hacky, but the best solution so far: if pkg_ref.uri[0].uri_type == "local" pkg_ref.srcs.each do |e| found = 0 pkg_ref.base_dir.each do |dir| if File.exist?("#{dir}/#{e}") pkg_prepare_list.push("#{dir}/#{e}") found = 1 break end end if found != 1 print_abort("Could not find file #{e} in the following dirs #{pkg_ref.base_dir}") end end # At first find all *.h files: header_files = [] pkg_ref.incdirs.each do |e| found = 0 pkg_ref.base_dir.each do |dir| if File.exist?("#{dir}/#{e}") header_files.concat(find_files_with_ending("#{dir}/#{e}", "h")) found = 1 break end end if found != 1 print_abort("Could not find path #{e} in the following dirs #{pkg_ref.base_dir}") end end pkg_prepare_list.concat(header_files) end file "#{pkg_ref.get_package_state_file("prepare")}" => pkg_prepare_list do print_any_green "Preparing #{pkg_ref.name}..." pkg_ref.prepare_package_state_dir() pkg_ref.prepare() print_debug "#{pkg_ref.name} prepare list: #{pkg_prepare_list}" end end
# File rem_core.rb, line 191 def create_remfile_generate_file_task(pkg_ref, package_list, remfile, dep_chain) Rake::Task["package:create_workdir"].invoke() file remfile do dep_ref_array = [] dep_chain.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_ref.name) dep_ref_array.concat(dep_ref.get_package_recipe_files) print_any_green("Writing #{dep_ref.name}") end yaml_store(remfile, "pkg", dep_ref_array) end end
# File rem_core.rb, line 69 def create_workdir FileUtils.mkdir_p(BUILD_DIR) FileUtils.mkdir_p(DL_DIR) FileUtils.mkdir_p(DL_STATE_DIR) end
# File scripts/misc/helper.rb, line 65 def execute(cmd) Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr| cmd_std_message = "" print_debug(cmd) stdout_err.each do |line| print_debug(line) cmd_std_message << line end exit_status = wait_thr.value unless exit_status.success? print_any_red("Error when calling #{cmd} - exit code: #{exit_status} - STDOUT/STDERR:") print_any_red(cmd_std_message) abort end end end
# File scripts/recipe_handling/recipes.rb, line 102 def filter_packages(pkg_list, current_arch_config, current_mach_config) tmp_pkg_list = [] pkg_list.each_with_index do |cur_pkg, index| # Filter out packages which do not match arch or mach config arch_config = cur_pkg.get_arch() mach_config = cur_pkg.get_mach() if ( (arch_config == "generic") or (arch_config == current_arch_config and mach_config == "generic") or (arch_config == current_arch_config and mach_config == current_mach_config) ) tmp_pkg_list.push(cur_pkg) else 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}" end end pkg_list = tmp_pkg_list print_debug("Now having the following recipes:") pkg_list.each do | pkg | print_debug(pkg.name) end return tmp_pkg_list end
Searches for files with ending in folderlist Returns files as array
# File scripts/misc/helper.rb, line 25 def find_files_with_ending(folder_list, ending) files = [] folders = folder_list # check if folder_list is array or string unless folder_list.is_a?(Array) folders = folder_list.split(" ") end folders.each do |e| if File.exist?("#{e}") Find.find("#{e}") do |path| files << path if path =~ /.*\.#{ending}$/ end else print_abort("Error: path #{e} does not exist!") end end return files end
Searches for files with ending in folderlist Returns files as string
# File scripts/misc/helper.rb, line 48 def find_files_with_ending_str(folder_list, ending) list = find_files_with_ending(folder_list, ending) return list.join(" ") end
Cuts the filename from the given uri
# File scripts/misc/helper.rb, line 107 def get_dirname_from_uri(uri) return File.dirname(uri) end
# File scripts/misc/helper.rb, line 53 def get_duplicates_in_array(array) return array.select{|element| array.count(element) > 1 } end
Returns the file extension from the given uri
# File scripts/misc/helper.rb, line 117 def get_extension_from_uri(uri) tmp = File.extname(uri) # return the "." tmp.slice!(0) return tmp end
Cuts the directory from the given uri
# File scripts/misc/helper.rb, line 112 def get_filename_from_uri(uri) return File.basename(uri) end
Cuts the directory and the extension from the given uri
# File scripts/misc/helper.rb, line 96 def get_filename_without_extension_from_uri(uri) #return File.basename(uri, extension) return File.basename(uri, File.extname(uri)) end
Copyright (C) 2015 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
# File scripts/recipe_handling/recipes.rb, line 21 def get_recipes(project_folders, recipe_file_ending) project_folders = project_folders.split(",") files = [] files = find_files_with_ending(project_folders, recipe_file_ending) if files.empty? return nil end print_debug("Found the following recipes:") print_debug(files) print_debug("") return files end
Copyright (C) 2016 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
# File rem_path.rb, line 21 def get_rem_path() File.expand_path(File.dirname(__FILE__)) end
Cuts the extension from the given uri
# File scripts/misc/helper.rb, line 102 def get_uri_without_extension(uri) return File.join(File.dirname(uri), File.basename(uri, '.*')) end
# File scripts/global_config/global_config.rb, line 234 def global_config return $global_config end
# File scripts/recipe_handling/recipes.rb, line 59 def merge_recipes_append(recipe_list, append_recipe_list) append_recipe_list.each do |append_pkg| tmp_pkg = pkg_get_ref_by_name(recipe_list, append_pkg.name) if tmp_pkg == nil print_any_yellow("Could not find matching base recipe for append recipe " + append_pkg.name) else print_any_yellow("Appending #{tmp_pkg.name}") # Iterate through instance_var_to_reset and reset all instance variables listed in this array vars_to_reset = append_pkg.instance_variable_get(:@instance_var_to_reset) if nil!=vars_to_reset vars_to_reset.each do |var| print_any_cyan("Reset all in #{var}") if tmp_pkg.instance_variable_get("@#{var}").nil? print_abort("sw_package variable #{var} does not exist!") else print_any_cyan("Clearing #{var}, which was #{tmp_pkg.instance_variable_get("@#{var}")}") tmp_pkg.instance_variable_get("@#{var}").clear end end print_any_cyan("Clearing instance_var_to_reset which was #{append_pkg.instance_variable_get(:@instance_var_to_reset)}") append_pkg.instance_variable_get(:@instance_var_to_reset).clear end # OK now simply load the new append package into the base package tmp_pkg.load_package(append_pkg.get_package_recipe_files[0]) # Add the remappend path tmp_pkg.add_recipe_path(append_pkg.get_package_recipe_files[0]) # Also add the new base_dir tmp_pkg.add_base_dir(append_pkg.get_package_recipe_files[0]) tmp_pkg.instance_variables.each do |var| print_any_cyan("#{var} is now #{tmp_pkg.instance_variable_get("#{var}")}") end end end print_any_yellow("Merging append recipes done.") end
Generates a list of dependencies input has to be composed like this package_list - list of package references 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 file_task - specifies if the output dependencies shall be file tasks or non file tasks
# File scripts/dependency_functions/dependency_tasks.rb, line 52 def package_add_common_task_dep_list(package_list, task_list, file_task, pkg_name) dep_str_array = [] # At first get the number of tasks task_count = ((task_list.length/2)-1) (0..task_count).step(1) do |i| # Every second entry is the dependency list deps_array = task_list[(i*2)] which = task_list[(i*2)+1] if(file_task == 1) dep_str_array.concat(package_add_file_task_dep(package_list, deps_array, which, pkg_name)) else dep_str_array.concat(package_add_non_file_task_dep(package_list, deps_array, which, pkg_name)) end end return dep_str_array end
# File scripts/dependency_functions/dependency_tasks.rb, line 33 def package_add_file_task_dep(package_list, dependency_list, which, pkg_name) dep_str_array = [] dependency_list.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_name) case which when "download" dep_str_array.push("#{dep_ref.pkg_dl_state_file}") else dep_str_array.push("#{dep_ref.get_package_state_file("#{which}")}") end end return dep_str_array end
# File scripts/dependency_functions/dependency_tasks.rb, line 24 def package_add_non_file_task_dep(package_list, dependency_list, which, pkg_name) dep_str_array = [] dependency_list.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg_name) dep_str_array.push("package:#{dep_ref.name}:#{which}") end return dep_str_array end
# File scripts/dependency_functions/dependency_tasks.rb, line 69 def package_get_dependency_list(package_list, pkg, dep_list) if(pkg.deps.any?) dep_list.concat(pkg.deps) end pkg.deps.each do |dep| dep_ref = pkg_get_ref_by_name(package_list, dep, pkg.name) package_get_dependency_list(package_list, dep_ref, dep_list) end end
Copyright (C) 2016 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
# File scripts/misc/helper_string_parse.rb, line 21 def parse_string(str_input_array, what) found = 0 ret_str = "" tmp_str_arr = str_input_array tmp_str = tmp_str_arr.split(";") tmp_str.each do |e| if(e[/#{what}(.*)/]) e.slice! "#{what}" ret_str = e found = 1 end end if(found == 1) return ret_str else return "undefined" end end
# File scripts/recipe_handling/recipes.rb, line 129 def pkg_get_ref_by_name(pkg_list, name, needed_by_info=nil) # find via index: #result = ref_list.index{ |item| item.name == name } #return ref_list[result] # find directly: result = pkg_list.find{ |item| item.name == name } if result == nil if needed_by_info != nil return print_abort("ERROR: No recipe found for package #{name}!" + " Needed by: " + needed_by_info) else return nil end else return result end end
# File scripts/recipe_handling/recipes.rb, line 37 def prepare_recipes(recipes) recipe_filenames = [] pkgs = [] print_debug "Searching for recipes..." # Remove directory from all recipes - this is needed to check for duplicates recipes.each {|e| recipe_filenames.push(get_filename_from_uri(e))} check_duplicates_exit_with_error(recipe_filenames, "recipes") recipes.each do |r| print_debug "parsing recipe #{r}:" # Parse and include submakefiles cur_pkg = SoftwarePackage.new(r) pkgs.push(cur_pkg) end return pkgs end
# File scripts/misc/print_functions.rb, line 49 def print_abort(text) # will produce red text color print_any_red(text) abort end
# File scripts/misc/print_functions.rb, line 45 def print_any(text) puts text end
# File scripts/misc/print_functions.rb, line 27 def print_any_cyan(text) puts "\033[36m#{text}\033[0m\n" end
# File scripts/misc/print_functions.rb, line 31 def print_any_green(text) puts "\033[32m#{text}\033[0m\n" end
# File scripts/misc/print_functions.rb, line 40 def print_any_red(text) # will produce red text color puts "\033[31m#{text}\033[0m\n" end
# File scripts/misc/print_functions.rb, line 35 def print_any_yellow(text) # will produce yellow text color puts "\033[33m#{text}\033[0m\n" end
Copyright (C) 2016 Franz Flasch <franz.flasch@gmx.at>
This file is part of REM - Rake for EMbedded Systems and Microcontrollers.
REM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
REM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with REM. If not, see <www.gnu.org/licenses/>.
# File scripts/misc/print_functions.rb, line 21 def print_debug(text) if(VERBOSE == "1") puts text end end
# File scripts/global_config/config_helper/check_env.rb, line 23 def set_input_env(var) if ENV[var].nil? || ENV[var].empty? abort ("#{var} not set!") end return ENV[var] end
# File scripts/global_config/config_helper/check_env.rb, line 31 def set_input_env_default(var, default_val) if ENV[var].nil? || ENV[var].empty? puts ("#{var} not set, using #{default_val}") return default_val else return ENV[var] end end
# File scripts/global_config/config_helper/check_env.rb, line 40 def set_workdir(input_keyword, default_val) tmp_path = set_input_env_default(input_keyword, default_val) if (Pathname.new tmp_path).absolute? return "#{tmp_path}" else return "#{Rake.original_dir}/#{tmp_path}" end end
Removes leading and trailing spaces as well as removing superflous spaces between strings
# File scripts/misc/helper.rb, line 84 def string_strip(val) return "#{val.gsub(/\s+/, " ").strip} " end
Does the same as string_strip
plus converts it to an array
# File scripts/misc/helper.rb, line 89 def string_strip_to_array(val) tmp = string_strip(val) tmp = tmp.split(" ") return tmp end
# File scripts/package.rb, line 27 def sw_package; return $global_sw_package; end
# File scripts/package.rb, line 28 def sw_package_set(pkg); $global_sw_package = pkg; end
# File scripts/remfile_functions/remfile_gen.rb, line 31 def yaml_parse(file, append) data = YAML::load_file(file) recipes = [] data['pkg'].each do |pkg| if append == true if pkg.include? ".remappend" (recipes||= []).push(pkg) end else if !pkg.include? ".remappend" (recipes||= []).push(pkg) end end end if recipes.empty? return nil else return recipes end end
# File scripts/remfile_functions/remfile_gen.rb, line 24 def yaml_store(file, fieldname, data) store = YAML::Store.new(file) store.transaction do store[fieldname] = data end end