Table Of Contents

Previous topic

25.2. Disassembler

Next topic

25.6. json2json

This Page

25.3. maketzjs

25.3.1. Usage

Syntax

maketzjs [options] <input files>

Converts a JavaScript file into a .tzjs file or .canvas.js file, with optional compression.

25.3.2. Options

For the complete set of available options, see the output of maketzjs -h.

--version

Show version number and exit.

--help, -h

Show help message and exit.

--verbose, -v

Verbose output.

--silent, -s

Silent running.

--output=OUTPUT, -o OUTPUT

Output file to process.

--templatedir=TEMPLATEDIRS, -t TEMPLATEDIRS

Template directory (multiple allowed).

--dependency, -M

Output all dependencies.

--MF=DEPENDENCYFILE

Output all dependencies to DEPENDENCYFILE (requires -M flag).

--mode=MODE, -m MODE

Generate a file for use in the given run mode. Supported modes include: plugin, canvas.

--hybrid

Start up a plugin as well as a canvas-based TurbulenzEngine. The plugin will be available as TurbulenzEnginePlugin. Available only for canvas mode.

--yui=YUI, -y YUI

Path to the YUI compressor, setting this enables the compactor

--closure=CLOSURE, -c CLOSURE

Path to the Closure compiler, setting this enables the compactor

--uglifyjs=UGLIFYJS, -u UGLIFYJS

Path to the UglifyJS application, setting this enables the compactor

--ignore-input-extension

Allow input files with an extension other than .js

--line-break=LENGTH, -l LENGTH

Split line length.

--use-strict

Enforce “use strict”; statement. This adds a single “use strict”; line at the top of the JavaScript code.

--include-use-strict

Don’t strip out “use strict”; statements. By default all “use strict”; statements are removed from the output file.

--no-strip-debug

Don’t strip out calls to methods on the debug object and disable static removal of branches based on the debug variable. Also, allow code to include jslib/debug.js (this option is set by default since this tool is only called in release modes, so it is only useful for developers wishing to disable this behavior in release configurations).

--strip-namespace

Any variable names specified with this flag will have all their method calls stripped from the resulting code. The debug object is stripped by default for both plugin and canvas modes. This corresponds to the –namespace flag on the strip-debug tool.

--strip-var

Any variable names specified with this flag will be statically evaluated as true, and simple if statements based on them will have the appropriate branches stripped from the resulting code. This corresponds to the -D flag on the strip-debug tool. By default, the variable debug is statically set to true unless –no-strip-debug is specified.

--profile

Enable the collection and output of profiling information

Any unrecognized options are assumed to be the names of input files. These are specified relative to one of the TEMPLATEDIRS paths given using the -t option.

For more information on templating see Templating JavaScript Applications.

25.3.3. Example

cd C:\Turbulenz\SDK\X.X.X\apps\sampleapp
maketzjs --mode plugin -t templates -t . -y yuicompressor-X.X.X.jar -o sampleapp.tzjs sampleapp.js

When only generating dependencies:

maketzjs --mode plugin -M --MF build/sampleapp.dep -t templates -t . -o sampleapp.tzjs sampleapp.js

Here X.X.X is the version of the SDK and yuicompressor-X.X.X.jar the path to the YUI compressor.

Note

When generating dependencies, this tool will output the dependencies required to build the target output, in the form:

<target-file> <dependency-file> : <source file> <source file> ...

The source files listed are those which, when changed, should trigger a rebuild of the target-file.

If one of these files is missing, the tool will fail to produce the output file, listing the first dependency it failed to find returning an error.

Note

Use of tools such as YUI compressor or UglifyJS for compression is optional, but recommended. It is worth measuring the effect the different tools have. Note that YUI Compressor requires both YUI and Java installed and configured on your machine.

25.4. strip-debug

This tool performs the removal of debug code in release builds. It will usually be invoked by maketzjs, so most developers will not need to call it directly. However, developers with custom code builds, in particular where code is pre-processed before being passed to maketzjs, may wish to invoke this to ensure that debug code does not appear in release versions of their games.

The tool can only recognise “fully qualified” calls, as described in the debug api.

0.25.0:

Since SDK 0.25.0 this tool also supports removing if-else clauses that can be statically resolved based on user-specified variable names. The condition part of the if-else clauses may only contain direct references to special identifiers (specified with the -D flag), and the unary ! operator. For example

if (debug)
{
  console.log("this will only be called in debug builds");
}

if (!debug)
{
  console.log("this will only be called in release builds");
}
else
{
  console.log("this will only be called in debug builds");
}

25.4.1. Usage

Syntax

strip-debug [<options>] [<infile>]

Reads from stdin, or infile and removes all calls to methods on a global object (the debug object by default). If no output file is specified, output is written to stdout.

25.4.2. Options

Run strip-debug -h for a complete list of all options.

-h, --help

Help text for the tool

-o <outfile>

Write the stripped code the given destination

--ignore-errors

By default, the tool will halt execution with an error if there are syntax errors in the code. This flag overrides that behavior allowing a build to continue even if a syntax error is found. Note that since it is impossible to parse and reliably remove calls from code with syntax errors, the tool will simply copy the input file verbatim to the output.

--namespace <name.space>

Set the name of the object or namespace for which method calls should be stripped. By default this is just debug, but could refer to any object that is accessible via global scope. e.g. mystudio.utilities.debug.

-D<variable>[=false]

Instructs the tool to assume that <variable> is true (or false if the =false suffix is given) everywhere, and remove the appropriate parts of if-else clauses.

Added in SDK 0.25.0

25.5. makehtml

25.5.1. Usage

Syntax

makehtml [options] <.js input> [.html input]

Converts a .js file and, optionally, some HTML template code into a full HTML page that can be used to load and run code built with the maketzjs tool.

25.5.2. Options

--version

Show version number and exit.

--help, -h

Show help message and exit.

--verbose, -v

Verbose output.

--silent, -s

Silent running.

--output=OUTPUT, -o OUTPUT

Output file to process.

--templatedir=TEMPLATEDIRS, -t TEMPLATEDIRS

Template directory (multiple allowed).

--dependency, -M

Output all dependencies.

--MF=DEPENDENCYFILE

Output all dependencies to DEPENDENCYFILE (requires -M flag).

--mode=MODE, -m MODE

Generate an HTML page for use in the given run mode. Supported modes include: plugin, canvas, canvas-debug.

--hybrid

Start up a plugin as well as a canvas-based TurbulenzEngine. The plugin will be available as TurbulenzEnginePlugin. Available only for canvas, canvas-debug modes.

--code=CODEFILE, -C CODEFILE

Generate an HTML page that loads and runs the code in CODEFILE (which is not required to exist when this tool is run). The HTML code will reference CODEFILE with a relative path from OUTPUT (see the -o option).

--dump-default-template, -D

Write the default template to the OUTPUT file. This is intended as a basis for creating custom HTML pages. In general, it is not expected that this will be necessary.

--use-strict

Enforce “use strict”; statement. This adds a single “use strict”; line at the top of the JavaScript code.

--include-use-strict

Don’t strip out “use strict”; statements. By default all “use strict”; statements are removed from the output file.

--profile

Enable the collection and output of profiling information

To generate an HTML game page, you must provide at least input JavaScript code and an output file. For some configurations (namely plugin and canvas), the final location of code built with maketzjs will also be required. Input files with the html extension are assumed to be templates which can either extend or override the default template.

Input files are given relative to a templates directory.

For more information on templating see Templating JavaScript Applications.

25.5.3. Example

cd C:\Turbulenz\SDK\X.X.X\apps\sampleapp

makehtml --mode plugin -t templates -t . --code sampleapp.tzjs -o sampleapp.release.html sampleapp.js sampleapp.html

makehtml --mode canvas-debug -t templates -t . --code sampleapp.canvas.js -o sampleapp.canvas.debug.html sampleapp.js sampleapp.html

When generating dependencies:

makehtml --mode plugin -t templates -t . -M --MF build/sampleapp.dep -o sampleapp.release.html sampleapp.js sampleapp.html