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