Feature #18

Guess the location of the share directory on Windows based on the location of the executable

Added by Florian over 5 years ago. Updated over 3 years ago.

Status:FeedbackStart date:2012-03-02
Priority:NormalDue date:
Assignee:Florian% Done:

90%

Category:-
Target version:Candidate for next minor release
Platform:

Description

GMT should be able to guess the location of the sharedir on Windows based on the location of the executable: <execdir>../share as discussed in the forum


Related issues

Related to Feature #26: Let NSIS installer replace the GMT_SHAREDIR environment v... Closed 2012-03-03

History

#1 Updated by Florian over 5 years ago

Actually this feature would be beneficial for all monolithic type stand-alone binary packages including OSX Bundles and Linux binary packages. Since the user can install these packages anywhere there must be a way to guess the share path from the location of the executable without need to specify GMT_SHARE_DIR. This is even more important when multiple side-by-side installations would require resetting the GMT_SHARE_DIR environment variable.

#2 Updated by Florian over 5 years ago

  • Target version changed from Candidate for next minor release to 5.1.0

#3 Updated by Florian over 5 years ago

  • Status changed from New to In Progress
  • Assignee changed from Joaquim to Florian
  • % Done changed from 0 to 50

Just remembered that I implemented something similar before. I'll look into it and port it to GMT.

I could implement

struct GMT_INIT { /* Holds misc run-time parameters */
...
char *progname;   /* Name of current GMT program */
char *runpath;    /* Directory, where current GMT program resides */
...
and New_GMT_Ctrl(session) instead of New_GMT_Ctrl(). Then in New_GMT_Ctrl(session):
/* We use the calling programs session name as program name */
C->init.progname = basename(session);

/* Set runpath */
GMT_runpath (C->init.runpath, session);
And in GMT_set_env(C):
/* If everything else failed and C->session.SHAREDIR is still not accessible,
 * make a smart guess based on C->init.runpath */
GMT_guess_sharedir (C->session.SHAREDIR, C->init.runpath);

#4 Updated by Florian over 5 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 50 to 90
Committed first try of an implementation as outlined before in r9832. Testet on MacOSX (app bundle) and Windows. Need some feedback on Linux. Features:
  • Extracted shared string manipulation functions (GMT+PSL) from gmt_support.c and gmt_io.c. Now in common_string.c
  • File common_runpath.c contains code to determine absolute runtime path and guess the GMT_SHAREDIR from that.
  • If the layout of the tree, especially the relative location of share with respect to bin is not altered GMT will find the share dir automatically (no need to set env GMT_SHAREDIR)
  • If GMT_SHAREDIR is set it takes precedence
  • Only if the path specified in GMT_SHAREDIR does not exist or if the hardcoded GMT_SHAREDIR is not found, GMT_guess_sharedir kicks in (GMT_set_env)
  • The same applies for PSL, which can determine its share dir automatically if all other options (env, hardcoded) fail.

I'm not very happy with the redundancy of functionality in GMT and PSL: If GMT initializes a PSL_CTRL the whole initialization of runpath and GMT_SHAREDIR is performed twice.

#5 Updated by Florian over 3 years ago

  • Target version changed from 5.1.0 to Candidate for next minor release

Also available in: Atom PDF