Class: Bake::Blocks::Makefile
- Inherits:
-
Object
- Object
- Bake::Blocks::Makefile
- Includes:
- HasExecuteCommand
- Defined in:
- lib/blocks/makefile.rb
Constant Summary collapse
- MAKE_COMMAND =
"make"- MAKE_FILE_FLAG =
"-f"- MAKE_DIR_FLAG =
"-C"- MAKE_CLEAN =
"clean"
Instance Attribute Summary
Attributes included from HasExecuteCommand
Instance Method Summary collapse
- #calcCleanLine ⇒ Object
- #calcCommandLine ⇒ Object
- #calcEnv ⇒ Object
- #calcPathTo(referencedConfigs) ⇒ Object
- #clean ⇒ Object
- #cleanStep ⇒ Object
- #do_clean ⇒ Object
- #execute ⇒ Object
- #exitStep ⇒ Object
- #fileAndDir ⇒ Object
-
#initialize(config, referencedConfigs, block) ⇒ Makefile
constructor
A new instance of Makefile.
- #run ⇒ Object
- #startupStep ⇒ Object
Methods included from HasExecuteCommand
Constructor Details
#initialize(config, referencedConfigs, block) ⇒ Makefile
Returns a new instance of Makefile.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |
Instance Method Details
#calcCleanLine ⇒ Object
66 67 68 69 70 71 72 |
# 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 ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/blocks/makefile.rb', line 58 def calcCommandLine @commandLine = remove_empty_strings_and_join([ MAKE_COMMAND, @target, @flags, fileAndDir, @path_to]) end |
#calcEnv ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# 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..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 ⇒ Object
129 130 131 |
# File 'lib/blocks/makefile.rb', line 129 def clean return do_clean() end |
#cleanStep ⇒ Object
133 134 135 |
# File 'lib/blocks/makefile.rb', line 133 def cleanStep return do_clean() end |
#do_clean ⇒ Object
123 124 125 126 127 |
# File 'lib/blocks/makefile.rb', line 123 def do_clean return true if Bake..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..filename end |
#execute ⇒ Object
111 112 113 |
# File 'lib/blocks/makefile.rb', line 111 def execute return run() end |
#exitStep ⇒ Object
119 120 121 |
# File 'lib/blocks/makefile.rb', line 119 def exitStep return run() end |
#fileAndDir ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# 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 ⇒ Object
105 106 107 108 109 |
# File 'lib/blocks/makefile.rb', line 105 def run return true if Bake..linkOnly @envs.each { |k,v| ENV[k] = v } return executeCommand(@commandLine, nil, @config.validExitCodes, @config.echo) end |
#startupStep ⇒ Object
115 116 117 |
# File 'lib/blocks/makefile.rb', line 115 def startupStep return run() end |