Skip to content

Building from source ​

Simplified Chinese

The release packages and the container image are ready to use, so building is rarely needed. Build pwikit yourself when you have changed its code or need a platform the releases do not cover.

pwikit is Go code plus a wikitext renderer, ftml, written in Rust. The renderer is compiled into a static library that Go links through cgo. Depending on the tools you have, there are three ways to build:

WayNeedsSuits
Go onlyGo, a C compilerChanging only the Go code
With DockerDockerInstalling no toolchain on the machine
Full buildGo, a C compiler, Rust, Node.js and YarnChanging the renderer or the web interface, or making a release package

Every way runs its commands from the repository root.

Go only ​

Download the prebuilt renderer library for the release your source matches, then compile:

sh
go run ./tools/ftmllib -url https://github.com/WikitTeam/ProjectWikit/releases/download/v1.0.0
CGO_ENABLED=1 go build -o pwikit ./cmd/pwikit

tools/ftmllib downloads the libftml_capi.a for this machine into ftml-capi/target/release/ and checks that its interface version is the one the source expects. When it is not, the tool says so; download the release that matches the source, or use the full build.

SystemC compiler
Linuxgcc or clang, for example apt install build-essential
macOSThe Xcode command line tools: xcode-select --install
WindowsThe MinGW-w64 gcc, for example from WinLibs or MSYS2, on PATH

A pwikit built this way carries neither the web interface assets nor the bundled PostgreSQL:

  • Assets: point -static-dir at a built static/ directory at run time, or build them in as in the full build.
  • PostgreSQL: use your own database with -database, or build the bundled one in as in the full build.

With Docker ​

Build the container image:

sh
docker build -t pwikit --build-arg VERSION=v1.0.0-local .

To take out only the Linux executable, without making an image:

sh
docker build --target binary --output dist .

The executable is written to dist/pwikit. It is compiled on Debian 12, needs glibc 2.36 or newer, and carries the web interface assets but not the bundled PostgreSQL.

On Windows and macOS, Docker reaches host directories slowly, and the first build downloads and compiles every dependency, so it takes a while. Later builds reuse Docker's build cache.

Full build ​

Install:

  • Go, at the version in go.mod
  • a C compiler (see above)
  • Rust, through rustup. On Windows, also the GNU toolchain: rustup toolchain install stable-x86_64-pc-windows-gnu
  • Node.js 20 and Yarn

Build a release package with the same program the releases are made with:

sh
go run ./tools/release build -version v1.0.0-local -out dist

It builds the web interface, the renderer library and the bundled PostgreSQL archive, compiles pwikit and packs it into dist/pwikit-<version>-<os>-<arch>.tar.gz (.zip on Windows). Parts already built can be skipped:

OptionSkips
-skip-frontendBuilding the web interface; uses the files already in static/
-skip-ftmlBuilding the renderer library; uses the files already in ftml-capi/target/release/
-skip-postgresDownloading the bundled PostgreSQL; uses the files already in internal/pgbundle/archive/

Or build step by step:

sh
cd frontend && yarn install --frozen-lockfile && yarn build && cd ..
cd ftml-capi && cargo build --release && cd ..
go run ./tools/pgarchive
CGO_ENABLED=1 go build -tags bundle -o pwikit ./cmd/pwikit

On Windows, compile the renderer library with the GNU toolchain and one extra link argument:

sh
cd ftml-capi
RUSTFLAGS="-C link-arg=-ladvapi32" cargo +stable-x86_64-pc-windows-gnu build --release
Build tagBuilds in
nonepwikit alone
assetsThe web interface assets
bundleThe web interface assets and the bundled PostgreSQL
nocgoNo renderer library. For development only; pages cannot be rendered

A package built on Linux needs the glibc of the build machine or newer. Releases are built in a manylinux_2_28 container so they run on any system with glibc 2.28 or newer:

sh
cd frontend && yarn install --frozen-lockfile && yarn build && cd ..
docker run --rm -v "$PWD:/src" -w /src -e VERSION=v1.0.0-local quay.io/pypa/manylinux_2_28_x86_64 sh tools/release/linux.sh

The version number ​

The version pwikit version shows is written in at compile time:

sh
CGO_ENABLED=1 go build -tags bundle -ldflags "-X github.com/WikitTeam/ProjectWikit/internal/version.Release=v1.0.0-local" -o pwikit ./cmd/pwikit

Without it, pwikit version shows the commit the build came from, and such a program neither checks for nor installs new releases; see Updating and rolling back.