I've written an
IDE plugin to integrate codesigning into the IDE workflow. To determine the output of the binary, I use $(TargetFile).
procedure TCodeSigningHelper.DoProjectBuildingFinished(ASender: TObject; ABuildSuccessful: boolean);
var
s: string;
sTargetOS: string;
b: boolean;
begin
s := '$(TargetFile)';
sTargetOS := GetTargetOS;
if IDEMacros.SubstituteMacros(s) then begin
if ABuildSuccessful then begin
b := False;
if TMicrosoftSignToolSigner.SupportsLazarusTargetOS(sTargetOS) then begin
b := CodeSigningOptions.MicrosoftSignToolOptions.AutoSign;
end else if TAppleCodeSignSigner.SupportsLazarusTargetOS(sTargetOS) then begin
b := CodeSigningOptions.AppleCodeSignOptions.AutoSign;
end else if TJavaKeyToolSigner.SupportsLazarusTargetOS(sTargetOS) then begin
b := CodeSigningOptions.JavaKeyToolOptions.AutoSign;
end;
if b then begin
AddIDEMessage(mluNone, rsCodeSigningStatusSigning, '', 0, 0, rsCodeSigningViewCodeSign);
CertificateSignExecutable(s);
end;
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, $(TargetFile) is the stuff to use for 'Execute after'.
According to
Macros in the Wiki, libraries are clearly included: "TargetFile - the output file of the current project (e.g. the executable or the library)"
- I use Lazarus 1.8.2 64 bit secondary (but only) installation as the current stable version
- Set Host application in Run Parameters to a 64 bit Total Commander executable, and code above will use the TC executable for IDEMacros.SubstituteMacros('$(TargetFile)')
- If I remove the Host application setting, the code above will use the correct project DLL file.
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)