Provide pre-built icons in the source tarball.

This reinstates the feature of the previous build system, that the C
icon files for the GTK puzzles were included in the source tarball, so
that users building from that instead of from the raw git repo would
not need to run the fiddly piece of build that regenerates them.

Running that fiddly piece of build is much easier in the CMake world
(because it's integrated with the main makefile), but it has a build
dependency on ImageMagick which is easily avoided.

The makefile will still build the icons if it _can_. But in the case
where it can't, it will use pre-built icon source files if they're
available, and only fall back to no-icon.c if it can't even do that.
(So a user checking out from git and building without ImageMagick
present will still be able to build _something_ playable.)
This commit is contained in:
Simon Tatham
2021-03-31 18:44:44 +01:00
parent b05a975fee
commit 76aa9619c0
3 changed files with 26 additions and 10 deletions

View File

@ -24,6 +24,16 @@ in puzzles do echo '$#define VER "Version $(Version)"' >> version.h
# them!) # them!)
in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx/Info.plist in puzzles do perl -i -pe 's/Unidentified build/$(Version)/' osx/Info.plist
ifneq "$(NOICONS)" yes then
# Run enough of a native Unix build to produce the various icons.
in . do cmake -B build-icons puzzles
in build-icons do make -j$(nproc) icons VERBOSE=1
# Copy the C icon files into the icons source subdirectory, for the
# distribution tarball.
in . do cp build-icons/icons/*-icon.c puzzles/icons
endif
# The very first thing we do is to make the source archive, before we # The very first thing we do is to make the source archive, before we
# fill up the build directory with extra files. # fill up the build directory with extra files.
delegate - delegate -
@ -38,13 +48,6 @@ delegate -
return puzzles-$(Version).tar.gz return puzzles-$(Version).tar.gz
enddelegate enddelegate
ifneq "$(NOICONS)" yes then
# Run enough of a native Unix build to produce the icons needed for
# the Windows builds and the website.
in puzzles do cmake -B build-icons .
in puzzles/build-icons do make -j$(nproc) icons VERBOSE=1
endif
ifneq "$(NOMACOS)" yes then ifneq "$(NOMACOS)" yes then
# Build the OS X binaries and .dmg archive. # Build the OS X binaries and .dmg archive.
delegate osx delegate osx
@ -59,8 +62,8 @@ ifneq "$(NOWINDOWS)" yes then
in puzzles do make -f Makefile.doc clean in puzzles do make -f Makefile.doc clean
in puzzles do make -f Makefile.doc -j$(nproc) # build help files for installer in puzzles do make -f Makefile.doc -j$(nproc) # build help files for installer
in puzzles do cmake -B build-win64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl64) . in . with cmake_at_least_3.20 do cmake -B puzzles/build-win64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl64) -DICO_DIR=$$PWD/build-icons/icons puzzles
in puzzles do cmake -B build-win32 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl32) . in . with cmake_at_least_3.20 do cmake -B puzzles/build-win32 -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_TOOLCHAIN_FILE=$(cmake_toolchain_clangcl32) -DICO_DIR=$$PWD/build-icons/icons puzzles
in puzzles/build-win64 do make -j$(nproc) VERBOSE=1 in puzzles/build-win64 do make -j$(nproc) VERBOSE=1
in puzzles/build-win32 do make -j$(nproc) VERBOSE=1 in puzzles/build-win32 do make -j$(nproc) VERBOSE=1
@ -150,7 +153,7 @@ in puzzles do echo RedirectMatch temp '(.*/)'puzzles-installer.msi '$$1'puzzles-
# Phew, we're done. Deliver everything! # Phew, we're done. Deliver everything!
ifneq "$(NOICONS)" yes then ifneq "$(NOICONS)" yes then
deliver puzzles/build-icons/icons/*-web.png $@ deliver build-icons/icons/*-web.png $@
endif endif
ifneq "$(NOWINDOWS)" yes then ifneq "$(NOWINDOWS)" yes then
deliver puzzles/winbin64/*.exe $@ deliver puzzles/winbin64/*.exe $@

View File

@ -51,9 +51,21 @@ endif()
function(get_platform_puzzle_extra_source_files OUTVAR NAME) function(get_platform_puzzle_extra_source_files OUTVAR NAME)
if(build_icons AND EXISTS ${CMAKE_SOURCE_DIR}/icons/${NAME}.sav) if(build_icons AND EXISTS ${CMAKE_SOURCE_DIR}/icons/${NAME}.sav)
# If we have the equipment to rebuild the puzzles' icon images
# from scratch, do so. Then changes in the puzzle display code
# will cause the icon to auto-update.
build_icon(${NAME}) build_icon(${NAME})
set(c_icon_file ${CMAKE_BINARY_DIR}/icons/${NAME}-icon.c) set(c_icon_file ${CMAKE_BINARY_DIR}/icons/${NAME}-icon.c)
elseif(EXISTS ${CMAKE_SOURCE_DIR}/icons/${NAME}-icon.c)
# Failing that, use a pre-built icon file in the 'icons'
# subdirectory, if there is one. (They don't exist in git, but the
# distribution tarball will have pre-built them and put them in
# there, so that users building from that can still have icons
# even if they don't have the wherewithal to rebuild them.)
set(c_icon_file ${CMAKE_SOURCE_DIR}/icons/${NAME}-icon.c)
else() else()
# Failing even that, include no-icon.c to satisfy the link-time
# dependencies. The puzzles will build without nice icons.
set(c_icon_file ${CMAKE_SOURCE_DIR}/no-icon.c) set(c_icon_file ${CMAKE_SOURCE_DIR}/no-icon.c)
endif() endif()

View File

@ -236,6 +236,7 @@ function(build_icon name)
DEPENDS DEPENDS
${icon_srcdir}/cicon.pl ${icon_srcdir}/cicon.pl
${cicon_pl_infiles}) ${cicon_pl_infiles})
list(APPEND output_icon_files ${icon_bindir}/${name}-icon.c)
add_custom_target(${name}-icons DEPENDS ${output_icon_files}) add_custom_target(${name}-icons DEPENDS ${output_icon_files})
add_dependencies(icons ${name}-icons) add_dependencies(icons ${name}-icons)