AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Delphi Preprocessor und Subprocessor?
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi Preprocessor und Subprocessor?

Ein Thema von Assarbad · begonnen am 10. Aug 2003 · letzter Beitrag vom 26. Mär 2010
Antwort Antwort
Seite 1 von 2  1 2      
Assarbad
(Gast)

n/a Beiträge
 
#1

Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 14:51
Hiho,

suche einen Experten (DLL!) oder ähnliches der folgendes macht:
  • Vor dem Kompilieren führt er eine Batchdatei oder Befehle meiner Wahl aus
  • Nach dem Kompilieren eine andere Batchdatei oder Befehle

Sinn und Zweck: direkt in der IDE die Ressourcen kompilieren (erst ab Delphi 5 kann man RCs einbinden, vorher gehen nur RES) und nach dem kompilieren die Checksumme der EXE setzen. (Und evtl noch per UPX packen)
  Mit Zitat antworten Zitat
jbg

Registriert seit: 12. Jun 2002
3.481 Beiträge
 
Delphi 10.1 Berlin Professional
 
#2

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 15:06
Das lässt sich doch recht schnell zusammen schreiben, vorausgesetzt man kennt sich mit der OpenTools API aus.

Delphi-Quellcode:
unit PrePostProcessor;
interface
uses
  SysUtils, ToolsAPI;
type
  TCompilerNotifier = class(TNotifierObject, IOTAIDENotifier)
  public
   // IOTAIDENotifier
    procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: string;
      var Cancel: Boolean); virtual;
    procedure BeforeCompile(const Project: IOTAProject;
      var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean); overload; virtual;
   // IOTAIDENotifier50
    procedure BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean;
      var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean); overload; virtual;
  end;

implementation
{ TCompilerNotifier }

{ veraltete Methoden }
procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean);
begin
end;

{ neue Methoden }
procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean; var Cancel: Boolean);
begin
  if SameText(ExtractFileExt(Project.FileName), '.bpg') then Exit; // This should never happen
  if IsCodeInsight then Exit;

// Project.FileName gibt den Dateinamen des Projekts an (.dpr).

{ // save all
  Cancel := not (BorlandIDEServices as IOTAModuleServices).SaveAll;
  if Cancel then Exit; }


end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean);
begin
  if not IsCodeInsight then
  
end;

procedure TCompilerNotifier.FileNotification(NotifyCode: TOTAFileNotification;
  const FileName: string; var Cancel: Boolean);
begin
  Cancel := False;
end;


var
  NotifierIndex: Integer;

{ CompilerNotifier registrieren }
initialization
  NotifierIndex := (BorlandIDEServices as IOTAServices).AddNotifier(TCompilerNotifier.Create);

finalization
  if NotifierIndex >= 0 then
    (BorlandIDEServices as IOTAServices).RemoveNotifier(NotifierIndex);

 // clear all IOTACustomMessages here, else Delphi unloads the dll and then
 // it wants to free the messages -> AccessViolation
  (BorlandIDEServices as IOTAMessageServices).ClearToolMessages;

end.
Das ganze musst du jetzt nur noch in ein DesignTime only Package verpacken, dass designide und rtl requires.
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#3

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 15:51
Wie ich schon sagte: "vor Delphi 4" ... erst seit Delphi 5 ist die OpenTools API so wie sie jetzt eben ist :-/

Ich schau mir deine Lösung mal an und geb dann Feedback-
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#4

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 16:06
Okay, habe nicht explizit sondern nur implizit gesagt, daß es Delphi 4 (oder niedriger) sein muß.

Entsprechend geht es hier auch nicht. Ich werd mal nochmal in die Units schauen, vielleicht läßt sich doch was machen. Vielen Dank, einstweilen
  Mit Zitat antworten Zitat
jbg

Registriert seit: 12. Jun 2002
3.481 Beiträge
 
Delphi 10.1 Berlin Professional
 
#5

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 17:27
Ich hätte auch besser lesen können.


Für Delphi 3 würde das ungefähr so aussehen:
Delphi-Quellcode:
uses ToolIntf, Exptintf;

type
  TCompilerNotifier = class(TIAddInNotifier)
  public
    procedure FileNotification(NotifyCode: TFileNotification;
      const FileName: string; var Cancel: Boolean); override;
    procedure EventNotification(NotifyCode: TEventNotification;
      var Cancel: Boolean); override;
  end;

procedure TCompilerNotifier.EventNotification(NotifyCode: TEventNotification;
  var Cancel: Boolean);
begin
  if NotifyCode = enBeforeCompile then
  begin
    // ..
  end
  else // if NotifyCode = enAfterCompile then
  begin
    // ...
  end;
end;

var
  CompilerNotifier: TCompilerNotifier;

initialization
  CompilerNotifier := TCompilerNotifier.Create;
  ToolServices.AddNotifierEx(CompilerNotifier);
finalization
  ToolServices.RemoveNotifier(CompilerNotifier);
end.
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#6

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 18:05
Dank dir vielmals, derzeit mäkelt er noch bei einem Typen aber ich schau mal, ob ich das ausbügeln kann. Ich melde mich dann nochmal
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#7

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 18:12
Funktioniert wunderbar:

Delphi-Quellcode:
unit PrePostProcessor;
interface
uses ToolIntf, Exptintf;

type
  TCompilerNotifier = class(TIAddInNotifier)
  public
    procedure EventNotification(NotifyCode: TEventNotification; var Cancel: Boolean); override;
  end;

implementation
var
  CompilerNotifier: TCompilerNotifier;

procedure TCompilerNotifier.EventNotification(NotifyCode: TEventNotification; var Cancel: Boolean);
begin
  case NotifyCode of
    enBeforeCompile:
      begin
      end;
    enAfterCompile:
      begin
      end;
  end;
end;

initialization
  CompilerNotifier := TCompilerNotifier.Create;
  ToolServices.AddNotifierEx(CompilerNotifier);
finalization
  ToolServices.RemoveNotifier(CompilerNotifier);
end.
Du hast damit ein lange bestehendes Problem bei mir aus dem Wege geräumt!
Top!
  Mit Zitat antworten Zitat
Assarbad
(Gast)

n/a Beiträge
 
#8

Re: Delphi Preprocessor und Subprocessor?

  Alt 10. Aug 2003, 18:41
Hiho,

auch mit Delphi 4 geht es ... man muß nur TNotifierObject durch TInterfacedObject ersetzen und ein paar Methoden implementieren. Ich werde das nochmal umschreiben. Wenn du erlaubst, würde ich es dann als OpenSource hier ins Forum stellen. Schreib mir doch mal ne PN was du drinstehen haben möchtest, jbg

Delphi-Quellcode:
unit ...
interface
uses
  SysUtils, ToolsAPI;

type
  TCompilerNotifier = class(TInterfacedObject, IOTAIDENotifier)
  public
// IOTAIDENotifier
    procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean); virtual;
    procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean); overload; virtual;
// IOTANotifier
    procedure AfterSave;
    procedure BeforeSave;
    procedure Modified;
    procedure Destroyed;
// IOTAIDENotifier50
    procedure BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean;
      var Cancel: Boolean); overload; virtual;
    procedure AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean); overload; virtual;
  end;


implementation
{ TCompilerNotifier }

procedure TCompilerNotifier.AfterSave;
begin
end;

procedure TCompilerNotifier.BeforeSave;
begin
end;

procedure TCompilerNotifier.Modified;
begin
end;

procedure TCompilerNotifier.Destroyed;
begin
end;

{ veraltete Methoden }

procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
begin
end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean);
begin
end;

{ neue Methoden }

procedure TCompilerNotifier.BeforeCompile(const Project: IOTAProject; IsCodeInsight: Boolean; var Cancel: Boolean);
begin
  if not IsCodeInsight then
  begin
    if not (BorlandIDEServices as IOTAModuleServices).SaveAll then
      Exit;
  end;
end;

procedure TCompilerNotifier.AfterCompile(Succeeded: Boolean; IsCodeInsight: Boolean);
begin
  if not IsCodeInsight then
  begin
  end;
end;

procedure TCompilerNotifier.FileNotification(NotifyCode: TOTAFileNotification; const FileName: string; var Cancel: Boolean);
begin
  Cancel := False;
end;

var
  NotifierIndex: Integer;

{ CompilerNotifier registrieren }
initialization
  NotifierIndex := (BorlandIDEServices as IOTAServices).AddNotifier(TCompilerNotifier.Create);

finalization
  if NotifierIndex >= 0 then
    (BorlandIDEServices as IOTAServices).RemoveNotifier(NotifierIndex);
// clear all IOTACustomMessages here, else Delphi unloads the dll and then
// it wants to free the messages -> AccessViolation
  (BorlandIDEServices as IOTAMessageServices).ClearToolMessages;

end.
  Mit Zitat antworten Zitat
Bomberbb

Registriert seit: 23. Sep 2003
227 Beiträge
 
#9

Re: Delphi Preprocessor und Subprocessor?

  Alt 12. Nov 2004, 17:54
Also, ich habe das mit dem pre und subprocessor hinbekommen. Was ich vorhabe: Ich will mit einem Project, abhängig von den compilieroptionen verschiedene Dateien erstellen (die Datei nach dem kompilieren umbenennen und eventuell gleich packen). nun will ich die Kompilieroptionen meiner Projekte im Postprocessor nutzen. Ich habe gesehen es gibt im Quelltext die Konstante Project:IOTAProject. Ich denke, dass das was ich brauche hier drin steckt. Es Gibt ja auch Project.Filename aber wie bekomme ich raus, was in der Konstanten noch drinsteckt. Wie gesagt, am wichtigsten wären die Kompilieroptionen. Habe nun den halben Tag im Internet gesucht, aber keine Lösung gefunden.
Kann mir hier jemand helfen???
  Mit Zitat antworten Zitat
Benutzerbild von mschaefer
mschaefer

Registriert seit: 4. Feb 2003
Ort: Hannover
2.029 Beiträge
 
Delphi XE3 Enterprise
 
#10

Re: Delphi Preprocessor und Subprocessor?

  Alt 26. Mär 2010, 20:39
Gibt es sowas eigentlich inzwischen als fertiger Experte für die IDE ? // Grüße Martin
Martin Schaefer
Phaeno
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz