Class: PlayerSDK::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/playersdk/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Compiler

Returns a new instance of Compiler.



5
6
7
8
9
# File 'lib/playersdk/compiler.rb', line 5

def initialize(config)
   self.config = config.clone
   
   self.compiler = PlayerSDK::Compilers::Flex.new(self.config);
end

Instance Attribute Details

#compilerObject

Returns the value of attribute compiler.



3
4
5
# File 'lib/playersdk/compiler.rb', line 3

def compiler
  @compiler
end

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/playersdk/compiler.rb', line 3

def config
  @config
end

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/playersdk/compiler.rb', line 11

def process
    tasks = self.config['tasks']
    
    puts "Found #{tasks.length} task(s) to process"
    
    tasks.each do |key,value|
       self.run_task(key, value)
    end
    
    puts "\n\n"
    puts "Completed #{tasks.length} tasks(s)"
    
    if self.config['player_src'] != ''
        #self.compiler.compile_mxmlc(self.config['player_source'], 'src/Main.mxml', true, true, false, 'vj-player.swf', self.config['build_dir'])
    end
end

#run_task(key, value) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/playersdk/compiler.rb', line 28

def run_task(key, value)
   puts "Running task #{key} in #{value['src']}"
    
   case value['type']
       when "player"
           self.compiler.compile_mxmlc(value['src'], value['main'], value['sdk'], value['engine'], value['libs'], value['target'], self.config['build_dir'], self.config['deployment_url'])
       when "engine"
           self.compiler.compile_compc(value['src'], value['sdk'], value['engine'], value['libs'], value['target'], self.config['build_dir'], self.config['deployment_url'])
           
           puts "Optimizing engine swf .."
           
           self.compiler.optimize_swc(value['target'], self.config['build_dir'])
       when "addon"
           self.compiler.compile_mxmlc(value['src'], value['main'], value['sdk'], value['engine'], value['libs'], value['target'], self.config['build_dir'], self.config['deployment_url'])
       when "framework"
           puts "Moving Flex framework RSLs to #{config['build_dir']}"
           
           self.compiler.run_command("cp #{config['flex_sdk']}/frameworks/rsls/#{value['framework_rsl']}.swz #{config['build_dir']}/framework.swz")
           self.compiler.run_command("cp #{config['flex_sdk']}/frameworks/rsls/#{value['framework_rsl']}.swf #{config['build_dir']}/framework.swf")
       when "clean"
           puts "Cleaning directories ..."
           
           self.compiler.run_command("rm -rf #{config['build_dir']}/* #{config['tmp_dir']}/*")
       when ""
           puts "Unknown task type, skipping task ..\n"
           return
   end
   
   puts "\n"
   puts "Successfully compiled #{key} to target #{value['target']}.\n"      
end