AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Tool zum Entfernen von IFDEFs?

Ein Thema von Dani · begonnen am 22. Mai 2005 · letzter Beitrag vom 23. Mai 2005
Antwort Antwort
Benutzerbild von Dani
Dani

Registriert seit: 19. Jan 2003
732 Beiträge
 
Turbo Delphi für Win32
 
#1

Tool zum Entfernen von IFDEFs?

  Alt 22. Mai 2005, 19:55
Kennt jemand ein Tool mit dem man {edit: automatisch} IFDEFs/IFNDEFs samt überflüssigem Code aus Units entfernen kann? Als Beispiel jemand der mit Delphi 7 nur für MS Windows programmiert ->

Vorher:
Delphi-Quellcode:
type
  {$IFDEF LINUX}
    {$IFNDEF VCL6ORABOVE}
    THandle = LongWord; //D6.System
    {$ENDIF}
  TIdThreadPriority = -20..19;
  {$ENDIF}
  {$IFDEF MSWINDOWS}
    {$IFNDEF VCL6ORABOVE}
    THandle = Windows.THandle;
    {$ENDIF}
  TIdThreadPriority = TThreadPriority;
  {$ENDIF}
Nachher:
Delphi-Quellcode:
type
  TIdThreadPriority = TThreadPriority;
Gruß,
Dani H.
At Least I Can Say I Tried
  Mit Zitat antworten Zitat
Robert Marquardt
(Gast)

n/a Beiträge
 
#2

Re: Tool zum Entfernen von IFDEFs?

  Alt 23. Mai 2005, 04:55
Dier JVCL verwendet dazu ein externes Tool.
Ich glaube das ist dieses hier http://www.sf.net/projects/dpp32
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#3

Re: Tool zum Entfernen von IFDEFs?

  Alt 23. Mai 2005, 05:13
Also ich benutze dazu Perl
Code:
#!/usr/bin/perl
##############################################################################
##
## Simple perl script to filter only a single DEFINE symbol from the input
## file.
##
##############################################################################
my ($param1, $param2) = @ARGV;

if ((-z $param1) || ($param2 eq ''))
{
  print <DATA>;
  exit;
}
my $positive = 1;
# Open and read and close the file
open(FILE, $param1) or die;
$x = join('', <FILE>);
close(FILE);
# Check wether the symbol is negated or not
if ($param2 =~ /^!(.+)$/i)
{
  $param2 = $1;
  $positive = 0;
}
# According to the commandline evaluate the symbol
if ($positive != 0)
{
  # Replace all IFDEF ELSE ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$2/gism;
  # Replace all IFDEF ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*//gism;
}
else # If the symbol was negated at the commandline
{
  # Replace all IFDEF ELSE ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$2/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  # Replace all IFDEF ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*//gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
}
# Output to STDOUT
print "$x";
__END__
Syntax:

  simple_pp.pl <filename> [!]<symbol>

Output is printed to STDOUT. If you want to treat multiple symbols simply run
the script multiple times.

The exclamation mark in front of the symbol can be used to undefine the
respective symbol - otherwise it will be defined.

Any DEFINE or UNDEF directives concerning the given symbol inside the input
file will be ignored. Only commandline is taken.
Bedienungsanleitung ist enthalten

Ist von hier. Ich weiß nicht wie Robert das sieht, aber ich denke mal dadurch, daß ich es ins CVS eingecheckt hatte, ist es automatisch unter MPL.
  Mit Zitat antworten Zitat
Robert Marquardt
(Gast)

n/a Beiträge
 
#4

Re: Tool zum Entfernen von IFDEFs?

  Alt 23. Mai 2005, 06:48
Das haengt davon ab ob es ein Bestandteil der JVCL sein soll oder nicht.
Die Tools sind genaugenommen nicht Bestandteil der JVCL.
Reine GPL-Sourcen als Komponenten waeren nicht moeglich. Dual-licensing MPL/GPL sind sogar erwuenscht.
  Mit Zitat antworten Zitat
Olli
(Gast)

n/a Beiträge
 
#5

Re: Tool zum Entfernen von IFDEFs?

  Alt 23. Mai 2005, 06:52
Zitat von Robert Marquardt:
Das haengt davon ab ob es ein Bestandteil der JVCL sein soll oder nicht.
Die Tools sind genaugenommen nicht Bestandteil der JVCL.
Reine GPL-Sourcen als Komponenten waeren nicht moeglich. Dual-licensing MPL/GPL sind sogar erwuenscht.
Also meinetwegen kann das auch Triple- oder sonstwas -licensed sein Soll ich das noch ins Script schreiben und neu einchecken?
Übrigens: JCL, nicht JVCL, im Falle meines Perlscripts.
  Mit Zitat antworten Zitat
Antwort Antwort


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 22:58 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