From 3884b8d44b4bfaed73f26227cd88d7946e2dfaa5 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Wed, 2 Jun 2021 00:26:55 -0700 Subject: [PATCH] build: Downgrade SDL2 to 2.0.12 temporarily --- ...1-fix-cmake-target-relocation-2.0.12.patch | 84 +++++++++++++++++++ ...-fix-cmake-target-relocation-2.0.14.patch} | 0 ubuntu-win64-cross/002-fix-link-order.patch | 35 ++++++++ ...-dont-duplicate-libs-in-libs-private.patch | 62 ++++++++++++++ ubuntu-win64-cross/Dockerfile | 29 +++---- ubuntu-win64-cross/sdl2.mk | 6 +- 6 files changed, 195 insertions(+), 21 deletions(-) create mode 100644 ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.12.patch rename ubuntu-win64-cross/{001-fix-cmake-target-relocation.patch => 001-fix-cmake-target-relocation-2.0.14.patch} (100%) create mode 100644 ubuntu-win64-cross/002-fix-link-order.patch create mode 100644 ubuntu-win64-cross/004-dont-duplicate-libs-in-libs-private.patch diff --git a/ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.12.patch b/ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.12.patch new file mode 100644 index 0000000000..0319c0c315 --- /dev/null +++ b/ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.12.patch @@ -0,0 +1,84 @@ +--- SDL2-2.0.12/sdl2-config.cmake.in.orig 2020-04-11 15:56:36.797056300 +0300 ++++ SDL2-2.0.12/sdl2-config.cmake.in 2020-04-11 16:21:11.621006100 +0300 +@@ -1,12 +1,14 @@ + # sdl2 cmake project-config input for ./configure scripts + +-set(prefix "@prefix@") +-set(exec_prefix "@exec_prefix@") +-set(libdir "@libdir@") +-set(SDL2_PREFIX "@prefix@") +-set(SDL2_EXEC_PREFIX "@prefix@") +-set(SDL2_LIBDIR "@libdir@") +-set(SDL2_INCLUDE_DIRS "@includedir@/SDL2") ++get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) ++ ++set(prefix "${PACKAGE_PREFIX_DIR}") ++set(exec_prefix "${PACKAGE_PREFIX_DIR}") ++set(libdir "${prefix}/lib") ++set(SDL2_PREFIX "${PACKAGE_PREFIX_DIR}") ++set(SDL2_EXEC_PREFIX "${PACKAGE_PREFIX_DIR}") ++set(SDL2_LIBDIR "${prefix}/lib") ++set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2") + set(SDL2_LIBRARIES "-L${SDL2_LIBDIR} @SDL_RLD_FLAGS@ @SDL_LIBS@") + string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES) + +@@ -20,20 +22,20 @@ + + add_library(SDL2::SDL2 SHARED IMPORTED) + set_target_properties(SDL2::SDL2 PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "@includedir@/SDL2" ++ INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" +- IMPORTED_LOCATION "@libdir@/libSDL2.so" ++ IMPORTED_LOCATION "${SDL2_LIBDIR}/libSDL2.dll.a" + INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}") + + add_library(SDL2::SDL2-static STATIC IMPORTED) + set_target_properties(SDL2::SDL2-static PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "@includedir@/SDL2" ++ INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" +- IMPORTED_LOCATION "@libdir@/libSDL2.a" ++ IMPORTED_LOCATION "${SDL2_LIBDIR}/libSDL2.a" + INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS_STATIC}") + + add_library(SDL2::SDL2main STATIC IMPORTED) + set_target_properties(SDL2::SDL2main PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" +- IMPORTED_LOCATION "@libdir@/libSDL2main.a") ++ IMPORTED_LOCATION "${SDL2_LIBDIR}/libSDL2main.a") + endif() +--- SDL2-2.0.12/CMakeLists.txt.orig 2020-04-11 16:44:16.343880000 +0300 ++++ SDL2-2.0.12/CMakeLists.txt 2020-04-11 16:48:12.677114500 +0300 +@@ -1916,7 +1916,7 @@ + set(EXTRA_CFLAGS ${_EXTRA_CFLAGS}) + + # Compat helpers for the configuration files +-if(NOT WINDOWS OR CYGWIN) ++if(NOT MSVC OR CYGWIN) + # TODO: we need a Windows script, too + execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh) + +@@ -2134,7 +2134,7 @@ + RUNTIME DESTINATION bin) + + ##### Export files ##### +-if (WINDOWS) ++if (MSVC) + set(PKG_PREFIX "cmake") + else () + set(PKG_PREFIX "lib${LIB_SUFFIX}/cmake/SDL2") +@@ -2175,11 +2175,11 @@ + set(SOPOSTFIX "") + endif() + +-if(NOT (WINDOWS OR CYGWIN)) ++if(NOT (MSVC OR CYGWIN)) + if(SDL_SHARED) + set(SOEXT ${CMAKE_SHARED_LIBRARY_SUFFIX}) # ".so", ".dylib", etc. + get_target_property(SONAME SDL2 OUTPUT_NAME) +- if(NOT ANDROID) ++ if(NOT ANDROID AND NOT MINGW) + install(CODE " + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + \"lib${SONAME}${SOPOSTFIX}${SOEXT}\" \"libSDL2${SOPOSTFIX}${SOEXT}\" diff --git a/ubuntu-win64-cross/001-fix-cmake-target-relocation.patch b/ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.14.patch similarity index 100% rename from ubuntu-win64-cross/001-fix-cmake-target-relocation.patch rename to ubuntu-win64-cross/001-fix-cmake-target-relocation-2.0.14.patch diff --git a/ubuntu-win64-cross/002-fix-link-order.patch b/ubuntu-win64-cross/002-fix-link-order.patch new file mode 100644 index 0000000000..aad8696f52 --- /dev/null +++ b/ubuntu-win64-cross/002-fix-link-order.patch @@ -0,0 +1,35 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7dfd3538..2ac95eff 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -233,9 +233,17 @@ endif() + + # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config, + # etc. are created correctly. +-set(SDL_LIBS "-lSDL2") ++set(SDL_LIBS "") + set(SDL_CFLAGS "") + ++if(MINGW OR CYGWIN) ++ list(APPEND SDL_LIBS "-mwindows") ++endif() ++list(APPEND SDL_LIBS "-lSDL2") ++if(MINGW OR CYGWIN) ++ list(APPEND SDL_LIBS "-lSDL2main" "-lmingw32") ++endif() ++ + # When building shared lib for Windows with MinGW, + # avoid the DLL having a "lib" prefix + if(WINDOWS) +@@ -1505,10 +1513,9 @@ elseif(WINDOWS) + file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc) + file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c) + if(MINGW OR CYGWIN) +- list(APPEND EXTRA_LIBS mingw32) ++ list(APPEND EXTRA_LIBS SDL2main mingw32) + list(APPEND EXTRA_LDFLAGS "-mwindows") + set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main") +- list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows") + endif() + + elseif(APPLE) diff --git a/ubuntu-win64-cross/004-dont-duplicate-libs-in-libs-private.patch b/ubuntu-win64-cross/004-dont-duplicate-libs-in-libs-private.patch new file mode 100644 index 0000000000..f1f2a65aa4 --- /dev/null +++ b/ubuntu-win64-cross/004-dont-duplicate-libs-in-libs-private.patch @@ -0,0 +1,62 @@ +# Based on SDL hg changeset fc03d19926ed, tweaked to apply here + +# HG changeset patch +# User James Le Cuirot +# Date 1586694276 -3600 +# Node ID fc03d19926ed02c5e96033a22e0a1956cb7d2968 +# Parent 89a457159af48f83585adab9ab9ea1d21be9505c +build: Don't duplicate Libs in Libs.private in pkg-config file + +pkg-config already prepends Libs to Libs.private when you specify +--static so there's no need to duplicate them. Most other projects +don't do this. + +diff -r 89a457159af4 -r fc03d19926ed CMakeLists.txt +--- a/CMakeLists.txt Sat Apr 11 23:38:34 2020 +0100 ++++ b/CMakeLists.txt Sun Apr 12 13:24:36 2020 +0100 +@@ -1962,7 +1962,7 @@ + + # Clean up the different lists + listtostr(EXTRA_LIBS _EXTRA_LIBS "-l") +- set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS}) ++ set(SDL_STATIC_LIBS ${EXTRA_LDFLAGS} ${_EXTRA_LIBS}) + list(REMOVE_DUPLICATES SDL_STATIC_LIBS) + listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS) + set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS}) +diff -r 89a457159af4 -r fc03d19926ed configure +--- a/configure Sat Apr 11 23:38:34 2020 +0100 ++++ b/configure Sun Apr 12 13:24:36 2020 +0100 +@@ -25717,7 +25717,7 @@ + SDL_RLD_FLAGS="" + fi + +-SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS" ++SDL_STATIC_LIBS="$EXTRA_LDFLAGS" + + + +diff -r 89a457159af4 -r fc03d19926ed configure.ac +--- a/configure.ac Sat Apr 11 23:38:34 2020 +0100 ++++ b/configure.ac Sun Apr 12 13:24:36 2020 +0100 +@@ -4271,7 +4271,7 @@ + SDL_RLD_FLAGS="" + fi + +-SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS" ++SDL_STATIC_LIBS="$EXTRA_LDFLAGS" + + dnl Expand the cflags and libraries needed by apps using SDL + AC_SUBST(SDL_CFLAGS) +diff -r 89a457159af4 -r fc03d19926ed sdl2-config.in +--- a/sdl2-config.in Sat Apr 11 23:38:34 2020 +0100 ++++ b/sdl2-config.in Sun Apr 12 13:24:36 2020 +0100 +@@ -49,7 +49,7 @@ + @ENABLE_SHARED_TRUE@ ;; + @ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs) + @ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs) +-@ENABLE_STATIC_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_STATIC_LIBS@ ++@ENABLE_STATIC_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@ @SDL_STATIC_LIBS@ + @ENABLE_STATIC_TRUE@ ;; + *) + echo "${usage}" 1>&2 + diff --git a/ubuntu-win64-cross/Dockerfile b/ubuntu-win64-cross/Dockerfile index d552586144..3d58c022ce 100644 --- a/ubuntu-win64-cross/Dockerfile +++ b/ubuntu-win64-cross/Dockerfile @@ -40,36 +40,27 @@ RUN apt-get update \ sed \ unzip \ wget \ - xz-utils + xz-utils \ + ninja-build RUN cd /opt \ && git clone https://github.com/mxe/mxe.git \ - && cd mxe \ - && make \ - MXE_TARGETS=x86_64-w64-mingw32.static \ - MXE_PLUGIN_DIRS=plugins/gcc10 \ - cc - -RUN make -C /opt/mxe \ + && make -C /opt/mxe \ MXE_TARGETS=x86_64-w64-mingw32.static \ MXE_PLUGIN_DIRS=plugins/gcc10 \ + cc \ glib \ libepoxy \ pixman \ libsamplerate \ - openssl - -RUN make -C /opt/mxe \ - MXE_TARGETS=x86_64-w64-mingw32.static \ - MXE_PLUGIN_DIRS=plugins/gcc10 \ + openssl \ cmake -RUN apt-get install ninja-build - -COPY sdl2.mk /opt/mxe/src/sdl2.mk -COPY 001-fix-cmake-target-relocation.patch /opt/mxe/src/sdl2-1-cmake.patch -COPY 003-fix-static-library-name.patch /opt/mxe/src/sdl2-3-static.patch -COPY sdl2-2-link.patch /opt/mxe/src/sdl2-2-link.patch +COPY sdl2.mk /opt/mxe/src/sdl2.mk +COPY 001-fix-cmake-target-relocation-2.0.12.patch /opt/mxe/src/sdl2-1-cmake.patch +COPY 002-fix-link-order.patch /opt/mxe/src/sdl2-2-link.patch +COPY 003-fix-static-library-name.patch /opt/mxe/src/sdl2-3-static.patch +COPY 004-dont-duplicate-libs-in-libs-private.patch /opt/mxe/src/sdl2-4-fix-duplicate-libs.patch RUN make -C /opt/mxe \ MXE_TARGETS=x86_64-w64-mingw32.static \ diff --git a/ubuntu-win64-cross/sdl2.mk b/ubuntu-win64-cross/sdl2.mk index 76de36e38f..044d7db40e 100644 --- a/ubuntu-win64-cross/sdl2.mk +++ b/ubuntu-win64-cross/sdl2.mk @@ -4,8 +4,10 @@ PKG := sdl2 $(PKG)_WEBSITE := https://www.libsdl.org/ $(PKG)_DESCR := SDL2 $(PKG)_IGNORE := -$(PKG)_VERSION := 2.0.14 -$(PKG)_CHECKSUM := d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc +$(PKG)_VERSION := 2.0.12 +# $(PKG)_VERSION := 2.0.14 +$(PKG)_CHECKSUM := 349268f695c02efbc9b9148a70b85e58cefbbf704abd3e91be654db7f1e2c863 +# $(PKG)_CHECKSUM := d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc $(PKG)_SUBDIR := SDL2-$($(PKG)_VERSION) $(PKG)_FILE := SDL2-$($(PKG)_VERSION).tar.gz $(PKG)_URL := https://www.libsdl.org/release/$($(PKG)_FILE)