Class: AsProject::MTASC

Inherits:
RemoteFileTask show all
Defined in:
lib/tasks/mtasc.rb

Direct Known Subclasses

HAMTASC

Instance Attribute Summary collapse

Attributes inherited from RemoteFileTask

#osx_extracted_file, #osx_mounted_path, #osx_url, #unix_extracted_file, #unix_url, #user_task, #win_extracted_file, #win_url

Instance Method Summary collapse

Methods inherited from RemoteFileTask

#clean_path, #define_user_task, #execute, #extracted_file_path, #user

Constructor Details

#initialize(name = :compile, do_not_define = false) ⇒ MTASC

Returns a new instance of MTASC.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tasks/mtasc.rb', line 29

def initialize(name=:compile, do_not_define=false)
  @compiler_version = '1.13'
  @options = []
  @cp = []
  @pack = []

  @user_task = nil
  @win_url = "http://www.mtasc.org/zip/mtasc-#{compiler_version}.zip"
  @win_extracted_file = "/mtasc-#{compiler_version}/mtasc.exe"
  @osx_url = "http://mtasc.org/zip/mtasc-1.12-osx.zip"
  @osx_extracted_file = "/mtasc-1.12-osx/mtasc"
  @unix_url = nil
  @unix_extracted_file = nil
  super(name, true)
  define unless do_not_define
end

Instance Attribute Details

#compiler_versionObject

Returns the value of attribute compiler_version.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def compiler_version
  @compiler_version
end

#cpObject

Returns the value of attribute cp.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def cp
  @cp
end

#excludeObject

Returns the value of attribute exclude.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def exclude
  @exclude
end

#frameObject

Returns the value of attribute frame.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def frame
  @frame
end

#groupObject

Returns the value of attribute group.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def group
  @group
end

#headerObject

Returns the value of attribute header.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def header
  @header
end

#inferObject

Returns the value of attribute infer.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def infer
  @infer
end

#inputObject

Returns the value of attribute input.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def input
  @input
end

#keepObject

Returns the value of attribute keep.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def keep
  @keep
end

#mainObject

Returns the value of attribute main.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def main
  @main
end

#msvcObject

Returns the value of attribute msvc.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def msvc
  @msvc
end

#mxObject

Returns the value of attribute mx.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def mx
  @mx
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def name
  @name
end

#outObject

Returns the value of attribute out.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def out
  @out
end

#packObject

Returns the value of attribute pack.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def pack
  @pack
end

#strictObject

Returns the value of attribute strict.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def strict
  @strict
end

#swfObject

Returns the value of attribute swf.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def swf
  @swf
end

#traceObject

Returns the value of attribute trace.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def trace
  @trace
end

#verboseObject

Returns the value of attribute verbose.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def verbose
  @verbose
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def version
  @version
end

#wimpObject

Returns the value of attribute wimp.



7
8
9
# File 'lib/tasks/mtasc.rb', line 7

def wimp
  @wimp
end

Instance Method Details

#add_path(path, list) ⇒ Object



99
100
101
102
103
104
105
106
107
108
# File 'lib/tasks/mtasc.rb', line 99

def add_path(path, list)
  as_files = FileList[path + '/**/**/*.as']
  file as_files
  file out => as_files
  xml_files = FileList[path + '/**/**/*.xml']
  file xml_files
  file out => xml_files
  
  list << clean_path(path)
end

#compile_task_descObject



50
51
52
# File 'lib/tasks/mtasc.rb', line 50

def compile_task_desc
  return "Compile #{name} using MTASC"
end

#defineObject

Create the tasks defined by this task lib.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/tasks/mtasc.rb', line 55

def define
  super
#      if(!swf && !header && pack_path.size == 0) 
#        raise MTASCError.new('MTASC task must be provided with an swf, a header argument, or at least one pack_path')
#      end
#      if(header && !swf && out)
#        raise MTASCError.new('It looks like you used the out parameter where you should have used the swf parameter')
#      end

  desc compile_task_desc
  task name => [out]
  CLEAN.add(out)

  if(swf)
    file swf
    task name => [swf]
  end
   
  @cleaned_class_paths = []
  cp.each do |path|
    add_path(path, @cleaned_class_paths)
  end
  
  file out do |f|
#        if(input && !File.exists?(input))
#          raise MTASCError.new('MTASC.input must be an existing file')
#        end

    user_task.execute(option_list.join(' '))
  end

  self
end

#option_listObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/tasks/mtasc.rb', line 110

def option_list
  result = @options.dup
  result << "-header" << header if header
  result << "-cp " + @cleaned_class_paths.join(" -cp ") if cp.size > 0
  result << "-exclude" << exclude if exclude
  result << "-frame" << frame if frame
  result << "-group" if group
  result << "-infer" if infer
  result << "-keep" if keep
  result << "-main" if main
  result << "-msvc" if msvc
  result << "-strict" if strict
  result << "-mx" if mx
  result << "-trace" << trace if trace
  result << "-v" if verbose
  result << "-version" << version if version
  result << "-wimp" if wimp
  result << "-pack " + pack.join(" -pack ") if pack.size > 0
  result << "-swf" << clean_path(swf) if swf
  result << "-out" << clean_path(out) if out
  result << clean_path(input) if input
  return result
end

#recurse_exclude_path(dir) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/tasks/mtasc.rb', line 89

def recurse_exclude_path(dir)
  paths = [dir]
  Dir[dir + '/*'].each do |f|
    if(File.directory?(f))
      paths << recurse_exclude_path(f)
    end
  end
  return paths
end

#remote_task_nameObject



46
47
48
# File 'lib/tasks/mtasc.rb', line 46

def remote_task_name
  return "mtasc-#{compiler_version}"
end