Sha256: 28fd7f7adcf70dd3ef4ec354b05890f5acc84e90694b55abcbeb8f31a4f79a7c

Contents?: true

Size: 1.89 KB

Versions: 12

Compression:

Stored size: 1.89 KB

Contents

module Distil
  
  class ExternalProject < Project

    option :name, String
    option :repository
    option :build_command, String, :aliases=>['build']
    option :linkage, WEAK_LINKAGE, :valid_values=> [WEAK_LINKAGE, STRONG_LINKAGE, LAZY_LINKAGE]

    option :import_name, OutputPath, "$(name)-debug.$(extension)", :aliases=>['import']
    option :concatenated_name, OutputPath, "$(name)-uncompressed.$(extension)", :aliases=>['concatenated']
    option :debug_name, OutputPath, "$(name)-debug.$(extension)", :aliases=>['debug']
    option :minified_name, OutputPath, "$(name).$(extension)", :aliases=>['minified']
    option :compressed_name, OutputPath, "$(name).$(extension).gz", :aliases=>['compressed']
    
    def initialize(config, parent=nil)
      if !config.has_key?("source_folder")
        config["source_folder"]= "build/$(mode)"
      end
      super(config, parent)

      self.output_folder= File.join(parent.output_folder, name)
    end

    def product_name(product_type, extension)
      info= Struct.new(:extension).new(extension)
      name= self.send("#{product_type.to_s}_name")
      Interpolated.value_of(name, info)
    end
    
    def up_to_date
      build
      true
    end
    
    def build
      wd= Dir.getwd
      Dir.chdir(path)
      system build_command
      Dir.chdir(wd)
      
      # external projects aren't included in the output when weak linked,
      # they are just expected to be there, somehow. Like magic.
      return if WEAK_LINKAGE==linkage
          
      FileUtils.rm_r(output_folder) if File.directory?(output_folder)
      FileUtils.rm(output_folder) if File.symlink?(output_folder)
      
      if DEBUG_MODE==mode
        FileUtils.symlink(SourceFile.path_relative_to_folder(File.expand_path(source_folder), File.dirname(output_folder)), output_folder)
      else
        FileUtils.cp_r(File.expand_path(source_folder), output_folder)
      end
    end
    
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
distil-0.13.6 lib/distil/project/external-project.rb
distil-0.13.5 lib/distil/project/external-project.rb
distil-0.13.4 lib/distil/project/external-project.rb
distil-0.13.3 lib/distil/project/external-project.rb
distil-0.13.2 lib/distil/project/external-project.rb
distil-0.13.1 lib/distil/project/external-project.rb
distil-0.13.0 lib/distil/project/external-project.rb
distil-0.12.6 lib/distil/project/external-project.rb
distil-0.12.4 lib/distil/project/external-project.rb
distil-0.12.3 lib/distil/project/external-project.rb
distil-0.12.2 lib/distil/project/external-project.rb
distil-0.12.1 lib/distil/project/external-project.rb