create linux bundles under the prebuilt directory

This commit is contained in:
Taner Sener 2022-08-02 01:32:16 +03:00
parent ba2b668c84
commit e4e97f59ce
10 changed files with 163 additions and 28 deletions

View File

@ -203,3 +203,17 @@ for run_arch in {0..12}; do
done
fi
done
# BUILD FFMPEG-KIT BUNDLE
if [[ -n ${TARGET_ARCH_LIST[0]} ]]; then
echo -e -n "\nCreating the bundle under prebuilt: "
echo -e "DEBUG: Creating the bundle directory\n" 1>>"${BASEDIR}"/build.log 2>&1
initialize_folder "${BASEDIR}/prebuilt/$(get_bundle_directory)"
create_linux_bundle
echo -e "ok\n"
fi

2
linux/configure vendored
View File

@ -6220,7 +6220,7 @@ CFLAGS="$cflags_bckup"
FFMPEG_LIBS="-lavcodec -lavfilter -lavformat -lavutil -lswscale -lswresample"
VERSION_INFO="5:5:1"
VERSION_INFO="9:1:5"
case `pwd` in

View File

@ -27,7 +27,7 @@ CFLAGS="$cflags_bckup"
FFMPEG_LIBS="-lavcodec -lavfilter -lavformat -lavutil -lswscale -lswresample"
AC_SUBST(FFMPEG_LIBS)
VERSION_INFO="5:5:1"
VERSION_INFO="9:1:5"
AC_SUBST(VERSION_INFO)
LT_INIT

View File

@ -17,7 +17,9 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fftools_ffmpeg.h"
extern "C" {
#include "fftools_ffmpeg.h"
}
#include "ArchDetect.h"
#include "FFmpegKit.h"
#include "FFmpegKitConfig.h"

View File

@ -19,9 +19,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "libavutil/ffversion.h"
#include "libavutil/bprint.h"
#include "fftools_ffmpeg.h"
extern "C" {
#include "libavutil/ffversion.h"
#include "libavutil/bprint.h"
#include "fftools_ffmpeg.h"
}
#include "ArchDetect.h"
#include "FFmpegKit.h"
#include "FFmpegKitConfig.h"
@ -91,12 +93,22 @@ __thread volatile long globalSessionId = 0;
/** Holds the default log level */
int configuredLogLevel = ffmpegkit::LevelAVLogInfo;
#ifdef __cplusplus
extern "C" {
#endif
/** Forward declaration for function defined in fftools_ffmpeg.c */
int ffmpeg_execute(int argc, char **argv);
/** Forward declaration for function defined in fftools_ffprobe.c */
int ffprobe_execute(int argc, char **argv);
void ffmpegkit_log_callback_function(void *ptr, int level, const char* format, va_list vargs);
#ifdef __cplusplus
}
#endif
static std::once_flag ffmpegKitInitializerFlag;
void* ffmpegKitInitialize();
@ -391,12 +403,16 @@ static void removeSession(long sessionId) {
std::atomic_store(&sessionMap[sessionId % SESSION_MAP_SIZE], 0);
}
#ifdef __cplusplus
extern "C" {
#endif
/**
* Adds a cancel session request to the session map.
*
* @param sessionId session id
*/
static void cancelSession(long sessionId) {
void cancelSession(long sessionId) {
std::atomic_store(&sessionMap[sessionId % SESSION_MAP_SIZE], 2);
}
@ -406,7 +422,7 @@ static void cancelSession(long sessionId) {
* @param sessionId session id
* @return 1 if exists, false otherwise
*/
static int cancelRequested(long sessionId) {
int cancelRequested(long sessionId) {
if (std::atomic_load(&sessionMap[sessionId % SESSION_MAP_SIZE]) == 2) {
return 1;
} else {
@ -414,6 +430,10 @@ static int cancelRequested(long sessionId) {
}
}
#ifdef __cplusplus
}
#endif
/**
* Resets the number of messages in transmit for this session.
*
@ -1182,6 +1202,8 @@ std::shared_ptr<ffmpegkit::Session> ffmpegkit::FFmpegKitConfig::getLastCompleted
return session;
}
}
return nullptr;
}
std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::Session>>> ffmpegkit::FFmpegKitConfig::getSessions() {

View File

@ -182,23 +182,6 @@ is_apple_architecture_variant_supported() {
echo "${SUPPORTED}"
}
#
# 1. folder path
#
initialize_folder() {
rm -rf "$1" 1>>"${BASEDIR}"/build.log 2>&1
if [[ $? -ne 0 ]]; then
return 1
fi
mkdir -p "$1" 1>>"${BASEDIR}"/build.log 2>&1
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
}
#
# 1. architecture variant
#

View File

@ -9,7 +9,7 @@ enable_default_linux_architectures() {
}
get_ffmpeg_kit_version() {
local FFMPEG_KIT_VERSION=$(grep '#define FFMPEG_KIT_VERSION' "${BASEDIR}"/linux/src/main/cpp/ffmpegkit.h | grep -Eo '\".*\"' | sed -e 's/\"//g')
local FFMPEG_KIT_VERSION=$(grep -Eo 'FFmpegKitVersion = .*' "${BASEDIR}/linux/src/FFmpegKitConfig.h" 2>>"${BASEDIR}"/build.log | grep -Eo ' \".*' | tr -d '"; ')
echo "${FFMPEG_KIT_VERSION}"
}
@ -90,6 +90,72 @@ enable_lts_build() {
export FFMPEG_KIT_LTS_BUILD="1"
}
install_pkg_config_file() {
local FILE_NAME="$1"
local SOURCE="${INSTALL_PKG_CONFIG_DIR}/${FILE_NAME}"
local DESTINATION="${FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY}/${FILE_NAME}"
# DELETE OLD FILE
rm -f "$DESTINATION" 2>>"${BASEDIR}"/build.log
if [[ $? -ne 0 ]]; then
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
# INSTALL THE NEW FILE
cp "$SOURCE" "$DESTINATION" 2>>"${BASEDIR}"/build.log
if [[ $? -ne 0 ]]; then
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
# UPDATE PATHS
${SED_INLINE} "s|${LIB_INSTALL_BASE}/ffmpeg-kit|${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit|g" "$DESTINATION" 1>>"${BASEDIR}"/build.log 2>&1 || return 1
${SED_INLINE} "s|${LIB_INSTALL_BASE}/ffmpeg|${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit|g" "$DESTINATION" 1>>"${BASEDIR}"/build.log 2>&1 || return 1
}
get_bundle_directory() {
local LTS_POSTFIX=""
if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]]; then
LTS_POSTFIX="-lts"
fi
echo "bundle-linux${LTS_POSTFIX}"
}
create_linux_bundle() {
set_toolchain_paths ""
local FFMPEG_KIT_VERSION=$(get_ffmpeg_kit_version)
local FFMPEG_KIT_BUNDLE_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit"
local FFMPEG_KIT_BUNDLE_INCLUDE_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include"
local FFMPEG_KIT_BUNDLE_LIB_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib"
local FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY="${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/pkgconfig"
initialize_folder "${FFMPEG_KIT_BUNDLE_INCLUDE_DIRECTORY}"
initialize_folder "${FFMPEG_KIT_BUNDLE_LIB_DIRECTORY}"
initialize_folder "${FFMPEG_KIT_BUNDLE_PKG_CONFIG_DIRECTORY}"
# COPY HEADERS
cp -r -P "${LIB_INSTALL_BASE}"/ffmpeg-kit/include/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log
cp -r -P "${LIB_INSTALL_BASE}"/ffmpeg/include/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log
cp -r -P ${FFMPEG_KIT_TMPDIR}/source/rapidjson/include/rapidjson "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/include" 2>>"${BASEDIR}"/build.log
# COPY LIBS
cp -P "${LIB_INSTALL_BASE}"/ffmpeg-kit/lib/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib" 2>>"${BASEDIR}"/build.log
cp -P "${LIB_INSTALL_BASE}"/ffmpeg/lib/* "${BASEDIR}/prebuilt/$(get_bundle_directory)/ffmpeg-kit/lib" 2>>"${BASEDIR}"/build.log
install_pkg_config_file "libavformat.pc"
install_pkg_config_file "libswresample.pc"
install_pkg_config_file "libswscale.pc"
install_pkg_config_file "libavdevice.pc"
install_pkg_config_file "libavfilter.pc"
install_pkg_config_file "libavcodec.pc"
install_pkg_config_file "libavutil.pc"
install_pkg_config_file "ffmpeg-kit.pc"
}
get_cmake_system_processor() {
case ${ARCH} in
x86-64)
@ -309,6 +375,25 @@ prefix = '${LIB_INSTALL_PREFIX}'
EOF
}
create_ffmpegkit_package_config() {
local FFMPEGKIT_VERSION="$1"
cat >"${INSTALL_PKG_CONFIG_DIR}/ffmpeg-kit.pc" <<EOF
prefix=${LIB_INSTALL_BASE}/ffmpeg-kit
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: ffmpeg-kit
Description: FFmpeg for applications
Version: ${FFMPEGKIT_VERSION}
Libs: -L\${libdir} -lstdc++ -lffmpegkit -lavutil
Requires: libavfilter, libswscale, libavformat, libavcodec, libswresample, libavutil
Cflags: -I\${includedir}
EOF
}
create_libaom_package_config() {
local AOM_VERSION="$1"

View File

@ -2384,8 +2384,8 @@ to_capital_case() {
# 2. destination file
#
overwrite_file() {
rm -f "$2"
cp "$1" "$2"
rm -f "$2" 2>>"${BASEDIR}"/build.log
cp "$1" "$2" 2>>"${BASEDIR}"/build.log
}
#
@ -2438,3 +2438,20 @@ command_exists() {
echo 1
fi
}
#
# 1. folder path
#
initialize_folder() {
rm -rf "$1" 1>>"${BASEDIR}"/build.log 2>&1
if [[ $? -ne 0 ]]; then
return 1
fi
mkdir -p "$1" 1>>"${BASEDIR}"/build.log 2>&1
if [[ $? -ne 0 ]]; then
return 1
fi
return 0
}

View File

@ -61,6 +61,9 @@ make -j$(get_cpu_count) 1>>"${BASEDIR}"/build.log 2>&1
make install 1>>"${BASEDIR}"/build.log 2>&1
# CREATE PACKAGE CONFIG MANUALLY
create_ffmpegkit_package_config "$(get_ffmpeg_kit_version)" || return 1
if [ $? -eq 0 ]; then
echo "ok"
else

View File

@ -449,6 +449,15 @@ if [[ $? -ne 0 ]]; then
exit 1
fi
# MANUALLY COPY PKG-CONFIG FILES
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavformat.pc "${INSTALL_PKG_CONFIG_DIR}/libavformat.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libswresample.pc "${INSTALL_PKG_CONFIG_DIR}/libswresample.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libswscale.pc "${INSTALL_PKG_CONFIG_DIR}/libswscale.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavdevice.pc "${INSTALL_PKG_CONFIG_DIR}/libavdevice.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavfilter.pc "${INSTALL_PKG_CONFIG_DIR}/libavfilter.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavcodec.pc "${INSTALL_PKG_CONFIG_DIR}/libavcodec.pc" || return 1
overwrite_file "${FFMPEG_LIBRARY_PATH}"/lib/pkgconfig/libavutil.pc "${INSTALL_PKG_CONFIG_DIR}/libavutil.pc" || return 1
# MANUALLY ADD REQUIRED HEADERS
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/x86 1>>"${BASEDIR}"/build.log 2>&1
mkdir -p "${FFMPEG_LIBRARY_PATH}"/include/libavutil/arm 1>>"${BASEDIR}"/build.log 2>&1