simon-git: puzzles (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat Apr 3 10:32:54 BST 2021


TL;DR:
  a1bab40 Support earlier versions of CMake.
  e1b9047 emscripten.cmake: remove a rogue diagnostic.
  f6434e8 Update web puzzles to current WASM-based Emscripten.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2021-04-03 10:32:54

commit a1bab40025a821909eea7d47e6d0af5c27338833
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=a1bab40025a821909eea7d47e6d0af5c27338833;hp=e763b9ead86df6a92666525f8d2ed0385e251c61
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Apr 3 08:03:25 2021 +0100

    Support earlier versions of CMake.
    
    At least, for the Unix build, so as to support Debian stable and a
    couple of prior Ubuntu LTSes.
    
    Not much needed to change in the cmake scripts; the only noticeable
    difference was that the 'install' command needs an explicit RUNTIME
    DESTINATION.

 CMakeLists.txt             |  2 +-
 cmake/platforms/unix.cmake | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

commit e1b9047b55199f3f5b8569029c5830104ddfae09
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=e1b9047b55199f3f5b8569029c5830104ddfae09;hp=a1bab40025a821909eea7d47e6d0af5c27338833
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Apr 3 08:44:22 2021 +0100

    emscripten.cmake: remove a rogue diagnostic.
    
    I somehow left this in while I was trying to get the Emscripten cmake
    build to work in the first place.

 cmake/platforms/emscripten.cmake | 1 -
 1 file changed, 1 deletion(-)

commit f6434e84964d840160eeff518bc812392c13160f
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=f6434e84964d840160eeff518bc812392c13160f;hp=e1b9047b55199f3f5b8569029c5830104ddfae09
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Apr 3 08:42:04 2021 +0100

    Update web puzzles to current WASM-based Emscripten.
    
    I presume this will improve performance. Also, if I've understood
    correctly, WASM-based compiled web code is capable of automatically
    growing its memory, which the previous asm.js build of the puzzles
    could not do, and occasionally caused people to complain that if they
    tried to play a _really big_ game in their browser, the JS would
    eventually freeze because the emulated memory ran out.
    
    I've been putting off doing this for ages because my previous
    Emscripten build setup was so finicky that I didn't like to meddle
    with it. But now that the new cmake system in this source tree makes
    things generally easier, and particularly since I've just found out
    that the up-to-date Emscripten is available as a Docker image (namely
    "emscripten/emsdk"), this seemed like a good moment to give it a try.
    
    The source and build changes required for this update weren't too
    onerous. I was half expecting a huge API upheaval, and indeed there
    was _some_ change, but very little:
    
     - in the JS initPuzzle function, move the call to Module.callMain()
       into Module.onRuntimeInitialized instead of doing it at the top
       level, because New Emscripten's .js output likes to load the
       accompanying .wasm file asynchronously, so you can't call the WASM
       main() until it actually exists.
    
     - in the JS-side library code, replace all uses of Emscripten's
       Pointer_stringify() function with the new name UTF8ToString(). (The
       new version also has an ASCIIToString(), so I guess the reason for
       the name change is that now you get to choose which character set
       you meant. I need to use UTF-8, so that the × and ÷ signs in Keen
       will work.)
    
     - set EXTRA_EXPORTED_RUNTIME_METHODS=[cwrap,callMain] on the emcc
       link command line, otherwise they aren't available for my JS setup
       code to call.
    
     - (removed -s ASM_JS=1 from the link options, though I'm not actually
       sure it made any difference one way or the other in the new WASM
       world)
    
     - be prepared for a set of .wasm files to show up as build products
       alongside the .js ones.
    
     - stop building with -DCMAKE_BUILD_TYPE=Release! I'm not sure why
       that was needed, but if I leave that flag on my cmake command line,
       the output .js file fails to embed my emccpre.js, so the initial
       call to initPuzzle() fails from the HTML wrapper page, meaning
       nothing at all happens.

 Buildscr                         | 25 ++++++++++++++++------
 cmake/platforms/emscripten.cmake |  4 +++-
 emcclib.js                       | 46 ++++++++++++++++++++--------------------
 emccpre.js                       | 24 +++++++++++----------
 4 files changed, 57 insertions(+), 42 deletions(-)



More information about the tartarus-commits mailing list