Building from source
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:
| Way | Needs | Suits |
|---|---|---|
| Go only | Go, a C compiler | Changing only the Go code |
| With Docker | Docker | Installing no toolchain on the machine |
| Full build | Go, a C compiler, Rust, Node.js and Yarn | Changing 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:
go run ./tools/ftmllib -url https://github.com/WikitTeam/ProjectWikit/releases/download/v1.0.0
CGO_ENABLED=1 go build -o pwikit ./cmd/pwikittools/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.
| System | C compiler |
|---|---|
| Linux | gcc or clang, for example apt install build-essential |
| macOS | The Xcode command line tools: xcode-select --install |
| Windows | The 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-dirat a builtstatic/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:
docker build -t pwikit --build-arg VERSION=v1.0.0-local .To take out only the Linux executable, without making an image:
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:
go run ./tools/release build -version v1.0.0-local -out distIt 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:
| Option | Skips |
|---|---|
-skip-frontend | Building the web interface; uses the files already in static/ |
-skip-ftml | Building the renderer library; uses the files already in ftml-capi/target/release/ |
-skip-postgres | Downloading the bundled PostgreSQL; uses the files already in internal/pgbundle/archive/ |
Or build step by step:
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/pwikitOn Windows, compile the renderer library with the GNU toolchain and one extra link argument:
cd ftml-capi
RUSTFLAGS="-C link-arg=-ladvapi32" cargo +stable-x86_64-pc-windows-gnu build --release| Build tag | Builds in |
|---|---|
| none | pwikit alone |
assets | The web interface assets |
bundle | The web interface assets and the bundled PostgreSQL |
nocgo | No 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:
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.shThe version number
The version pwikit version shows is written in at compile time:
CGO_ENABLED=1 go build -tags bundle -ldflags "-X github.com/WikitTeam/ProjectWikit/internal/version.Release=v1.0.0-local" -o pwikit ./cmd/pwikitWithout 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.
