Replace custom build_lib.sh with canonical hero_lib copy + standardize Makefile #4

Closed
opened 2026-04-19 21:17:46 +00:00 by mahmoud · 3 comments
Owner

Context

scripts/build_lib.sh is a ~18-line custom shim that just runs cargo build --workspace --release. The canonical hero_lib build library provides build_binaries, install_binaries, cargo_env, publish_binaries, forge_config, and hero_service_stop — the build_lib / makefile_helper skills require we source it. The current Makefile also lacks SHELL := /bin/bash, CARGO_ENV, and standard targets (test-all, ci-local, ci-docker, ship-binary, installdev, status, version). Makefile targets use raw socat / pkill for stop/status.

Goals

  • Replace scripts/build_lib.sh with the canonical copy from lhumina_code/hero_lib (or sync script that pulls it).
  • Add scripts/ci-docker.sh for local CI replication.
  • Rewrite Makefile:
    • SHELL := /bin/bash, BUILD_LIB := scripts/build_lib.sh, CARGO_ENV := source $(BUILD_LIB) && cargo_env &&.
    • Targets: build, installdev (debug), install (release), run, stop, status, version, fmt, fmt-check, clippy, test, test-all, ci-local, ci-docker, ship-binary, release, logs-server, logs-ui, clean.
    • Drop socat + pkill; delegate stop/status to the CLI / hero_proc (see #1).
  • Update buildenv.sh: add DOCKER_LINUX_BUILD, ensure BINARIES lists all produced binaries including the CLI (#1) and hero_do_hero_livekit once added.

Related skills: build_lib, build_lib_ci, makefile_helper, makefile_helper_ci.

## Context `scripts/build_lib.sh` is a ~18-line custom shim that just runs `cargo build --workspace --release`. The canonical `hero_lib` build library provides `build_binaries`, `install_binaries`, `cargo_env`, `publish_binaries`, `forge_config`, and `hero_service_stop` — the `build_lib` / `makefile_helper` skills require we source it. The current `Makefile` also lacks `SHELL := /bin/bash`, `CARGO_ENV`, and standard targets (`test-all`, `ci-local`, `ci-docker`, `ship-binary`, `installdev`, `status`, `version`). `Makefile` targets use raw `socat` / `pkill` for stop/status. ## Goals - Replace `scripts/build_lib.sh` with the canonical copy from `lhumina_code/hero_lib` (or sync script that pulls it). - Add `scripts/ci-docker.sh` for local CI replication. - Rewrite `Makefile`: - `SHELL := /bin/bash`, `BUILD_LIB := scripts/build_lib.sh`, `CARGO_ENV := source $(BUILD_LIB) && cargo_env &&`. - Targets: `build`, `installdev` (debug), `install` (release), `run`, `stop`, `status`, `version`, `fmt`, `fmt-check`, `clippy`, `test`, `test-all`, `ci-local`, `ci-docker`, `ship-binary`, `release`, `logs-server`, `logs-ui`, `clean`. - Drop `socat` + `pkill`; delegate stop/status to the CLI / `hero_proc` (see #1). - Update `buildenv.sh`: add `DOCKER_LINUX_BUILD`, ensure `BINARIES` lists all produced binaries including the CLI (#1) and `hero_do_hero_livekit` once added. Related skills: `build_lib`, `build_lib_ci`, `makefile_helper`, `makefile_helper_ci`.
Member

Implementation Spec for Issue #4

Objective

Replace the naive scripts/build_lib.sh with the canonical version from hero_os/hero_lib, standardize the Makefile with SHELL := /bin/bash, BUILD_LIB, CARGO_ENV, and all standard targets, create CI helper scripts, and update buildenv.sh.

Requirements

  • Replace scripts/build_lib.sh with canonical version (forge_config, build_binaries, publish_binaries, cargo_env, etc.)
  • Rewrite Makefile: add SHELL := /bin/bash, BUILD_LIB, CARGO_ENV pattern
  • Add missing targets: help, version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui
  • Fix install to build release (currently builds debug)
  • Create scripts/ci-local.sh, scripts/ci-docker.sh, scripts/ci-patch-deps.sh
  • Update buildenv.sh: add DOCKER_LINUX_BUILD, use ${INSTALL_DIR:-...} pattern

Files to Modify/Create

  • buildenv.sh - Add DOCKER_LINUX_BUILD, fix INSTALL_DIR pattern
  • Makefile - Full rewrite with canonical structure
  • scripts/build_lib.sh - Replace with canonical version from hero_os
  • scripts/ci-local.sh - New: CI without workspace overrides
  • scripts/ci-docker.sh - New: CI in Docker container
  • scripts/ci-patch-deps.sh - New: Cross-repo dep patching for feature branches

Implementation Plan

Step 1: Update buildenv.sh + Replace build_lib.sh

Files: buildenv.sh, scripts/build_lib.sh

  • Add DOCKER_LINUX_BUILD=1 to buildenv.sh
  • Use ${INSTALL_DIR:-$HOME/hero/bin} pattern
  • Add comment about hero_do_hero_livekit being built separately via make build-rhai
  • Replace naive build_lib.sh with canonical version from hero_os
    Dependencies: none

Step 2: Rewrite Makefile

Files: Makefile

  • Add SHELL, BUILD_LIB, CARGO_ENV, VERSION, PORTS variables
  • Add help target as default goal
  • Add version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui targets
  • Fix install to build --release
  • Prefix cargo calls with CARGO_ENV
  • Keep existing run/stop/status/restart functionality (socat/pkill approach stays until issue #1)
    Dependencies: Step 1

Step 3: Create CI scripts

Files: scripts/ci-local.sh, scripts/ci-docker.sh, scripts/ci-patch-deps.sh

  • ci-local.sh: Moves aside parent workspace .cargo/config.toml, runs make test-all
  • ci-docker.sh: Runs CI in same Docker image as Forgejo Actions
  • ci-patch-deps.sh: Patches cross-repo deps on feature branches (reads .forgejo/deps.txt)
  • All based on canonical patterns from hero_archipelagos
    Dependencies: Step 2 (references make targets)

Acceptance Criteria

  • make help displays all available targets
  • make version prints hero_livekit v0.1.0
  • make fmt runs cargo fmt --all
  • make fmt-check runs cargo fmt --check
  • make install builds release binaries (not debug)
  • make installdev builds and installs debug binaries
  • make ci runs fmt-check, check, clippy, test
  • make ship-binary delegates to build_lib.sh ship_binary
  • make release delegates to build_lib.sh release
  • scripts/build_lib.sh contains forge_config, build_binaries, publish_binaries
  • scripts/ci-local.sh and scripts/ci-docker.sh exist and are executable
  • buildenv.sh contains DOCKER_LINUX_BUILD=1

Notes

  • stop/status targets keep existing socat/pkill approach until issue #1 (hero_proc service) is implemented
  • hero_do_hero_livekit is built separately via make build-rhai (requires rhai feature, not compatible with --workspace --features)
  • CI workflow files (build.yml, release.yaml) are NOT modified here -- that is issue #8's scope
## Implementation Spec for Issue #4 ### Objective Replace the naive `scripts/build_lib.sh` with the canonical version from hero_os/hero_lib, standardize the Makefile with `SHELL := /bin/bash`, `BUILD_LIB`, `CARGO_ENV`, and all standard targets, create CI helper scripts, and update `buildenv.sh`. ### Requirements - Replace `scripts/build_lib.sh` with canonical version (forge_config, build_binaries, publish_binaries, cargo_env, etc.) - Rewrite Makefile: add `SHELL := /bin/bash`, `BUILD_LIB`, `CARGO_ENV` pattern - Add missing targets: help, version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui - Fix `install` to build release (currently builds debug) - Create `scripts/ci-local.sh`, `scripts/ci-docker.sh`, `scripts/ci-patch-deps.sh` - Update `buildenv.sh`: add `DOCKER_LINUX_BUILD`, use `${INSTALL_DIR:-...}` pattern ### Files to Modify/Create - `buildenv.sh` - Add DOCKER_LINUX_BUILD, fix INSTALL_DIR pattern - `Makefile` - Full rewrite with canonical structure - `scripts/build_lib.sh` - Replace with canonical version from hero_os - `scripts/ci-local.sh` - New: CI without workspace overrides - `scripts/ci-docker.sh` - New: CI in Docker container - `scripts/ci-patch-deps.sh` - New: Cross-repo dep patching for feature branches ### Implementation Plan #### Step 1: Update buildenv.sh + Replace build_lib.sh Files: `buildenv.sh`, `scripts/build_lib.sh` - Add DOCKER_LINUX_BUILD=1 to buildenv.sh - Use `${INSTALL_DIR:-$HOME/hero/bin}` pattern - Add comment about hero_do_hero_livekit being built separately via make build-rhai - Replace naive build_lib.sh with canonical version from hero_os Dependencies: none #### Step 2: Rewrite Makefile Files: `Makefile` - Add SHELL, BUILD_LIB, CARGO_ENV, VERSION, PORTS variables - Add help target as default goal - Add version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui targets - Fix install to build --release - Prefix cargo calls with CARGO_ENV - Keep existing run/stop/status/restart functionality (socat/pkill approach stays until issue #1) Dependencies: Step 1 #### Step 3: Create CI scripts Files: `scripts/ci-local.sh`, `scripts/ci-docker.sh`, `scripts/ci-patch-deps.sh` - ci-local.sh: Moves aside parent workspace .cargo/config.toml, runs make test-all - ci-docker.sh: Runs CI in same Docker image as Forgejo Actions - ci-patch-deps.sh: Patches cross-repo deps on feature branches (reads .forgejo/deps.txt) - All based on canonical patterns from hero_archipelagos Dependencies: Step 2 (references make targets) ### Acceptance Criteria - [ ] make help displays all available targets - [ ] make version prints hero_livekit v0.1.0 - [ ] make fmt runs cargo fmt --all - [ ] make fmt-check runs cargo fmt --check - [ ] make install builds release binaries (not debug) - [ ] make installdev builds and installs debug binaries - [ ] make ci runs fmt-check, check, clippy, test - [ ] make ship-binary delegates to build_lib.sh ship_binary - [ ] make release delegates to build_lib.sh release - [ ] scripts/build_lib.sh contains forge_config, build_binaries, publish_binaries - [ ] scripts/ci-local.sh and scripts/ci-docker.sh exist and are executable - [ ] buildenv.sh contains DOCKER_LINUX_BUILD=1 ### Notes - stop/status targets keep existing socat/pkill approach until issue #1 (hero_proc service) is implemented - hero_do_hero_livekit is built separately via make build-rhai (requires rhai feature, not compatible with --workspace --features) - CI workflow files (build.yml, release.yaml) are NOT modified here -- that is issue #8's scope
Member

Test Results

  • Total: 34
  • Passed: 34
  • Failed: 0
  • Ignored: 4 (doc-tests)

All workspace tests pass after Makefile standardization and build_lib.sh replacement.

## Test Results - Total: 34 - Passed: 34 - Failed: 0 - Ignored: 4 (doc-tests) All workspace tests pass after Makefile standardization and build_lib.sh replacement.
Member

Implementation Summary

Changes Made

buildenv.sh

  • Added DOCKER_LINUX_BUILD=1 for Docker CI builds
  • Changed INSTALL_DIR to use ${INSTALL_DIR:-$HOME/hero/bin} pattern (environment-overridable)
  • Added comment noting hero_do_hero_livekit is built separately via make build-rhai

scripts/build_lib.sh

  • Replaced naive 22-line build script with canonical 2371-line version from hero_os
  • Provides: forge_config, build_binaries, publish_binaries, setup_linux_toolchain, cargo_env, ci_setup_toolchain, ship_binary, release, and more

Makefile (full rewrite)

  • Added SHELL := /bin/bash, BUILD_LIB, CARGO_ENV canonical structure
  • Added VERSION and PORTS derived from build_lib.sh
  • Added .DEFAULT_GOAL := help with full target listing
  • New targets: help, version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui
  • Fixed install target to build --release (was building debug)
  • All cargo calls use CARGO_ENV for consistent PATH setup
  • stop/status kept with existing socat/pkill approach (TODO: migrate to hero_proc per issue #1)

scripts/ci-local.sh (new)

  • Moves aside parent workspace .cargo/config.toml, runs make test-all, restores on exit

scripts/ci-docker.sh (new)

  • Runs CI in ghcr.io/despiegk/builder:latest Docker container (same as Forgejo Actions)

scripts/ci-patch-deps.sh (new)

  • Generic cross-repo dep patching for feature branches (reads .forgejo/deps.txt)

Test Results

  • 34 passed, 0 failed, 4 ignored (doc-tests)
## Implementation Summary ### Changes Made **buildenv.sh** - Added DOCKER_LINUX_BUILD=1 for Docker CI builds - Changed INSTALL_DIR to use ${INSTALL_DIR:-$HOME/hero/bin} pattern (environment-overridable) - Added comment noting hero_do_hero_livekit is built separately via make build-rhai **scripts/build_lib.sh** - Replaced naive 22-line build script with canonical 2371-line version from hero_os - Provides: forge_config, build_binaries, publish_binaries, setup_linux_toolchain, cargo_env, ci_setup_toolchain, ship_binary, release, and more **Makefile** (full rewrite) - Added SHELL := /bin/bash, BUILD_LIB, CARGO_ENV canonical structure - Added VERSION and PORTS derived from build_lib.sh - Added .DEFAULT_GOAL := help with full target listing - New targets: help, version, fmt, fmt-check, installdev, ci, ci-local, ci-docker, test-all, ship-binary, release, logs-server, logs-ui - Fixed install target to build --release (was building debug) - All cargo calls use CARGO_ENV for consistent PATH setup - stop/status kept with existing socat/pkill approach (TODO: migrate to hero_proc per issue #1) **scripts/ci-local.sh** (new) - Moves aside parent workspace .cargo/config.toml, runs make test-all, restores on exit **scripts/ci-docker.sh** (new) - Runs CI in ghcr.io/despiegk/builder:latest Docker container (same as Forgejo Actions) **scripts/ci-patch-deps.sh** (new) - Generic cross-repo dep patching for feature branches (reads .forgejo/deps.txt) ### Test Results - 34 passed, 0 failed, 4 ignored (doc-tests)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_livekit#4
No description provided.