fcshd 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +6 -0
- data/bin/fcshc +17 -12
- data/bin/fcshd +12 -4
- data/lib/fcshd.rb +3 -2
- data/lib/fcshd/compiler.rb +4 -57
- data/lib/fcshd/flex-home.rb +49 -0
- data/lib/fcshd/server.rb +3 -1
- data/lib/fcshd/version.rb +1 -1
- metadata +7 -5
data/Makefile
ADDED
data/bin/fcshc
CHANGED
@@ -23,15 +23,6 @@ $extra_arguments = []
|
|
23
23
|
OptionParser.new do |parser|
|
24
24
|
parser.banner = "Usage: fcshc MAIN [SRCDIR|LIB]... -o OUTPUT"
|
25
25
|
|
26
|
-
parser.on("--halo", "Use the Halo theme") do
|
27
|
-
if ENV["FLEX_HOME"]
|
28
|
-
$extra_arguments << "-theme=" +
|
29
|
-
File.join(ENV["FLEX_HOME"], *%w(frameworks themes Halo halo.swc))
|
30
|
-
else
|
31
|
-
die "must set $FLEX_HOME to use --halo option"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
26
|
parser.on("-o", "--output FILENAME", "Write SWF to FILENAME") do |value|
|
36
27
|
$output_filename = File.expand_path(value)
|
37
28
|
end
|
@@ -40,7 +31,16 @@ OptionParser.new do |parser|
|
|
40
31
|
$extra_arguments << "-compatibility-version=3"
|
41
32
|
end
|
42
33
|
|
43
|
-
parser.on("-
|
34
|
+
parser.on("--no-flex", "Remove all runtime shared libraries (RSLs)") do
|
35
|
+
$extra_arguments << "-runtime-shared-library-path="
|
36
|
+
end
|
37
|
+
|
38
|
+
parser.on("--halo", "Use the Halo theme") do
|
39
|
+
die "must set $FLEX_HOME to use --halo option" if not FlexHome.known?
|
40
|
+
$extra_arguments << "-theme=#{FlexHome.halo_swc}"
|
41
|
+
end
|
42
|
+
|
43
|
+
parser.on("-X EXTRA-ARGUMENT", "Pass EXTRA-ARGUMENT to mxmlc (multiple allowed)") do |value|
|
44
44
|
$extra_arguments << value
|
45
45
|
end
|
46
46
|
|
@@ -68,6 +68,10 @@ if $source_filename == nil
|
|
68
68
|
die "missing source file to compile"
|
69
69
|
end
|
70
70
|
|
71
|
+
if $source_directories == []
|
72
|
+
$source_directories << File.dirname($source_filename)
|
73
|
+
end
|
74
|
+
|
71
75
|
if $output_filename == nil
|
72
76
|
$source_filename.sub(/\.(as|mxml)$/, ".swf").tap do |filename|
|
73
77
|
local_filename = File.basename(filename)
|
@@ -79,6 +83,7 @@ $fcshd_arguments = ["mxmlc #$source_filename -output=#$output_filename"]
|
|
79
83
|
|
80
84
|
for directory in $source_directories
|
81
85
|
$fcshd_arguments << "-compiler.source-path+=#{directory}"
|
86
|
+
$fcshd_arguments << "-compiler.library-path+=#{directory}"
|
82
87
|
end
|
83
88
|
|
84
89
|
for filename in $library_filenames
|
@@ -88,10 +93,10 @@ end
|
|
88
93
|
$fcshd_arguments.concat($extra_arguments)
|
89
94
|
|
90
95
|
begin
|
91
|
-
host, port = "localhost",
|
96
|
+
host, port = "localhost", FCSHD::Server::PORT
|
92
97
|
socket = TCPSocket.new(host, port)
|
93
98
|
rescue Errno::ECONNREFUSED
|
94
|
-
die "
|
99
|
+
die "could not connect to fcshd at #{host}:#{port}"
|
95
100
|
end
|
96
101
|
|
97
102
|
basedir = File.join(File.expand_path("."), "")
|
data/bin/fcshd
CHANGED
@@ -9,16 +9,24 @@ rescue LoadError
|
|
9
9
|
end
|
10
10
|
|
11
11
|
logger = FCSHD::Logger.new(STDERR)
|
12
|
+
|
13
|
+
logger.die <<"^D" if not FCSHD::FlexHome.known?
|
14
|
+
Please put the Flex SDK in #{FlexHome.default} or set $FLEX_HOME.
|
15
|
+
^D
|
16
|
+
|
17
|
+
logger.log "This is fcshd #{FCSHD::VERSION}."
|
18
|
+
logger.log "Flex SDK: #{FCSHD::FlexHome}"
|
19
|
+
|
12
20
|
compiler = FCSHD::Compiler.new(logger)
|
13
21
|
compiler.start!
|
14
22
|
|
15
23
|
Thread.abort_on_exception = true
|
16
24
|
|
17
|
-
FCSHD_PORT = 34345
|
18
|
-
|
19
25
|
begin
|
20
|
-
|
21
|
-
|
26
|
+
FCSHD::Server.new(FCSHD::Server::PORT, compiler, logger).run!
|
27
|
+
logger.log "Now listening to port #{FCSHD_PORT}."
|
22
28
|
rescue Interrupt
|
23
29
|
logger.log "Exiting."
|
30
|
+
rescue Exception => error
|
31
|
+
logger.error "Could not listen to port #{FCSHD_PORT}: #{error}"
|
24
32
|
end
|
data/lib/fcshd.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require "fcshd/compiler-output-writer"
|
2
|
-
require "fcshd/compiler-output"
|
3
1
|
require "fcshd/compiler"
|
2
|
+
require "fcshd/compiler-output"
|
3
|
+
require "fcshd/compiler-output-writer"
|
4
|
+
require "fcshd/flex-home"
|
4
5
|
require "fcshd/logger"
|
5
6
|
require "fcshd/problem"
|
6
7
|
require "fcshd/server"
|
data/lib/fcshd/compiler.rb
CHANGED
@@ -1,52 +1,6 @@
|
|
1
1
|
require "find"
|
2
2
|
|
3
3
|
module FCSHD
|
4
|
-
module FlexHome
|
5
|
-
extend self
|
6
|
-
|
7
|
-
DEFAULT_FLEX_HOME = "/Library/Flex"
|
8
|
-
|
9
|
-
def known?
|
10
|
-
!!flex_home
|
11
|
-
end
|
12
|
-
|
13
|
-
def fcsh
|
14
|
-
flex_path("bin", "fcsh")
|
15
|
-
end
|
16
|
-
|
17
|
-
def find_standard_component(name)
|
18
|
-
Find.find(standard_source_directory_root) do |filename|
|
19
|
-
if barename(filename) == name
|
20
|
-
break File.dirname(filename).
|
21
|
-
sub(%r{.+/src/}, "").gsub("/", ".")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def flex_home
|
29
|
-
ENV["FLEX_HOME"] or
|
30
|
-
if File.directory? DEFAULT_FLEX_HOME
|
31
|
-
DEFAULT_FLEX_HOME
|
32
|
-
else
|
33
|
-
nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def flex_path(*components)
|
38
|
-
File.join(flex_home, *components)
|
39
|
-
end
|
40
|
-
|
41
|
-
def standard_source_directory_root
|
42
|
-
flex_path("frameworks", "projects")
|
43
|
-
end
|
44
|
-
|
45
|
-
def barename(filename)
|
46
|
-
File.basename(filename).sub(/\..*/, "")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
4
|
class Compiler
|
51
5
|
def initialize(logger)
|
52
6
|
@logger = logger
|
@@ -54,7 +8,6 @@ module FCSHD
|
|
54
8
|
end
|
55
9
|
|
56
10
|
def start!
|
57
|
-
ensure_flex_home_known!
|
58
11
|
start_fcsh_process!
|
59
12
|
parse_fcsh_boilerplate!
|
60
13
|
@logger.log "Started Flex #@flex_version compiler shell."
|
@@ -76,15 +29,6 @@ module FCSHD
|
|
76
29
|
|
77
30
|
private
|
78
31
|
|
79
|
-
def ensure_flex_home_known!
|
80
|
-
if not FlexHome.known?
|
81
|
-
@logger.log <<"^D"
|
82
|
-
Please put the Flex SDK in #{FlexHome::DEFAULT_FLEX_HOME} or set $FLEX_HOME.
|
83
|
-
^D
|
84
|
-
@logger.exit
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
32
|
def start_fcsh_process!
|
89
33
|
stop_fcsh_process!
|
90
34
|
@fcsh_process = IO.popen("#{FlexHome.fcsh} 2>&1", "r+")
|
@@ -107,7 +51,7 @@ Please put the Flex SDK in #{FlexHome::DEFAULT_FLEX_HOME} or set $FLEX_HOME.
|
|
107
51
|
end
|
108
52
|
|
109
53
|
def compile_new!
|
110
|
-
@frontend.puts "fcshd:
|
54
|
+
@frontend.puts "fcshd: compiling from scratch"
|
111
55
|
@frontend.flush
|
112
56
|
send_fcsh_command! @command
|
113
57
|
parse_compilation_output!
|
@@ -115,6 +59,9 @@ Please put the Flex SDK in #{FlexHome::DEFAULT_FLEX_HOME} or set $FLEX_HOME.
|
|
115
59
|
if not have_command_id?
|
116
60
|
@logger.error "Could not determine compilation ID:"
|
117
61
|
@logger.error @logger.format_command("(fcsh) #@command", @output)
|
62
|
+
|
63
|
+
@frontend.puts "fcshd: internal error"
|
64
|
+
@frontend.flush
|
118
65
|
end
|
119
66
|
end
|
120
67
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FCSHD
|
2
|
+
module FlexHome
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def default
|
6
|
+
"/Library/Flex"
|
7
|
+
end
|
8
|
+
|
9
|
+
def known?
|
10
|
+
!value.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def value
|
14
|
+
ENV["FLEX_HOME"] or
|
15
|
+
if File.directory? default
|
16
|
+
default
|
17
|
+
else
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
value
|
24
|
+
end
|
25
|
+
|
26
|
+
def [](*components)
|
27
|
+
File.join(value, *components)
|
28
|
+
end
|
29
|
+
|
30
|
+
# ------------------------------------------------------
|
31
|
+
|
32
|
+
def fcsh
|
33
|
+
self["bin/fcsh"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def halo_swc
|
37
|
+
self["frameworks/themes/Halo/halo.swc"]
|
38
|
+
end
|
39
|
+
|
40
|
+
# ------------------------------------------------------
|
41
|
+
|
42
|
+
def find_component(name)
|
43
|
+
Find.find(self["frameworks/projects"]) do |filename|
|
44
|
+
break File.dirname(filename).sub(%r{.+/src/}, "").gsub("/", ".") if
|
45
|
+
File.basename(filename).sub(/\..*/, "") == name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/fcshd/server.rb
CHANGED
@@ -2,6 +2,8 @@ require "socket"
|
|
2
2
|
|
3
3
|
module FCSHD
|
4
4
|
class Server
|
5
|
+
PORT = 34345
|
6
|
+
|
5
7
|
def initialize(port, compiler, logger)
|
6
8
|
@server = TCPServer.new("localhost", port)
|
7
9
|
@compiler = compiler
|
@@ -22,7 +24,7 @@ module FCSHD
|
|
22
24
|
when /^mxmlc /
|
23
25
|
compiler.compile! command, socket
|
24
26
|
else
|
25
|
-
sockets.puts "fcshd:
|
27
|
+
sockets.puts "fcshd: unrecognized command: #{command}"
|
26
28
|
end
|
27
29
|
rescue Errno::EPIPE
|
28
30
|
logger.log "Broken pipe."
|
data/lib/fcshd/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fcshd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 3
|
9
|
+
version: "0.3"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Brockman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-11-
|
17
|
+
date: 2011-11-02 00:00:00 Z
|
18
18
|
dependencies: []
|
19
19
|
|
20
20
|
description: |
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- .gitignore
|
36
36
|
- Gemfile
|
37
37
|
- Gemfile.lock
|
38
|
+
- Makefile
|
38
39
|
- README
|
39
40
|
- bin/fcshc
|
40
41
|
- bin/fcshd
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- lib/fcshd/compiler-output-writer.rb
|
44
45
|
- lib/fcshd/compiler-output.rb
|
45
46
|
- lib/fcshd/compiler.rb
|
47
|
+
- lib/fcshd/flex-home.rb
|
46
48
|
- lib/fcshd/logger.rb
|
47
49
|
- lib/fcshd/problem.rb
|
48
50
|
- lib/fcshd/server.rb
|
@@ -77,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
79
|
requirements: []
|
78
80
|
|
79
81
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.8.
|
82
|
+
rubygems_version: 1.8.10
|
81
83
|
signing_key:
|
82
84
|
specification_version: 3
|
83
85
|
summary: Usable CLI for the Adobe Flex compiler shell (fcsh)
|