diff options
| author | Simon Tatham <anakin@pobox.com> | 2021-03-29 18:23:11 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2021-03-29 19:02:23 +0100 |
| commit | cc7f5503dc8f4ddf468e080a73028c83d1196e83 (patch) | |
| tree | 10e17f66ff5a417f8ce9cf23d0f926380c2a6957 /unfinished | |
| parent | 72b28b5e71b05e7775d14b1e3e2e00b82af4d87a (diff) | |
| download | puzzles-cc7f5503dc8f4ddf468e080a73028c83d1196e83.zip puzzles-cc7f5503dc8f4ddf468e080a73028c83d1196e83.tar.gz puzzles-cc7f5503dc8f4ddf468e080a73028c83d1196e83.tar.bz2 puzzles-cc7f5503dc8f4ddf468e080a73028c83d1196e83.tar.xz | |
Migrate to a CMake-based build system.
This completely removes the old system of mkfiles.pl + Recipe + .R
files that I used to manage the various per-platform makefiles and
other build scripts in this code base. In its place is a
CMakeLists.txt setup, which is still able to compile for Linux,
Windows, MacOS, NestedVM and Emscripten.
The main reason for doing this is because mkfiles.pl was a horrible
pile of unmaintainable cruft. It was hard to keep up to date (e.g.
didn't reliably support the latest Visual Studio project files); it
was so specific to me that nobody else could maintain it (or was even
interested in trying, and who can blame them?), and it wasn't even
easy to _use_ if you weren't me. And it didn't even produce very good
makefiles.
In fact I've been wanting to hurl mkfiles.pl in the bin for years, but
was blocked by CMake not quite being able to support my clang-cl based
system for cross-compiling for Windows on Linux. But CMake 3.20 was
released this month and fixes the last bug in that area (it had to do
with preprocessing of .rc files), so now I'm unblocked!
CMake is not perfect, but it's better at mkfiles.pl's job than
mkfiles.pl was, and it has the great advantage that lots of other
people already know about it.
Other advantages of the CMake system:
- Easier to build with. At least for the big three platforms, it's
possible to write down a list of build commands that's actually the
same everywhere ("cmake ." followed by "cmake --build ."). There's
endless scope for making your end-user cmake commands more fancy
than that, for various advantages, but very few people _have_ to.
- Less effort required to add a new puzzle. You just add a puzzle()
statement to the top-level CMakeLists.txt, instead of needing to
remember eight separate fiddly things to put in the .R file. (Look
at the reduction in CHECKLST.txt!)
- The 'unfinished' subdirectory is now _built_ unconditionally, even
if the things in it don't go into the 'make install' target. So
they won't bit-rot in future.
- Unix build: unified the old icons makefile with the main build, so
that each puzzle builds without an icon, runs to build its icon,
then relinks with it.
- Windows build: far easier to switch back and forth between debug
and release than with the old makefiles.
- MacOS build: CMake has its own .dmg generator, which is surely
better thought out than my ten-line bodge.
- net reduction in the number of lines of code in the code base. In
fact, that's still true _even_ if you don't count the deletion of
mkfiles.pl itself - that script didn't even have the virtue of
allowing everything else to be done exceptionally concisely.
Diffstat (limited to 'unfinished')
| -rw-r--r-- | unfinished/CMakeLists.txt | 31 | ||||
| -rw-r--r-- | unfinished/README | 15 | ||||
| -rw-r--r-- | unfinished/group.R | 25 | ||||
| -rw-r--r-- | unfinished/separate.R | 21 | ||||
| -rw-r--r-- | unfinished/slide.R | 24 | ||||
| -rw-r--r-- | unfinished/sokoban.R | 19 |
6 files changed, 41 insertions, 94 deletions
diff --git a/unfinished/CMakeLists.txt b/unfinished/CMakeLists.txt new file mode 100644 index 0000000..0c1e331 --- /dev/null +++ b/unfinished/CMakeLists.txt @@ -0,0 +1,31 @@ +puzzle(group + DISPLAYNAME "Group" + DESCRIPTION "Group theory puzzle" + OBJECTIVE "Complete the unfinished Cayley table of a group.") +solver(group ${CMAKE_SOURCE_DIR}/latin.c) + +puzzle(separate + DISPLAYNAME "Separate" + DESCRIPTION "Rectangle-dividing puzzle" + OBJECTIVE "Partition the grid into regions containing one of each letter.") + +puzzle(slide + DISPLAYNAME "Slide" + DESCRIPTION "Sliding block puzzle" + OBJECTIVE "Slide the blocks to let the key block out.") +solver(slide) + +puzzle(sokoban + DISPLAYNAME "Sokoban" + DESCRIPTION "Barrel-pushing puzzle" + OBJECTIVE "Push all the barrels into the target squares.") + +# These unfinished programs don't even have the structure of a puzzle +# game yet; they're just command-line programs containing test +# implementations of some of the needed functionality. + +cliprogram(numgame numgame.c) + +cliprogram(path path.c COMPILE_DEFINITIONS TEST_GEN) + +export_variables_to_parent_scope() diff --git a/unfinished/README b/unfinished/README index 0f8bb41..c96ccc9 100644 --- a/unfinished/README +++ b/unfinished/README @@ -2,8 +2,13 @@ This subdirectory contains puzzle implementations which are half-written, fundamentally flawed, or in other ways unready to be shipped as part of the polished Puzzles collection. -Those puzzles which have .R files can be built as part of the -Puzzles collection by symlinking their source files into the parent -directory and re-running mkfiles.pl. Anything without a .R file -isn't even finished enough to do that, and you should read the -source file itself to find out the status. +The CMake build system will _build_ all of the source in this +directory (to ensure it hasn't become unbuildable), but they won't be +included in all-in-one puzzle binaries or installed by 'make install' +targets. If you want to temporarily change that, you can reconfigure +your build by defining the CMake variable PUZZLES_ENABLE_UNFINISHED. +For example, + + cmake . -DPUZZLES_ENABLE_UNFINISHED="group;slide" + +will build as if both Group and Slide were fully official puzzles. diff --git a/unfinished/group.R b/unfinished/group.R deleted file mode 100644 index 394e364..0000000 --- a/unfinished/group.R +++ /dev/null @@ -1,25 +0,0 @@ -# -*- makefile -*- - -GROUP_EXTRA = LATIN -GROUP_EXTRA_SOLVER = LATIN_SOLVER - -group : [X] GTK COMMON group GROUP_EXTRA group-icon|no-icon - -group : [G] WINDOWS COMMON group GROUP_EXTRA group.res|noicon.res - -groupsolver : [U] group[STANDALONE_SOLVER] GROUP_EXTRA_SOLVER STANDALONE -groupsolver : [C] group[STANDALONE_SOLVER] GROUP_EXTRA_SOLVER STANDALONE - -ALL += group[COMBINED] GROUP_EXTRA - -!begin am gtk -GAMES += group -!end - -!begin >list.c - A(group) \ -!end - -!begin >gamedesc.txt -group:group.exe:Group:Group theory puzzle:Complete the unfinished Cayley table of a group. -!end diff --git a/unfinished/separate.R b/unfinished/separate.R deleted file mode 100644 index f861c8f..0000000 --- a/unfinished/separate.R +++ /dev/null @@ -1,21 +0,0 @@ -# -*- makefile -*- - -SEPARATE_EXTRA = divvy dsf - -separate : [X] GTK COMMON separate SEPARATE_EXTRA separate-icon|no-icon - -separate : [G] WINDOWS COMMON separate SEPARATE_EXTRA separate.res|noicon.res - -ALL += separate[COMBINED] SEPARATE_EXTRA - -!begin am gtk -GAMES += separate -!end - -!begin >list.c - A(separate) \ -!end - -!begin >gamedesc.txt -separate:separate.exe:Separate:Rectangle-dividing puzzle:Partition the grid into regions containing one of each letter. -!end diff --git a/unfinished/slide.R b/unfinished/slide.R deleted file mode 100644 index 189ed65..0000000 --- a/unfinished/slide.R +++ /dev/null @@ -1,24 +0,0 @@ -# -*- makefile -*- - -SLIDE_EXTRA = dsf tree234 - -slide : [X] GTK COMMON slide SLIDE_EXTRA slide-icon|no-icon - -slide : [G] WINDOWS COMMON slide SLIDE_EXTRA slide.res|noicon.res - -slidesolver : [U] slide[STANDALONE_SOLVER] SLIDE_EXTRA STANDALONE -slidesolver : [C] slide[STANDALONE_SOLVER] SLIDE_EXTRA STANDALONE - -ALL += slide[COMBINED] SLIDE_EXTRA - -!begin am gtk -GAMES += slide -!end - -!begin >list.c - A(slide) \ -!end - -!begin >gamedesc.txt -slide:slide.exe:Slide:Sliding block puzzle:Slide the blocks to let the key block out. -!end diff --git a/unfinished/sokoban.R b/unfinished/sokoban.R deleted file mode 100644 index 3b6dab5..0000000 --- a/unfinished/sokoban.R +++ /dev/null @@ -1,19 +0,0 @@ -# -*- makefile -*- - -sokoban : [X] GTK COMMON sokoban sokoban-icon|no-icon - -sokoban : [G] WINDOWS COMMON sokoban sokoban.res? - -ALL += sokoban[COMBINED] - -!begin am gtk -GAMES += sokoban -!end - -!begin >list.c - A(sokoban) \ -!end - -!begin >gamedesc.txt -sokoban:sokoban.exe:Sokoban:Barrel-pushing puzzle:Push all the barrels into the target squares. -!end |