Skip to content
Draft
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
15 changes: 13 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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" (
Expand All @@ -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%
22 changes: 20 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ param (
[string]$Target = "windows-dev",

[Parameter()]
[switch]$Clean = $false
[switch]$Clean = $false,

[Parameter()]
[string[]]$Feature = @()
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -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)..."
Expand Down
27 changes: 23 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <val> Enable a feature (e.g. avif)"
echo "Presets (auto-detected if omitted):"
echo " macos-arm64, macos-x64, linux-release, mingw"
exit 0
Expand All @@ -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
Expand Down Expand Up @@ -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"