hpeikemo-flexfarm 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ === 0.3.2 / 2009-29-7
2
+
3
+ * ffdebugger: Error output gets red text color.
4
+
5
+ === 0.3.1 / 2009-24-6
6
+
7
+ * Using join(" ") instead og Array#to_s.
8
+
9
+ === 0.3.0 / 2009-21-5
10
+
11
+ * Improved ffdebugger
12
+
13
+ === 0.2.2 / 2009-20-5
14
+
15
+ * Improved error handling in flexmate.
16
+ * generate_rakefile no longer halts vim.
17
+
18
+ === 0.2.1 / 2009-02-2
19
+
20
+ * Fixed bug in ffcompile where it would not find compiler-deamon.
21
+
22
+ === 0.2.0 / 2009-02-1
23
+
24
+ * Config and rakefile generator
25
+ * Renamed bin files; added ff-prefix.
26
+
27
+ === 0.1.2 / 2009-01-25
28
+
29
+ * Added support for previewing air apps by setting Project#air_descriptor.
30
+
31
+ === 0.1.1 / 2009-01-17
32
+
33
+ * Refactored to Flexfarm package.
34
+
35
+ === 0.1.0 / 2009-01-13
36
+
37
+ * First implementation of gem-package.
38
+
@@ -0,0 +1,18 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ rakefile.rb.example
6
+ bin/ffarm
7
+ bin/ffcompile
8
+ bin/ffdebugger
9
+ bin/fffcshd
10
+ lib/flexfarm.rb
11
+ lib/cliwrapper.rb
12
+ lib/fcsh.rb
13
+ lib/fdb.rb
14
+ lib/flashmate.rb
15
+ lib/flexfarm_config.rb
16
+ lib/flexrake.rb
17
+ lib/generator.rb
18
+ lib/default_config.rb
@@ -0,0 +1,42 @@
1
+ = flexfarm
2
+
3
+ http://hpeikemo.github.com/flexfarm/
4
+
5
+ == DESCRIPTION:
6
+
7
+ flexFarm is a set of tools to charge and improve ActionScript development.
8
+
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Compile as3 projects. Quickly.
13
+ * Debug as3 projects
14
+
15
+ == SYNOPSIS:
16
+
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * Adobe Flex 3 SDK
21
+
22
+ == INSTALL:
23
+
24
+ * sudo gem install ....
25
+
26
+ == LICENSE:
27
+
28
+ flexFarm is a set of tools to charge and improve ActionScript development.
29
+ Copyright (C) 2009 Hans Petter Eikemo
30
+
31
+ This program is free software: you can redistribute it and/or modify
32
+ it under the terms of the GNU General Public License as published by
33
+ the Free Software Foundation, either version 3 of the License, or
34
+ (at your option) any later version.
35
+
36
+ This program is distributed in the hope that it will be useful,
37
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
38
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39
+ GNU General Public License for more details.
40
+
41
+ You should have received a copy of the GNU General Public License
42
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,26 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/flexfarm.rb'
6
+
7
+ Hoe.plugin :git
8
+
9
+ Hoe.spec('flexfarm') do
10
+ developer('Hans Petter Eikemo', 'hpeikemo@me.com')
11
+ end
12
+
13
+ # vim: syntax=Ruby
14
+
15
+ begin
16
+ require 'jeweler'
17
+ Jeweler::Tasks.new do |gem|
18
+ gem.name = "flexfarm"
19
+ gem.summary = "flexFarm is a set of tools to charge and improve ActionScript development."
20
+ gem.email = "hpeikemo@me.com"
21
+ gem.homepage = "http://github.com/hpeikemo/flexfarm"
22
+ gem.authors = ["Hans Petter Eikemo"]
23
+ end
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
26
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.2
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
4
+ $:<<File.dirname(__FILE__)
5
+ @command = ARGV.shift
6
+ bin_name = File.basename(__FILE__)
7
+
8
+ unless @command
9
+ puts "Type '#{bin_name} help' for usage."
10
+ exit 1
11
+ end
12
+
13
+ def edit(file)
14
+ `#{ENV["EDITOR"] || "vim"} #{file}`
15
+ end
16
+
17
+
18
+ case @command
19
+ when "config"
20
+ require "generator.rb"
21
+ edit(Flexfarm::create_userconfig)
22
+ when "generate_rakefile"
23
+ require "generator.rb"
24
+ Flexfarm::create_rakefile
25
+ when "compile"
26
+ load "ffcompile"
27
+ when "fcshd"
28
+ load "fffcshd"
29
+ when "debugger"
30
+ load "ffdebugger"
31
+ when "help"
32
+ puts "#{bin_name} compile [compiler args...]","#{bin_name} fcshd","#{bin_name} debugger","#{bin_name} config","#{bin_name} generate_rakefile"
33
+ else
34
+ puts "Unknown flexfarm command '#{@command}'. Type '#{bin_name} help' for usage."
35
+ exit 1
36
+ end
37
+
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path("#{File.dirname(__FILE__)}/../lib")
4
+
5
+
6
+ require "flexfarm_config.rb"
7
+ require "socket"
8
+
9
+ include Flexfarm
10
+
11
+
12
+ SERVER_SCRIPT = File.dirname(__FILE__)+"/fffcshd"
13
+ COMPILE_ARGS = ARGV.join(" ")
14
+
15
+ errors = []
16
+ compileErrors = []
17
+ completed = false
18
+
19
+ connection = TCPSocket.new("127.0.0.1", COMPILER_PORT) rescue nil
20
+ if !connection
21
+ if File.exist? SERVER_SCRIPT
22
+ verbose_puts("Compiler deamon not running, attempting to start...")
23
+ system("#{SERVER_SCRIPT} 1>/dev/null 2>/dev/null &")
24
+ sleep 0.5
25
+ connection = TCPSocket.new("127.0.0.1", COMPILER_PORT)
26
+ else
27
+ verbose_puts("Compiler deamon not running",1)
28
+ errors.push("Compiler deamon not running")
29
+ end
30
+ end
31
+
32
+ hello = connection.gets.chomp rescue nil
33
+
34
+ if hello == "[connected]"
35
+ connection.puts COMPILE_ARGS
36
+ while !connection.closed? && (line = connection.gets)
37
+ if line =~ /^\[done\]/
38
+ verbose_puts("Operation complete.",1)
39
+ completed = true
40
+ elsif line =~ /^\[compileError\](.*)$/
41
+ compileErrors.push( $1 )
42
+ elsif line =~ /^\[error\](.*)$/
43
+ compileErrors.push( $1 )
44
+ else
45
+ puts color("Output: ",36)+ line
46
+ end
47
+ end
48
+ verbose_puts("Disconnected",1)
49
+ end
50
+
51
+ if (completed && compileErrors.empty?)
52
+ puts "[SUCCESS]"
53
+ else
54
+ puts "[FAIL]"
55
+ (errors+compileErrors).each do |error|
56
+ STDERR.puts error
57
+ end
58
+ exit 1
59
+ end
60
+
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ $: << File.expand_path("#{File.dirname(__FILE__)}/../lib")
5
+
6
+ require "flexfarm_config.rb"
7
+ require "fdb.rb"
8
+ require "readline"
9
+
10
+ include Flexfarm
11
+
12
+ puts "\tStarting Flash debugger.","\tWaiting for connections."
13
+
14
+ begin
15
+ fdb = FDB.new(FDB_BIN)
16
+ while fdb.running?
17
+ sleep 0.1
18
+
19
+ keyboard_input = FDB::getLines(STDIN).to_a
20
+
21
+ fdb.getErrors do |line|
22
+ puts color("Error: ",31)+line
23
+ end
24
+ fdb.getOutput do |line|
25
+ debugger_output(line) unless [FDB::WAITING_MODE,FDB::IDLE_MODE].include? fdb.mode
26
+ end
27
+ if fdb.available
28
+ fdb.dispatch("run") if fdb.mode == FDB::IDLE_MODE
29
+ fdb.dispatch("continue") if fdb.mode == FDB::RUNNING_MODE
30
+ if fdb.mode == FDB::BREAK_MODE
31
+ begin
32
+ input = Readline::readline( color("input: ",31) )
33
+ Readline::HISTORY.push(input)
34
+ end while input !~ /\w/
35
+ fdb.dispatch( input )
36
+ end
37
+ elsif keyboard_input.last == "\n"
38
+ fdb.break
39
+ end
40
+ end
41
+ rescue Exception => e
42
+ if e.class == Interrupt
43
+ puts "","Caught interupt signal.."
44
+ else
45
+ puts color("Unhandled exception: ",31)+e.inspect
46
+ end
47
+ ensure
48
+ fdb.cleanup
49
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.expand_path("#{File.dirname(__FILE__)}/../lib")
4
+
5
+ require "flexfarm_config.rb"
6
+ require "fcsh.rb"
7
+ require "socket"
8
+
9
+ include Flexfarm
10
+
11
+
12
+ begin
13
+ fcsh = FCSH.new(FCSH_BIN)
14
+ server = TCPServer.new("127.0.0.1", COMPILER_PORT)
15
+ while fcsh.running? && !fcsh.available
16
+ sleep 0.2
17
+ fcsh.getOutput do |line|
18
+ debugger_output(line)
19
+ end
20
+ end
21
+
22
+ fcsh.mode = FCSH::IDLE_MODE
23
+ puts "Accepting connections."
24
+
25
+ while fcsh.running? && (connection = server.accept)
26
+ verbose_puts("Got connection",1)
27
+ connection.puts "[connected]"
28
+
29
+ queue = []
30
+
31
+ until connection.closed?
32
+ sleep 0.01
33
+ queue.push( *FCSH::getLines(connection).to_a )
34
+
35
+ fcsh.getErrors do |line|
36
+ puts color("Error: ",31)+line
37
+ if line =~ /.+\(\d+\)\: col\: /
38
+ connection.puts "[compileError]#{line}"
39
+ elsif line =~ /Error\:/
40
+ connection.puts "[error]#{line}"
41
+ end
42
+ end
43
+ fcsh.getOutput do |line|
44
+ debugger_output(line)
45
+ connection.puts line
46
+ end
47
+ if fcsh.available
48
+ if !queue.empty?
49
+ input = queue.shift
50
+ connection.close if input == "\r\n"
51
+
52
+ if input =~ /^(mxmlc|compc )/
53
+ fcsh.compile( input.chomp )
54
+ elsif input =~ /^q/
55
+ fcsh.dispatch("quit")
56
+ exit 0
57
+ end
58
+ else
59
+ connection.puts "[done]"
60
+ connection.close
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ rescue Exception => e
67
+ if e.class == Interrupt
68
+ puts "","Caught interupt signal.."
69
+ else
70
+ puts color("Unhandled exception: ",31)+e.inspect
71
+ end
72
+ ensure
73
+ fcsh.cleanup
74
+ end
@@ -0,0 +1,53 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{flexfarm}
5
+ s.version = "0.3.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Hans Petter Eikemo"]
9
+ s.date = %q{2009-07-05}
10
+ s.email = %q{hpeikemo@me.com}
11
+ s.executables = ["ffarm", "ffcompile", "ffdebugger", "fffcshd"]
12
+ s.extra_rdoc_files = [
13
+ "README.txt"
14
+ ]
15
+ s.files = [
16
+ "History.txt",
17
+ "Manifest.txt",
18
+ "README.txt",
19
+ "Rakefile",
20
+ "VERSION",
21
+ "bin/ffarm",
22
+ "bin/ffcompile",
23
+ "bin/ffdebugger",
24
+ "bin/fffcshd",
25
+ "flexfarm.gemspec",
26
+ "lib/cliwrapper.rb",
27
+ "lib/default_config.rb",
28
+ "lib/fcsh.rb",
29
+ "lib/fdb.rb",
30
+ "lib/flashmate.rb",
31
+ "lib/flexfarm.rb",
32
+ "lib/flexfarm_config.rb",
33
+ "lib/flexrake.rb",
34
+ "lib/generator.rb",
35
+ "rakefile.rb.example"
36
+ ]
37
+ s.has_rdoc = true
38
+ s.homepage = %q{http://github.com/hpeikemo/flexfarm}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.1}
42
+ s.summary = %q{flexFarm is a set of tools to charge and improve ActionScript development.}
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 2
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
@@ -0,0 +1,66 @@
1
+ require "open3"
2
+ require 'readline'
3
+
4
+ module Flexfarm
5
+
6
+
7
+ class CliWrapper
8
+
9
+ attr_reader :mode
10
+ attr_reader :available
11
+
12
+ CLEANUP_MODE = :cleanup
13
+
14
+ def initialize(executable_path)
15
+ @stdin, @stdout, @stderr = Open3.popen3(executable_path)
16
+ @running = true
17
+ @available = false
18
+ end
19
+
20
+ def cleanup
21
+ return unless @running
22
+ self.mode = CLEANUP_MODE
23
+ verbose_puts("Quiting #{self.class}",1)
24
+ @running = false
25
+ @stdin.close unless @stdin.closed?
26
+ @stdout.close unless @stdout.closed?
27
+ @stderr.close unless @stderr.closed?
28
+ end
29
+
30
+ def running?
31
+ @running && @stdin.syswrite(nil)==0 rescue false
32
+ end
33
+
34
+ def getErrors
35
+ CliWrapper::getLines(@stderr).each {|line| yield(line) }
36
+ end
37
+
38
+ def getOutput
39
+ CliWrapper::getLines(@stdout).each {|line| yield(line) }
40
+ end
41
+
42
+ def dispatch(command="")
43
+ if available && !command.empty?
44
+ verbose_puts("[command: #{command}] ",2)
45
+ @stdin.puts command
46
+ @available = false
47
+ else
48
+ verbose_puts("[blocked command: #{command}] ",2)
49
+ end
50
+ end
51
+
52
+ def mode= (value)
53
+ if (@mode != value)
54
+ @mode=value
55
+ verbose_puts("[Mode is #{@mode}]",2)
56
+ end
57
+ end
58
+
59
+ def self.getLines(io)
60
+ buffer = ""
61
+ buffer += io.read_nonblock(1024) while true rescue buffer.to_a
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,18 @@
1
+ module Flexfarm
2
+
3
+ # Note that mxmlc do not handle (even escaped) spaces in any path.
4
+ # (symlink to resolve related issues)
5
+
6
+ FLEX_HOME = "/usr/share/flex/sdks/3.2.0"
7
+ FDB_BIN = "#{FLEX_HOME}/bin/fdb"
8
+ FCSH_BIN = "#{FLEX_HOME}/bin/fcsh"
9
+ ADL_BIN = "#{FLEX_HOME}/bin/adl"
10
+ ADT_BIN = "#{FLEX_HOME}/bin/adt"
11
+
12
+ ADL_RUNTIME = "#{FLEX_HOME}/runtimes/air/mac"
13
+ FLEX_COMPILER = "ffcompile"
14
+
15
+ COMPILER_PORT = 4200
16
+ $verbose_level = 1
17
+
18
+ end
@@ -0,0 +1,65 @@
1
+ require "cliwrapper.rb"
2
+
3
+ module Flexfarm
4
+
5
+
6
+ class FCSH < CliWrapper
7
+
8
+ MAX_TARGETS = 15
9
+
10
+ SILENT = /^\(fcsh\) /
11
+ INPUT_PROMPT = /^\(fcsh\) /
12
+ ASSIGNED_TARGET = /Assigned (\d+) as the compile target id/
13
+
14
+ INIT_MODE = :init
15
+ IDLE_MODE = :idle
16
+ COMPILE_MODE = :compile
17
+
18
+ def initialize(*args)
19
+ super(*args)
20
+ self.mode = INIT_MODE
21
+ @currentCommand = nil
22
+ clean_targets
23
+ end
24
+
25
+ def getOutput
26
+ lines = FCSH::getLines(@stdout)
27
+ lines.each do |line|
28
+ yield(line) unless line =~ SILENT
29
+ if line =~ ASSIGNED_TARGET
30
+ target = $1.to_i
31
+ @compileTargets[@currentCommand] = $1
32
+ end
33
+ end
34
+ if lines.last && lines.last =~ INPUT_PROMPT
35
+ @available = true
36
+ clean_targets if @compileTargets.length > MAX_TARGETS
37
+ end
38
+ self.mode = IDLE_MODE if available && self.mode == COMPILE_MODE
39
+ end
40
+
41
+ def compile(command)
42
+ self.mode = COMPILE_MODE
43
+ @currentCommand = command
44
+ target = @compileTargets[@currentCommand]
45
+ if target
46
+ dispatch("compile #{target}")
47
+ else
48
+ dispatch(command)
49
+ end
50
+ end
51
+
52
+ private
53
+ def clean_targets
54
+ if @compileTargets
55
+ verbose_puts("Too many targets (#{@compileTargets.length}), cleaning up..")
56
+ dispatch( "clear" )
57
+ end
58
+ @compileTargets = {}
59
+ end
60
+
61
+
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,60 @@
1
+ require "cliwrapper.rb"
2
+
3
+ module Flexfarm
4
+
5
+
6
+ class FDB < CliWrapper
7
+
8
+ SILENT = /^\(fdb\) |Do you want to attempt to halt execution|To help out, try nudging the Player/
9
+ INPUT_PROMPT = /^\(fdb\) |\(y or n\)/
10
+ WAITING_FOR_PLAYER = /Waiting for Player to connect/
11
+ ALREADY_IN_USE = /Another Flash debugger is probably running/
12
+ FAILED_TO_CONNECT = /Failed to connect\; session timed out/
13
+ SESSION_STARTED = /Player connected\; session starting/
14
+ SESSION_TERMINATED = /Player session terminated/
15
+ NOT_CONFIRMED = /Not confirmed/
16
+ EXECUTION_HALTED = /^(Execution halted|Fault)/
17
+
18
+ IDLE_MODE = :idle # Not waiting for anything, debugger just started or session just ended.
19
+ WAITING_MODE = :waiting # Waiting for player to connect
20
+ STARTING_MODE = :starting # Player connected; session starting.
21
+ RUNNING_MODE = :running # Session running.
22
+ BREAK_MODE = :break # Enter debugger. Interactive mode.
23
+
24
+ def initialize(*args)
25
+ super(*args)
26
+ self.mode = IDLE_MODE
27
+ end
28
+
29
+ def getOutput
30
+ lines = FDB::getLines(@stdout)
31
+ lines.each do |line|
32
+ yield(line) unless line =~ SILENT
33
+ self.mode = WAITING_MODE if line =~ WAITING_FOR_PLAYER
34
+ self.mode = IDLE_MODE if line =~ FAILED_TO_CONNECT || line =~ SESSION_TERMINATED
35
+ self.mode = BREAK_MODE if line =~ EXECUTION_HALTED
36
+ init_session if line =~ SESSION_STARTED
37
+ return cleanup if line =~ ALREADY_IN_USE
38
+ end
39
+
40
+ if lines.last && lines.last =~ INPUT_PROMPT
41
+ @available = true
42
+ else
43
+ # self.mode = RUNNING_MODE
44
+ @available = false
45
+ end
46
+ end
47
+
48
+ def break
49
+ @stdin.puts("","y") #if self.mode == RUNNING_MODE
50
+ end
51
+
52
+ private
53
+
54
+ def init_session
55
+ self.mode = RUNNING_MODE
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,89 @@
1
+ module FlexMate
2
+
3
+ ERROR_REGEX = /(\/.*?)(?:(\(([0-9]+)\)|): col: (\d+)|:).*(Error|Warning):\s*(.*)$/
4
+ GENERIC_ERROR_REGEX = /Error/
5
+
6
+
7
+
8
+ def self.execute_build
9
+ require "open3"
10
+ @project_path = ENV['TM_PROJECT_DIRECTORY']
11
+ @build_command = "rake"
12
+
13
+
14
+
15
+ @stdin, @stdout, @stderr = Open3.popen3(@build_command)
16
+ compileErrors = []
17
+ genericErrors = []
18
+ while out = @stderr.gets
19
+ # puts out
20
+ m = ERROR_REGEX.match( out )
21
+ m2 = GENERIC_ERROR_REGEX.match( out )
22
+
23
+ if m
24
+ compileErrors << {
25
+ "message" => m[6],
26
+ "filepath" => m[1],
27
+ "file" => File.basename(m[1]),
28
+ "line" => m[3] || "1",
29
+ "column" => m[4] || "0"
30
+ }
31
+ elsif m2
32
+
33
+ compileErrors << {
34
+ "message" => out
35
+ }
36
+ end
37
+
38
+ end
39
+ # while out = @stdout.gets
40
+ # puts out
41
+ # end
42
+
43
+ return compileErrors
44
+ end
45
+
46
+ def self.compile_project()
47
+ return unless ENV["TM_SUPPORT_PATH"]
48
+
49
+ tm_path = ENV["TM_SUPPORT_PATH"] || ""
50
+ require tm_path+"/lib/textmate.rb"
51
+ require tm_path+"/lib/exit_codes"
52
+ require tm_path+"/lib/progress"
53
+ require tm_path+"/lib/web_preview"
54
+
55
+
56
+ TextMate.call_with_progress({
57
+ :title => "Rake",
58
+ :summary => 'Starting Up...',
59
+ :indeterminate => false,
60
+ # :cancel => lambda { puts "Canceled compile!"; Process.kill('SIGUSR1') }
61
+ }) do |dialog|
62
+
63
+ dialog.parameters = {'summary' => 'Compiling','progressValue' => 10 }
64
+ @errors = execute_build
65
+ # sleep(10)
66
+ dialog.parameters = {'summary' => 'Compile complete','progressValue' => 100 }
67
+
68
+
69
+ end
70
+
71
+
72
+
73
+ if @errors && @errors.length > 0
74
+ #maxchars = @errors.map{ |c| c["file"].to_s.length }.max
75
+ @errors.each { |choice|
76
+ if (choice["file"])
77
+ choice["title"] = choice["file"] + ":" +choice["line"] + " "+ choice["message"]
78
+ else
79
+ choice["title"] = choice["message"]
80
+ end
81
+ }
82
+ choice = TextMate::UI.menu(@errors[0..9])
83
+ if choice && choice["filepath"]
84
+ TextMate.go_to :file => choice["filepath"] , :line => choice["line"], :column => choice["column"]
85
+ end
86
+ end
87
+ end
88
+
89
+ end
@@ -0,0 +1,10 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+ require "flexrake.rb"
3
+ require "flashmate.rb"
4
+
5
+
6
+ module Flexfarm
7
+ VERSION = '0.3.2'
8
+
9
+
10
+ end
@@ -0,0 +1,51 @@
1
+ module Flexfarm
2
+
3
+ CONFIG_FILES = [File.expand_path("#{File.dirname(__FILE__)}/default_config.rb"),"/etc/ffarm.conf.rb",File.expand_path("~/.ffarm.conf.rb")]
4
+ CONFIG_FILES.reverse.each do |file|
5
+ if File.exists?(file)
6
+ require file
7
+ break
8
+ end
9
+ end
10
+
11
+ def heading( msg, padding=1 )
12
+ style = [47,30]
13
+ heading = "--#{" "*padding}#{msg}#{" "*padding}--"
14
+ return "",color("="*(heading.length),*style),color(heading,*style),color("-"*(heading.length),*style)
15
+ end
16
+
17
+
18
+ def color(input,*args)
19
+ return input if args.length==0 || ENV["TERM"] !~ /color/
20
+ "\e[#{args.join(";")}m#{input}\e[0m"
21
+ end
22
+
23
+ COLOR_MODES = [[30,42],[33],[33]]
24
+ def verbose_puts(str,mode=0)
25
+ puts color(str,*COLOR_MODES[mode]) if $verbose_level >= mode
26
+ end
27
+
28
+ def debugger_output(line)
29
+ if m = line.match(/^(\[[^\]]+\])\s?(.+)/)
30
+ printContext = true
31
+ argsMessage = [0]
32
+ args = [33]
33
+ if (m[1]=="[Fault]")
34
+ args = [32,41]
35
+ argsMessage = [31]
36
+ end
37
+ if (m[1]=="[trace]")
38
+ printContext = false
39
+ argsMessage = [32]
40
+ end
41
+ if m[2].match(/^Error/)
42
+ argsMessage = [31]
43
+ end
44
+
45
+ puts (printContext ? color(m[1],*args)+" " : "")+color(m[2],*argsMessage)
46
+ else
47
+ puts color(line.chomp)
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,341 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+ require "flexfarm_config.rb"
3
+ require 'rake'
4
+
5
+ module Flexfarm
6
+ module Rake
7
+
8
+ module Tasks
9
+ start_time = Time.new
10
+ task :benchmark do
11
+ puts "Rake completed in %.2f seconds." % (Time.new-start_time)
12
+ end
13
+
14
+ task :default => :debug
15
+
16
+ desc "Compile for debugging and preview project"
17
+ task :debug => [:compileDebug,:copyAssetsDebug,:preview,:benchmark]
18
+
19
+ desc "Compile project for release"
20
+ task :release => [:clean,:compileRelease,:copyAssetsRelease,:benchmark]
21
+
22
+ desc "Output project settings."
23
+ task :info do
24
+ Flexfarm::Rake::each_project do |project|
25
+ puts heading("Project info for #{project.name}",35),"",project.info
26
+ end
27
+ end
28
+
29
+ namespace :info do
30
+
31
+ desc "Output project assets"
32
+ task :assets do
33
+ Flexfarm::Rake::each_project do |project|
34
+ puts "## #{project.name} (#{project.expand_path(project.basedir)})"
35
+ project.assets.each { |source_dir|
36
+ puts source_dir.collect {|file| "\t#{file}" }
37
+ }
38
+ end
39
+ end
40
+
41
+ namespace :command do
42
+
43
+ desc "Output compiler-command for debug-build"
44
+ task :debug do
45
+ Flexfarm::Rake::each_project do |project|
46
+ project[:debug] = true
47
+ project[:optimize] = false
48
+ project.define["CONFIG::debug"] = true
49
+ project.targets { |target|
50
+ puts "","## #{project.name}, #{target.main_src} => #{target.output_file}",target.compile_to(project.debug_dir),""
51
+ }
52
+
53
+ end
54
+ end
55
+
56
+ desc "Output compiler-command for release-build"
57
+ task :release do
58
+ Flexfarm::Rake::each_project do |project|
59
+ project[:debug] = false
60
+ project[:optimize] = true
61
+ project.define["CONFIG::debug"] = false
62
+ project.targets { |target|
63
+ puts "","## #{project.name}, #{target.main_src} => #{target.output_file}",target.compile_to(project.debug_dir),""
64
+ }
65
+
66
+ end
67
+ end
68
+
69
+
70
+ end
71
+ end
72
+
73
+ desc "Previews project by opening preview file. Requires project to be compiled for debugging."
74
+ task :preview do
75
+ project = Flexfarm::Rake::each_project.last
76
+ if project
77
+ if project.air_descriptor
78
+ system("#{Flexfarm::ADL_BIN} -runtime #{Flexfarm::ADL_RUNTIME} #{project.expand_path("#{project.debug_dir}/#{project.air_descriptor}",true)} #{project.expand_path(project.debug_dir)} &")
79
+ else
80
+ system("open", project.expand_path("#{project.debug_dir}/#{project.preview_file}",true) )
81
+ end
82
+ end
83
+ end
84
+
85
+ desc "Compile project for debugging."
86
+ task :compileDebug do
87
+ Flexfarm::Rake::each_project do |project|
88
+ project[:debug] = true
89
+ project[:optimize] = false
90
+ project.define["CONFIG::debug"] = true
91
+ project.compile_to(project.debug_dir)
92
+ sleep 0.05
93
+ end
94
+ end
95
+
96
+ desc "Compile project for release."
97
+ task :compileRelease do
98
+ Flexfarm::Rake::each_project do |project|
99
+ project[:debug] = false
100
+ project[:optimize] = true
101
+ project.define["CONFIG::debug"] = false
102
+ project.compile_to(project.release_dir)
103
+ sleep 0.05
104
+ end
105
+ end
106
+
107
+ desc "Package air application."
108
+ task :package => [:compileRelease] do
109
+ puts "Not implemented"
110
+ project = Flexfarm::Rake::each_project.last
111
+ if project && project.air_descriptor
112
+ app_file = "app.air"
113
+ password = ""
114
+ certificate = ""
115
+ system("#{Flexfarm::ADT_BIN} -package -storetype pkcs12 -storepass #{password} -keystore #{certificate} -keypass #{password} #{app_file} bin-release/Application-app.xml -C #{project.expand_path(project.release_dir)} .")
116
+
117
+ end
118
+ end
119
+
120
+ desc "Copy all assets to debug-dir."
121
+ task :copyAssetsDebug do
122
+ Flexfarm::Rake::each_project do |project|
123
+ project.assets.each {|a| a.copy_to(project.debug_dir) }
124
+ end
125
+ end
126
+
127
+ desc "Copy all assets to release-dir."
128
+ task :copyAssetsRelease do
129
+ Flexfarm::Rake::each_project do |project|
130
+ project.assets.each {|a| a.copy_to(project.release_dir) }
131
+ end
132
+ end
133
+
134
+ desc "Remove release-dir and debug-dir."
135
+ task :clean do
136
+ Flexfarm::Rake::each_project do |project|
137
+ time = Time.new.to_i
138
+ [project.debug_dir,project.release_dir].each do |dir|
139
+ path = project.expand_path(dir)
140
+ FileUtils.mv(path,"/tmp/deleted_#{project.name}_#{File.basename(dir)}_#{time}") if File.exist? path
141
+ end
142
+ end
143
+ end
144
+ end
145
+
146
+
147
+ @defined_projects = []
148
+ def self.each_project(&block)
149
+ projects = @defined_projects.reverse
150
+ projects.each(&block) if block_given?
151
+ projects
152
+ end
153
+ def self.define_project(&block)
154
+ @defined_projects.push(Project.new(&block))
155
+ end
156
+
157
+ MXMLC_DEFAULT_ARGS = {
158
+ :defaultSize => [800,600],
159
+ :defaultFrameRate => 25,
160
+ :defaultBackgroundColor => "0x9CCA43",
161
+ :defaultScriptLimits => [15000,60],
162
+ :strict => true,
163
+ :benchmark => true
164
+ }
165
+
166
+ class Project
167
+
168
+ attr_accessor :basedir, :release_dir, :debug_dir, :doc_dir, :air_descriptor
169
+ attr_reader :assets, :libs, :srcs, :args, :define
170
+
171
+ def initialize
172
+ @basedir = "."
173
+ @release_dir = "bin-release"
174
+ @debug_dir = "bin-debug"
175
+ @doc_dir = "doc"
176
+ @targets = []
177
+ @assets = []
178
+ @libs = []
179
+ @srcs = []
180
+ @args = MXMLC_DEFAULT_ARGS
181
+ @define = {}
182
+ yield(self) if block_given?
183
+ end
184
+
185
+ def compile_to(dir)
186
+ targets do |target|
187
+ success = system(FLEX_COMPILER,target.compile_to(dir));
188
+ raise "Compile error." unless success
189
+ end
190
+ end
191
+
192
+ def name
193
+ File.basename(expand_path(@basedir))
194
+ end
195
+
196
+ def info
197
+ spacer = " "*14
198
+
199
+ [ color("Basedir : ",33)+expand_path(@basedir),
200
+ color("Release-dir : ",33)+@release_dir,
201
+ color("Debug-dir : ",33)+@debug_dir,
202
+ color("Doc-dir : ",33)+@doc_dir,
203
+ color("Source-dirs :",33),
204
+ @srcs.map { |l| spacer+l },
205
+ color("Libraries :",33),
206
+ @libs.map { |l| spacer+l },
207
+ color("Arguments :",33),
208
+ @args.map{|k,v| spacer+"-#{k}=#{v}" },
209
+ @define.map{|k,v| "-define=#{k},#{v}" },
210
+ color("Assets :",33),
211
+ @assets.map { |a| spacer+a.to_s },
212
+ color("Targets :",33),
213
+ @targets.map { |t| spacer+"#{t.main_src} => #{t.output_file}" },
214
+ color("Preview : ",33)+preview_file
215
+ ]
216
+ end
217
+
218
+
219
+ def []=(k,v)
220
+ @args[k] = v
221
+ end
222
+ def [](k)
223
+ @args[k]
224
+ end
225
+
226
+ def preview_file=(str)
227
+ @preview = str
228
+ end
229
+
230
+ def preview_file()
231
+ @preview || targets.last.output_file rescue nil
232
+ end
233
+
234
+ def add_target(output_file,main_src)
235
+ target = Target.new(self)
236
+ target.output_file = output_file
237
+ target.main_src = main_src
238
+ @targets << target
239
+ end
240
+
241
+ def targets(&block)
242
+ tgts = @targets.reverse
243
+ tgts.each(&block) if block_given?
244
+ tgts
245
+ end
246
+
247
+ def expand_path(path,ensure_existence=false)
248
+ path = File.expand_path(path,@basedir)
249
+ raise Exception.new("#{path} was not found") if ensure_existence && !File.exists?(path)
250
+ raise Exception.new("compiler does not support paths with whitespace (#{path})") if path =~ /\s/
251
+ return path
252
+ end
253
+
254
+ end
255
+
256
+ class Target
257
+
258
+ attr_accessor :output_file
259
+ attr_accessor :main_src
260
+
261
+ def initialize(project)
262
+ @project = project
263
+ end
264
+
265
+ def compile_to(dir)
266
+ cmd = ["mxmlc"]
267
+ cmd.push *@project.args.map{|k,v| "-#{transformArgumentKey(k)}=#{transformArgumentValue(v)}" }
268
+ cmd.push *@project.define.map{|k,v| "-define=#{transformArgumentKey(k)},#{transformArgumentValue(v)}" }
269
+ cmd.push "-sp", *@project.srcs.map{|p| @project.expand_path(p,true) }
270
+ cmd.push "-l", *@project.libs.map{|p| @project.expand_path(p,true) }
271
+ cmd.push "-o", @project.expand_path("#{dir}/#{output_file}")
272
+ cmd.push "--", @project.expand_path(main_src,true)
273
+ cmd.join(" ")
274
+ end
275
+
276
+
277
+ private
278
+
279
+ def transformArgumentKey(key)
280
+ if key.class == Symbol
281
+ key.to_s.gsub(/[A-Z]/,'-\0').downcase
282
+ else
283
+ key
284
+ end
285
+ end
286
+ def transformArgumentValue(value)
287
+ if value.respond_to? :join
288
+ value.join(",")
289
+ else
290
+ value.to_s
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+ class SourceDir < FileList
297
+ TO_S_ITEMS = 3
298
+
299
+ attr_reader :root_dir
300
+
301
+ def initialize(rootDir,&block)
302
+ @root_dir = rootDir
303
+ @root_dir.taint
304
+ super(&block)
305
+ end
306
+
307
+ def resolve_add(fn)
308
+ super(@root_dir+"/"+fn)
309
+ end
310
+
311
+ def to_s()
312
+ existing = collect.select { |item| File.exist?(item) }
313
+ files = existing.select { |item| File.file? item }
314
+ dirs = existing.select { |item| File.directory? item }
315
+ combined = (files+dirs)
316
+ combined[0...TO_S_ITEMS].join(", ")+ (combined.length > TO_S_ITEMS ? "..." : "") +" (#{files.length} files, #{dirs.length} dirs)"
317
+ end
318
+
319
+ def copy_to(targetdir)
320
+ targetdir = File.expand_path(targetdir)
321
+ basedir = File.expand_path(@root_dir)
322
+ each do |source|
323
+ target = File.expand_path(source).gsub(basedir,targetdir)
324
+ copy_item(source,target)
325
+ end
326
+ end
327
+
328
+ private
329
+ def copy_item(source,target)
330
+ if File.directory?(source) && !File.exist?(target)
331
+ FileUtils.mkdir_p( target )
332
+ elsif File.file? source
333
+ FileUtils.rm(target) if File.exist?(target) && File.mtime(source) != File.mtime(target)
334
+ FileUtils.copy_file(source,target, :preserve => true) unless File.exist? target
335
+ end
336
+ end
337
+
338
+ end
339
+
340
+ end
341
+ end
@@ -0,0 +1,24 @@
1
+ require 'fileutils'
2
+
3
+ module Flexfarm
4
+
5
+ def self.create_userconfig
6
+ require "flexfarm_config"
7
+ FileUtils.copy(CONFIG_FILES.first,CONFIG_FILES.last) if !File.exist? CONFIG_FILES.last
8
+ return File.expand_path(CONFIG_FILES.last)
9
+ end
10
+
11
+ def self.create_rakefile
12
+ target_file = "./rakefile.rb"
13
+ if File.exist? target_file
14
+ puts "Rakefile already exist. #{target_file}"
15
+ else
16
+ source_file = "#{File.dirname(__FILE__)}/../rakefile.rb.example"
17
+ FileUtils.copy(source_file,target_file)
18
+ end
19
+ return File.expand_path(target_file)
20
+ end
21
+
22
+
23
+
24
+ end
@@ -0,0 +1,29 @@
1
+ require "flexfarm"
2
+
3
+ #
4
+ ## Project have some default properties,
5
+ ## run 'rake info' to print full configuration.
6
+ #
7
+
8
+ Flexfarm::Rake::define_project do |p|
9
+ p.add_target( "main.swf","src/Main.as" )
10
+
11
+ p.preview_file = "index.html"
12
+
13
+ p.srcs << "src" << "lib" << "tests"
14
+
15
+ p.libs.push << "lib"\
16
+ << "#{Flexfarm::FLEX_HOME}/frameworks/libs/flex.swc"\
17
+ << "#{Flexfarm::FLEX_HOME}/frameworks/libs/utilities.swc"\
18
+ << "#{Flexfarm::FLEX_HOME}/frameworks/libs/framework.swc"\
19
+ << "#{Flexfarm::FLEX_HOME}/frameworks/libs/player/9/playerglobal.swc"
20
+
21
+ p.assets << Flexfarm::Rake::SourceDir.new("src") { |fl|
22
+ fl.add "assets","assets/**/*","*.xml","*.swf"
23
+ fl.exclude(/ Report\.txt$/)
24
+ }
25
+ p.assets << Flexfarm::Rake::SourceDir.new("html-template") { |fl|
26
+ fl.add "**/*"
27
+ }
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hpeikemo-flexfarm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ platform: ruby
6
+ authors:
7
+ - Hans Petter Eikemo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: hpeikemo@me.com
18
+ executables:
19
+ - ffarm
20
+ - ffcompile
21
+ - ffdebugger
22
+ - fffcshd
23
+ extensions: []
24
+
25
+ extra_rdoc_files:
26
+ - README.txt
27
+ files:
28
+ - History.txt
29
+ - Manifest.txt
30
+ - README.txt
31
+ - Rakefile
32
+ - VERSION
33
+ - bin/ffarm
34
+ - bin/ffcompile
35
+ - bin/ffdebugger
36
+ - bin/fffcshd
37
+ - flexfarm.gemspec
38
+ - lib/cliwrapper.rb
39
+ - lib/default_config.rb
40
+ - lib/fcsh.rb
41
+ - lib/fdb.rb
42
+ - lib/flashmate.rb
43
+ - lib/flexfarm.rb
44
+ - lib/flexfarm_config.rb
45
+ - lib/flexrake.rb
46
+ - lib/generator.rb
47
+ - rakefile.rb.example
48
+ has_rdoc: true
49
+ homepage: http://github.com/hpeikemo/flexfarm
50
+ licenses:
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.5
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: flexFarm is a set of tools to charge and improve ActionScript development.
75
+ test_files: []
76
+