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 Method Summary collapse
- #calcCleanLine ⇒ Object
- #calcCommandLine ⇒ Object
- #calcPathTo(referencedConfigs) ⇒ Object
- #clean ⇒ Object
- #execute ⇒ Object
- #exitStep ⇒ Object
-
#initialize(config, referencedConfigs, block) ⇒ Makefile
constructor
A new instance of Makefile.
- #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 |
# File 'lib/blocks/makefile.rb', line 14 def initialize(config, referencedConfigs, block) @config = config @projectDir = config.get_project_dir @path_to = "" @flags = adjustFlags("",config.flags) if config.flags @makefile = config.name @target = config.target != "" ? config.target : "all" calcPathTo(referencedConfigs) calcCommandLine calcCleanLine block.lib_elements[config.line_number] = [LibElement.new(LibElement::LIB_WITH_PATH, config.lib)] if config.lib != "" end |
Instance Method Details
#calcCleanLine ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/blocks/makefile.rb', line 37 def calcCleanLine @cleanLine = remove_empty_strings_and_join([ MAKE_COMMAND, MAKE_CLEAN, MAKE_DIR_FLAG, File.dirname(@makefile), MAKE_FILE_FLAG, File.basename(@makefile), @path_to]) end |
#calcCommandLine ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/blocks/makefile.rb', line 28 def calcCommandLine @commandLine = remove_empty_strings_and_join([ MAKE_COMMAND, @target, @flags, MAKE_DIR_FLAG, File.dirname(@makefile), MAKE_FILE_FLAG, File.basename(@makefile), @path_to]) end |
#calcPathTo(referencedConfigs) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/blocks/makefile.rb', line 45 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+"/"+nameOfP if File.exists?(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
88 89 90 |
# File 'lib/blocks/makefile.rb', line 88 def clean return executeCommand(@cleanLine, "No rule to make target 'clean'.", @config.validExitCodes) unless Bake..filename end |
#execute ⇒ Object
76 77 78 |
# File 'lib/blocks/makefile.rb', line 76 def execute return executeCommand(@commandLine, nil, @config.validExitCodes) end |
#exitStep ⇒ Object
84 85 86 |
# File 'lib/blocks/makefile.rb', line 84 def exitStep return executeCommand(@commandLine, nil, @config.validExitCodes) end |
#startupStep ⇒ Object
80 81 82 |
# File 'lib/blocks/makefile.rb', line 80 def startupStep return executeCommand(@commandLine, nil, @config.validExitCodes) end |