* * *

Author Topic: Relative path to .app package contents in OSX  (Read 2057 times)

Uto

  • New member
  • *
  • Posts: 25
Relative path to .app package contents in OSX
« on: December 08, 2015, 12:16:26 pm »
Hi,

I have a project that was running in Windows and Linux so far, and now I'm trying to port it to OSX as well. The project is an IDE for a compiler of mine, which is a C application.

On other OSs, the IDE executable is in the same folder where compiler is, so the IDE default path to compiler is just the compiler file name.

In OSX, Lazarus creates (cause I asked for it) a .app package, where as you know, the actual executable is at Contents/MacOS folder.

I would want to include the compiler and some required libraries in the package, so I can share just the app file, cause it is more close to OSX standards, so I've tried to add the compiler to the Contents/MacOS folder, but it seems the execution folder is the path were the .app "file" is, so the result is "compiler not found" when trying to compile.

I have also tried to set default path to myapp.app/Contents/MacOS/compiler (where "compiler" is the name of the compiler executable file) and to ./myapp.app/Contents/MacOS/compiler, but I had no success.

Probably I'm not doing it the right way, is there something I'm missing? Maybe a better organized way of building the package?

GetMem

  • Hero Member
  • *****
  • Posts: 2248
Re: Relative path to .app package contents in OSX
« Reply #1 on: December 08, 2015, 01:41:20 pm »
Quote
In OSX, Lazarus creates (cause I asked for it) a .app package, where as you know, the actual executable is at Contents/MacOS folder.
The actual executable is inside your project folder. The alias inside Contents/MacOS  is just a "link". After the development is done, you should replace it with the executable from your project dir. Anyway ParamStr(0) should always indicate ../Contents/MacOS/
Code: Pascal  [Select]
  1. CompilerPath := ParamStr(0) + 'CompilarName';

Uto

  • New member
  • *
  • Posts: 25
Re: Relative path to .app package contents in OSX
« Reply #2 on: December 08, 2015, 08:27:30 pm »
Thank you for your reply.

I hadn't noticed the "executable" within the package was just a symbolic link. Also, using ParamStr(0) seems to be the perfect way to set all required files locations relatively to that path.

Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.

Also, I've noticed when I put the executable zip file inside the package,  Lazarus cannot create symbolic link anymore cause a file with same name already exists, what is very inconvenient. Is there any walkaround for this issue?


GetMem

  • Hero Member
  • *****
  • Posts: 2248
Re: Relative path to .app package contents in OSX
« Reply #3 on: December 08, 2015, 09:03:11 pm »
Quote
@Uto
Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.
I. Create a bash script with all the command you need:
    1. copy executable under "Contents/MacOS"
    2. copy compiler under "Contents/MacOS/Compiler"
    3. etc...
II. Lazarus Menu-->Project-->Project Options-->Compiler Commands-->Execute After. Type the exact path of your bash script. After every Compile or/and Build or/and Run the script is executed. First you need to make the script executable with chmod.

Uto

  • New member
  • *
  • Posts: 25
Re: Relative path to .app package contents in OSX
« Reply #4 on: December 09, 2015, 12:59:02 pm »
Quote
@Uto
Now I just wonder if is there any way to make the Lazarus compiler put the real exe file inside the package, together with the localization folder (my IDE is multilanguage). Otherwise as you say I have to move the exe file to the inner folder, and the language files too, and I'm worried cause I may well forget it.
I. Create a bash script with all the command you need:
    1. copy executable under "Contents/MacOS"
    2. copy compiler under "Contents/MacOS/Compiler"
    3. etc...
II. Lazarus Menu-->Project-->Project Options-->Compiler Commands-->Execute After. Type the exact path of your bash script. After every Compile or/and Build or/and Run the script is executed. First you need to make the script executable with chmod.

That will do it, I had the script already built (apart of the compiler it needs some libraries) but I didn't know about the "execute after" option, many thanks!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus