Skip to content

Commit c7592d5

Browse files
authored
Merge pull request #1 from externpro/xpro
externpro devel package
2 parents bd57d5a + c67a73b commit c7592d5

File tree

20 files changed

+366
-0
lines changed

20 files changed

+366
-0
lines changed

.devcontainer

Submodule .devcontainer added at e914c17

.github/workflows/xpbuild.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [ "dev" ]
5+
pull_request:
6+
branches: [ "dev" ]
7+
workflow_dispatch:
8+
jobs:
9+
linux:
10+
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
11+
with:
12+
cmake-workflow-preset: LinuxRelease
13+
runon: ubuntu-latest
14+
secrets: inherit
15+
linux-arm64:
16+
uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2
17+
with:
18+
cmake-workflow-preset: LinuxRelease
19+
runon: ubuntu-24.04-arm
20+
secrets: inherit
21+
macos:
22+
uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2
23+
with:
24+
cmake-workflow-preset: DarwinRelease
25+
secrets: inherit
26+
windows:
27+
uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.2
28+
with:
29+
cmake-workflow-preset: WindowsRelease
30+
secrets: inherit

.github/workflows/xprelease.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
workflow_run_url:
6+
description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)'
7+
required: true
8+
type: string
9+
jobs:
10+
# Upload build artifacts as release assets
11+
release-from-build:
12+
uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.2
13+
with:
14+
workflow_run_url: ${{ github.event.inputs.workflow_run_url }}
15+
artifact_pattern: "*.tar.xz"
16+
permissions:
17+
contents: write
18+
id-token: write
19+
attestations: write
20+
secrets: inherit

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@
8888
/tools/seek_print
8989
/tools/uncoded_frame
9090
/tools/zmqsend
91+
# externpro
92+
.env
93+
_bld*/
94+
docker-compose.override.yml

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule ".devcontainer"]
2+
path = .devcontainer
3+
url = https://github.com/externpro/externpro
4+
[submodule "mswbin"]
5+
path = mswbin
6+
url = https://github.com/externpro/ffmpegBin

CMakeLists.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
cmake_minimum_required(VERSION 3.31)
2+
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake)
3+
project(FFmpeg)
4+
include(GNUInstallDirs)
5+
include(xpflags)
6+
set(libs # libraries, in linking order
7+
# https://github.com/FFmpeg/FFmpeg/blob/n2.6.2/configure#L2667-L2675
8+
avdevice
9+
avfilter
10+
avformat
11+
avcodec
12+
swresample
13+
swscale
14+
avutil
15+
)
16+
string(JOIN "\n" EXT1
17+
"# libraries, in linking order"
18+
"# https://github.com/FFmpeg/FFmpeg/blob/n2.6.2/configure#L2667-L2675"
19+
"# TRICKY ffmpeg_all_libs used by FFmpeg-targets.cmake"
20+
"set(ffmpeg_all_libs ${libs})"
21+
"string(REPLACE \";\" \" \" ffmpeg_all_libs \"\${ffmpeg_all_libs}\")"
22+
"# FFMPEG_LIBRARIES - the FFmpeg libraries"
23+
"set(FFMPEG_LIBRARIES \${ffmpeg_all_libs})"
24+
"list(TRANSFORM FFMPEG_LIBRARIES PREPEND ffmpeg::)"
25+
"list(APPEND reqVars FFMPEG_LIBRARIES)"
26+
""
27+
)
28+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
29+
foreach(lib ${libs})
30+
string(TOUPPER ${lib} LIB)
31+
file(READ "lib${lib}/version.h" VERSION_H_CONTENTS)
32+
string(REGEX MATCH "#define[ \t]+LIB${LIB}_VERSION_MAJOR[ \t]+([0-9]+)" _ ${VERSION_H_CONTENTS})
33+
set(VERSION_MAJOR ${CMAKE_MATCH_1})
34+
list(APPEND dlls ${lib}-${VERSION_MAJOR}.dll)
35+
endforeach()
36+
string(JOIN "\n" EXT3
37+
"# FFMPEG_DLLNAMES - the FFmpeg shared object names (dll, so)"
38+
"set(FFMPEG_DLLNAMES ${dlls})"
39+
"string(REPLACE \";\" \" \" FFMPEG_DLLNAMES \"\${FFMPEG_DLLNAMES}\")"
40+
"# FFMPEG_DLLS - the full path to FFmpeg shared objects (dll, so)"
41+
"set(FFMPEG_DLLS \${FFMPEG_DLLNAMES})"
42+
"list(TRANSFORM FFMPEG_DLLS PREPEND \${XP_ROOTDIR}/${CMAKE_INSTALL_BINDIR}/)"
43+
"list(APPEND reqVars FFMPEG_DLLNAMES FFMPEG_DLLS)"
44+
""
45+
)
46+
endif()
47+
if(NOT DEFINED XP_INSTALL_CMAKEDIR)
48+
set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake)
49+
endif()
50+
set(targetsFile ${PROJECT_NAME}-targets)
51+
xpPackageDevel(TARGETS_FILE ${targetsFile} DEPS openh264)
52+
install(FILES cmake/${targetsFile}.cmake DESTINATION ${XP_INSTALL_CMAKEDIR})
53+
string(TOLOWER ${PROJECT_NAME} prj)
54+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
55+
set(mswLibs ${libs})
56+
list(TRANSFORM mswLibs PREPEND "mswbin/bin/")
57+
list(TRANSFORM mswLibs APPEND "${CMAKE_STATIC_LIBRARY_SUFFIX}")
58+
set(mswDlls ${dlls})
59+
list(TRANSFORM mswDlls PREPEND "mswbin/bin/")
60+
install(FILES ${mswLibs} DESTINATION ${CMAKE_INSTALL_LIBDIR})
61+
install(PROGRAMS ${mswDlls} DESTINATION ${CMAKE_INSTALL_BINDIR})
62+
set(incDir ${CMAKE_INSTALL_INCLUDEDIR}/${prj})
63+
foreach(lib ${libs})
64+
add_subdirectory(lib${lib}) # each library installs headers to incDir
65+
endforeach()
66+
else()
67+
find_package(openh264)
68+
find_package(yasm)
69+
get_filename_component(yasmBinDir ${xpuse-yasm_DIR}/../../bin ABSOLUTE)
70+
configure_file(${xpuse-openh264_DIR}/openh264.pc.in ${CMAKE_BINARY_DIR}/openh264.pc @ONLY)
71+
set(XP_CONFIGURE ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}
72+
PATH=${yasmBinDir}:$ENV{PATH} # prepend path to yasm
73+
<SOURCE_DIR>/configure --prefix=<INSTALL_DIR> #--enable-shared --disable-static
74+
--enable-pic --disable-bzlib --disable-iconv
75+
--disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape
76+
--disable-lzma --disable-xlib --disable-zlib
77+
)
78+
list(APPEND XP_CONFIGURE --enable-libopenh264 --disable-sdl)
79+
list(APPEND XP_CONFIGURE --disable-debug)
80+
xpVerboseListing("[CONFIGURE]" "${XP_CONFIGURE}")
81+
include(ExternalProject)
82+
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/epbase)
83+
ExternalProject_Add(${PROJECT_NAME}
84+
SOURCE_DIR ${CMAKE_SOURCE_DIR}
85+
CONFIGURE_COMMAND ${XP_CONFIGURE}
86+
BUILD_COMMAND ${CMAKE_COMMAND} -E env PATH=${yasmBinDir}:$ENV{PATH} make # prepend path to yasm
87+
INSTALL_COMMAND # use default
88+
)
89+
ExternalProject_Get_Property(${PROJECT_NAME} INSTALL_DIR)
90+
install(DIRECTORY ${INSTALL_DIR}/bin/ DESTINATION ${CMAKE_INSTALL_BINDIR})
91+
install(DIRECTORY ${INSTALL_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${prj})
92+
list(TRANSFORM libs PREPEND "${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}")
93+
list(TRANSFORM libs APPEND "${CMAKE_STATIC_LIBRARY_SUFFIX}")
94+
install(FILES ${libs} DESTINATION lib) # TRICKY: NOT ${CMAKE_INSTALL_LIBDIR} because FFmpeg-targets expects lib
95+
install(DIRECTORY ${INSTALL_DIR}/share/ DESTINATION ${CMAKE_INSTALL_DATADIR})
96+
endif()

CMakePresets.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": 8,
3+
"include": [
4+
".devcontainer/cmake/presets/xpLinuxNinja.json",
5+
".devcontainer/cmake/presets/xpDarwinNinja.json",
6+
".devcontainer/cmake/presets/xpWindowsVs2022.json"
7+
]
8+
}

CMakePresetsBase.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "config-base",
6+
"hidden": true,
7+
"binaryDir": "${sourceDir}/_bld-${presetName}"
8+
}
9+
],
10+
"buildPresets": [
11+
{
12+
"name": "build-base",
13+
"hidden": true
14+
}
15+
]
16+
}

cmake/FFmpeg-targets.cmake

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
include(CheckLibraryExists)
2+
function(checkLibraryConcat lib symbol liblist)
3+
string(TOUPPER ${lib} LIB)
4+
check_library_exists("${lib}" "${symbol}" "" XP_FFMPEG_HAS_${LIB})
5+
if(XP_FFMPEG_HAS_${LIB})
6+
list(APPEND ${liblist} ${lib})
7+
set(${liblist} ${${liblist}} PARENT_SCOPE)
8+
endif()
9+
endfunction()
10+
# _ffmpeg_*_libs
11+
checkLibraryConcat(asound snd_strerror _ffmpeg_avdevice_libs)
12+
checkLibraryConcat(Xext XShmDetach _ffmpeg_avdevice_libs)
13+
xpGetPkgVar(openh264 LIBRARIES) # sets OPENH264_LIBRARIES
14+
set(_ffmpeg_avcodec_libs ${OPENH264_LIBRARIES})
15+
# _ffmpeg_*_deps
16+
set(_ffmpeg_avdevice_deps avfilter avformat)
17+
set(_ffmpeg_avfilter_deps avcodec swresample swscale) # libavfilter code calls swr_*, sws_* functions
18+
set(_ffmpeg_avformat_deps avcodec)
19+
set(_ffmpeg_avcodec_deps swresample) # libavcodec code calls swr_* functions
20+
set(_ffmpeg_swresample_deps avutil)
21+
set(_ffmpeg_swscale_deps avutil)
22+
set(_ffmpeg_avutil_deps)
23+
# this file (FFmpeg-targets) installed to share/cmake
24+
get_filename_component(XP_ROOTDIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
25+
get_filename_component(XP_ROOTDIR ${XP_ROOTDIR} ABSOLUTE) # remove relative parts
26+
set(includeDirs ${XP_ROOTDIR}/include ${XP_ROOTDIR}/include/ffmpeg)
27+
foreach(lib ${ffmpeg_all_libs})
28+
if(NOT TARGET ffmpeg::${lib})
29+
add_library(ffmpeg::${lib} STATIC IMPORTED)
30+
set(${lib}_RELEASE ${XP_ROOTDIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
31+
if(EXISTS "${${lib}_RELEASE}")
32+
set_property(TARGET ffmpeg::${lib} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
33+
set_target_properties(ffmpeg::${lib} PROPERTIES
34+
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "ASM_NASM;C;CXX"
35+
IMPORTED_LOCATION_RELEASE "${${lib}_RELEASE}"
36+
)
37+
set_target_properties(ffmpeg::${lib} PROPERTIES
38+
INTERFACE_INCLUDE_DIRECTORIES "${includeDirs}"
39+
)
40+
if(_ffmpeg_${lib}_deps OR _ffmpeg_${lib}_libs)
41+
unset(linkLibs)
42+
foreach(dep ${_ffmpeg_${lib}_deps})
43+
list(APPEND linkLibs \$<LINK_ONLY:ffmpeg::${dep}>)
44+
endforeach()
45+
foreach(dep ${_ffmpeg_${lib}_libs})
46+
list(APPEND linkLibs \$<LINK_ONLY:${dep}>)
47+
endforeach()
48+
set_target_properties(ffmpeg::${lib} PROPERTIES
49+
INTERFACE_LINK_LIBRARIES "${linkLibs}"
50+
)
51+
endif()
52+
endif()
53+
endif()
54+
endforeach()

docker-compose.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.devcontainer/compose.pro.sh

0 commit comments

Comments
 (0)