#!/usr/bin/env bash # Build KiCad's PCB editor as WebAssembly (PCBJam port of KiCad 10.0.6) with BuildKit. # kicad-web/build.sh [out-dir] default out-dir: kicad-web/dist # Env: PCBJAM_REF (pinned commit), BUILDER (buildx builder, default: the current one), JOBS (default 16), # KICAD_RELEASE=1 (PCBJam's --release build instead of its default, tested one), # PCBJAM_DIR (checkout location, default cache/pcbjam). set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" root="$(dirname "$here")" ref="${PCBJAM_REF:-89cef1c}" src="${PCBJAM_DIR:-$root/cache/pcbjam}" out="${1:-$here/dist}" if [ ! -d "$src/.git" ]; then git clone -q https://github.com/emergence-engineering/pcbjam.git "$src" fi git -C "$src" fetch -q origin git -C "$src" checkout -q "$ref" git -C "$src" submodule update --init --depth 50 kicad wxwidgets git -C "$src/wxwidgets" submodule update --init --recursive --depth 1 source "$src/scripts/common/versions.sh" docker buildx build ${BUILDER:+--builder "$BUILDER"} --progress=plain \ -f "$here/Dockerfile" \ --build-arg EMSCRIPTEN_VERSION="$EMSCRIPTEN_VERSION" \ --build-arg EMSDK_TARBALL_SHA256="$EMSDK_TARBALL_SHA256" \ --build-arg JOBS="${JOBS:-16}" \ --build-arg KICAD_RELEASE="${KICAD_RELEASE:-0}" \ --target out --output type=local,dest="$out" "$src" ls -l "$out"