Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ jobs:
cd artifacts
# Flatten subdirectories
for dir in */; do
[[ -d "$dir" ]] && mv "$dir"* . 2>/dev/null && rmdir "$dir" 2>/dev/null || true
if [[ -d "$dir" ]]; then
mv "$dir"* . 2>/dev/null || true
rmdir "$dir" 2>/dev/null || true
fi
done

# Verify count
Expand Down
93 changes: 13 additions & 80 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,11 @@ set -euo pipefail
# Resolve script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
readonly SCRIPT_DIR PROJECT_ROOT

# =============================================================================
# Colors
# =============================================================================

if [[ -t 1 ]]; then
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m'
else
readonly RED=''
readonly GREEN=''
readonly YELLOW=''
readonly BLUE=''
readonly NC=''
fi

log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
log_step() { echo -e "${BLUE}[STEP]${NC} $*"; }
# Source shared libraries
source "${PROJECT_ROOT}/scripts/lib/logging.sh"
source "${PROJECT_ROOT}/scripts/lib/common.sh"

# =============================================================================
# Configuration
Expand All @@ -65,9 +47,11 @@ fi
case "$PLATFORM" in
linux-x64)
DOCKER_TARGET="builder-x64"
EXPECTED_ARCH="x86-64"
;;
linux-arm64)
DOCKER_TARGET="builder-arm64"
EXPECTED_ARCH="aarch64"
;;
*)
log_error "Unknown platform: $PLATFORM"
Expand All @@ -76,31 +60,13 @@ case "$PLATFORM" in
;;
esac

# Backwards compatibility: map old values to new
case "$LICENSE" in
bsd|lgpl)
log_warn "DEPRECATION: LICENSE=$LICENSE is deprecated. Use LICENSE=free instead."
LICENSE="free"
;;
gpl)
log_warn "DEPRECATION: LICENSE=gpl is deprecated. Use LICENSE=non-free instead."
LICENSE="non-free"
;;
esac

# Validate license
if [[ ! "$LICENSE" =~ ^(free|non-free)$ ]]; then
log_error "Invalid LICENSE=$LICENSE. Must be: free, non-free"
exit 1
fi
# Normalize license
LICENSE="$(normalize_license "$LICENSE")" || exit 1

# =============================================================================
# Docker Functions
# =============================================================================

#######################################
# Check if Docker is available and running.
#######################################
check_docker() {
if ! command -v docker &>/dev/null; then
log_error "Docker is not installed"
Expand All @@ -114,9 +80,6 @@ check_docker() {
fi
}

#######################################
# Build the Docker image for the platform.
#######################################
build_image() {
local image_name="ffmpeg-build:${PLATFORM}"

Expand All @@ -129,22 +92,14 @@ build_image() {
"${PROJECT_ROOT}"
}

#######################################
# Run the build inside Docker container.
#######################################
run_build() {
run_docker_build() {
local image_name="ffmpeg-build:${PLATFORM}"

log_step "Running build in container..."
log_info "Platform: ${PLATFORM}"
log_info "Target: ${TARGET}"
log_info "License: ${LICENSE}"

# Run build with project mounted
# --rm: Remove container after exit
# -v: Mount project directory
# -e: Pass environment variables
# -w: Set working directory
docker run --rm \
-v "${PROJECT_ROOT}:/build:rw" \
-e "LICENSE=${LICENSE}" \
Expand All @@ -154,10 +109,7 @@ run_build() {
make -C "/build/platforms/${PLATFORM}" LICENSE="${LICENSE}" "${TARGET}"
}

#######################################
# Verify the build output.
#######################################
verify_build() {
verify_docker_build() {
local artifacts_dir="${PROJECT_ROOT}/artifacts/${PLATFORM}-${LICENSE}"
local ffmpeg_bin="${artifacts_dir}/bin/ffmpeg"

Expand All @@ -168,29 +120,10 @@ verify_build() {

log_step "Verifying build..."

# Verify architecture
local expected_arch
case "$PLATFORM" in
linux-x64)
expected_arch="x86-64"
;;
linux-arm64)
expected_arch="aarch64"
;;
esac

local file_output
file_output="$(file "$ffmpeg_bin")"

if ! echo "$file_output" | grep -qi "$expected_arch"; then
log_error "Architecture mismatch!"
log_error "Expected: $expected_arch"
log_error "Got: $file_output"
if ! verify_binary_arch "$ffmpeg_bin" "$EXPECTED_ARCH"; then
exit 1
fi

log_info "Architecture verified: $expected_arch"

# Verify static linking (only libc, libm, libpthread should be dynamic)
log_step "Checking dynamic dependencies..."
if command -v ldd &>/dev/null && [[ "$PLATFORM" == "linux-x64" ]]; then
Expand All @@ -214,10 +147,10 @@ main() {

check_docker
build_image
run_build
run_docker_build

if [[ "$TARGET" == "all" ]] || [[ "$TARGET" == "package" ]]; then
verify_build
verify_docker_build

local artifacts_dir="${PROJECT_ROOT}/artifacts/${PLATFORM}-${LICENSE}"
echo ""
Expand Down
2 changes: 1 addition & 1 deletion openspec/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ Each platform's `config.mk` sets: `LIBVPX_TARGET`, `X264_HOST`, `AOM_TARGET_CPU`
- npm registry (@pproenca scope)

**Version Management:**
All versions, URLs, and checksums centralized in `shared/versions.mk`. Bump `CACHE_VERSION` to invalidate CI cache.
All versions, URLs, and checksums centralized in `shared/versions.mk`.
25 changes: 2 additions & 23 deletions platforms/darwin-arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ include $(ROOT_DIR)/config.mk
include $(PROJECT_ROOT)/shared/verify.mk
include $(PROJECT_ROOT)/shared/codecs/pkgconfig.mk
include $(PROJECT_ROOT)/shared/codecs/codec.mk
include $(PROJECT_ROOT)/shared/ffmpeg.mk

# =============================================================================
# Include Individual Codec Build Rules (from shared)
Expand Down Expand Up @@ -124,29 +125,7 @@ FFMPEG_BASE_OPTS := \
--disable-podpages \
--disable-txtpages

FFMPEG_BSD_OPTS := \
--enable-libvpx \
--enable-libaom \
--enable-libsvtav1 \
--enable-libdav1d \
--enable-libopus \
--enable-libvorbis

FFMPEG_LGPL_OPTS := \
--enable-libmp3lame

FFMPEG_GPL_OPTS := \
--enable-gpl \
--enable-libx264 \
--enable-libx265

ifeq ($(LICENSE),free)
FFMPEG_LICENSE_OPTS := $(FFMPEG_BSD_OPTS) $(FFMPEG_LGPL_OPTS)
else
# non-free: includes GPL codecs
FFMPEG_LICENSE_OPTS := $(FFMPEG_BSD_OPTS) $(FFMPEG_LGPL_OPTS) $(FFMPEG_GPL_OPTS)
endif

# FFmpeg codec options (BSD, LGPL, GPL) defined in shared/ffmpeg.mk
FFMPEG_CONFIGURE_OPTS := $(FFMPEG_BASE_OPTS) $(FFMPEG_LICENSE_OPTS)

# -----------------------------------------------------------------------------
Expand Down
Loading
Loading