lfd 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +22 -0
  5. data/README.md +43 -0
  6. data/README.zhCN.md +43 -0
  7. data/Rakefile +23 -0
  8. data/lfd.gemspec +27 -0
  9. data/lib/lfd/app.rb +53 -0
  10. data/lib/lfd/build.rb +188 -0
  11. data/lib/lfd/env.rb +92 -0
  12. data/lib/lfd/init.rb +18 -0
  13. data/lib/lfd/run.rb +46 -0
  14. data/lib/lfd/setup.rb +20 -0
  15. data/lib/lfd_version.rb +1 -1
  16. data/test/fixture/projects/flash10_flex_proj/.actionScriptProperties +23 -0
  17. data/test/fixture/projects/flash10_proj/asproj.info +17 -0
  18. data/test/fixture/projects/flash10_proj/bin/test_as_proj.swf +0 -0
  19. data/test/fixture/projects/flash10_proj/flash10_proj.as3proj +84 -0
  20. data/test/fixture/projects/flash10_proj/src/Main.as +13 -0
  21. data/test/fixture/projects/flash10_proj/tmp_proj/asproj.info +17 -0
  22. data/test/fixture/projects/flash10_proj/tmp_proj/tmp_proj/asproj.info +6 -0
  23. data/test/fixture/projects/flash10_swc_proj/asproj.info +16 -0
  24. data/test/fixture/projects/flash10_swc_proj/bin/test_as_proj.swc/catalog.xml +32 -0
  25. data/test/fixture/projects/flash10_swc_proj/bin/test_as_proj.swc/library.swf +0 -0
  26. data/test/fixture/projects/flash10_swc_proj/bin/test_as_proj.swf +0 -0
  27. data/test/fixture/projects/flash10_swc_proj/flash10_proj.as3proj +84 -0
  28. data/test/fixture/projects/flash10_swc_proj/src/Main.as +13 -0
  29. data/test/fixture/projects/flash10_swc_proj/tmp_proj/asproj.info +17 -0
  30. data/test/fixture/projects/flash10_swc_proj/tmp_proj/tmp_proj/asproj.info +6 -0
  31. data/test/fixture/projects/flash9_flex_proj/.actionScriptProperties +23 -0
  32. data/test/fixture/projects/flash9_proj/flash9_proj.as3proj +84 -0
  33. data/test/fixture/projects/should_fail_proj/should_fail_proj.as3proj +85 -0
  34. data/test/helper.rb +41 -0
  35. data/test/tc_building_proj_test.rb +28 -0
  36. data/test/tc_check_mm_cfg_test.rb +37 -0
  37. data/test/tc_env_test.rb +23 -0
  38. data/test/tc_initing_proj_test.rb +27 -0
  39. data/test/tc_running_proj_test.rb +23 -0
  40. metadata +38 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4ce85aaaba42163a9852ae64239f5e093d8aade
4
- data.tar.gz: 3068d2725b514cc53ca3aa5141da23135a4f84bd
3
+ metadata.gz: c4507a5267e60427b4efafdb750fac6ecdfd3c3f
4
+ data.tar.gz: eebef4eab558051b2baf347be392bbe61fb0b171
5
5
  SHA512:
6
- metadata.gz: 5399aa29fb4eb399c600ecdbc6bfad668bad6c988bcc30ca8d6abd74ad7c075447aedc3355ede10606b96ad5eeb5713bcdef8db78fafda295e07992e97d9c4b0
7
- data.tar.gz: 09ff11b23084fa6f6cc1d1729a7cf49f731fcc870acc841576b3e5b6649dfd009c77d37b1d1094dcc217e482d1ce223db85455f5f92b55e075d6001232ca43a5
6
+ metadata.gz: 263e5003781e9b077611eb6edbe96b93d32d290c3bbf95c4d3bad4aacdd941e4c7a797c47b1734022a2a60fdb7675d725a8e6962765df86fb3a65f3358492f8b
7
+ data.tar.gz: c524903561fd09e2650976d7933c55e68fd4d5e0bdc53e45e70186298e508b3c23a35ac33a316d9883e0140df3ed55c83fbe692c006cb54c9d8a0171a6cbd090
@@ -0,0 +1 @@
1
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lfd (0.0.1)
5
+ gli
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ gli (1.6.0)
11
+ json (1.6.6)
12
+ rake (0.9.2.2)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ lfd!
21
+ rake
22
+ rdoc
@@ -0,0 +1,43 @@
1
+ # Linux Flash Develp
2
+ LFD, which stands for "Linux Flash Develop", will help you develop Flash and Flex applications on Linux, especially Ubuntu.
3
+
4
+ ## Pain of Flash Developing On Linux
5
+ 1. you must write many lines of command to compile your code into a swf file
6
+ 2. 'trace' do not output in standard output (such as terminal) in new version of standalone flash player
7
+
8
+ LFD is your firend if you are suffering from the pain as well as me.
9
+
10
+ ## Usage
11
+
12
+ lfd init # init your project home, creating file: asproj.info, making dirs: bin/ src/ lib/ etc.
13
+ lfd build # compile your appliation (configed in asproj.info) with a binary swf file output
14
+ lfd run # open swf file with standalone Adobe flash player.
15
+ lfd test # equals "lfd build && lfd run"
16
+ lfd clean # delete project info file and folders created by LFD. will not delete non-empty folder
17
+
18
+ ## Installation
19
+ ### System Requirements
20
+ 1. ruby 1.9.2+
21
+
22
+ you can install ruby1.9.2 with this commands on unbuntu:
23
+
24
+ sudo apt-get install ruby1.9.1
25
+
26
+ 2. Flex SDK
27
+
28
+ you can [download](http://sourceforge.net/adobe/flexsdk/wiki/Downloads/) Flex SDK from Adobe, version 4.5+ is suggested because I havn't test many versions of SDK.
29
+
30
+ 3. Standalone Flash Player
31
+
32
+ you can [download](http://www.adobe.com/support/flashplayer/downloads.html) it from Adobe. Make sure to use the latest debugger version.
33
+
34
+ ### Install LFD
35
+
36
+ gem install lfd
37
+
38
+ ## Configuration
39
+
40
+ LFD depends on Flex SDK and Flash Player heavily. Please config them in your bash config (~/.bashrc commonly)
41
+
42
+ export MXMLC="/path/to/flex_sdk/bin/mxmlc"
43
+ export FLASH_PLAYER="/path/to/flashplayer_standalone"
@@ -0,0 +1,43 @@
1
+ # Linux Flash Develp
2
+ LFD 可以帮助你在Linux下开发和调试Flash(ActionScript3和Flex)项目
3
+
4
+ ## 解决的问题
5
+ 1. 在Linux下没有方便的flash编译工具,手动写命令比较繁琐
6
+ 2. 新的播放器默认不会将trace输出到终端,查看程序日志比较麻烦
7
+
8
+ ## 使用方法
9
+
10
+ lfd #显示帮助
11
+ lfd init #在当前目录初始化项目
12
+ lfd build #编译项目
13
+ lfd run #以flashplayer打开编译出来的swf文件
14
+ lfd test #编译并打开, 等同于 lfd build && lfd run
15
+ lfd clean #删除项目,会删除lfd创建出来的 asproj.info 文件
16
+
17
+ ## 安装
18
+ ### 系统要求
19
+ 1. ruby 1.9.2+ 运行环境
20
+
21
+ unbuntu 下可以通过命令安装
22
+
23
+ sudo apt-get install ruby1.9.1
24
+
25
+ 2. flex sdk
26
+
27
+ 可以从Adobe官方网站[下载](http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK),建议使用4.5以上的SDK
28
+
29
+ 3. 独立Flash播放器
30
+
31
+ 可以从Adobe官方网站[下载](http://www.adobe.com/support/flashplayer/downloads.html),建议使用最新的Debugger版
32
+
33
+ ### 安装LFD
34
+
35
+ gem install lfd
36
+
37
+ ## 配置
38
+
39
+ lfd 运行时会调用flex sdk和flash播放器,请将他们所在的路径添加到$PATH中.
40
+ 在$HOME/.bashrc中指定以下配置:
41
+
42
+ export MXMLC="/path/to/flex_sdk/bin/mxmlc"
43
+ export FLASH_PLAYER="/path/to/flashplayer_standalone"
@@ -0,0 +1,23 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+
6
+ Rake::RDocTask.new do |rd|
7
+ rd.main = "README.rdoc"
8
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
9
+ rd.title = 'Your application title'
10
+ end
11
+
12
+ spec = eval(File.read('lfd.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |pkg|
15
+ end
16
+
17
+ require 'rake/testtask'
18
+ Rake::TestTask.new do |t|
19
+ t.libs << "test"
20
+ t.test_files = FileList['test/tc_*.rb']
21
+ end
22
+
23
+ task :default => :test
@@ -0,0 +1,27 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','lfd_version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'lfd'
5
+ s.description = <<-EOF
6
+ LFD, which stands for "Linux Flash Develop", will help you develop Flash and Flex applications on Linux.
7
+ EOF
8
+ s.version = Lfd::VERSION
9
+ s.author = 'qhwa'
10
+ s.email = 'qhwa@163.com'
11
+ s.homepage = 'https://github.com/qhwa/LFD'
12
+ s.platform = Gem::Platform::RUBY
13
+ s.summary = 'Flash develop tool on Linux'
14
+ # Add your other files here if you make them
15
+ s.files = `git ls-files`.split("
16
+ ")
17
+ s.require_paths << 'lib'
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = ['README.rdoc','lfd.rdoc']
20
+ s.rdoc_options << '--title' << 'lfd' << '--main' << 'README.rdoc' << '-ri'
21
+ s.bindir = 'bin'
22
+ s.executables << 'lfd'
23
+ s.add_development_dependency('rake')
24
+ s.add_development_dependency('rdoc')
25
+ s.add_runtime_dependency('gli')
26
+ s.add_runtime_dependency('colored')
27
+ end
@@ -0,0 +1,53 @@
1
+ require 'fileutils'
2
+ require 'lfd/env'
3
+ require 'lfd/setup'
4
+ require 'lfd/init'
5
+ require 'lfd/build'
6
+ require 'lfd/run'
7
+
8
+ module LFD
9
+
10
+ CONFIG_FILE = 'asproj.info'
11
+
12
+ class App
13
+
14
+ include FileUtils
15
+
16
+ ################################################
17
+ # subcommand: env
18
+ # 'env' also contains other helper methods
19
+ include Env
20
+
21
+ ###############################################
22
+ # subcommand: setup
23
+ include Setup
24
+
25
+ ###############################################
26
+ # subcommand: init
27
+ include Init
28
+
29
+ ###############################################
30
+ # subcommand: build & release
31
+ include Build
32
+
33
+ ###############################################
34
+ # subcommand: run
35
+ include Run
36
+
37
+ ###############################################
38
+ # subcommand: test
39
+ def test
40
+ build
41
+ run
42
+ end
43
+
44
+ ###############################################
45
+ # subcommand: clean
46
+ def clean(opt={})
47
+ rm_f CONFIG_FILE
48
+ rmdir %w(bin lib src tmp)
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,188 @@
1
+ module LFD
2
+
3
+ module Build
4
+
5
+ # TODO: support building swc
6
+ attr_reader :info
7
+
8
+ def build(opt={})
9
+ @options = opt
10
+ if File.exist?(CONFIG_FILE)
11
+ if mxmlc_ready?
12
+ @info = YAML.load_file(CONFIG_FILE)
13
+ if compile_to_swc?
14
+ cmd = compc_path << " " << swc_build_arg.join( ' ' )
15
+ puts cmd
16
+ system cmd
17
+ else
18
+ system mxmlc_path, info["main"], *swf_build_arg
19
+ end
20
+ else
21
+ fail "mxmlc not found!"
22
+ end
23
+ else
24
+ fail "#{CONFIG_FILE} not found, exiting"
25
+ exit
26
+ end
27
+ end
28
+
29
+ def release(opt={})
30
+ build( opt.merge :debug => false )
31
+ end
32
+
33
+ private
34
+
35
+ def compile_to_swc?
36
+ output_path =~ /\.swc$/i
37
+ end
38
+
39
+ def output_path
40
+ info["output"] && info["output"]["file"]
41
+ end
42
+
43
+ # swc compile options:
44
+ #
45
+ # -benchmark
46
+ # -compiler.accessible
47
+ # -compiler.actionscript-file-encoding <string>
48
+ # -compiler.compress
49
+ # -compiler.context-root <context-path>
50
+ # -compiler.debug
51
+ # -compiler.enable-runtime-design-layers
52
+ # -compiler.extensions.extension [extension] [parameters] [...]
53
+ # -compiler.external-library-path [path-element] [...]
54
+ # -compiler.fonts.advanced-anti-aliasing
55
+ # -compiler.fonts.flash-type
56
+ # -compiler.fonts.max-glyphs-per-face <string>
57
+ # -compiler.include-libraries [library] [...]
58
+ # -compiler.incremental
59
+ # -compiler.library-path [path-element] [...]
60
+ # -compiler.locale [locale-element] [...]
61
+ # -compiler.minimum-supported-version <string>
62
+ # -compiler.mobile
63
+ # -compiler.mxml.compatibility-version <version>
64
+ # -compiler.mxml.minimum-supported-version <string>
65
+ # -compiler.namespaces.namespace [uri] [manifest] [...]
66
+ # -compiler.omit-trace-statements
67
+ # -compiler.optimize
68
+ # -compiler.preloader <string>
69
+ # -compiler.report-invalid-styles-as-warnings
70
+ # -compiler.services <filename>
71
+ # -compiler.show-actionscript-warnings
72
+ # -compiler.show-binding-warnings
73
+ # -compiler.show-invalid-css-property-warnings
74
+ # -compiler.show-shadowed-device-font-warnings
75
+ # -compiler.show-unused-type-selector-warnings
76
+ # -compiler.source-path [path-element] [...]
77
+ # -compiler.strict
78
+ # -compiler.theme [filename] [...]
79
+ # -compiler.use-resource-bundle-metadata
80
+ # -compiler.verbose-stacktraces
81
+ # -compute-digest
82
+ # -directory
83
+ # -framework <string>
84
+ # -help [keyword] [...]
85
+ # -include-classes [class] [...]
86
+ # -include-file <name> <path>
87
+ # -include-namespaces [uri] [...]
88
+ # -include-resource-bundles [bundle] [...]
89
+ # -include-sources [path-element] [...]
90
+ # -include-stylesheet <name> <path>
91
+ # -licenses.license <product> <serial-number>
92
+ # -load-config <filename>
93
+ # -metadata.contributor <name>
94
+ # -metadata.creator <name>
95
+ # -metadata.date <text>
96
+ # -metadata.description <text>
97
+ # -metadata.language <code>
98
+ # -metadata.localized-description <text> <lang>
99
+ # -metadata.localized-title <title> <lang>
100
+ # -metadata.publisher <name>
101
+ # -metadata.title <text>
102
+ # -output <filename>
103
+ # -runtime-shared-libraries [url] [...]
104
+ # -runtime-shared-library-path [path-element] [rsl-url] [policy-file-url] [rsl-url] [policy-file-url]
105
+ # -static-link-runtime-shared-libraries
106
+ # -swf-version <int>
107
+ # -target-player <version>
108
+ # -tools-locale <string>
109
+ # -use-direct-blit
110
+ # -use-gpu
111
+ # -use-network
112
+ # -version
113
+ # -warnings
114
+ def swc_build_arg
115
+ [
116
+ "-target-player #{info["target"]}",
117
+ "-output #{output_path}",
118
+ "-compiler.source-path #{array_opt_to_s info["source"], ' '}"
119
+ # TODO: 加上更多的编译选项
120
+ ].tap do |args|
121
+
122
+ info["library"].tap do |libs|
123
+ if libs
124
+ args << "-compiler.library-path #{array_opt_to_s libs, ' '}"
125
+ end
126
+ end
127
+
128
+ info["include_classes"].tap do |classes|
129
+ if classes && !classes.empty?
130
+ args << "-include-classes #{array_opt_to_s classes, ' '}"
131
+ end
132
+ end
133
+
134
+ end
135
+
136
+ end
137
+
138
+ def debug?
139
+ @options[:debug] != false
140
+ end
141
+
142
+ def swf_build_arg
143
+ [
144
+ "--target-player=#{info["target"]}",
145
+ "--output=#{output_path}",
146
+ "--source-path=#{array_opt_to_s info["source"]}",
147
+ "--debug=#{@options[:debug] != false}",
148
+ "-static-link-runtime-shared-libraries=true"
149
+ # TODO: 加上更多的编译选项
150
+ ].tap do |args|
151
+
152
+ info["library"].each do |lib|
153
+ args << "--library-path+=#{lib}"
154
+ end
155
+
156
+ w, h = output["width"], output["height"]
157
+ args << "--default-size=#{w},#{h}" if w and h
158
+
159
+ # conditional compilation, set in asproj.info:
160
+ #
161
+ # compile_condition:
162
+ # CONFIG::debugging: true
163
+ #
164
+ cc = info["compile_condition"]
165
+ cc && cc.each do |k, v|
166
+ args << "-define+=#{k},#{v}"
167
+ end
168
+
169
+ end
170
+ end
171
+
172
+ def output
173
+ info["output"]
174
+ end
175
+
176
+ def array_opt_to_s(src, sep = ',')
177
+ case src
178
+ when Array
179
+ src.join sep
180
+ else
181
+ src.to_s
182
+ end
183
+ end
184
+
185
+
186
+ end
187
+
188
+ end
@@ -0,0 +1,92 @@
1
+ module LFD
2
+
3
+ module Env
4
+
5
+ # Public: Check the flash developing environment
6
+ def env(opt={})
7
+ check_flex_sdk
8
+ check_flash_player
9
+ end
10
+
11
+ def check_flex_sdk
12
+ check_cmd( "flex sdk - mxmlc", mxmlc_path )
13
+ check_cmd( "flex sdk - compc", compc_path )
14
+ end
15
+
16
+ def check_cmd title, cmd_path
17
+ print "#{title}: ".capitalize.rjust(20)
18
+ if cmd_path
19
+ puts cmd_path.chomp.green
20
+ else
21
+ puts "✗".red
22
+ end
23
+ end
24
+
25
+ def check_flash_player
26
+ check_cmd 'Flash Player', fp_path
27
+ end
28
+
29
+ def flex_sdk_ready?
30
+ mxmlc_ready? && compc_ready?
31
+ end
32
+
33
+ def mxmlc_ready?
34
+ executable? mxmlc
35
+ end
36
+
37
+ def executable? cmd
38
+ !!executable_path( cmd )
39
+ end
40
+
41
+ def executable_path cmd
42
+ path = `which #{Shellwords.escape(cmd)}`
43
+ path.empty? ? nil : path.chomp
44
+ end
45
+
46
+ def compc_ready?
47
+ executable? compc
48
+ end
49
+
50
+ def mxmlc
51
+ ENV['MXMLC'] || 'mxmlc'
52
+ end
53
+
54
+ def mxmlc_path
55
+ @mxmlc_path ||= executable_path( mxmlc )
56
+ end
57
+
58
+ def compc
59
+ ENV['COMPC'] || 'compc'
60
+ end
61
+
62
+ def compc_path
63
+ @compc_path ||= executable_path( compc )
64
+ end
65
+
66
+ def flash_player_ready?
67
+ executable? flash_player
68
+ end
69
+
70
+ alias_method :fp_ready?, :flash_player_ready?
71
+
72
+ def flash_player
73
+ ENV['FLASH_PLAYER'] || 'flashplayer'
74
+ end
75
+
76
+ def flash_player_path
77
+ @fp_path ||= executable_path( flash_player )
78
+ end
79
+
80
+ alias_method :fp_path, :flash_player_path
81
+
82
+ def trace_log_file
83
+ File.join ENV['HOME'], '.macromedia/Flash_Player/Logs/flashlog.txt'
84
+ end
85
+
86
+ def mm_cfg
87
+ File.join ENV['HOME'], 'mm.cfg'
88
+ end
89
+
90
+ end
91
+
92
+ end