# Your own scripts

> CustomBuild runs scripts/build.sh with the tools and releases your group pins, for anything plinto has no build system for.

**CustomBuild builds a project with your own `scripts/build.sh`, with the tools and releases your group pins on hand, for anything plinto has no build system for.**

Build system: `CustomBuild`
Start one: `plinto create custom-build HelloTool`
Ships as: whatever your script writes

## The project {#project}

```text
HelloTool/
  plinto.conf
  scripts/build.sh   writes the release into $PLINTO_OUT (required)
  scripts/test.sh    runs the tests (optional)
```

Both run with `bash`, in the project's folder.

```conf file=plinto.conf
{
  name = HelloTool
  version = 1.0
  build = CustomBuild

  build-dependencies: {
    CustomBuild = 1.0
    Gcc = 15             # a tool: its bin/ on the scripts' PATH
  }
  dependencies: {
    LibOne = 1.0         # its release in $PLINTO_DEPENDENCIES/LibOne
  }
}
```

## What the scripts get {#environment}

| Variable | What it holds |
|---|---|
| `PLINTO_OUT` | the folder the release goes into |
| `PLINTO_TOOLS/<Name>` | each build dependency, with its `bin/` on the `PATH` |
| `PLINTO_DEPENDENCIES/<Name>` | each dependency's release |
| `PLINTO_PROJECT`, `PLINTO_VERSION` | the project's name and version |
| `PLINTO_PLATFORM` | the platform it builds for |
| `PLINTO_RELEASE`, `PLINTO_SKIP_TESTS` | whether it is a release, and whether tests are skipped |

They also run with `SOURCE_DATE_EPOCH`, `TZ=UTC` and `LC_ALL=C.UTF-8` set, so tools that honour them make the same files every time.

## Settings {#settings}

`configuration/CustomBuild.config` takes `platform = host`, the default, for a release made for the machine that builds it, or `platform = any` for one that runs anywhere.

`build.sh` runs once, for `$PLINTO_PLATFORM`: what it compiles is for the machine building, and a custom build has no list of platforms, as Go's [`platforms`](go.md#settings) is. plinto's build service builds on `linux-x64`, so a `platform = host` release runs on x86-64 servers only. For ARM64 servers too, release what runs anywhere with `platform = any`, and have each archive carry its platform's programs as tools: see [A service](#service).

## What it releases {#releases}

What the script writes to `$PLINTO_OUT`, as `HelloTool-1.0.tar.gz`.

## A service {#service}

A project with a `scripts/run.sh` is a service: `plinto run` starts it, and a deployment starts it on your servers. The Archive packager packs what `build.sh` made as the archive's `app/`, with your `scripts/`, and `run.sh` gets these:

| Variable | What it holds |
|---|---|
| `APP_HOME` | the release's folder on the server; the project's folder with `plinto run` |
| `APP_DIR` | what `build.sh` made: `app/` on the server, `build/out` with `plinto run` |
| `APP_TOOLS` | the tools `Archive.tools` lists, one folder each: `tools/` on the server, the build's tools with `plinto run` |

A program a tool brings is for one platform, so leave it out of your release and let each archive carry its own. With `platform = any` in `configuration/CustomBuild.config`, Archive makes an archive per platform, each with the tools' releases for that platform:

```conf file=plinto.conf
Archive: { platforms = [linux-x64, linux-aarch64], tools = [Caddy, CaddyAgent] }
```

`run.sh` then starts `"$APP_TOOLS/Caddy/caddy"`, the server's own. A tool's release has to be made for each platform listed, and a tool released in your workspace is packed for your machine's platform only.

- [Run a script during the build](../guides/build-scripts.md): add a step to any other build system
- [Packages](../concepts/packages.md): the tools a script can use
- [Projects](../concepts/projects.md): what a plinto.conf says
