Skip to content

Building

With a2c build you compile a Lua file, an AutoPlay project or a project file. Most of what you can set in the application can also be given as an option here.

a2c build <input> [options]

The input is one of these:

Input What is built
A Lua file (.lua) A module DLL. Needs --target.
An AutoPlay project (.autoplay) A module DLL and the rewritten project
A project file (.autoplay2c) Whatever the project file names, with its settings

Options

Option Description Default
-t\|--target The host: ams8, ams9, suf9-x86, suf9-x64, suf10-x86 or suf10-x64 (suf10 for short) A project's own host; required for a Lua file
-m\|--module The module name, the one require loads A Lua file's name; for a project, made from its file name
-o\|--output The DLL to write. Files you keep with --emit go next to it. The Lua file with .dll; for a project CD_Root\AutoPlay\Scripts\<module>.dll
--project-output The rewritten project to write The project with .a2c.autoplay
--data-folder Replace the data folder AutoPlay with this name in the scripts' strings None
--serialize-objects Create the project's objects from the module at run time, see Serialized Objects Off
--tab-order With serialized objects: emulate the tab order Off
--exclude-kind With serialized objects: kinds to leave in the project, comma separated (input,listbox) None
--exclude-object With serialized objects: an object to leave in the project, as Page::Object. Repeat it for more objects. None
--version-from-project Give the DLL the version information of the AutoPlay project. Asks first if the project file's would be replaced. Off
--save-version With --version-from-project and a project file: write the project's version information into the project file once the build succeeds Off
-y\|--yes Answer yes to the questions a build asks, such as whether --version-from-project may replace the project file's version information Off
--file-version The DLL's file version, one to four numbers (2.1.0.15), see On the Command Line The project file's, else autoplay2c's
--product-version The DLL's product version, the same way The project file's, else autoplay2c's
--version-string A text field of the DLL's version information, as Name=Value (ProductName=My App). Repeat it for more fields. The project file's, else autoplay2c's
--emit What to write, see below dll, and project for a project
--backend native or c, see Backends native, or c with --tcc
--tcc The tcc folder, for --backend c (which it implies) See Backends
--diagnostics How much of the compilation log to report besides errors and warnings: warnings, missed, applied or all warnings, or the project file's
--allow A diagnostic not to report, by code or name, see Silencing. Repeat it, or separate several with commas. None
--message-format human or json, see Messages human
-h\|--help Show the options

With a Project File

When the input is a project file, its settings are used, and the options you give win over them:

a2c build MyProject.autoplay2c --target ams9 --emit dll,project,lua

The object options are added to the project file's own. For example, --exclude-object leaves one more object in the project, on top of the ones the project file names. The version options work the same way: --file-version changes the version number and keeps the rest of the project file's version information.

Choosing What to Write

--emit takes a comma separated list. Each item is a kind, optionally with a path as kind=path, and a path of - writes to standard output.

Kind What it writes
dll The module DLL
project The rewritten project (projects only)
lua The module's Lua source (projects only)
c The module as C source
ir The compiler's intermediate code, as a listing
asm The machine code of the native backend, disassembled

Without a path, a file goes next to the DLL as <module>.intermediate.<extension>, such as core.intermediate.lua. It's never core.lua: require "core" looks for Lua files before DLLs, and AutoPlay looks in the DLL's folder, so the project would run that source, interpreted, instead of the compiled module.

rem The DLL, the rewritten project, and the module's Lua source next to the DLL
a2c build MyProject.autoplay --emit dll,project,lua

rem Only the generated C, on screen; nothing is compiled
a2c build tools.lua -t ams8 --emit c=-

rem The DLL and its disassembly, to see what a function became
a2c build tools.lua -t ams9 --emit dll,asm=tools.asm

Note

When you give --emit, only what you list is written. If you leave out dll, no DLL is made, and if you leave out project, the rewritten project isn't written.

Examples

rem A project, with a module named "core"
a2c build MyProject.autoplay --module core

rem A project published with the data folder renamed to "data"
a2c build MyProject.autoplay --data-folder data

rem Serialized objects, keeping every input and one image in the project
a2c build MyProject.autoplay --serialize-objects --tab-order --exclude-kind input --exclude-object "Main::Logo"

rem A module for 64-bit Setup Factory 9.7
a2c build tools.lua --target suf9-x64 -o build\tools.dll

rem A project whose DLL carries the project's version information, at version 2.1
a2c build MyProject.autoplay --version-from-project --file-version 2.1 --product-version 2.1