denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Denemo-devel] OSX hardwired paths


From: Nils Gey
Subject: [Denemo-devel] OSX hardwired paths
Date: Tue, 19 Apr 2011 23:06:56 +0200

(19:56) ( rshann) The link you gave Nils^ for identifying OSX in a C program 
indicates we should test for __APPLE__
(19:58) ( rshann) Shall I check in code that tests for this - and what
path should be used - ie where will we tell OSX to install denemo?

Below in this mail is a way to retrieve the exe path of an osx application.

Here are all paths we need for osx. What comes out of Gub is a dir that is 
called GNU_Denemo (or just Denemo when I finally change it for a release, like 
in Windows.) This is our root for this mail. In there are two, osx specific, 
bundle dirs with only metadata in it. So we have (case sensitive!)

......GNU_Denemo/Contents/Resources/
  bin/<all bins, including denemo>
  etc/
        etc/denemo
        etc/fonts
        etc/gtk-2.0
        etc/pango
        etc/relocate  <this is gub specific! see below>
  lib/<all libs with subdirs.>
  license/<textfiles>
  share/<no /usr/share. just share. here is denemos share and others like 
lilypond and guile in their subdirs>
  var/cache/fontconfig/<empty>

So whatever Denemo needs it is always ../xyz

I anticipate problems with Denemos font. I remember we had to choose a font 
path in Windows. There seems to be at least one way to do this in the bundle 
(via the metadata I mentioned). Maybe I look for this once Denemo starts.

Regarding the relocate folder. It has files for guile, gtk and few others in 
there. The guile.reloc has one line which is:

prependdir GUILE_LOAD_PATH=$INSTALLER_PREFIX/share/guile/1.8

Janneke told me about this in a recent mail, before we had relocating enabled! 
I don't know how this works with or against Denemo Guile version:
> LilyPond reads and processes .../etc/relocate/*.reloc; guile.reloc
> sets the necessary paths and directories for GUILE.  The GUILE
> executable does not do that.
> 
> Denemo, iirc, uses another binreloc mechanism.  I think I added
> some patches to make it work with GUB. <<Nils: there is no patch. It was just 
> --enable-binreloc and make compiler flags for this>>
> 
> So, for GUILE to work from Denemo, either Denemo (or GUILE, that would
> be nicest) should read ../etc/relocate/*.reloc and/or set
> GUILE_LOAD_PATH etc directly using binreloc.


To get the path.
http://stackoverflow.com/questions/799679/programatically-retrieving-the-absolute-path-of-an-os-x-command-line-app

The function _NSGetExecutablePath will return a full path to the executable 
(GUI or not). The path may contain symbolic links, "..", 
etc. but the realpath function can be used to clean those up if needed. See man 
3 dyld for more information.

char path[1024];
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0)
    printf("executable path is %s\n", path);
else
    printf("buffer too small; need size %u\n", size);

The secret to this function is that the Darwin kernel puts the executable path 
on the process stack immediately after the envp array when it creates the 
process. The dynamic link editor dyld grabs this on initialization and keeps a 
pointer to it. This function uses that pointer.


Nils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]