Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please make it easier to make the DATA_PATH directory relative #754

Open
duganchen opened this issue Feb 20, 2024 · 0 comments
Open

Please make it easier to make the DATA_PATH directory relative #754

duganchen opened this issue Feb 20, 2024 · 0 comments

Comments

@duganchen
Copy link

duganchen commented Feb 20, 2024

Okay, use case first.

I want to build Attract Mode for my Steam Deck, but I don't want to build it on my Steam Deck because that would involve enabling Developer Mode, setting the filesystem to be read-write, and, well, making those intrusive changes. Instead, I want to build it on another machine (using Docker, of course), smoke-test it on that machine (where my username isn't "deck"), copy the output directory to my Steam Deck's home directory, and then add it to Steam as a non-Steam game. So, in the end, my Steam Deck would have:

  • ~/attract-2.7.0/bin/attract
  • ~/attract-2.7.0/share/attract/
  • ~/attract-2.7.0/lib/ (any libraries I need to copy over go here)

The lib directory can be dealt with using patchelf (I know I should be able to do this with an environment variable, but I couldn't get that to work):

patchelf --set-rpath \$ORIGIN/../lib /path/to/attract-2.7.0/bin/attract

(Reference: https://stackoverflow.com/questions/13769141/can-i-change-rpath-in-an-already-compiled-binary)

The share directory location, well, that's why I entered the ticket. I want Attract Mode to look for it in a place relative to the executable location. The only way I could get that to work was by patching the Makefile:

diff '--color=auto' -rupN attract-2.7.0.orig/Makefile attract-2.7.0/Makefile
--- attract-2.7.0.orig/Makefile 2023-06-10 12:32:15.000000000 -0700
+++ attract-2.7.0/Makefile      2024-02-19 21:12:09.231851985 -0800
@@ -784,13 +784,13 @@ $(GSBASE_OBJ_DIR)/%.o: $(EXTLIBS_DIR)/ga
 $(GSBASE_OBJ_DIR):
        $(MD) $@

-$(DATA_PATH):
+$(datarootdir):
        $(MD) -p $(DESTDIR)$@

-install: $(EXE) $(DATA_PATH)
+install: $(EXE) $(datarootdir)
        install -D $(EXE) $(DESTDIR)$(bindir)/$(EXE)
-       mkdir -p $(DESTDIR)$(DATA_PATH)
-       cp -r config/* $(DESTDIR)$(DATA_PATH)
+       mkdir -p $(datarootdir)/attract
+       cp -r config/* $(datarootdir)/attract

 smallclean:
        -$(RM) $(OBJ_DIR)/*.o *~ core

I don't know if I did it exactly right, but that does work. My build command line is then:

make install prefix=/output/attract-2.7.0 datadir=../share

Reference:
https://stackoverflow.com/questions/9654062/tell-a-configure-script-to-use-a-relative-path-for-datarootdir

The point is is that it would be nice to have an easier way of making the executable look for DATA_PATH in a relative location, and not an absolute one.

This would also make it easier to build, say, an AppImage, which needs the executable to look for data in paths that are relative to the executable location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant