Sha256: d9e188db65ed5037cfefae43c62f8340c3a87c01ca0c05934ed9850c99a1507d

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 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)
      
      @options.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 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.unlink(output_folder) if File.symlink?(output_folder)
      
      if DEBUG_MODE==mode
        FileUtils.symlink(File.expand_path(source_folder), output_folder)
      else
        FileUtils.cp_r(File.expand_path(source_folder), output_folder)
      end
    end
    
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
distil-0.11.6 lib/distil/project/external-project.rb
distil-0.11.5 lib/distil/project/external-project.rb
distil-0.11.4 lib/distil/project/external-project.rb
distil-0.11.3 lib/distil/project/external-project.rb
distil-0.11.1 lib/distil/project/external-project.rb
distil-0.11.0 lib/distil/project/external-project.rb