fixup libjxl build

This commit is contained in:
2026-03-27 09:24:21 -05:00
parent d001965e71
commit bd2f457181
6 changed files with 37 additions and 29 deletions
+10 -2
View File
@@ -301,6 +301,14 @@ print_os() {
echo "${FB_OS}"
}
set_sudo() {
if is_windows || test "$(id -u)" -eq 0; then
SUDO=''
else
SUDO='sudo '
fi
}
is_positive_integer() {
local input="$1"
if [[ ${input} != ?(-)+([[:digit:]]) || ${input} -lt 0 ]]; then
@@ -431,7 +439,7 @@ have_required_version() {
recreate_dir() {
local dirs=("$@")
for dir in "${dirs[@]}"; do
test -d "${dir}" && rm -rf "${dir}"
test -d "${dir}" && ${SUDO_MODIFY} rm -rf "${dir}"
mkdir -p "${dir}" || return 1
done
}
@@ -439,7 +447,7 @@ recreate_dir() {
ensure_dir() {
local dirs=("$@")
for dir in "${dirs[@]}"; do
test -d "${dir}" || mkdir -p "${dir}" || return 1
test -d "${dir}" || ${SUDO_MODIFY} mkdir -p "${dir}" || return 1
done
}
+20 -13
View File
@@ -31,6 +31,9 @@ set_compile_opts() {
BUILD_TYPE
NO_BUILD_TYPE
SHARED
BINDIR
LIBDIR
INCDIR
)
unset "${BUILD_ENV_NAMES[@]}"
export "${EXPORTED_ENV_NAMES[@]}"
@@ -39,6 +42,10 @@ set_compile_opts() {
JOBS="$(nproc)"
# local vs system prefix
test "${PREFIX}" == 'local' && PREFIX="${LOCAL_PREFIX}"
# relevant prefix directories
BINDIR="${PREFIX}/bin"
LIBDIR="${PREFIX}/lib"
INCDIR="${PREFIX}/include"
# check if we need to handle PREFIX with sudo
local testfile=''
@@ -53,14 +60,11 @@ set_compile_opts() {
SUDO_MODIFY=''
else
SUDO_MODIFY="${SUDO}"
echo_warn "using ${SUDO}to install"
${SUDO_MODIFY} mkdir -p "${PREFIX}/bin/" || return 1
echo_warn "using ${SUDO}to modify PREFIX"
fi
test -f "${testfile}" && ${SUDO_MODIFY} rm "${testfile}"
test -d "${PREFIX}" || { ${SUDO_MODIFY} mkdir -p "${PREFIX}" || return 1; }
ensure_dir "${BINDIR}" || return 1
# set library/pkgconfig directory
LIBDIR="${PREFIX}/lib"
LDFLAGS_ARR=("-L${LIBDIR}")
# android has different library location/names
@@ -182,7 +186,7 @@ fi' >"${compilerDir}/which"
# add prefix include
# TODO use cygpath for windows
CPPFLAGS_ARR+=("-I${PREFIX}/include")
CPPFLAGS_ARR+=("-I${INCDIR}")
# if PGO is enabled, first build run will be to generate
# second run will be to use generated profdata
@@ -684,11 +688,11 @@ build() {
# skip packaging on PGO generate run
if [[ ${PGO} == 'ON' && ${PGO_RUN} == 'generate' ]]; then
PATH="${PREFIX}/bin:${PATH}" gen_profdata
PATH="${BINDIR}:${PATH}" gen_profdata
return $?
fi
local ffmpegBin="${PREFIX}/bin/ffmpeg"
local ffmpegBin="${BINDIR}/ffmpeg"
# run ffmpeg to show completion
"${ffmpegBin}" -version || return 1
@@ -698,8 +702,8 @@ build() {
if [[ ${ffmpeg} != "${ffmpegBin}" ]]; then
echo
echo_warn "ffmpeg in path (${ffmpeg}) is not the built one (${ffmpegBin})"
echo_info "consider adding ${PREFIX}/bin to \$PATH"
echo "echo 'export PATH=\"${PREFIX}/bin:\$PATH\"' >> ~/.bashrc"
echo_info "consider adding ${BINDIR} to \$PATH"
echo "echo 'export PATH=\"${BINDIR}:\$PATH\"' >> ~/.bashrc"
fi
package || return 1
@@ -1072,6 +1076,9 @@ build_libssh() {
}
build_libjxl() {
# jxl headers interfere with this build
recreate_dir "${INCDIR}/jxl" || return 1
meta_cmake_build \
-DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
-DJPEGXL_BUNDLE_LIBPNG=OFF || return 1
@@ -1084,7 +1091,7 @@ build_libjxl() {
if [[ ${STATIC} == ON ]]; then
libs+=(libjxl_extras_codec)
else
libs+=(libjxl_jni)
is_darwin || libs+=(libjxl_jni)
fi
sanitize_sysroot_libs "${libs[@]}" || return 1
}
@@ -1321,7 +1328,7 @@ build_libcrypto() {
cryptoFlags+=(
enable-{brotli,zlib,zstd}
--with-{brotli,zlib,zstd}-include="${PREFIX}/include"
--with-{brotli,zlib,zstd}-include="${INCDIR}"
--with-{brotli,zlib,zstd}-lib="${LIBDIR}"
)
@@ -1405,7 +1412,7 @@ build_ffmpeg() {
meta_configure_build \
"${ffmpegFlags[@]}" || return 1
LTO="${ltoBackup}"
${SUDO_MODIFY} cp ff*_g "${PREFIX}/bin"
${SUDO_MODIFY} cp ff*_g "${BINDIR}"
sanitize_sysroot_libs \
libavcodec libavdevice libavfilter libswscale \
libavformat libavutil libswresample || return 1
+4 -1
View File
@@ -7,7 +7,7 @@
unset FB_COMP_OPTS_DESC
declare -Ag FB_COMP_OPTS_DESC
# default compile options
# default build options
FB_COMP_OPTS_DESC['CLEAN']='clean build directories before building'
DEFAULT_CLEAN=ON
@@ -29,6 +29,9 @@ DEFAULT_ARCH=native
FB_COMP_OPTS_DESC['PREFIX']='prefix to install to, default is local install in ./gitignore/sysroot'
DEFAULT_PREFIX='local'
FB_COMP_OPTS_DESC['PACKAGE']='package ffmpeg binaries to tarball in ./gitignore/package'
DEFAULT_PACKAGE=OFF
FB_COMP_OPTS_DESC['ENABLE']='configure what ffmpeg enables'
DEFAULT_ENABLE="\
libaom \
-8
View File
@@ -2,14 +2,6 @@
# shellcheck disable=SC2120
determine_pkg_mgr() {
# sudo used externally
# shellcheck disable=SC2034
if is_windows || test "$(id -u)" -eq 0; then
SUDO=''
else
SUDO='sudo '
fi
# pkg-mgr update-cmd upgrade-cmd install-cmd check-cmd
# shellcheck disable=SC2016
local PKG_MGR_MAP='
+1 -3
View File
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
check_for_package_cfg() {
local requiredCfg='ON:ON:ON:3'
local currentCfg="${STATIC}:${LTO}:${PGO}:${OPT}"
if [[ ${currentCfg} == "${requiredCfg}" ]]; then
if [[ ${PACKAGE} == 'ON' ]]; then
return 0
else
return 1