From 5a37a5ef1c74c3a9344124a08b1c5f7dfe1d54ce Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Fri, 15 Dec 2023 02:33:42 +0100 Subject: [PATCH 1/5] Update the vcpkg version hash Also remove broken debugging code from the macOS build config. See #2075. --- .github/workflows/build.yaml | 7 +------ vcpkg.json | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4454c1898c..6abc8bd8b5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -225,7 +225,7 @@ jobs: - uses: lukka/run-vcpkg@v10 name: Install dependencies with: - vcpkgGitCommitId: 50fd3d9957195575849a49fa591e645f1d8e7156 + vcpkgGitCommitId: 23ceb9cbf9b6d32f485cf039547b70102a6ef9d8 - name: Build uses: lukka/run-cmake@v10 with: @@ -264,11 +264,6 @@ jobs: "Freeciv21-${{steps.split.outputs.fragment}}.dmg" \ "staging/" shasum -a 256 Freeciv21-${{steps.split.outputs.fragment}}.dmg > Freeciv21-${{steps.split.outputs.fragment}}.dmg.sha256 - - name: Debug - if: failure() - run: | - cat CMakeCache.txt - echo ${{steps.split.outputs.fragment}} - name: Upload package uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') diff --git a/vcpkg.json b/vcpkg.json index 507b4a9b86..a1d83044c0 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "name": "freeciv21", "version-string": "3.0.0", - "builtin-baseline": "50fd3d9957195575849a49fa591e645f1d8e7156", + "builtin-baseline": "23ceb9cbf9b6d32f485cf039547b70102a6ef9d8", "dependencies": [ "qt5-base", "qt5-svg", From 0e1abcbd2d4eaad8253a1e212b69bd1bff89ed2c Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Fri, 15 Dec 2023 02:35:12 +0100 Subject: [PATCH 2/5] Force the Python version on the macOS CI This is needed to work around a bug in the meson build system used by fontconfig, which is pulled as a dependency by vcpkg. See #2069. --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6abc8bd8b5..a44920a98c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -222,6 +222,9 @@ jobs: gettext \ create-dmg brew link gettext --force + - uses: actions/setup-python@v4 # Workaround for #2069 + with: + python-version: '3.11' - uses: lukka/run-vcpkg@v10 name: Install dependencies with: From 09ddd75b0a060e8d8d83826e26bfe8e8ede721ef Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Fri, 15 Dec 2023 02:36:33 +0100 Subject: [PATCH 3/5] macOS CI: make hdiutil more verbose In case it fails to create an image, make sure it tells us why. --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a44920a98c..33a1090790 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -256,6 +256,7 @@ jobs: mkdir staging mv Freeciv21.app staging create-dmg \ + --hdiutil-verbose \ --volname "Freeciv21 Installer" \ --volicon "client.icns" \ --window-pos 200 120 \ From 8416eeecadfc65ddb4714aa1b2b88702ed51737a Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Fri, 15 Dec 2023 02:38:32 +0100 Subject: [PATCH 4/5] Remove custom FindSDL2.cmake SDL2 supports CMake natively and installs an SDL2Config.cmake file. Hence we do not need a find module. The custom module was not handling linking to macOS frameworks, which was hard coded into client CMakeLists.txt instead. Just switch to the native module, which does all of this for us natively. See #2075. --- client/CMakeLists.txt | 9 ++- cmake/FindSDL2.cmake | 181 ------------------------------------------ 2 files changed, 5 insertions(+), 185 deletions(-) delete mode 100644 cmake/FindSDL2.cmake diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 8223f973bc..7ab0ba6686 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -158,7 +158,6 @@ target_link_libraries(freeciv21-client PRIVATE tolua) target_link_libraries(freeciv21-client PRIVATE Qt5::Widgets) target_link_libraries(freeciv21-client PRIVATE Qt5::Svg) -target_link_libraries(freeciv21-client PRIVATE ${SDL2_MIXER_LIBRARIES} ${SDL2_LIBRARY}) if(NOT EMSCRIPTEN) target_sources(freeciv21-client PRIVATE servers.cpp) @@ -168,13 +167,15 @@ if (AUDIO_SDL) target_sources(freeciv21-client PRIVATE audio/audio_sdl.cpp) if (NOT EMSCRIPTEN) # SDL comes with the -s option on emscripten - target_include_directories(freeciv21-client PRIVATE ${SDL2_INCLUDE_DIR}) + # See https://github.com/microsoft/vcpkg/blob/2023.12.12/ports/sdl2/usage + target_link_libraries(freeciv21-client + PRIVATE $,SDL2::SDL2,SDL2::SDL2-static>) + target_link_libraries(freeciv21-client PRIVATE ${SDL2_MIXER_LIBRARIES}) target_include_directories(freeciv21-client PRIVATE ${SDL2_MIXER_INCLUDE_DIR}) endif() endif() -if(APPLE) - target_link_libraries(freeciv21-client PRIVATE "-framework AudioUnit" "-framework CoreAudio" "-framework ForceFeedback" "-framework AudioToolbox") +if (APPLE) qt5_import_plugins(freeciv21-client INCLUDE Qt5::QCocoaIntegrationPlugin Qt5::QSvgPlugin) endif() diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake deleted file mode 100644 index aa45ac3690..0000000000 --- a/cmake/FindSDL2.cmake +++ /dev/null @@ -1,181 +0,0 @@ -# - Locate SDL library -# This module defines -# SDL_LIBRARY, the name of the library to link against -# SDL_FOUND, if false, do not try to link to SDL -# SDL_INCLUDE_DIR, where to find SDL.h -# SDL_VERSION_STRING, human-readable string containing the version of SDL -# -# This module responds to the the flag: -# SDL_BUILDING_LIBRARY -# If this is defined, then no SDL_main will be linked in because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the the proper link flags -# as part of the returned SDL_LIBRARY variable. -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDLmain which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration -# and no SDL_LIBRARY, it means CMake did not find your SDL library -# (SDL.dll, libsdl.so, SDL.framework, etc). -# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again. -# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value -# as appropriate. These values are used to generate the final SDL_LIBRARY -# variable, but when these values are unset, SDL_LIBRARY does not get created. -# -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# l.e.galup 9-20-02 -# -# Modified by Eric Wing. -# Added code to assist with automated building by using environmental variables -# and providing a more controlled/consistent search behavior. -# Added new modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL guidelines. -# Added a search for SDLmain which is needed by some platforms. -# Added a search for threads which is needed by some platforms. -# Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDL_LIBRARY to override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. -# -# Note that the header path has changed from SDL/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention -# is #include "SDL.h", not . This is done for portability -# reasons because not all systems place things in SDL/ (see FreeBSD). - -#============================================================================= -# Copyright 2003-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_path(SDL2_INCLUDE_DIR SDL.h - HINTS - ENV SDLDIR - PATH_SUFFIXES include/SDL2 include -) - -# On FreeBSD SDL depends on libiconv and SDL_stdinc.h includes iconv.h, which is -# located in ${LOCALBASE}/include. Append {LOCALBASE}/include to -# the SDL_INCLUDE_DIR, thus allow to build SDL apps out of box. -list(APPEND SDL2_INCLUDE_DIR /usr/local/include) - -find_library(SDL_LIBRARY_TEMP - NAMES SDL2 SDL2-2.0 - HINTS - ENV SDLDIR - PATH_SUFFIXES lib -) - -if(NOT SDL_BUILDING_LIBRARY) - if(NOT "${SDL2_INCLUDE_DIR}" MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDLmain for compatibility even though they don't - # necessarily need it. - find_library(SDLMAIN2_LIBRARY - NAMES SDLmain2 SDLmain2.0 - HINTS - ENV SDLDIR - PATH_SUFFIXES lib - PATHS - /sw - /opt/local - /opt/csw - /opt - ) - endif() -endif() - -# SDL may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -if(NOT APPLE) - find_package(Threads) -endif() - -# MinGW needs an additional library, mwindows -# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows -# (Actually on second look, I think it only needs one of the m* libraries.) -if(MINGW) - set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") -endif() - -if(SDL_LIBRARY_TEMP) - # For SDLmain - if(SDLMAIN2_LIBRARY AND NOT SDL_BUILDING_LIBRARY) - list(FIND SDL_LIBRARY_TEMP "${SDLMAIN2_LIBRARY}" _SDL_MAIN_INDEX) - if(_SDL_MAIN_INDEX EQUAL -1) - set(SDL_LIBRARY_TEMP "${SDLMAIN2_LIBRARY}" ${SDL_LIBRARY_TEMP}) - endif() - unset(_SDL_MAIN_INDEX) - endif() - - # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there if I modify a pre-used variable. - # I think it has something to do with the CACHE STRING. - # So I use a temporary variable until the end so I can set the - # "real" variable in one-shot. - if(APPLE) - set(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa") - endif() - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - if(NOT APPLE) - set(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) - endif() - - # For MinGW library - if(MINGW) - set(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP}) - endif() - - # Set the final string here so the GUI reflects the final state. - set(SDL2_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") - # Set the temp variable to INTERNAL so it is not seen in the CMake GUI - set(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "") -endif() - -if(SDL2_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h") - file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}") - set(SDL2_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH}) - unset(SDL_VERSION_MAJOR_LINE) - unset(SDL_VERSION_MINOR_LINE) - unset(SDL_VERSION_PATCH_LINE) - unset(SDL_VERSION_MAJOR) - unset(SDL_VERSION_MINOR) - unset(SDL_VERSION_PATCH) -endif() - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR - VERSION_VAR SDL2_VERSION_STRING) From c77869601e9bc314626645f7628f4bd5a811fea1 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Fri, 15 Dec 2023 03:10:05 +0100 Subject: [PATCH 5/5] Add documentation about workarounds Recommend opening an issue to check them. See #2075. --- docs/Contributing/index.rst | 1 + docs/Contributing/release.rst | 5 +++++ docs/Contributing/workarounds.rst | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 docs/Contributing/workarounds.rst diff --git a/docs/Contributing/index.rst b/docs/Contributing/index.rst index 8ed635e53f..0ca9e3dc48 100644 --- a/docs/Contributing/index.rst +++ b/docs/Contributing/index.rst @@ -12,6 +12,7 @@ Freeciv21 project. pull-request.rst eval-pull-request.rst release.rst + workarounds.rst stable-branch.rst style-guide.rst :maxdepth: 1 diff --git a/docs/Contributing/release.rst b/docs/Contributing/release.rst index 77f6307ddf..c1c8dca667 100644 --- a/docs/Contributing/release.rst +++ b/docs/Contributing/release.rst @@ -53,6 +53,11 @@ These are the general steps to prepare and finalize a release: created PR's. #. While inside the ``Release Update of AutoRevision.txt`` PR, the release manager will enable an automatic rebase and merge. +#. The release manager will open an issue titled ``Review workarounds after release`` with the following text: + + We should review the workarounds in the source code and check that they are still needed. Some + workarounds are documented here: :doc:`Workarounds`. + #. When all the CI actions are complete, the release manager will make a post in the ``#news-channel`` on the Longturn.net Discord server. #. The release manager will download the Windows i686 and x86_64 installer packages and use their Microsoft diff --git a/docs/Contributing/workarounds.rst b/docs/Contributing/workarounds.rst new file mode 100644 index 0000000000..d3a4f7a2cc --- /dev/null +++ b/docs/Contributing/workarounds.rst @@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-3.0-or-later +.. SPDX-FileCopyrightText: Louis Moureaux + +Workarounds +*********** + +This page lists workarounds in the code. They should be checked from time to +time and removed once they are no longer needed. + +#. The macOS CI installs a fixed Python version to work around a bug in Meson. + (``.github/workflows/build.yaml``)