Forum > Options

Execute after

<< < (2/2)

Gustavo 'Gus' Carreno:
Hey Tim,


--- Quote from: timppl on August 23, 2021, 07:23:52 am ---Gustavo, I tried your solution but could not get it to work.

--- End quote ---

Humm, that's rather strange, I would swear that the way windows works it should work. At least what I thought would be the way Windows would look for the extension.
Maybe I'm confused and it's only possible if you use the cmd.exe.
I guess that the extension guessing does not apply when Lazarus is running it under a TProcess.


--- Quote from: timppl on August 23, 2021, 07:23:52 am ---I did some playing around and found a solution. Instead of using a script, I rewrote it in pascal and compiled a version for linux and one for windows. Then in the execute after I put

--- Quote ---$MakeExe($(ProjSrcPath)/clean_after)
--- End quote ---
The MakeExe macro does nothing under linux so that "clean_after" is executed, and under windows it adds .exe to the name so that "clean_after.exe" is executed.
Once I worked this out it seemed so simple :D.

 Thanks Lazarus devs for this facility

--- End quote ---

Oddly enough, this was exactly what I was trying to achieve, LOL :D !!
Well, almost. I was trying with the .bat instead of the .exe.
But HEY, it works, so problem solved :)

Looks like I need to revisit my knowledge of how, if even it does, TProcess looks for the extension of an executable file when you don't include it.

Cheers,
Gus

timppl:
Hi all

The small problem with this can occur if cross compiling, because $MakeExe uses the build target to name the executable, so, for example, building a Win32 target on linux it looks for foo.exe.

Those clever Lazarus developers have thought of this as well  :D.
In later varsions of Lazarus ( certainly from 2.0.12 ) there is a $MakeExe which takes two parameters so you can do $MakeExe(ide, $(ProjSrcPath)/foo) which will rename foo according to the OS that the IDE is running under.

Navigation

[0] Message Index

[*] Previous page

Go to full version