Class: ASRake::Compc

Inherits:
BaseCompiler show all
Includes:
Rake::DSL
Defined in:
lib/asrake/compc.rb

Instance Attribute Summary collapse

Attributes inherited from BaseExecutable

#output, #output_dir, #output_file

Instance Method Summary collapse

Methods inherited from BaseCompiler

#dynamically_link, #isAIR, #isAIR=, #statically_link, #statically_link_only_referenced_classes

Methods inherited from BaseExecutable

#output_is_dir?, #pathmap, #to_s, #to_str

Constructor Details

#initialize(swc_file) ⇒ Compc

Create a compc task for the provided swc



15
16
17
# File 'lib/asrake/compc.rb', line 15

def initialize(swc_file)
  super(swc_file, FlexSDK::compc)
end

Instance Attribute Details

#include_asdocObject

Returns the value of attribute include_asdoc.



10
11
12
# File 'lib/asrake/compc.rb', line 10

def include_asdoc
  @include_asdoc
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asrake/compc.rb', line 19

def execute
  super
  # include asdoc if needed

  if self.include_asdoc
    asdoc = ASRake::Asdoc.new File.join(self.output_dir, ".asrake_temp_#{Time.now.to_i}_#{rand(1000)}")
    asdoc.add(self)
    asdoc.keep_xml = true
    asdoc.skip_xsl = true
    asdoc.lenient = true
    puts "> #{FlexSDK::asdoc}"
    asdoc.execute {|line| puts ">    #{line}"}

    if output_is_dir?
      cp_r "#{asdoc.output}/tempdita", File.join(self.output_dir, "docs")
    else
      Zip::ZipFile.open(self.output) do |zipfile|
        # remove existing docs (eg, from -include-libraries linking a swc with pre-existing docs)

        begin
          zipfile.remove("docs")
        rescue
          #no rescue

        end
        FileList["#{asdoc.output}/tempdita/*"].each do |file|
          zipfile.add("docs/#{File.basename(file)}", file)
        end
      end
    end

    rm_rf asdoc.output, :verbose => false
  end
end

#generate_argsObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/asrake/compc.rb', line 51

def generate_args
  compc = super
  
  #compc << " -include-sources=#{Path::forward source_path.join(',')}" if !source_path.empty?

  self.source_path.each do |path|
    compc << " -include-classes #{ASRake::get_classes(path).join(' ')}"
  end

  return compc
end

#merge_in(args) ⇒ Object



62
63
64
65
# File 'lib/asrake/compc.rb', line 62

def merge_in(args)
  super
  self.include_asdoc = args.include_asdoc
end