[sdl1] Enable mingw (#25095)

* Portfile CMake style

* Fix mingw

* Add polyfill for missing 'which'

* Add patch for relocatable sdl-config

Fixes mingw on Windows builds.

* Update versions

* CR requests

* Remove man3

* Update versions
This commit is contained in:
Kai Pastor 2022-06-08 23:30:48 +02:00 committed by GitHub
parent 0a74827c24
commit 7a199e7786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 46 deletions

View File

@ -7,13 +7,13 @@ vcpkg_from_github(
PATCHES
export-symbols-only-in-shared-build.patch
fix-linux-build.patch
sdl-config.patch
)
configure_file(${SOURCE_PATH}/include/SDL_config.h.default ${SOURCE_PATH}/include/SDL_config.h COPYONLY)
configure_file("${SOURCE_PATH}/include/SDL_config.h.default" "${SOURCE_PATH}/include/SDL_config.h" COPYONLY)
if (VCPKG_TARGET_IS_WINDOWS)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/SDL1_2017.sln DESTINATION ${SOURCE_PATH}/VisualC/ )
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/SDL1_2017.sln" DESTINATION "${SOURCE_PATH}/VisualC/")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(LIB_TYPE StaticLibrary)
@ -29,14 +29,14 @@ if (VCPKG_TARGET_IS_WINDOWS)
set(CRT_TYPE_REL MultiThreaded)
endif()
configure_file(${CURRENT_PORT_DIR}/SDL.vcxproj.in ${SOURCE_PATH}/VisualC/SDL/SDL.vcxproj @ONLY)
configure_file(${CURRENT_PORT_DIR}/SDLmain.vcxproj.in ${SOURCE_PATH}/VisualC/SDLmain/SDLmain.vcxproj @ONLY)
configure_file("${CURRENT_PORT_DIR}/SDL.vcxproj.in" "${SOURCE_PATH}/VisualC/SDL/SDL.vcxproj" @ONLY)
configure_file("${CURRENT_PORT_DIR}/SDLmain.vcxproj.in" "${SOURCE_PATH}/VisualC/SDLmain/SDLmain.vcxproj" @ONLY)
# This text file gets copied as a library, and included as one in the package
file(REMOVE_RECURSE ${SOURCE_PATH}/src/hermes/COPYING.LIB)
file(REMOVE_RECURSE "${SOURCE_PATH}/src/hermes/COPYING.LIB")
vcpkg_install_msbuild(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH VisualC/SDL1_2017.sln
INCLUDES_SUBPATH include
LICENSE_SUBPATH COPYING
@ -44,47 +44,44 @@ if (VCPKG_TARGET_IS_WINDOWS)
)
#Take all the fils into include/SDL to sovle conflict with SDL2 port
file(GLOB files ${CURRENT_PACKAGES_DIR}/include/*)
foreach(file ${files})
file(COPY ${file} DESTINATION ${CURRENT_PACKAGES_DIR}/include/SDL)
file(REMOVE ${file})
endforeach()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/SDL/doxyfile)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/doxyfile")
file(RENAME "${CURRENT_PACKAGES_DIR}/include" "${CURRENT_PACKAGES_DIR}/include.tmp")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/include")
file(RENAME "${CURRENT_PACKAGES_DIR}/include.tmp" "${CURRENT_PACKAGES_DIR}/include/SDL")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/SDLmain.lib ${CURRENT_PACKAGES_DIR}/lib/manual-link/SDLmain.lib)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/SDLmain.lib ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDLmaind.lib)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/manual-link")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/SDLmain.lib" "${CURRENT_PACKAGES_DIR}/lib/manual-link/SDLmain.lib")
if(NOT DEFINED VCPKG_BUILD_TYPE)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/SDLmain.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/manual-link/SDLmaind.lib")
endif()
else()
if(VCPKG_TARGET_IS_LINUX)
message("libgles2-mesa-dev must be installed before sdl1 can build. Install it with \"apt install libgles2-mesa-dev\".")
endif()
find_program(WHICH_COMMAND NAMES which)
if(NOT WHICH_COMMAND)
set(polyfill_scripts "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-bin")
file(REMOVE_RECURSE "${polyfill_scripts}")
file(MAKE_DIRECTORY "${polyfill_scripts}")
vcpkg_host_path_list(APPEND ENV{PATH} "${polyfill_scripts}")
# sdl's autoreconf.sh needs `which`, but our msys root doesn't have it.
file(WRITE "${polyfill_scripts}/which" "#!/bin/sh\nif test -f \"/usr/bin/\$1\"; then echo \"/usr/bin/\$1\"; else false; fi\n")
file(CHMOD "${polyfill_scripts}/which" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
endif()
vcpkg_configure_make(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_install_make()
vcpkg_fixup_pkgconfig(IGNORE_FLAGS -Wl,-rpath,${CURRENT_PACKAGES_DIR}/lib/pkgconfig/../../lib
-Wl,-rpath,${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/../../lib
SYSTEM_LIBRARIES pthread)
vcpkg_fixup_pkgconfig()
file(GLOB SDL1_TOOLS "${CURRENT_PACKAGES_DIR}/bin/*")
foreach (SDL1_TOOL ${SDL1_TOOLS})
file(COPY ${SDL1_TOOL} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)
file(REMOVE ${SDL1_TOOL})
endforeach()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/${PORT}/man3"
)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
if(EXISTS "${CURRENT_PACKAGES_DIR}/tools/sdl1/bin/sdl-config")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/sdl1/bin/sdl-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../..")
endif()
if(EXISTS "${CURRENT_PACKAGES_DIR}/tools/sdl1/debug/bin/sdl-config")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/sdl1/debug/bin/sdl-config" "${CURRENT_INSTALLED_DIR}" "`dirname $0`/../../..")
endif()
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
endif()

View File

@ -0,0 +1,13 @@
diff --git a/sdl-config.in b/sdl-config.in
index e0fcc0c..de602d8 100644
--- a/sdl-config.in
+++ b/sdl-config.in
@@ -1,6 +1,7 @@
#!/bin/sh
-prefix=@prefix@
+DIRNAME=$(dirname $0)
+prefix=$(CDPATH= cd -- "${DIRNAME%/tools/sdl1/*}" && pwd -P)
exec_prefix=@exec_prefix@
exec_prefix_set=no
libdir=@libdir@

View File

@ -1,9 +1,9 @@
{
"name": "sdl1",
"version": "1.2.15",
"port-version": 16,
"port-version": 17,
"description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.",
"homepage": "https://www.libsdl.org",
"license": "LGPL-2.1+",
"license": "LGPL-2.1-or-later",
"supports": "!osx & !uwp"
}

View File

@ -6410,7 +6410,7 @@
},
"sdl1": {
"baseline": "1.2.15",
"port-version": 16
"port-version": 17
},
"sdl1-net": {
"baseline": "1.2.8",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "45b686784ad1b01e7cfa7988bc3f95bf9aff6b6a",
"version": "1.2.15",
"port-version": 17
},
{
"git-tree": "5ffe0bac6645cd0fe0c98a0c33cf86a6bc2ddcfc",
"version": "1.2.15",