Aisleriot: how can I specify the path to the games

I want to have a shot at porting Aisleriot to gtk4. I’m not sure how successful I’ll be, as I have lots of experience with python and gtk, but little experience with c, but I want to take a shot at it.

I’ve checked out the code and compiled it. When I run it, how can I point it to the directory containing the game .go files, without copying said files to a system directory?

I did a strace to see where it was trying to open the files from, which yielded only system folders:

newfstatat(AT_FDCWD, "/usr/share/guile/3.0/klondike.scm", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/3.0/klondike", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/site/3.0/klondike.scm", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/site/3.0/klondike", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/site/klondike.scm", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/site/klondike", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/klondike.scm", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/share/guile/klondike", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/local/share/aisleriot/guile/3.0/klondike.scm", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/local/share/aisleriot/guile/3.0/klondike", 0x7ffdef1d36f0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib64/guile/3.0/ccache/klondike.go", 0x7ffdef1d3450, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib64/guile/3.0/site-ccache/klondike.go", 0x7ffdef1d3450, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/local/lib64/aisleriot/guile/3.0/klondike.go", 0x7ffdef1d3450, 0) = -1 ENOENT (No such file or directory)

I’m not familiar with how Aisleriot is implemented, but the most likely solution is to adjust some environment variables.

If Aisleriot follows the XDG Base Directory Specification, you can adjust the XDG_DATA_DIRS env variable.

The following code in src/game.c#L2581-2584 automatically loads the games from the prefix used during meson setup.

  path = g_build_filename (ar_runtime_get_directory (AR_RUNTIME_PKG_LIBRARY_DIRECTORY),
                           "guile",
                           SCM_EFFECTIVE_VERSION,
                           NULL);

Example:

With

$ meson setup _build -Dprefix=/tmp/aisleriot/_install

the following line in above C code

ar_runtime_get_directory (directory=AR_RUNTIME_PKG_LIBRARY_DIRECTORY) 

returns

"/tmp/aisleriot/_install/lib/x86_64-linux-gnu/aisleriot"

Actual game path can be obtained by

g_build_filename ("/tmp/aisleriot/_install/lib/x86_64-linux-gnu/aisleriot", "guile", "3.0")

returns

"/tmp/aisleriot/_install/lib/x86_64-linux-gnu/aisleriot/guile/3.0/"

which has the .go files.

1 Like

Thanks! That worked.