Permalink
Browse files

Added HemlockPixel.as, bin/HemlockPixel.swc, and hemlock:build:pixel …

…task

Beginnings of the bridge for transferring data between JS and AS.
  • Loading branch information...
1 parent 7df9d33 commit 6d895460c50e370e0ae55be61c7a06e302069e05 @rondevera rondevera committed Apr 17, 2010
View
@@ -23,5 +23,6 @@ namespace :hemlock do
puts 'Advanced:'
puts '- rake hemlock:build:core # Re-compiles HemlockCore.swc'
puts '- rake hemlock:build:loaders # Re-compiles HemlockLoaders.swc'
+ puts '- rake hemlock:build:pixel # Re-compiles HemlockPixel.swc'
end
end
View
Binary file not shown.
View
@@ -24,14 +24,18 @@ namespace :hemlock do
]
mxmlc_options << '-compiler.debug=true' if args.debug
- `cd src && #{ENV['FLEX_SDK_HOME']}/bin/mxmlc #{mxmlc_options.join(' ')} #{input_file}`
- puts "Built #{output_file}"
+ working_dir = 'src'
+ `cd #{working_dir} && #{ENV['FLEX_SDK_HOME']}/bin/mxmlc #{mxmlc_options.join(' ')} #{input_file}`
+ puts "Built #{working_dir}/#{output_file}"
end
desc 'Build HemlockCore.swc'
task :core => ['hemlock:core:build']
desc 'Build HemlockLoaders.swc'
task :loaders => ['hemlock:loaders:build']
+
+ desc 'Build HemlockPixel.swc and HemlockPixel.swf'
+ task :pixel => ['hemlock:pixel:build']
end
end
View
@@ -5,11 +5,18 @@ namespace :hemlock do
task :manifest do
manifest_filename = 'manifestCore.xml'
-
xml = <<-EOS
<?xml version="1.0"?>
<componentPackage>
EOS
+
+ includes = %w[
+ com/mintdigital/hemlock
+ com/adobe
+ com/dynamicflash
+ com/gsolo
+ com/pixelbreaker
+ ]
excludes = ["handlers", "events", "assets", "views"]
# TODO: Remove 'events' and 'views', since widgets should now use delegate classes instead
excludeRegexes = [
@@ -19,17 +26,19 @@ EOS
]
# Recursively include all the files from given namespaces
- xml << ['com/mintdigital/hemlock', 'com/adobe', 'com/dynamicflash', 'com/gsolo', 'com/pixelbreaker'].map do |dir|
- Dir["src/#{dir}/**/*.as"].map{|path| path.gsub("src/","").gsub(".as","").gsub("/",".") }.map do |klass|
- if excludes.include?(klass.gsub(/.*\./,"")) || excludeRegexes.map{ |regex| klass =~ regex }.any?
- ''
- else
- <<-EOS
- <component id="#{klass}" class="#{klass}"/>
- EOS
-
- end
- end.join
+ xml << includes.map do |dir|
+ Dir["src/#{dir}/**/*.as"].
+ map { |path| path.gsub("src/","").gsub(".as","").gsub("/",".") }.
+ map do |klass|
+ if excludes.include?(klass.gsub(/.*\./,"")) ||
+ excludeRegexes.map{ |regex| klass =~ regex }.any?
+ ''
+ else
+ <<-EOS
+<component id="#{klass}" class="#{klass}"/>
+EOS
+ end
+ end.join
end.join
xml << <<-EOS
@@ -39,7 +48,7 @@ EOS
File.open("src/#{manifest_filename}","w+") do |file|
file << xml
end
- end
+ end # task :manifest
task :compile do
namespace = 'http://hemlock.mintdigital.com'
@@ -58,6 +67,7 @@ EOS
]
`#{ENV['FLEX_SDK_HOME']}/bin/compc #{compc_options.join(' ')}`
- end
+ end # task :compile
+
end # namespace :core
end
View
@@ -36,7 +36,7 @@ EOS
end
task :compile do
- namespace = 'http://hemlock-loaders.mintdigital.com'
+ namespace = 'http://loaders.hemlock.mintdigital.com'
manifest_filename = 'src/manifestLoaders.xml'
output = 'bin/HemlockLoaders.swc'
View
@@ -0,0 +1,110 @@
+namespace :hemlock do
+ namespace :pixel do
+ desc 'Build HemlockPixel.swc'
+ task :build => %w[
+ hemlock:pixel:swc:manifest
+ hemlock:pixel:swc:compile
+ hemlock:pixel:swf:build
+ ]
+
+ namespace :swc do
+ task :manifest do
+ manifest_filename = 'manifestPixel.xml'
+ xml = <<-EOS
+<?xml version="1.0"?>
+<componentPackage>
+EOS
+
+ includes = %w[
+ com/mintdigital/hemlock
+ com/mintdigital/hemlockPixel
+ com/adobe
+ com/dynamicflash
+ com/gsolo
+ com/pixelbreaker
+ ]
+ excludes = ["handlers", "events", "assets", "views"]
+ # TODO: Remove 'events' and 'views', since widgets should now use delegate classes instead
+ excludeRegexes = [
+ /\._[^.]*$/, # e.g., _baseSkin.as (intended as an include)
+ /.*Skin$/,
+ /.*Widget/,
+ /.*WidgetEvents$/,
+ /.*WidgetViews$/
+ ]
+
+ # Recursively include all the files from given namespaces
+ xml << includes.map do |dir|
+ Dir["src/#{dir}/**/*.as"].
+ map { |path| path.gsub("src/","").gsub(".as","").gsub("/",".") }.
+ map do |klass|
+ if excludes.include?(klass.gsub(/.*\./,"")) ||
+ excludeRegexes.map{ |regex| klass =~ regex }.any?
+ ''
+ else
+ <<-EOS
+<component id="#{klass}" class="#{klass}"/>
+EOS
+ end
+ end.join
+ end.join
+
+ xml << <<-EOS
+</componentPackage>
+EOS
+
+ File.open("src/#{manifest_filename}","w+") do |file|
+ file << xml
+ end
+ end # task :manifest
+
+ task :compile do
+ namespace = 'http://pixel.hemlock.mintdigital.com'
+ manifest_filename = 'src/manifestPixel.xml'
+ output = 'bin/HemlockPixel.swc'
+
+ puts "Preparing #{output}..."
+
+ compc_options = [
+ "-namespace #{namespace} #{manifest_filename}",
+ "-include-namespaces=#{namespace}",
+ '-sp=src',
+ '-sp=vendor/xiff/src',
+ '-managers=flash.fonts.AFEFontManager',
+ "-output=#{output}"
+ ]
+ `#{ENV['FLEX_SDK_HOME']}/bin/compc #{compc_options.join(' ')}`
+ end # task :compile
+ end # namespace :swc
+
+ namespace :swf do
+ task :build, [:debug] do |t, args|
+ # Usage:
+ # - `rake hemlock:pixel:swf:build`
+ # - `rake hemlock:pixel:swf:build[true] (debug mode)
+
+ # Enabling debug mode here enables Flash Player to report code line
+ # numbers in error messages.
+
+ args.with_defaults(:debug => false)
+
+ puts "Building HemlockPixel.swf#{' (debug mode)' if args.debug}..."
+
+ input_file = 'com/mintdigital/hemlockPixel/HemlockPixel.as'
+ output_file = 'com/mintdigital/hemlockPixel/HemlockPixel.swf'
+ mxmlc_options = [
+ '-compiler.source-path=.',
+ '-compiler.fonts.managers=flash.fonts.AFEFontManager',
+ '-compiler.include-libraries=../bin/HemlockPixel.swc',
+ "-output=#{output_file}"
+ ]
+ mxmlc_options << '-compiler.debug=true' if args.debug
+
+ working_dir = 'src'
+ `cd #{working_dir} && #{ENV['FLEX_SDK_HOME']}/bin/mxmlc #{mxmlc_options.join(' ')} #{input_file}`
+ puts "Built #{working_dir}/#{output_file}"
+ end # task :build
+ end # namespace :swf
+
+ end # namespace :pixel
+end
Oops, something went wrong.

0 comments on commit 6d89546

Please sign in to comment.