Archive for the ‘automation’ Category

taskman: yet another Ant alternative

Wednesday, October 13th, 2010

I created a small PHP library taskman for writing project related tasks in a similar with Ant and rake fashion.

There is a lib-taskman project on the google code hosting where you can find the full documentation, sources and latest releases.

It’s probably not that elegant as rake but if you want to stick to PHP and have Ant-alike functionality without any XML programming then taskman may turn out to be handy. taskman is very simple to use, it requires only one include, all its code resides in one PHP file, and it has no external dependencies.

Here is the simplest usage example. Download and unpack the archive. Put taskman.inc.php to some place where you can include it from(I personally tend to bundle this script with every project). Create a task.php script with the following contents:

<?php
require('taskman.inc.php');
 
taskman_run($argv);
 
function task_hello()
{
  echo "Hello\n";
}
 
function task_comma()
{
  echo ",\n";
}
 
/**
 * @deps comma
 */
function task_world()
{
  echo "World\n";
}
 
/**
 * @deps hello,world
 */
function task_say($args = array())
{
  if(isset($args[0]))
    echo $args[0] . "\n";
}

You can run this script now in the command line as follows:

>php task.php say Whatever
************************ Running task 'hello' ************************
Hello
************************* 'hello' done (0 sec.)*************************
************************ Running task 'comma' ************************
,
************************* 'comma' done (0 sec.)*************************
************************ Running task 'world' ************************
World
************************* 'world' done (0 sec.)*************************
************************ Running task 'say' ************************
Whatever
************************* 'say' done (0 sec.)*************************
************************ All done (0 sec.)************************

You might be wondering what these “project related tasks” are. There can be lot of them: build the sources, bootstrap database, auto-generate code, migrate database schema, deploy project onto remote servers, etc. Maintenance of such tasks can become pretty tedious at some moment. Furthermore, some tasks may depend on other task, e.g. you can not build the sources without running code auto-generation task first.

P.S. Looks like there is a similar PHP solution called pake. The biggest difference between taskman and pake is the way tasks are specified. In case of taskman one has to prefix task functions with task_ keyword while in pake one has to register tasks explicitly using pake_task(..) function. Furthermore, in taskman one attaches task meta information using a PHPDoc block while in pake one should use separate functions, e.g. pake_desc(..).

P.P.S As David noted in comments there is also a Phake project which has, I believe, the strongest resemblance with rake thanks to new PHP-5.3 only features(e.g closures). Some of its ideas I’m going to borrow for taskman2 which will be PHP-5.3 only as well.

fla2swf - command line utility for publishing .fla files to .swf

Monday, October 4th, 2010

Continuing my flash automation saga this time I’m going to blog about a fla2swf utility, as I promised in the previous post about fcshd. You can grab it in the downloads section of the flash-automation project.

fla2swf is a command line utility written in PHP which can be used in a batch mode for publishing .fla files to .swf. It consists of the client and server parts. The cool thing behind this utility is the fact the client can be run on the box without Flash IDE installed(even on the *nix box). Of course, you will need the server to be run on the workstation with the Flash authoring environment installed.
(more…)

Cross-platform convenience wrapper around fcsh (for fast incremental Flex builds)

Tuesday, September 28th, 2010

For the impatient

fcshd is a convenient command line PHP based wrapper around fcsh shell. It works both in *nix and Windows. You can grab it from the downloads section of the flash-automation project. Just unzip it, enter the directory and run “php fcshc.php” in the shell to get the basic usage help.
(more…)

Redirect build errors into vim

Thursday, December 10th, 2009

Here is a small bash function which wraps the executed command in the shell and redirects all build errors right into vim. In vim you can jump between errors using standard :cn,:cp commands(as well as view them all using :cope).

function vimize () 
{ 
  local file=/tmp/vimize.errors
  if [ "$1" != "" ] ; then
    rm $file 2> /dev/null
    $1 "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" 2>&1 | tee $file
  fi
  grep ': error:' $file 
  if [ "$?" == "0" ] ; then
    vim -q $file -c :copen
  fi
}

Just put it into your ~/.bashrc, reload the shell and ejoy it. It can be used as follows:

$ vimize ./run_some_build_script

dctl Xtra 0.1 released

Monday, September 14th, 2009

dctlI created a simple Xtra dctl(Director ConTroL) which allows us to control the Adobe Director via the network socket. The idea is very simple: the Xtra listens on some port using Multiuser facility and allows to run a set of predefined tasks(which can be very easily extended, since these tasks are written in Lingo) or eval an arbitrary Lingo string.
(more…)