mxmlc task with command-line argument

44 views
Skip to first unread message

mosesoak

unread,
Feb 10, 2012, 12:23:15 PM2/10/12
to ProjectSprouts
Hey y'all. I want to be able to invoke an mxmlc task where the target
is dynamically generated. The mxmlc task is set up to require a target
path though which makes that difficult.

Given a simple compilation task like this:

desc 'Build orange skin swf'
task :skin_orange => 'bin-debug/skins/orange/orange.swf'
mxmlc 'bin-debug/skins/orange/orange.swf' do |t|
t.input = 'src/skins/orange/orange.css'
t.allow_source_path_overlap = true
t.static_link_runtime_shared_libraries = true
t.target_player = TARGET_PLAYER
end

I would like to be able to do this:

rake compile_skin['orange']

I understand how to write vanilla rake tasks that accept parameters,
but the fact that the mxmlc task requires the output target as an
input makes this difficult, since the target directory would need to
be built within the task (something like "bin-debug/skins/
#{args[:skin_name]}.swf"). That forces me to start researching how to
do Rake::Task['mxmlc']invoke(:skin_name) or something complicated.

So, is there any way to write an mxmlc task without the requirement of
an output file up front? If not, how would I set up an mxmlc task like
the one I'm thinking of?

Thanks!
:-)
Moses

Alan Pinstein

unread,
Feb 10, 2012, 12:29:35 PM2/10/12
to project...@googlegroups.com
We do this all the time.

task :doSomethingDynamic do
myTaskOutput = calculateOutputFile()
myTaskDeps = calculateDepsArray()
# define a task on-the-fly
mxmlc myTaskOutput => myTaskDeps do |t|
t.input = "foo.as"
end
# execute newly defined task
Rake::Task[myTaskOutput].invoke
end

Something like that...

Alan

> --
> You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
> To post to this group, send email to project...@googlegroups.com
> To unsubscribe from this group, send email to projectsprout...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/projectsprouts?hl=en
>
> For other info you can visit our project at: http://projectsprouts.org, or on Github at: http://github.com/lukebayes/project-sprouts

Alan Pinstein

unread,
Feb 10, 2012, 12:36:58 PM2/10/12
to project...@googlegroups.com
FYI you can also use mxmlc to generate tasks outside of a task; we do this at the top of our Rakefile to dynamically generate tasks to build a suite of sub-projects based on items in a directory.

mosesoak

unread,
Feb 10, 2012, 1:26:42 PM2/10/12
to ProjectSprouts
Great, thanks Alan! I'll try it out.
> >> For more options, visit this group athttp://groups.google.com/group/projectsprouts?hl=en
>
> >> For other info you can visit our project at:http://projectsprouts.org, or on Github at:http://github.com/lukebayes/project-sprouts
>
> > --
> > You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
> > To post to this group, send email to project...@googlegroups.com
> > To unsubscribe from this group, send email to projectsprout...@googlegroups.com
> > For more options, visit this group athttp://groups.google.com/group/projectsprouts?hl=en
Reply all
Reply to author
Forward
0 new messages