Skip to content
Adam
Build and run

Projects

A folder, a project.toml, and one command to build it.

The project file

A project is a folder with a project.toml at its root. It is opt-in: a program with none at or above its folder builds from its main module alone (Building).

The file holds a root format (an integer, 1 today), a [project] table with name, type (exe, dll or lib) and main (required strings) and output (optional, output when absent), a [pack] table with an optional password, and an optional [deps] table (Dependencies):

text
format = 1

[project]
name = "mygame"
type = "exe"
main = "src/mygame.adam"
output = "output"

[pack]
password = "..."

main and output are relative to the project's folder and never leave it; main is a .adam file that exists; output is neither the project's folder itself nor inside its src or assets folder. A project name is an identifier that is no Adam keyword in any case and no Windows device name; a pack password is printable ASCII. A key or table project.toml does not know is a warning (PJ0004) and is ignored, never an error.

Making a project

adam init <name> <exe|dll|lib> makes the folder <name> under the current folder with project.toml, src/<name>.adam (a starter for the kind) and an empty assets folder. The new project.toml carries a 64-character pack password from the system's secure random generator.

Building it

adam build <folder> builds the project whose project.toml is in <folder> (the current folder when none is given).

Dependencies

An exe project uses its dll and lib projects through a [deps] table, one line per project: the key is the dependency's project name, the value its folder, relative to this project's (it may leave it).

text
[deps]
mathlib = "../mathlib"
engine = "../engine"

Before the exe is compiled, each dependency is built for the exe's target and mode, its own dependencies first; one reached twice is built once, and its compiled units keep an unchanged one quick. With -o given, the dependencies build into the same output folder; without, each into its own. Each one's binding unit is found by a plain import mathlib, and its library is linked, with no @addmodulepath or @addlibrarypath. A dll dependency's file is copied beside the exe, as the .rez is.

adam deps edits the table from the command line: adam deps add mathlib ../mathlib adds a dependency, checked as a build checks it, adam deps remove mathlib takes one out, and adam deps list prints them; each takes the project's folder last (the current folder when none is given). Only the one [deps] line changes: every other line of project.toml, its comments included, stays as written. A name already there is PJ0021, and removing one that is not there is PJ0022.

A dependency's folder with no project.toml is PJ0017, a key that is not the project's name PJ0018, an exe project PJ0019, and dependencies that lead back to a project already being built PJ0020, the chain named.

The examples under res\examples\language\projects hold one project of each kind: a multi-unit exe, an exe with packed assets, a lib and a dll each used by an exe through [deps], and a lib whose variable, object type and extend an exe binds by hand with external.

Assets

adam pack <folder> zips the project's assets folder into <name>.rez in its output folder, protected by its pack password, and every build copies the .rez beside the exe it writes. adam info <folder> prints the project as one line of JSON, for an editor.

Assets at run time

A program opens its assets from the .rez its build copied beside the exe. CreateZipFileIO("$P:<name>.rez", "<entry>", ProjectPassword()) opens one entry as a read-only IO; CreateZipIOSource("$P:<name>.rez", ProjectPassword()) opens the whole archive as a source to open entries from. With a wrong password an entry opens as nil. Both are in System.CustomIO (Standard library).

ProjectPassword() is the project file's pack password. The build hands it to the program scrambled, so the exe does not hold its plain text. It is "" when the project has none, and it is for project builds only.

A path that starts with $P: is under the folder of the program's exe, and one that starts with $D: or $S: under the working folder. The prefixes mean the same on every target, in the std's file IO, its IO sources and System.IO's paths.

↑ ↓ moveEnter openEsc close