Lazarus

Using the Lazarus IDE => General => Topic started by: CCRDude on March 23, 2018, 11:16:49 am

Title: $(TargetFile) bug for DLLs with set Host application?
Post by: CCRDude on March 23, 2018, 11:16:49 am
I've written an IDE plugin to integrate codesigning into the IDE workflow (https://gitlab.com/ccrdude/lazcodesigninghelper). To determine the output of the binary, I use $(TargetFile).

Code: Pascal  [Select][+][-]
  1. procedure TCodeSigningHelper.DoProjectBuildingFinished(ASender: TObject; ABuildSuccessful: boolean);
  2. var
  3.    s: string;
  4.    sTargetOS: string;
  5.    b: boolean;
  6. begin
  7.    s := '$(TargetFile)';
  8.    sTargetOS := GetTargetOS;
  9.    if IDEMacros.SubstituteMacros(s) then begin
  10.       if ABuildSuccessful then begin
  11.          b := False;
  12.          if TMicrosoftSignToolSigner.SupportsLazarusTargetOS(sTargetOS) then begin
  13.             b := CodeSigningOptions.MicrosoftSignToolOptions.AutoSign;
  14.          end else if TAppleCodeSignSigner.SupportsLazarusTargetOS(sTargetOS) then begin
  15.             b := CodeSigningOptions.AppleCodeSignOptions.AutoSign;
  16.          end else if TJavaKeyToolSigner.SupportsLazarusTargetOS(sTargetOS) then begin
  17.             b := CodeSigningOptions.JavaKeyToolOptions.AutoSign;
  18.          end;
  19.          if b then begin
  20.             AddIDEMessage(mluNone, rsCodeSigningStatusSigning, '', 0, 0, rsCodeSigningViewCodeSign);
  21.             CertificateSignExecutable(s);
  22.          end;
  23.  

Today, I was trying to sign a DLL for which I had set a Host application in Run Parameters. The signing code then tried to sign this host application executable, not my library.

According to the Wiki (http://wiki.lazarus.freepascal.org/IDE_Window:_Compiler_Options), $(TargetFile) is the stuff to use for 'Execute after'.
According to Macros in the Wiki (http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames), libraries are clearly included: "TargetFile - the output file of the current project (e.g. the executable or the library)"


I assume this is a bug? Or am I missing something?

(Update: I verified this on another machine with a November 2017 trunk svn version, with a different DLL project with different host application, and could verify it. Lazarus wouldn't compile the updated trunk any longer, so I can't confirm for the latest svn version yet)
(Update #2: meanwhile confirmed with the latest trunk)
Title: Re: $(TargetFile) bug for DLLs with set Host application?
Post by: CCRDude on April 04, 2018, 04:54:13 pm
Got a fresh IDE installed today and verified again; it can be verified much easier using post compile events, here's the reference to Mantis where I now reported it:

https://bugs.freepascal.org/view.php?id=33560
Title: Re: $(TargetFile) bug for DLLs with set Host application?
Post by: CCRDude on October 31, 2018, 09:49:46 am
Small update: it's a duplicate of this one:
https://bugs.freepascal.org/view.php?id=27729

I would love to write a better fix for this, but I need some feedback which direction that should take before creating patches.
TinyPortal © 2005-2018