Standard library · Web and browser

gui/webview/bundle

What salam bundle runs to make installers.

import gui.webview.bundle

This package is what runs when you type salam bundle. It reads the [app] table of salam.toml, builds the program, packs its assets and makes installers. See making installers for how to use it.

The [app] table

Everything salam bundle needs is in the [app] table of salam.toml. Only id and name matter much: the version defaults to 0.1.0, the entry file to main.salam and the category to Utility. slug is made from the name for file names. ReadManifest returns false when there is no table.

gui-webview-bundle-guide-manifest.salam
import gui.webview.bundle
import io

func main:
    text := "[app]\nid = \"com.example.notes\"\nname = \"Notes\"\nversion = \"1.2.0\"\nassets = \"www\"\ncategory = \"Utility\"\n"
    io.WriteFile("salam.toml", text)
    mut m := bundle.Manifest {}
    if not bundle.ReadManifest("salam.toml", m):
        println "no [app] table"
        ret 1
    end
    println m.id
    println m.name, m.version
    println "main file:", m.main
    println "assets:", m.assets
    println "file name:", m.slug
end
Outputcom.example.notes Notes 1.2.0 main file: main.salam assets: www file name: notes

Formats and targets

The default formats are tar and deb on Linux, zip on Windows, and app and tar on macOS. Name others with --format; each needs its tool on the PATH.

$ salam bundle --format=rpm,appimage      # rpmbuild, appimagetool
$ salam bundle --target=x86_64-w64-windows-gnu --format=nsis   # makensis
$ salam bundle --target=arm64-apple-macos --format=app,dmg     # hdiutil
$ salam bundle --output=dist

A cross build needs no extra software, because the compiler links Windows and macOS programs itself. A PNG icon is converted to .ico and .icns. Nothing is signed, so sign and notarize before you hand a program to other people.

The web engine is part of the [app] table too. By default a program uses the web view of the operating system. Set engine = "chromium", or pass --engine=chromium, to build against Chromium Embedded Framework, and point runtime (or --runtime=DIR, or the SALAM_CEF_DIR environment variable) at the folder with the built salam_webview_cef library, salam_cef_helper and the CEF runtime files. That folder is copied next to the program, and only for tar on Linux and zip on Windows. See choosing the web engine for what the Chromium engine can do today.

Building installers in CI

Run the same command on one Linux runner for every system, passing a different --target and --output each time, and upload the results. The desktop.yml workflow in the Salam repository does this and then runs each result on a real Windows, macOS and Linux machine.

Types

Manifest

struct Manifest
The [app] table of salam.toml.
NameTypeDescription
idstr = ""The application id.
namestr = ""The name people see.
versionstr = "0.1.0"The version.
mainstr = "main.salam"The entry file, main.salam by default.
assetsstr = ""The folder packed into the application.
iconstr = ""A PNG icon; it is converted for each system.
descriptionstr = ""One line about the application.
publisherstr = ""Who publishes it.
categorystr = "Utility"The desktop menu category.
slugstr = ""The file name made from the name.
enginestr = "system"The web engine of the program: system (the web view of the operating system, the default) or chromium.
runtimestr = ""The folder with the Chromium runtime files, used with the chromium engine.
gui-webview-bundle-Main.salam
import gui.webview.bundle
import os

func main:
    mut m := bundle.Manifest {
        id = "com.example.app", name = "App", version = "1.0", main = "main.salam", assets = "www", icon = "icon.png", description = "An app", publisher = "Example", category = "Utility", slug = "app", engine = "system", runtime = ""
    }
    println bundle.ReadManifest("salam.toml", m), m.name
    ret bundle.Main(os.Args())
end

Functions

ReadManifest

func ReadManifest(path: str, out &: Manifest): bool
Reads the [app] table of a file.

The example for this item is shown with the ones above: gui-webview-bundle-Main.salam

Main

func Main(args: Vector<str>): int
What salam bundle runs. Returns the exit code.

The example for this item is shown with the ones above: gui-webview-bundle-Main.salam