Sha256: 5295c7f2e81b540ace3a566c050af6a2bfa84489295ce8168297a0120bbdeefb

Contents?: true

Size: 1.38 KB

Versions: 50

Compression:

Stored size: 1.38 KB

Contents

# modified version of Rake's provided make-style dependency loader
# customizations: 
#  (1) handles windows drives in paths -- colons don't confuse task demarcation
#  (2) handles spaces in directory paths

module Rake

  # Makefile loader to be used with the import file loader.
  class MakefileLoader

    # Load the makefile dependencies in +fn+.
    def load(fn)
      open(fn) do |mf|
        lines = mf.read
        lines.gsub!(/#[^\n]*\n/m, "") # remove comments
        lines.gsub!(/\\\n/, ' ')      # string together line continuations into single line
        lines.split("\n").each do |line|
          process_line(line)
        end
      end
    end

    private

    # Process one logical line of makefile data.
    def process_line(line)
      # split on presence of task demaractor followed by space (i.e don't get confused by a colon in a win path)
      file_tasks, args = line.split(/:\s/)

      return if args.nil?
      
      # split at non-escaped space boundary between files (i.e. escaped spaces in paths are left alone)
      dependents = args.split(/\b\s+/)
      # replace escaped spaces and clean up any extra whitespace
      dependents.map! { |path| path.gsub(/\\ /, ' ').strip }

      file_tasks.strip.split.each do |file_task|
        file file_task => dependents
      end
    end
  end

  # Install the handler
  Rake.application.add_loader('mf', MakefileLoader.new)
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
ceedling-0.31.1 lib/ceedling/makefile.rb
ceedling-0.31.0 lib/ceedling/makefile.rb
ceedling-0.30.0 lib/ceedling/makefile.rb
ceedling-0.28.3 lib/ceedling/makefile.rb
ceedling-0.28.2 lib/ceedling/makefile.rb
ceedling-0.28.1 lib/ceedling/makefile.rb
ceedling-0.27.0 lib/ceedling/makefile.rb
ceedling-0.25.0 lib/ceedling/makefile.rb
ceedling-0.24.0 lib/ceedling/makefile.rb
ceedling-0.22.0 lib/ceedling/makefile.rb
ceedling-0.21.0 lib/ceedling/makefile.rb
ceedling-0.20.3 lib/ceedling/makefile.rb
ceedling-0.20.2 lib/ceedling/makefile.rb
ceedling-0.19.0 lib/ceedling/makefile.rb
ceedling-0.18.0 lib/ceedling/makefile.rb
ceedling-0.17.0 lib/ceedling/makefile.rb
ceedling-0.16.0 lib/ceedling/makefile.rb
ceedling-0.15.6 lib/ceedling/makefile.rb
ceedling-0.15.5 lib/ceedling/makefile.rb
ceedling-0.15.4 lib/ceedling/makefile.rb