Sha256: 5830503ca61397d3c8a2055d68dd916d4ab2a79e551c647f4db47b341a1ac53a

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

	
class Project < BuildTarget

	SHIP_FILE = "#{TARGET}-#{TARGET.VERSION.tag}"

	desc  "clean", "clean #{SHIP_FILE} products", :for => :clean
	desc  "make", "make #{SHIP_FILE} products", :for => :make
	desc  "build", "build #{SHIP_FILE} products", :for => :build

	desc  "ship", "create ship file #{SHIP_FILE}.zip file"
	method_option :config,  type: :array, aliases: '-c', default: '', desc: "use IDE config(s): Debug, Release, etc"
	def ship
		get_idevers.each do |idever|
			configs = [options[:config]].flatten
			configs.each do |cfg|
				build_ship(idever, cfg)
			end
		end
	end
	
protected

	def do_clean(idetag, cfg)
		ide = IDEServices.new(idetag, ROOT)
		ide.msbuild('Clean', cfg)
	end

	def do_make(idetag, cfg)
		ide = IDEServices.new(idetag, ROOT)
		ide.msbuild('Make', cfg)
	end

	def do_build(idetag, cfg)
		ide = IDEServices.new(idetag, ROOT)
		ide.msbuild('Build', cfg)
	end

private

	def get_idevers
		IDEServices.ideused
	end

	def build_ship(idever, config)
		cfg_segment = config.strip
		cfg_segment = "-#{cfg_segment}" unless cfg_segment.empty?
    
		zip_fname = ROOT + 'ship' + "#{SHIP_FILE}-#{idever}#{cfg_segment}.zip"
		zip_fname.dirname.mkpath
		zip_fname.delete if zip_fname.exist? 
		
		groups = [
			["output", ROOT + 'out' + idever + config, Pathname('.')],
			["source", ROOT + 'src', Pathname('src') + SHIP_FILE],
			["samples", ROOT + 'samples', Pathname('samples') + SHIP_FILE],
			["documentation", ROOT + 'doc', Pathname('doc') + SHIP_FILE]
		]
		puts "Ship file " + zip_fname.to_s
		Zip::ZipFile.open(zip_fname, Zip::ZipFile::CREATE) do |zipfile|
		  groups.each do |group|
				puts "Add #{group[0]} files"		
				Pathname.glob((group[1] + '**' + '*.*').to_s).each do |source_file|
					zip_entry = group[2] + source_file.relative_path_from(group[1])
					zipfile.get_output_stream(zip_entry) { |f| f.puts source_file.read(:mode => "rb") }
				end
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
delphivm-0.8.1 lib/dvm/project.thor
delphivm-0.8.0 lib/dvm/project.thor