Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .devcontainer
Submodule .devcontainer added at 917b29
25 changes: 25 additions & 0 deletions .github/workflows/xpbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:
jobs:
linux:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
with:
cmake-workflow-preset: LinuxRelease
runon: ubuntu-latest
secrets: inherit
linux-arm64:
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
with:
cmake-workflow-preset: LinuxRelease
runon: ubuntu-24.04-arm
secrets: inherit
macos:
uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2
with:
cmake-workflow-preset: DarwinRelease
secrets: inherit
20 changes: 20 additions & 0 deletions .github/workflows/xprelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
workflow_dispatch:
inputs:
workflow_run_url:
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
required: true
type: string
jobs:
# Upload build artifacts as release assets
release-from-build:
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.2
with:
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
artifact_pattern: "*.tar.xz"
permissions:
contents: write
id-token: write
attestations: write
secrets: inherit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
/src
/mapfile
/tools/python/__pycache__/
# externpro
.env
_bld*/
docker-compose.override.yml
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".devcontainer"]
path = .devcontainer
url = https://github.com/externpro/externpro
76 changes: 76 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.31)
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)
project(FFmpeg)
include(GNUInstallDirs)
include(xpflags)
set(libs # libraries, in linking order
# https://github.com/FFmpeg/FFmpeg/blob/n2.6.2/configure#L2667-L2675
avdevice
avfilter
avformat
avcodec
swresample
swscale
avutil
)
string(JOIN "\n" EXT1
"# libraries, in linking order"
"# https://github.com/FFmpeg/FFmpeg/blob/n2.6.2/configure#L2667-L2675"
"# TRICKY ffmpeg_all_libs used by FFmpeg-targets.cmake"
"set(ffmpeg_all_libs ${libs})"
"# FFMPEG_LIBRARIES - the FFmpeg libraries"
"set(FFMPEG_LIBRARIES \${ffmpeg_all_libs})"
"list(TRANSFORM FFMPEG_LIBRARIES PREPEND ffmpeg::)"
"list(APPEND reqVars FFMPEG_LIBRARIES)"
""
)
if(NOT DEFINED XP_INSTALL_CMAKEDIR)
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake)
endif()
set(targetsFile ${PROJECT_NAME}-targets)
xpPackageDevel(TARGETS_FILE ${targetsFile} DEPS openh264)
install(FILES cmake/${targetsFile}.cmake DESTINATION ${XP_INSTALL_CMAKEDIR})
string(TOLOWER ${PROJECT_NAME} prj)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(cmake/configure.cmake)
set(incDir ${CMAKE_INSTALL_INCLUDEDIR}/${prj})
foreach(lib ${libs})
add_subdirectory(lib${lib}) # each library installs headers to incDir
endforeach()
else()
find_package(openh264)
find_package(yasm)
get_filename_component(yasmBinDir ${xpuse-yasm_DIR}/../../bin ABSOLUTE)
configure_file(${xpuse-openh264_DIR}/openh264.pc.in ${CMAKE_BINARY_DIR}/openh264.pc @ONLY)
file(READ ${CMAKE_BINARY_DIR}/openh264.pc OPENH264_PC)
string(REPLACE "Libs: -L\${libdir} -lopenh264 -lstdc++"
"Libs: -L\${libdir} -lopenh264 -lstdc++ -lm -lpthread"
OPENH264_PC "${OPENH264_PC}"
)
file(WRITE ${CMAKE_BINARY_DIR}/openh264.pc "${OPENH264_PC}")
set(XP_CONFIGURE ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}
PATH=${yasmBinDir}:$ENV{PATH} # prepend path to yasm
<SOURCE_DIR>/configure --prefix=<INSTALL_DIR> #--enable-shared --disable-static
--enable-pic --disable-bzlib --disable-iconv
--disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape
--disable-lzma --disable-xlib --disable-zlib
)
list(APPEND XP_CONFIGURE --enable-libopenh264)
list(APPEND XP_CONFIGURE --disable-debug)
xpVerboseListing("[CONFIGURE]" "${XP_CONFIGURE}")
include(ExternalProject)
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/epbase)
ExternalProject_Add(${PROJECT_NAME}
SOURCE_DIR ${CMAKE_SOURCE_DIR}
CONFIGURE_COMMAND ${XP_CONFIGURE}
BUILD_COMMAND ${CMAKE_COMMAND} -E env PATH=${yasmBinDir}:$ENV{PATH} make # prepend path to yasm
INSTALL_COMMAND # use default
)
ExternalProject_Get_Property(${PROJECT_NAME} INSTALL_DIR)
install(DIRECTORY ${INSTALL_DIR}/bin/ DESTINATION ${CMAKE_INSTALL_BINDIR} USE_SOURCE_PERMISSIONS)
install(DIRECTORY ${INSTALL_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${prj})
list(TRANSFORM libs PREPEND "${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}")
list(TRANSFORM libs APPEND "${CMAKE_STATIC_LIBRARY_SUFFIX}")
install(FILES ${libs} DESTINATION lib) # TRICKY: NOT ${CMAKE_INSTALL_LIBDIR} because FFmpeg-targets expects lib
install(DIRECTORY ${INSTALL_DIR}/share/ DESTINATION ${CMAKE_INSTALL_DATADIR})
endif()
8 changes: 8 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 8,
"include": [
".devcontainer/cmake/presets/xpLinuxNinja.json",
".devcontainer/cmake/presets/xpDarwinNinja.json",
".devcontainer/cmake/presets/xpWindowsVs2022.json"
]
}
16 changes: 16 additions & 0 deletions CMakePresetsBase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 8,
"configurePresets": [
{
"name": "config-base",
"hidden": true,
"binaryDir": "${sourceDir}/_bld-${presetName}"
}
],
"buildPresets": [
{
"name": "build-base",
"hidden": true
}
]
}
68 changes: 68 additions & 0 deletions cmake/FFmpeg-targets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
include(CheckLibraryExists)
function(checkLibraryConcat lib symbol liblist)
string(TOUPPER ${lib} LIB)
check_library_exists("${lib}" "${symbol}" "" XP_FFMPEG_HAS_${LIB})
if(XP_FFMPEG_HAS_${LIB})
list(APPEND ${liblist} ${lib})
set(${liblist} ${${liblist}} PARENT_SCOPE)
endif()
endfunction()
# _ffmpeg_*_libs
checkLibraryConcat(asound snd_strerror _ffmpeg_avdevice_libs)
checkLibraryConcat(Xext XShmDetach _ffmpeg_avdevice_libs)
xpGetPkgVar(openh264 LIBRARIES) # sets OPENH264_LIBRARIES
set(_ffmpeg_avcodec_libs ${OPENH264_LIBRARIES})
# _ffmpeg_*_deps
set(_ffmpeg_avdevice_deps avfilter avformat)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_library(Cocoa_LIB Cocoa)
find_library(AVFoundation_LIB AVFoundation)
find_library(CoreMedia_LIB CoreMedia)
find_library(VideoDecodeAcceleration_LIB VideoDecodeAcceleration)
find_library(QuartzCore_LIB QuartzCore)
set(_ffmpeg_avdevice_libs
${Cocoa_LIB}
${AVFoundation_LIB}
${CoreMedia_LIB}
${VideoDecodeAcceleration_LIB}
${QuartzCore_LIB}
)
endif()
set(_ffmpeg_avfilter_deps avcodec swresample swscale) # libavfilter code calls swr_*, sws_* functions
set(_ffmpeg_avformat_deps avcodec)
set(_ffmpeg_avcodec_deps swresample) # libavcodec code calls swr_* functions
set(_ffmpeg_swresample_deps avutil)
set(_ffmpeg_swscale_deps avutil)
set(_ffmpeg_avutil_deps)
# this file (FFmpeg-targets) installed to share/cmake
get_filename_component(XP_ROOTDIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
get_filename_component(XP_ROOTDIR ${XP_ROOTDIR} ABSOLUTE) # remove relative parts
set(includeDirs ${XP_ROOTDIR}/include ${XP_ROOTDIR}/include/ffmpeg)
foreach(lib ${ffmpeg_all_libs})
if(NOT TARGET ffmpeg::${lib})
add_library(ffmpeg::${lib} STATIC IMPORTED)
set(${lib}_RELEASE ${XP_ROOTDIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
if(EXISTS "${${lib}_RELEASE}")
set_property(TARGET ffmpeg::${lib} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(ffmpeg::${lib} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "ASM_NASM;C;CXX"
IMPORTED_LOCATION_RELEASE "${${lib}_RELEASE}"
)
set_target_properties(ffmpeg::${lib} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${includeDirs}"
)
if(_ffmpeg_${lib}_deps OR _ffmpeg_${lib}_libs)
unset(linkLibs)
foreach(dep ${_ffmpeg_${lib}_deps})
list(APPEND linkLibs \$<LINK_ONLY:ffmpeg::${dep}>)
endforeach()
foreach(dep ${_ffmpeg_${lib}_libs})
list(APPEND linkLibs \$<LINK_ONLY:${dep}>)
endforeach()
set_target_properties(ffmpeg::${lib} PROPERTIES
INTERFACE_LINK_LIBRARIES "${linkLibs}"
)
endif()
endif()
endif()
endforeach()
Loading