![]() |
Tool zum Entfernen von IFDEFs?
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:
Nachher:
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}
Delphi-Quellcode:
Gruß,
type
TIdThreadPriority = TThreadPriority; |
Re: Tool zum Entfernen von IFDEFs?
Dier JVCL verwendet dazu ein externes Tool.
Ich glaube das ist dieses hier ![]() |
Re: Tool zum Entfernen von IFDEFs?
Also ich benutze dazu Perl ;)
Code:
Bedienungsanleitung ist enthalten ;)
#!/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. Ist von ![]() |
Re: Tool zum Entfernen von IFDEFs?
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. |
Re: Tool zum Entfernen von IFDEFs?
Zitat:
Übrigens: JCL, nicht JVCL, im Falle meines Perlscripts. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:03 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz