Data paths configurable at runtime

2011-06-10
2013-03-05
  • Jared Quick

    Jared Quick - 2011-06-10

    Hello,

    I am trying to package this into a OSX app using the GTK-OSX framework. I have the most recent SVN version working fine from the command line. The issue im hitting on is that the data paths are hard coded on compile:

    configure.ac: datadir='${prefix}'
    configure.ac: pioneers_datadir=$datadir
    configure.ac: pioneers_themedir=$datadir/games/pioneers/themes

    When I try to package this into a "bundle" everything works fine except it dies when trying to access a theme at the hardcoded DATADIR. Digging around GTK-OSK bundler it looks like it should automatically update them if  we use the freedesktop "data dir" specification. Greping through the source I see that someone tried to set this up awhile ago:

    client/help/C/pioneers.xml:   <title>Settings file <application>$XDG_CONFIG_HOME/pioneers</application></title>
    docs/pioneers-server-gtk.6:.B $XDG_DATA_HOME/pioneers/*.game
    docs/pioneers-server-gtk.6:.B $XDG_CONFIG_HOME/pioneers-server
    docs/pioneers.6:.B $XDG_CONFIG_HOME/pioneers
    docs/pioneers.6:.B $XDG_DATA_HOME/pioneers/themes

    But looks like its deprecated and got thrown in docs? Long story short. Is there any easy way to setup the $XDG configuration again? If not do you know another way to assign DATADIR to the relative dir pioneers is running from?

    Please view https://sourceforge.net/apps/phpbb/gtk-osx/viewtopic.php?f=4&t=62&p=313#p313 for more in depth explanation.

    Thanks for your help.

     
  • Jared Quick

    Jared Quick - 2011-06-10

    I was able to build a partial windows version and use the $XDG variables to locate the themes properly. Now I need to figure out how to fix:

    6/10/11 9:32:18 AM .com.jq.pioneers (Pioneers-bin:53333): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file '///Users/jquick/Desktop/Pioneers.app/Contents/Resources/etc/gdk-pixbuf-2.0/2.10.0/gdk-pixbuf.loaders': No such file or directory

     
  • Jared Quick

    Jared Quick - 2011-06-10

    Fixed that issue, now im just working on the pixmap locations.

    6/10/11 9:52:08 AM .com.jq.pioneers ** (Pioneers-bin:64605): WARNING **: Pixmap not found: ./pixmaps/pioneers/brick.png

     
  • Jared Quick

    Jared Quick - 2011-06-10

    overriding pioneers_datadir=$datadir in the config seemed to fix the issue. All working now.

    Thanks!

     
  • Bas Wijnen

    Bas Wijnen - 2011-06-10

    As to your first question (which is appearantly already answered):
    - The paths in configure.ac are the program's installation directory. If you want to change them, you should change configure.ac as you did. These will only be used at build time, and must be absolute paths.
    - At run time, the directories are located using XDG_* (with appropriate fallback) for user data and the values from configure.ac. Most (all?) data can be both in a user dir or the global installation dir.

    So when building a package, you should change configure.ac to point to the installation directory. It is not possible to build the package without knowing the installation directory, I think. (That is, a package which can be "installed" by unpacking it in any place.)

     
  • Jared Quick

    Jared Quick - 2011-06-10

    Ok so it looks like it was still using local pixmaps when running.

    This is what I used to get themes to work:
    export XDG_DATA_HOME="$bundle_data"/games

    But I cannot find an XDG that will alter the pixmap path at runtime. I've tried:

    export XDG_DATA_DIR="$bundle_data" but no go. It keeps trying to access it out of my install path:

    6/10/11 1:05:04 PM .com.jq.pioneers ** (Pioneers-bin:89362): WARNING **: Pixmap not found: /Users/jquick/gtk/inst/share/pixmaps/pioneers/dice.png

    I'm reading up on XDG because im still foggy on how they get set and work.

     
  • Bas Wijnen

    Bas Wijnen - 2011-06-10

    Actually, XDG is quite simpel:
    - A program should use the value of XDG_* variables if they are defined, or certains defaults if not.
    - This is only about user-specific data, not about "installed" data.
    - We use XDG_CONFIG_HOME and XDG_DATA_HOME, I think. We don't need the others.
    - I think we don't provide a way to change the install directory after build. You may check the source to be sure, and you can patch it to support an environment variable, if you'd like. I think it's passed as DATADIR or something (check Makefile.am); grep the sources for that.

     
  • Jared Quick

    Jared Quick - 2011-06-10

    Yeah it does use DATADIR. What is the best way to patch this into a EVN? Is there a main C file that is triggered on start that I can just insert an assignment into?

     
  • Jared Quick

    Jared Quick - 2011-06-11

    Not sure if its the best way to do this.. but it turns out DATADIR is only used in about 4 files. So i just replaced it with g_get_user_data() so it points to XDG_DATA_HOME also. Worked like a charm.

     
  • Jared Quick

    Jared Quick - 2011-06-12

    Thanks for all your help! If anyone has a mac and wants to try it out feel free.

    https://github.com/jquick/pioneers_app

    Should work fine on any intel mac >10.4.

     
  • iN8sWoRld

    iN8sWoRld - 2011-06-12

    Tried to run on 10.5.8 on Intel Macbook.  Are you developing on 10.6 by any chance?

    Date/Time:       2011-06-12 09:29:04.485 -0400
    OS Version:      Mac OS X 10.5.8 (9L30)
    Report Version:  6
    Anonymous UUID:  EB1CFCDF-E116-4567-A6B6-EABD7F5C8627

    Exception Type:  EXC_BREAKPOINT (SIGTRAP)
    Exception Codes: 0x0000000000000002, 0x0000000000000000
    Crashed Thread:  0

    Dyld Error Message:
      unknown required load command 0x80000022

     
  • Jared Quick

    Jared Quick - 2011-06-12

    Ah yes, looking deeper into my gtk-osx i am setting it to 10.6.  It looks like it requires intel >= 10.6.

    Sorry for the confusion.

     
  • Brian Wellington

    The app works for me (at least the server, client, and AI; didn't try network play).  The only weirdness I see is that the Quit menu options (in the main menubar, not the gtk menubar) have no effect, but that's probably a GTK-OSX issue.  Thanks!

     
  • Jared Quick

    Jared Quick - 2011-06-14

    Yeah im still working on that, GTK-OSX has a library to help integrate the app with the OSX menu bar. But other then that it should be fully functional.

     
  • Brian Wellington

    Actually, one more thing.  When selecting a game from the settings, each map is duplicated (the second one has a "1" at the end).  Could something be adding the map directory twice?

     
  • Jared Quick

    Jared Quick - 2011-06-14

    hmm yeah I bet its looking both local and the ENV I setup. I'll see if i can fix that.

     
  • Jared Quick

    Jared Quick - 2011-06-15

    NEW VERSION OUT: https://github.com/downloads/jquick/pioneers_app/Pioneers.app.zip
    changelog:
       -menu is now up on the osx bar
       -all keybinding for all programs now use their native osx <command> keys
       -quit menu at osx bar and doc now work
       -fixed dupe maps showing up in server list
       -unbound XDG_CONFIG_HOME/XDG_DATA_HOME so you can use custom maps/config if you wish

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks