class Bake::Blocks::Makefile
Constants
- MAKE_CLEAN
- MAKE_COMMAND
- MAKE_DIR_FLAG
- MAKE_FILE_FLAG
Public Class Methods
new(config, referencedConfigs, block)
click to toggle source
# File lib/blocks/makefile.rb, line 14 def initialize(config, referencedConfigs, block) @config = config @tcs = block.tcs @projectDir = config.get_project_dir @path_to = "" @flags = adjustFlags("",config.flags) if config.flags @makefile = block.convPath(config.name) @target = config.target != "" ? config.target : "all" calcPathTo(referencedConfigs) calcCommandLine calcCleanLine calcEnv if config.lib != "" block.lib_elements << LibElement.new(LibElement::LIB_WITH_PATH, block.convPath(config.lib)) end end
Public Instance Methods
calcCleanLine()
click to toggle source
# File lib/blocks/makefile.rb, line 66 def calcCleanLine @cleanLine = remove_empty_strings_and_join([ MAKE_COMMAND, MAKE_CLEAN, @flags, fileAndDir, @path_to]) end
calcCommandLine()
click to toggle source
# File lib/blocks/makefile.rb, line 58 def calcCommandLine @commandLine = remove_empty_strings_and_join([ MAKE_COMMAND, @target, @flags, fileAndDir, @path_to]) end
calcEnv()
click to toggle source
# File lib/blocks/makefile.rb, line 32 def calcEnv @envs = {} [:CPP, :C, :ASM].each do |type| compiler = @tcs[:COMPILER][type] defs = compiler[:DEFINES].map {|k| "#{compiler[:DEFINE_FLAG]}#{k}"}.join(" ") args = [defs, compiler[:FLAGS]].reject(&:empty?).join(" ") @envs["BAKE_#{type.to_s}_FLAGS"] = args @envs["BAKE_#{type.to_s}_COMMAND"] = compiler[:COMMAND] end @envs["BAKE_AR_FLAGS"] = @tcs[:ARCHIVER][:FLAGS] @envs["BAKE_LD_FLAGS"] = @tcs[:LINKER][:FLAGS] @envs["BAKE_AR_COMMAND"] = @tcs[:ARCHIVER][:COMMAND] @envs["BAKE_LD_COMMAND"] = @tcs[:LINKER][:COMMAND] end
calcPathTo(referencedConfigs)
click to toggle source
# File lib/blocks/makefile.rb, line 74 def calcPathTo(referencedConfigs) @path_to = "" if @config.pathTo != "" pathHash = {} @config.pathTo.split(",").each do |p| nameOfP = p.strip dirOfP = nil if referencedConfigs.include?nameOfP dirOfP = referencedConfigs[nameOfP].first.get_project_dir else Bake.options.roots.each do |r| absIncDir = r.dir+"/"+nameOfP if File.exist?(absIncDir) dirOfP = absIncDir break end end end if dirOfP == nil Bake.formatter.printError("Project '#{nameOfP}' not found", @config) ExitHelper.exit(1) end pathHash[nameOfP] = File.rel_from_to_project(File.dirname(@projectDir),File.dirname(dirOfP)) end path_to_array = [] pathHash.each { |k,v| path_to_array << "PATH_TO_#{k}=#{v}" } @path_to = path_to_array.join(" ") end end
clean()
click to toggle source
# File lib/blocks/makefile.rb, line 129 def clean return do_clean() end
cleanStep()
click to toggle source
# File lib/blocks/makefile.rb, line 133 def cleanStep return do_clean() end
do_clean()
click to toggle source
# File lib/blocks/makefile.rb, line 123 def do_clean return true if Bake.options.linkOnly || @config.noClean @envs.each { |k,v| ENV[k] = v } return executeCommand(@cleanLine, "No rule to make target 'clean'.", @config.validExitCodes, @config.echo) unless Bake.options.filename end
execute()
click to toggle source
# File lib/blocks/makefile.rb, line 111 def execute return run() end
exitStep()
click to toggle source
# File lib/blocks/makefile.rb, line 119 def exitStep return run() end
fileAndDir()
click to toggle source
# File lib/blocks/makefile.rb, line 47 def fileAndDir if @config.changeWorkingDir return remove_empty_strings_and_join([ MAKE_DIR_FLAG, File.dirname(@makefile), MAKE_FILE_FLAG, File.basename(@makefile)]) else return remove_empty_strings_and_join([ MAKE_FILE_FLAG, @makefile]) end end
run()
click to toggle source
# File lib/blocks/makefile.rb, line 105 def run return true if Bake.options.linkOnly @envs.each { |k,v| ENV[k] = v } return executeCommand(@commandLine, nil, @config.validExitCodes, @config.echo) end
startupStep()
click to toggle source
# File lib/blocks/makefile.rb, line 115 def startupStep return run() end