redtamarin logo

Redbean

The RedTamarin build tool

Description

Redbean is a tool that allows to build, compile, run, manipulate, organise, etc.
ActionScript 3.0 projects for RedTamarin.

Here a list of basic functionalities

  • compile()
    compile AS3 source code as ABC file

  • shell()
    execute AS, ABC, SWF file(s)

  • projector()
    create executable projectors from ABC file(s)

  • generateIncludes()
    generate the include files(s) from your AS3 sources tree

Redbean is an executable written in AS3 with the RedTamarin API.

Redbean run AS3 build scripts.

It works like any build or make tools

  • you provide a build file
    by default we use 'build.as3'

  • because this build file run AS3 code
    you first import redbean.*; to use the redbean API

  • and then you can use commands
    for ex: compile(), shell(), projector(), etc.

  • those commands are adapted to the RedTamarin environment
    they simplify complicated and repetitive tasks


Installation

Redbean is provided pre-compilled with the RedTamarin SDK

Attention

redbean is dependant on the RedTamarin SDK installation, if not properly configured it will not work.
  • you need to have the SDK deployed on your local machine
  • you need to have an environment variable pointing to the SDK root path
    ex: REDTAMARIN_SDK=/path/to/sdk/redtamarin
  • and/or you need to have a 'redbean.cfg' file in your HOME directory
  • and/or you need to have a 'redbean.cfg' file in your current directory

By default, redbean will try to locate the RedTamarin SDK in this order

  1. first, it will look for the REDTAMARIN_SDK
    environment variable

  2. then it will look for a 'redbean.cfg' config file
    in your HOME directory

  3. finally it will look for a local config file 'redbean.cfg'
    in its current working directory

example of 'redbean.cfg' file

var REDTAMARIN_SDK = "/some/path/RedTamarinSDK";

If the RedTamarin SDK can not be found,
redbean will throw an error and stop.

[error] RedTamarin SDK Not Found!!

If the RedTamarin SDK has been found,
you will see at least the redbean banner

[redbean 1.0.0]
...

Usage

Command line help

redbean -- [-h] [-i] [-e] [-q] [-v] [-dd] [-f buildfile]

Options:
  -h              display this help
  -i              display informations
  -e              display environment variables
  -q              quiet mode
  -v              verbose mode
  -dd             use debug debugger
  -f buildfile    run buildfile

Example:

#to build with mybuild.as3
$ ./redbean -- -f mybuild.as3

#display informations
$ ./redbean -- -i

You mainly use redbean from the command line,
in general you will want to create a link
from redbean path location to your project root directory.

Under Mac OS X and Linux

# move to your project root directory
$ cd /your/project/path

# create a symbolic link to the redbean executable
$ ln -s /sdk/redtamarin/bin/redbean redbean

# run redbean from the project directory
$ ./redbean

Under Windows

if you use Cygwin, using the bash prompt is similar than with mac and linux

# move to your project root directory
$ cd /cygdrive/c/your/project/path

# create a symbolic link to the redbean executable
$ ln -s /cygdrive/c/sdk/redtamarin/bin/redbean.exe redbean.exe

# run redbean from the project directory
$ ./redbean.exe

With the classic DOS/Windows command prompt

  • you will need to select 'redbean.exe'
    from the SDK path, right click and create a shortcut

  • then you will need to move this shortcut
    to your project root directory and rename it 'redbean.lnk'

  • then you will need to edit this shortcut
    select 'redbean.lnk' and right click properties
    you will need to change the Start in
    to the path of your current project directory

  • after all that you can run the shortcut from the command line

C:/> redbean.lnk
Depending on your Windows operating system,
you may get a Security warning each time you run the 'redbean.lnk' shortcut.

You can disable it by unchecking "Always ask before opening this file".
Those two methods are not compatible with each other
you can not run a Cygwin symlink from the Windows command prompt
you can not run a Windows shortcut from the Cywin bash prompt.

If you need a solution that can work with both the Cygwin bash prompt
and the Windows command prompt, simply copy the 'redbean.exe'
from the SDK path to your current project root directory.

General behaviour

By default, redbean will look for a 'build.as3' file
in the current working directory.

If the file is not found you will get an error

[redbean 1.0.0]
[error] "build.as3" is not a valid file

one simple way to solve and test that is to add a 'build.as3' file
containing a trace() statement

trace( "found!!" );

now when you run redbean you should see

[redbean 1.0.0]
found!!

From that point, just edit the 'build.as3' file to do what you want.

Under Flash Builder

In some code editors you can configure command line tools
to run automatically as your main build.

You can exactly do that in Flash Builder with redbean :).

  1. In your project properties, select the builders section

  2. Create a new Program builder, name it "redbean"

  3. For the Location
    ${env_var:REDTAMARIN_SDK}/bin/redbean (for Mac OS X)
    ${env_var:REDTAMARIN_SDK}/bin/redbean.exe (for Windows)

  4. For the Working Directory
    just select the root of your project

  5. Save, and also remove the default "Builder" created originally by Flex.
    Ignore the warning about side-effects.

  6. Now, from your project properties clicking "Build project"
    will run the redbean builder which will try to run the default "build.as3"

From that point, just create or edit the 'build.as3' file to do what you want.

General usage

With the following project structure

(root directory)
   |_ src
   |    |_ test.as    <- your source code
   |
   |_ build.as3       <- redbean build file
   |_ redbean.cfg     <- redbean configuration file (optional)

the 'src/test.as' file


trace( "hello world from test.as" );

the 'build.as3' file

import redbean.*; // you need to import redbean scope

// compile some AS3 source code
compile( "src/test.as" ); // this will generate an ABC file

// run the ABC file with the shell
shell( "src/test.abc" );

example of 'redbean.cfg' file

//var REDTAMARIN_SDK = "/sdk/redtamarin/2.0";
//var showHelp = false; // -h
//var showInformations = true; // -i
//var showEnvironment = true; // -e
//var quietMode = false; // -q
//var verboseMode = true; // -v
//var buildFile = "local.as3" // -f local.as3
//var useDebugger = true; // -dd

from the root directory run

$ ./redbean

you should see this output

[redbean 1.0.0]
[run] build.as3

[compile] src/test.as

test.abc, 82 bytes written

[shell] src/test.abc

hello world from test.as


[done] in 01s.091ms

Documentation

latest documentation


Copyright 2017 zwetan

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.