Recent

Author Topic: Project, Compiler Options, Execute After  (Read 14439 times)

wmike

  • Newbie
  • Posts: 3
Project, Compiler Options, Execute After
« on: January 11, 2009, 05:40:03 am »
Is there a way I can call a bat file to run strip.exe and upx.exe in this section?

I can't seem to find the app variable so I can pass it to the bat file.

Thanks,
Mike Wheaton

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Project, Compiler Options, Execute After
« Reply #1 on: January 12, 2009, 06:13:43 am »
if you have (in .bat file):
Code: [Select]
strip -s %1
upx --best --lzma %1
then you can use (in execute after):
Code: [Select]
batfile.bat $TargetFile()In case I was wrong, try looking the suitable macro here.

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 133
Re: Project, Compiler Options, Execute After
« Reply #2 on: April 21, 2009, 11:14:30 am »
This is my solution for Windows SO...

In Compiler Options, Execute after I inserted this

Strip_Exe.bat  $Path($CompPath()) $TargetCPU() $TargetFile()

and in the project path I've inserted the file Strip_Exe.Bat
Code: [Select]
rem Batch per "strippare" il file
rem riceve come parametri:
rem 1 - il percorso in cui si trovano i file binari di FPC (es.

rem 2 - il processore utilizzato (per ora Arm o x86)
rem 3 - il file eseguibile da strippare...
echo percorso %1
echo Processore %2
echo file %3

rem Nessun check di validità dei parametri...

IF %2%==arm goto l_ARM

IF %2%==i386 goto l_I386

goto fine

:l_ARM
Rem Strip per processore Arm
echo Processore %2%
%1arm-wince-strip --strip-all %3

goto fine

:l_I386
Rem Strip per processore i386
echo Processore %2%
%1strip --strip-all %3


:fine
rem chiudo il bat...

Missing the Upx only....

Bye


Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
Re: Project, Compiler Options, Execute After
« Reply #3 on: April 21, 2009, 03:49:38 pm »
Checking -Xs in the compiler options is not enough?

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 133
Re: Project, Compiler Options, Execute After
« Reply #4 on: April 28, 2009, 11:31:19 am »
yes...

jmLandsvik

  • New Member
  • *
  • Posts: 29
Re: Project, Compiler Options, Execute After
« Reply #5 on: April 06, 2011, 11:38:07 am »
This problem persists?

I've put in this under Project/options/Compiler/options/compilation
command:
D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe --strip-all $(TargetFile)
and get this message
D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe: Documents\PROSJEKT\lazarus\AttriButeNumbering\Attributes.exe: No such file or directory

looking at the error, it's even missing a part, as my path is:
"D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering"

Reading the "manual",under "Paths & Parts" says this:
TargetFile - the output file of the current project (e.g. the executable or the library)

So, where did I go wrong?

Checking -Xs in the compiler options is not enough?
Nope, not on my puter it is...

regards...
//JM

« Last Edit: April 06, 2011, 12:04:48 pm by jmLandsvik »

jmLandsvik

  • New Member
  • *
  • Posts: 29
Re: Project, Compiler Options, Execute After
« Reply #6 on: April 06, 2011, 12:09:56 pm »
I don't belive this....

After looking at the error and seeing that it is missing the "first part" of my path, I did a little experimenting, and when I got to this:

D:\lazarus\fpc\2.4.3\bin\i386-win32\strip.exe --strip-all "$(TargetFile)"

(Note the double qoutes) it actually worked...

Great, but, really, this can't be intentioanlly? or can it ?

//Jan Magne

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Project, Compiler Options, Execute After
« Reply #7 on: April 06, 2011, 08:35:41 pm »
Quote
looking at the error, it's even missing a part, as my path is:
"D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering"

(Note the double qoutes) it actually worked...

Great, but, really, this can't be intentioanlly? or can it ?
You have spaces in the project path, surely without quotes it would be regarded as two arguments for strip.

jmLandsvik

  • New Member
  • *
  • Posts: 29
Re: Project, Compiler Options, Execute After
« Reply #8 on: April 08, 2011, 03:30:43 pm »
Quote
looking at the error, it's even missing a part, as my path is:
"D:\users\myDir\My Documents\PROSJEKT\lazarus\AttriButeNumbering"

(Note the double qoutes) it actually worked...

Great, but, really, this can't be intentioanlly? or can it ?
You have spaces in the project path, surely without quotes it would be regarded as two arguments for strip.

Hi,
Well, first I would think that when using $(TargeFile) I would get the "FileName", and not "Drive:\Path\FileName"
Second, when putting in av "$(variable)" like that, it would be handled properly, ie. either double qoutes be insertet automatiacally, or when needed.
Or is it normal, that ONE systemvariable will be treated different depending on what's inside? *cofused*

tnx., and regards
Jan Magne


Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Project, Compiler Options, Execute After
« Reply #9 on: April 09, 2011, 05:46:55 am »
Quote
Well, first I would think that when using $(TargeFile) I would get the "FileName", and not "Drive:\Path\FileName"
Hmm... agreed. The macro name is a little misleading, but it's already there for a long time. And it's easy to get just the filename: $NameOnly($TargetFile())
Quote
Second, when putting in av "$(variable)" like that, it would be handled properly, ie. either double qoutes be insertet automatiacally, or when needed.
AFAIK the macro expander only expands to the contents, no more no less. Everything outside the $() construct isn't part of the macro and is totally your freedom.
Quote
Or is it normal, that ONE systemvariable will be treated different depending on what's inside? *cofused*
AFAIK no.

ArtLogi

  • Full Member
  • ***
  • Posts: 194
Re: Project, Compiler Options, Execute After
« Reply #10 on: January 19, 2016, 04:59:54 pm »
I have also a problem with this strip.exe tool under Lazarus. I'm using FPC v2.6.4 and Laz v1.2.6 under w7.

Trying to get that 15Mb a bit smaller, since tbh, for tool that counts 1+1 it is a bit much. So debugging data have to go. :)

I did follow these instructions: http://lazplanet.blogspot.fi/2013/03/how-to-reduce-exe-file-size-of-your.html

I assume I would also go through just project settings, but since there is now rather simplistic problem in hand (hope so) I would like to know the solution, I have stried some alteration of the "working directory path" as follows: "$ProjPath()" --strip-all "$TargetFile()" etc. , but obviously ending even more obscure result of wrong path.

The fields are like:
C:\FPC\2.6.4\bin\i386-win32\strip.exe
--strip-all "$TargetFile()"

The wrong path error is then:
Unable to run the tool "Strip current EXE":
Working directory C:\lazarus\--strip-all
"C:\users\Me\Desktop\MyProject\Verkko.exe"\ not found.

The C:\Lazarus\ is the folder as set in the "IDE options"

How I can get rid of that? So the tool can work no matter the project folder..

Thank you.
While Record is a drawer and method is a clerk, when both are combined to same space it forms an concept of office, which is alias for a great suffering.

balazsszekely

  • Guest
Re: Project, Compiler Options, Execute After
« Reply #11 on: January 19, 2016, 05:10:23 pm »
1. Go to: Lazarus Menu-->Project-->Project Options-->Compiler Option-->Build Modes-->Create Debug and Release modes-->Select release
2. Build your application again. Form 15M you're down to 1.5 M(empty application). You can further shrink the size with upx, but please note some AV's may detect your exe as false positive.

ArtLogi

  • Full Member
  • ***
  • Posts: 194
Re: Project, Compiler Options, Execute After
« Reply #12 on: January 19, 2016, 05:38:12 pm »
1. Go to: Lazarus Menu-->Project-->Project Options-->Compiler Option-->Build Modes-->Create Debug and Release modes-->Select release
2. Build your application again. Form 15M you're down to 1.5 M(empty application). You can further shrink the size with upx, but please note some AV's may detect your exe as false positive.
OK, that way it works as should without any problems in my case 15Mb to 1.8Mb (without UPX).. Although the route for the right option you propose is not most clear one, since the Build Modes seems to be behind that tickbox at up middle. (For future readers)
Picture:
http://i.imgur.com/yHtbFSj.png

Does anyone have idea how the strip.exe can be properly linked, so it does search from the true project path and not from the path entered in IDE settings (my case C:\Lazarus\).

For my part this is now solved.

Edit. Two unworking variation to call strip.exe

http://i.imgur.com/qyJL9bT.png
http://i.imgur.com/SrFxHCB.png

OK, the last (and the most obvious thing I didn't try is place the parameters to parameters field.  :-[

Strip.exe also works now... http://i.imgur.com/IWb25S5.png

That tutorial on that blog seems to be out dated. ?? No.. I have somesort of dyslexia going on right here atm. it seems. From blog:
Quote
Parameters: --strip-all "$TargetFile()"
« Last Edit: January 19, 2016, 06:12:48 pm by ArtLogi »
While Record is a drawer and method is a clerk, when both are combined to same space it forms an concept of office, which is alias for a great suffering.

 

TinyPortal © 2005-2018