Guest User

Untitled

a guest
Feb 21st, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. #
  3. # Build - compile ActionScript using MTASC
  4. #
  5. # Based on a command by Chris Sessions, Released on 2006-06-02.
  6. # Copyright (c) 2006. MIT License.
  7. # Modified by Ale Muñoz <ale@bomberstudios.com> on 2006-11-24.
  8. #
  9. # TODO: Documentation
  10. # TODO: Use -main only when it's in the config
  11.  
  12. require "open3"
  13. require "yaml"
  14.  
  15. require ENV['TM_SUPPORT_PATH'] + "/lib/exit_codes"
  16. require ENV['TM_SUPPORT_PATH'] + "/lib/progress"
  17.  
  18. def mtasc_compile
  19.  
  20. Dir.chdir(ENV['TM_PROJECT_DIRECTORY'])
  21. yml = YAML.load(File.open('mtasc.yaml'))
  22.  
  23. if !yml['mtasc_path']
  24. cmd = "\"#{ENV['TM_BUNDLE_SUPPORT']}/bin/mtasc\" "
  25. else
  26. cmd = "\"#{yml['mtasc_path']}\" "
  27. end
  28. cmd += " \"#{yml['app']}\" "
  29. cmd += " -version #{yml['player']} "
  30. cmd += " -cp \"#{ENV['TM_BUNDLE_SUPPORT']}/lib/std/\" "
  31. cmd += " -cp \"#{ENV['TM_BUNDLE_SUPPORT']}/lib/std8/\" "
  32. if yml['classpaths']
  33. cmd += " -cp \"#{yml['classpaths'].join('" -cp "')}\" "
  34. end
  35. if !File.exists? yml['swf']
  36. cmd += " -header #{yml['width']}:#{yml['height']}:#{yml['fps']} "
  37. else
  38. cmd += " -keep "
  39. end
  40. cmd += " -main "
  41. cmd += " -swf #{yml['swf']} "
  42.  
  43. puts "<h1>#{yml['app']} → #{yml['swf']} </h1>"
  44. puts "Command: <code style=\"color: #666;\">#{cmd}</code>"
  45.  
  46. stdin, stdout, stderr = Open3.popen3(cmd)
  47. warnings = []
  48. errors = []
  49.  
  50. while err = stderr.gets
  51. if err[0, 10] == 'Warning : '
  52. warnings.push(err.chomp)
  53. else
  54. m = /(.+):([0-9]+): characters ([0-9]+)/.match(err)
  55. if m != nil
  56. a = "txmt://open?url=file://#{m[1]}&line=#{m[2]}&column=#{m[3].to_i + 1}"
  57. err = "<a href=\"#{a}\">#{err}</a>"
  58. end
  59. errors.push(err.chomp)
  60. end
  61. end
  62.  
  63. if !errors.empty?
  64. puts '<h1>Errors:</h1>'
  65. puts "<p>#{errors.uniq.join('</p><p>')}</p>"
  66. end
  67.  
  68. if !warnings.empty?
  69. puts '<h1>Warnings:</h1>'
  70. puts "<p>#{warnings.uniq.join('</p><p>')}</p>"
  71. end
  72.  
  73. if errors.empty? && warnings.empty?
  74. #puts '<script type="text/javascript">self.close()</script>'
  75. `#{yml['after']}` if yml["after"]
  76. `open #{yml['preview']}` if yml["preview"]
  77.  
  78. else
  79. TextMate.exit_show_html
  80. end
  81.  
  82. end
  83.  
  84. if File.exist?("#{ENV['TM_PROJECT_DIRECTORY']}/mtasc.yaml")
  85. # compile with MTASC
  86. TextMate.call_with_progress({:title => "MTASC", :message => "Compiling Classes"}) do
  87. mtasc_compile
  88. end
  89.  
  90. else
  91. # compile with Flash IDE
  92. `echo "flash.getDocumentDOM().testMovie()" > /tmp/test.jsfl; open /tmp/test.jsfl;`
  93. puts '<script type="text/javascript">self.close()</script>'
  94. end
Add Comment
Please, Sign In to add comment