diff --git a/build.bat b/build.bat index a513c45c..0f13789e 100644 --- a/build.bat +++ b/build.bat @@ -1,10 +1,11 @@ @echo off -setlocal +setlocal enabledelayedexpansion REM This script is a wrapper for build.ps1 to allow execution from a standard command prompt. set "TARGET=windows-dev" set "CLEAN_ARG=" +set "FEATURE_ARG=" set "ARGS=" :arg_loop @@ -13,6 +14,13 @@ if /i "%~1"=="--clean" ( set "CLEAN_ARG=-Clean" ) else if /i "%~1"=="--android" ( set "TARGET=android" +) else if /i "%~1"=="--feature" ( + if defined FEATURE_ARG ( + set "FEATURE_ARG=!FEATURE_ARG!,%~2" + ) else ( + set "FEATURE_ARG=%~2" + ) + shift ) else ( REM Assuming the first non-flag argument is the target if /i "%~1"=="windows" ( @@ -26,7 +34,10 @@ goto arg_loop :end_arg_loop set "ARGS=-Target %TARGET% %CLEAN_ARG%" +if defined FEATURE_ARG ( + set "ARGS=!ARGS! -Feature !FEATURE_ARG!" +) -powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0\build.ps1" %ARGS% +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0\build.ps1" !ARGS! exit /b %errorlevel% diff --git a/build.ps1 b/build.ps1 index 59e8c3e0..42d75306 100644 --- a/build.ps1 +++ b/build.ps1 @@ -27,7 +27,10 @@ param ( [string]$Target = "windows-dev", [Parameter()] - [switch]$Clean = $false + [switch]$Clean = $false, + + [Parameter()] + [string[]]$Feature = @() ) $ErrorActionPreference = "Stop" @@ -98,8 +101,23 @@ function Build-Native { } } + $ExtraArgs = @() + if ($Feature.Count -gt 0) { + $FeatureString = $Feature -join "," + $ExtraArgs += "-DVCPKG_MANIFEST_FEATURES=$FeatureString" + if ($Feature -contains "avif") { + $ExtraArgs += "-DWITH_AVIF=ON" + } + } + Write-Log "Configuring ($Preset)..." - cmake --preset $Preset + if ($ExtraArgs.Count -gt 0) { + Write-Log "Features: $($Feature -join ",")" + cmake --preset $Preset $ExtraArgs + } else { + cmake --preset $Preset + } + if ($LASTEXITCODE -ne 0) { throw "Configuration failed." } Write-Log "Building ($Preset)..." diff --git a/build.sh b/build.sh index c3738d83..e6347d56 100755 --- a/build.sh +++ b/build.sh @@ -81,17 +81,32 @@ ensure_ios_deps() { PRESET="" CLEAN=0 TARGET_ANDROID=0 +FEATURES="" +EXTRA_CMAKE_ARGS="" # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --clean) CLEAN=1; shift ;; --android) TARGET_ANDROID=1; shift ;; + --feature) + if [ -n "$FEATURES" ]; then + FEATURES="$FEATURES,$2" + else + FEATURES="$2" + fi + + if [ "$2" == "avif" ]; then + EXTRA_CMAKE_ARGS="$EXTRA_CMAKE_ARGS -DWITH_AVIF=ON" + fi + shift 2 + ;; --help|-h) echo "Usage: ./build.sh [options] [preset]" echo "Options:" - echo " --clean Clean build directory before building" - echo " --android Build for Android" + echo " --clean Clean build directory before building" + echo " --android Build for Android" + echo " --feature Enable a feature (e.g. avif)" echo "Presets (auto-detected if omitted):" echo " macos-arm64, macos-x64, linux-release, mingw" exit 0 @@ -100,6 +115,10 @@ while [[ $# -gt 0 ]]; do esac done +if [ -n "$FEATURES" ]; then + EXTRA_CMAKE_ARGS="$EXTRA_CMAKE_ARGS -DVCPKG_MANIFEST_FEATURES=$FEATURES" +fi + # Android Build if [ "$TARGET_ANDROID" -eq 1 ]; then ensure_tsc @@ -130,8 +149,8 @@ if [ "$CLEAN" -eq 1 ]; then rm -rf "$PROJECT_ROOT/out/build/$PRESET" fi -log "Configuring preset: $PRESET" -cmake --preset "$PRESET" +log "Configuring preset: $PRESET (Features: $FEATURES)" +cmake --preset "$PRESET" $EXTRA_CMAKE_ARGS log "Building preset: $PRESET" cmake --build --preset "$PRESET" \ No newline at end of file