Skip to content

Conversation

@pproenca
Copy link
Owner

@pproenca pproenca commented Jan 9, 2026

Summary

  • Create shared logging and build utility libraries to eliminate code duplication
  • Extract common FFmpeg codec options to shared/ffmpeg.mk
  • Refactor all platform build scripts to use centralized functions
  • Standardize config.mk files across platforms
  • Remove unused variables and fix terminal detection bug

Changes

New Shared Libraries

File Purpose
scripts/lib/logging.sh Centralized logging functions with terminal detection
scripts/lib/common.sh Shared build functions: normalize_license(), verify_binary_arch(), install_cmake_3x()
shared/ffmpeg.mk Common FFmpeg codec options (BSD, LGPL, GPL)

Files Refactored

  • platforms/darwin-arm64/build.sh (319 → 179 lines)
  • platforms/darwin-x64/build.sh (267 → 199 lines)
  • platforms/linux-arm64/build.sh (217 → 167 lines)
  • platforms/linux-x64/build.sh (208 → 159 lines)
  • docker/build.sh (233 → 165 lines)
  • All 4 platform Makefiles now include shared/ffmpeg.mk

Fixes

  • darwin-x64: Added terminal detection for colors (was missing)
  • darwin configs: Added STRIP variable for consistency with linux

Removed Unused Code

  • CACHE_VERSION from shared/versions.mk
  • AUTOCONF_DARWIN_ARGS from shared/codecs/codec.mk
  • PARALLEL_CODECS from shared/codecs/codec.mk
  • validate_versions macro from shared/versions.mk

Test plan

  • Run mise run lint to verify shell/yaml syntax
  • Run shellcheck scripts/lib/*.sh platforms/*/build.sh docker/build.sh
  • Verify Makefile parsing with make -C platforms/<platform> -n help
  • Run a full build on at least one platform

- Create scripts/lib/logging.sh with centralized logging functions
- Create scripts/lib/common.sh with shared build utilities (normalize_license, verify_binary_arch, install_cmake_3x)
- Create shared/ffmpeg.mk with common FFmpeg codec options (BSD, LGPL, GPL)
- Refactor all platform build.sh scripts to use shared libraries
- Update docker/build.sh to use shared libraries
- Add STRIP variable to darwin config.mk files for consistency with linux
- Fix darwin-x64 terminal detection (was missing [[ -t 1 ]] check)
- Remove unused variables: CACHE_VERSION, AUTOCONF_DARWIN_ARGS, PARALLEL_CODECS, validate_versions
Replace `A && B && C || D` pattern with proper if-then-else to avoid
ambiguous control flow that shellcheck warns about.
@pproenca pproenca merged commit 24b5f77 into master Jan 9, 2026
4 of 5 checks passed
@pproenca pproenca deleted the refactor/code-simplification branch January 9, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants