Class: Purple::MakefileMaven
- Inherits:
-
Object
- Object
- Purple::MakefileMaven
- Defined in:
- lib/purple/makefile.rb
Overview
Makefile aware predicate container. Initialize with path to source directory.
Instance Method Summary collapse
- #has_makefile? ⇒ Boolean
-
#initialize(srcdir) ⇒ MakefileMaven
constructor
A new instance of MakefileMaven.
- #makefile_contents ⇒ Object
- #makefile_rules ⇒ Object
- #makefilename ⇒ Object
- #uses_destdir? ⇒ Boolean
- #uses_prefix? ⇒ Boolean
Constructor Details
#initialize(srcdir) ⇒ MakefileMaven
Returns a new instance of MakefileMaven.
7 8 9 |
# File 'lib/purple/makefile.rb', line 7 def initialize srcdir @srcdir = srcdir end |
Instance Method Details
#has_makefile? ⇒ Boolean
11 12 13 |
# File 'lib/purple/makefile.rb', line 11 def has_makefile? makefilename && true end |
#makefile_contents ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/purple/makefile.rb', line 38 def makefile_contents return @contents if defined? @contents @contents = '' files = [makefilename]; while files.size > 0 filename = File.join(@srcdir, files.shift) if FileTest.exist? filename puts "DEBUG MakefileMaven#makefile_contents: loop->if" text = File.open(filename) { |f| f.read } @contents << text text.grep(/^include /).each do |s| md = /^include (.*?)\n$/.match s files << md[1] end end end puts "DEBUG MakefileMaven#makefile_contents: #{@contents.to_a.size} lines" @contents end |
#makefile_rules ⇒ Object
33 34 35 36 |
# File 'lib/purple/makefile.rb', line 33 def makefile_rules return @rules if defined? @rules @rules = `make -pn -C #{@srcdir}` end |
#makefilename ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/purple/makefile.rb', line 15 def makefilename return @makefilename if defined? @makefilename @makefilename = ['GNUmakefile', 'makefile', 'Makefile'].find do |name| puts "DEBUG MakefileMaven#makefilename: testing #{File.join(@srcdir, name)}" FileTest.exist? File.join(@srcdir, name) end end |
#uses_destdir? ⇒ Boolean
28 29 30 31 |
# File 'lib/purple/makefile.rb', line 28 def uses_destdir? return true if makefile_rules.grep(/DESTDIR/).size > 0 false end |
#uses_prefix? ⇒ Boolean
23 24 25 26 |
# File 'lib/purple/makefile.rb', line 23 def uses_prefix? return true if makefile_rules.grep(/^prefix/).size > 0 false end |