From 0895a813036f4d189e2bdd1b62741744614347b4 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Tue, 1 Aug 2023 18:25:34 +0200 Subject: [PATCH] [smpeg2] Cleanup, fix build, export config (#32807) * [smpeg2] Fix non-msvc-build * Update CI baseline * [smpeg2] Cleanup, cmake config * Update copyright * Fix config --- .../smpeg2/001-correct-sdl-headers-dir.patch | 17 -- ports/smpeg2/002-use-SDL2-headers.patch | 229 ------------------ ports/smpeg2/CMakeLists.txt | 38 +-- ports/smpeg2/hufftable-uint.patch | 27 +++ ports/smpeg2/portfile.cmake | 27 ++- ports/smpeg2/vcpkg.json | 7 +- scripts/ci.baseline.txt | 4 - versions/baseline.json | 2 +- versions/s-/smpeg2.json | 5 + 9 files changed, 79 insertions(+), 277 deletions(-) delete mode 100644 ports/smpeg2/001-correct-sdl-headers-dir.patch delete mode 100644 ports/smpeg2/002-use-SDL2-headers.patch create mode 100644 ports/smpeg2/hufftable-uint.patch diff --git a/ports/smpeg2/001-correct-sdl-headers-dir.patch b/ports/smpeg2/001-correct-sdl-headers-dir.patch deleted file mode 100644 index 6cbcb6b9b2..0000000000 --- a/ports/smpeg2/001-correct-sdl-headers-dir.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/smpeg.h b/smpeg.h -index 6bc2dbd..d12c8f8 100644 ---- a/smpeg.h -+++ b/smpeg.h -@@ -22,9 +22,9 @@ - #ifndef _SMPEG_H_ - #define _SMPEG_H_ - --#include "SDL.h" --#include "SDL_mutex.h" --#include "SDL_audio.h" -+#include "SDL2/SDL.h" -+#include "SDL2/SDL_mutex.h" -+#include "SDL2/SDL_audio.h" - #include "MPEGframe.h" - - #ifdef __cplusplus diff --git a/ports/smpeg2/002-use-SDL2-headers.patch b/ports/smpeg2/002-use-SDL2-headers.patch deleted file mode 100644 index 9737c6d7be..0000000000 --- a/ports/smpeg2/002-use-SDL2-headers.patch +++ /dev/null @@ -1,229 +0,0 @@ -diff --git a/MPEG.cpp b/MPEG.cpp -index 1645965..9d44166 100644 ---- a/MPEG.cpp -+++ b/MPEG.cpp -@@ -1,4 +1,4 @@ --#include "SDL.h" -+#include "SDL2/SDL.h" - - #include "MPEG.h" - -diff --git a/MPEG.h b/MPEG.h -index ca04260..d0b0d55 100644 ---- a/MPEG.h -+++ b/MPEG.h -@@ -28,7 +28,7 @@ - #include - #include - --#include "SDL.h" -+#include "SDL2/SDL.h" - - #include "MPEGerror.h" - #include "MPEGstream.h" -diff --git a/MPEGaction.h b/MPEGaction.h -index f9da3a3..ea0b94f 100644 ---- a/MPEGaction.h -+++ b/MPEGaction.h -@@ -24,7 +24,7 @@ - #ifndef _MPEGACTION_H_ - #define _MPEGACTION_H_ - --#include "SDL.h" -+#include "SDL2/SDL.h" - #include "MPEGframe.h" - - typedef enum { -diff --git a/MPEGaudio.h b/MPEGaudio.h -index 3f315d2..2ec4377 100644 ---- a/MPEGaudio.h -+++ b/MPEGaudio.h -@@ -24,7 +24,7 @@ - #ifndef _MPEGAUDIO_H_ - #define _MPEGAUDIO_H_ - --#include "SDL.h" -+#include "SDL2/SDL.h" - #include "MPEGerror.h" - #include "MPEGaction.h" - -diff --git a/MPEGlist.h b/MPEGlist.h -index 3a58a5f..fe0dbac 100644 ---- a/MPEGlist.h -+++ b/MPEGlist.h -@@ -6,7 +6,7 @@ - #ifndef _MPEGLIST_H_ - #define _MPEGLIST_H_ - --#include "SDL.h" -+#include "SDL2/SDL.h" - - class MPEGlist { - public: -diff --git a/MPEGring.cpp b/MPEGring.cpp -index 6d9dabb..0350d54 100644 ---- a/MPEGring.cpp -+++ b/MPEGring.cpp -@@ -23,7 +23,7 @@ - #include - #include - --#include "SDL_timer.h" -+#include "SDL2/SDL_timer.h" - - #include "MPEGring.h" - -diff --git a/MPEGring.h b/MPEGring.h -index 89172ac..550fbcc 100644 ---- a/MPEGring.h -+++ b/MPEGring.h -@@ -24,8 +24,8 @@ - #ifndef _MPEGRING_H - #define _MPEGRING_H - --#include "SDL_types.h" --#include "SDL_thread.h" -+#include "SDL2/SDL_types.h" -+#include "SDL2/SDL_thread.h" - - class MPEG_ring { - public: -diff --git a/MPEGstream.h b/MPEGstream.h -index b96c631..50e0c3a 100644 ---- a/MPEGstream.h -+++ b/MPEGstream.h -@@ -22,7 +22,7 @@ - #ifndef _MPEGSTREAM_H_ - #define _MPEGSTREAM_H_ - --#include "SDL_types.h" -+#include "SDL2/SDL_types.h" - #include "MPEGerror.h" - #include "MPEGvideo.h" - #include "MPEGaudio.h" -diff --git a/MPEGsystem.h b/MPEGsystem.h -index 823b679..28454b3 100644 ---- a/MPEGsystem.h -+++ b/MPEGsystem.h -@@ -6,8 +6,8 @@ - #define _MPEGSYSTEM_H_ - #define USE_SYSTEM_TIMESTAMP - --#include "SDL.h" --#include "SDL_thread.h" -+#include "SDL2/SDL.h" -+#include "SDL2/SDL_thread.h" - #include "MPEGerror.h" - - class MPEGstream; -diff --git a/MPEGvideo.h b/MPEGvideo.h -index 12da092..9f1ed43 100644 ---- a/MPEGvideo.h -+++ b/MPEGvideo.h -@@ -24,8 +24,8 @@ - #ifndef _MPEGVIDEO_H_ - #define _MPEGVIDEO_H_ - --#include "SDL.h" --#include "SDL_thread.h" -+#include "SDL2/SDL.h" -+#include "SDL2/SDL_thread.h" - #include "MPEGerror.h" - #include "MPEGaction.h" - -diff --git a/README.SDL_mixer b/README.SDL_mixer -index c01b575..5cacc4f 100644 ---- a/README.SDL_mixer -+++ b/README.SDL_mixer -@@ -5,7 +5,7 @@ You can have the SDL mixer library mix audio from a movie by hooking into - the SDL mixer music hooks: - - #include "smpeg.h" --#include "SDL_mixer.h" -+#include "SDL2/SDL_mixer.h" - - .. set up the mixer audio ... - -diff --git a/acinclude/sdl2.m4 b/acinclude/sdl2.m4 -index 93bc4b0..776ad42 100644 ---- a/acinclude/sdl2.m4 -+++ b/acinclude/sdl2.m4 -@@ -84,7 +84,7 @@ dnl - #include - #include - #include --#include "SDL.h" -+#include "SDL2/SDL.h" - - char* - my_strdup (char *str) -@@ -167,7 +167,7 @@ int main (int argc, char *argv[]) - LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ - #include --#include "SDL.h" -+#include "SDL2/SDL.h" - - int main(int argc, char *argv[]) - { return 0; } -diff --git a/configure b/configure -index 4ac7e60..ee1d934 100644 ---- a/configure -+++ b/configure -@@ -15270,7 +15270,7 @@ else - #include - #include - #include --#include "SDL.h" -+#include "SDL2/SDL.h" - - char* - my_strdup (char *str) -@@ -15367,7 +15367,7 @@ $as_echo "no" >&6; } - /* end confdefs.h. */ - - #include --#include "SDL.h" -+#include "SDL2/SDL.h" - - int main(int argc, char *argv[]) - { return 0; } -diff --git a/video/gdith.cpp b/video/gdith.cpp -index c56da96..53ba388 100644 ---- a/video/gdith.cpp -+++ b/video/gdith.cpp -@@ -52,7 +52,7 @@ - #include "video.h" - #include "proto.h" - #include "dither.h" --#include "SDL_timer.h" -+#include "SDL2/SDL_timer.h" - - #ifdef __STDC__ - #include -diff --git a/video/readfile.cpp b/video/readfile.cpp -index eb71194..a19e66d 100644 ---- a/video/readfile.cpp -+++ b/video/readfile.cpp -@@ -56,7 +56,7 @@ - #include - #include - --#include "SDL_endian.h" -+#include "SDL2/SDL_endian.h" - #include "video.h" - #include "proto.h" - #include "util.h" -diff --git a/video/video.h b/video/video.h -index 96de89b..a35095b 100644 ---- a/video/video.h -+++ b/video/video.h -@@ -400,7 +400,7 @@ extern unsigned int cacheMiss[8][8]; - #define __SCO__ 1 - #endif - --#include "SDL_endian.h" -+#include "SDL2/SDL_endian.h" - #if SDL_BYTEORDER == SDL_BIG_ENDIAN - #ifdef LITTLE_ENDIAN_ARCHITECTURE - #undef LITTLE_ENDIAN_ARCHITECTURE diff --git a/ports/smpeg2/CMakeLists.txt b/ports/smpeg2/CMakeLists.txt index 5515c698f2..3c1e11d54f 100644 --- a/ports/smpeg2/CMakeLists.txt +++ b/ports/smpeg2/CMakeLists.txt @@ -1,22 +1,15 @@ -cmake_minimum_required(VERSION 2.6) -project(SMPEG2 CXX) +cmake_minimum_required(VERSION 3.25) +project(smpeg2 CXX) -find_path(SDL_INCLUDE_DIR SDL2/SDL.h) find_package(SDL2 CONFIG REQUIRED) -include_directories(${SDL_INCLUDE_DIR}) -include_directories(${SDL_INCLUDE_DIR}/SDL2) -include_directories(${CMAKE_SOURCE_DIR}) - if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) + # some c++ code just assumes memset is available + add_definitions(-FIstring.h) endif() add_definitions(-DNOCONTROLS -DTHREADED_AUDIO) -# some c++ code just assumes memset is available -file(WRITE ${CMAKE_SOURCE_DIR}/declare_memset.h "#include \n") -add_definitions(-FIdeclare_memset.h) - add_library(smpeg2 audio/bitwindow.cpp audio/filter.cpp @@ -45,21 +38,34 @@ add_library(smpeg2 MPEGsystem.cpp smpeg.cpp) -set_target_properties(smpeg2 PROPERTIES DEFINE_SYMBOL DLL_EXPORT) -if(BUILD_SHARED_LIBS) +if(WIN32 AND BUILD_SHARED_LIBS) + target_compile_definitions(smpeg2 PRIVATE -DDLL_EXPORT) +endif() + +target_include_directories(smpeg2 PUBLIC + "$" + $ +) + + +if(TARGET SDL2::SDL2) target_link_libraries(smpeg2 SDL2::SDL2) else() target_link_libraries(smpeg2 SDL2::SDL2-static) endif() install(TARGETS smpeg2 + EXPORT smpeg2-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +install(EXPORT smpeg2-targets + FILE unofficial-smpeg2-config.cmake + NAMESPACE unofficial::smpeg2:: + DESTINATION share/unofficial-smpeg2 +) + if(NOT DEFINED SMPEG_SKIP_HEADERS) install(FILES smpeg.h MPEGframe.h DESTINATION include) endif() - -message(STATUS "Link-time dependencies:") -message(STATUS " " ${SDL_LIBRARY}) diff --git a/ports/smpeg2/hufftable-uint.patch b/ports/smpeg2/hufftable-uint.patch new file mode 100644 index 0000000000..14036a3dd5 --- /dev/null +++ b/ports/smpeg2/hufftable-uint.patch @@ -0,0 +1,27 @@ +diff --git a/audio/hufftable.cpp b/audio/hufftable.cpp +index 6bc8e86..1ef2d7e 100644 +--- a/audio/hufftable.cpp ++++ b/audio/hufftable.cpp +@@ -550,11 +550,11 @@ htd33[ 31][2]={{ 16, 1},{ 8, 1},{ 4, 1},{ 2, 1},{ 0, 0},{ 0, 1}, + + const HUFFMANCODETABLE MPEGaudio::ht[HTN]= + { +- { 0, 0-1, 0-1, 0, 0, htd33}, ++ { 0, 0u-1, 0u-1, 0, 0, htd33}, + { 1, 2-1, 2-1, 0, 7,htd01}, + { 2, 3-1, 3-1, 0, 17,htd02}, + { 3, 3-1, 3-1, 0, 17,htd03}, +- { 4, 0-1, 0-1, 0, 0, htd33}, ++ { 4, 0u-1, 0u-1, 0, 0, htd33}, + { 5, 4-1, 4-1, 0, 31,htd05}, + { 6, 4-1, 4-1, 0, 31,htd06}, + { 7, 6-1, 6-1, 0, 71,htd07}, +@@ -564,7 +564,7 @@ const HUFFMANCODETABLE MPEGaudio::ht[HTN]= + {11, 8-1, 8-1, 0,127,htd11}, + {12, 8-1, 8-1, 0,127,htd12}, + {13,16-1,16-1, 0,511,htd13}, +- {14, 0-1, 0-1, 0, 0, htd33}, ++ {14, 0u-1, 0u-1, 0, 0, htd33}, + {15,16-1,16-1, 0,511,htd15}, + {16,16-1,16-1, 1,511,htd16}, + {17,16-1,16-1, 2,511,htd16}, diff --git a/ports/smpeg2/portfile.cmake b/ports/smpeg2/portfile.cmake index b1f31968c4..570bee625e 100644 --- a/ports/smpeg2/portfile.cmake +++ b/ports/smpeg2/portfile.cmake @@ -1,5 +1,3 @@ - -set(VERSION 2.0.0) vcpkg_download_distfile(ARCHIVE URLS "https://www.libsdl.org/projects/smpeg/release/smpeg2-${VERSION}.tar.gz" FILENAME "smpeg2-${VERSION}.tar.gz" @@ -9,11 +7,9 @@ vcpkg_download_distfile(ARCHIVE vcpkg_extract_source_archive( SOURCE_PATH ARCHIVE "${ARCHIVE}" - SOURCE_BASE "${VERSION}" PATCHES - "001-correct-sdl-headers-dir.patch" - "002-use-SDL2-headers.patch" - "003-fix-double-ptr-to-int-comparison.patch" + hufftable-uint.patch + 003-fix-double-ptr-to-int-comparison.patch ) file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") @@ -21,9 +17,22 @@ file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH} vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS_DEBUG - -DSMPEG_SKIP_HEADERS=ON) - + -DSMPEG_SKIP_HEADERS=ON +) vcpkg_cmake_install() vcpkg_copy_pdbs() -file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-smpeg2) +file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-smpeg2/unofficial-smpeg2-config.cmake" config) +file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-smpeg2/unofficial-smpeg2-config.cmake" +"include(CMakeFindDependencyMacro) +find_dependency(SDL2 CONFIG) +${config}" +) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +file(READ "${SOURCE_PATH}/video/video.h" video_terms) +string(REGEX REPLACE "#ifndef .*" "" video_terms "${video_terms}") +file(WRITE "${SOURCE_PATH}/Additional notes" "${video_terms}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING" "${SOURCE_PATH}/Additional notes") diff --git a/ports/smpeg2/vcpkg.json b/ports/smpeg2/vcpkg.json index 3e48eac405..5b8c653bde 100644 --- a/ports/smpeg2/vcpkg.json +++ b/ports/smpeg2/vcpkg.json @@ -1,14 +1,19 @@ { "name": "smpeg2", "version": "2.0.0", - "port-version": 9, + "port-version": 10, "description": "SDL MPEG Player Library", "homepage": "https://www.libsdl.org/projects/smpeg/", + "license": null, "dependencies": [ "sdl2", { "name": "vcpkg-cmake", "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true } ] } diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 059db7f978..21924deaf4 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -1233,10 +1233,6 @@ sleepy-discord:arm64-android=fail slikenet:arm-neon-android=fail slikenet:arm64-android=fail slikenet:x64-android=fail -smpeg2:arm-neon-android=fail -smpeg2:arm64-android=fail -smpeg2:x64-android=fail -smpeg2:x64-linux=fail soem:arm-neon-android=fail soem:arm64-android=fail soem:x64-android=fail diff --git a/versions/baseline.json b/versions/baseline.json index 2e8ba415cb..180424fb99 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7622,7 +7622,7 @@ }, "smpeg2": { "baseline": "2.0.0", - "port-version": 9 + "port-version": 10 }, "snappy": { "baseline": "1.1.10", diff --git a/versions/s-/smpeg2.json b/versions/s-/smpeg2.json index 4c60667681..6c7c9d6ff7 100644 --- a/versions/s-/smpeg2.json +++ b/versions/s-/smpeg2.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "e72c715fb637688426feaa616ab0bc07c7758f8c", + "version": "2.0.0", + "port-version": 10 + }, { "git-tree": "8152688421f7023b7160c97976631b798025bb39", "version": "2.0.0",