pas2js: added -i -iD -iSO -iSP -TO -iTP

git-svn-id: trunk@37754 -
This commit is contained in:
Mattias Gaertner 2017-12-18 13:23:46 +00:00
parent 09dd6047f7
commit 8d36c0d64e
2 changed files with 136 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="11"/>
<General> <General>
<Flags> <Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/> <MainUnitHasUsesSectionForAllUnits Value="False"/>
@ -21,10 +21,10 @@
<Version Value="2"/> <Version Value="2"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
<CommandLineParams Value="/home/michael/pinc.pp"/> <Mode0 Name="default"/>
</local> </Modes>
</RunParams> </RunParams>
<Units Count="9"> <Units Count="9">
<Unit0> <Unit0>

View File

@ -383,9 +383,11 @@ type
class function GetVersion(ShortVersion: boolean): string; class function GetVersion(ShortVersion: boolean): string;
procedure WriteHelp; procedure WriteHelp;
procedure WriteLogo; procedure WriteLogo;
procedure WriteVersionLine;
procedure WriteOptions; procedure WriteOptions;
procedure WriteDefines; procedure WriteDefines;
procedure WriteFoldersAndSearchPaths; procedure WriteFoldersAndSearchPaths;
procedure WriteInfo;
function GetShownMsgTypes: TMessageTypes; function GetShownMsgTypes: TMessageTypes;
procedure AddDefine(const aName: String); procedure AddDefine(const aName: String);
@ -433,6 +435,11 @@ function CompareFileAndCompilerFilePasFile(Filename, Item: Pointer): integer;
function CompareCompilerFilesPasUnitname(Item1, Item2: Pointer): integer; function CompareCompilerFilesPasUnitname(Item1, Item2: Pointer): integer;
function CompareUnitnameAndCompilerFile(TheUnitname, Item: Pointer): integer; function CompareUnitnameAndCompilerFile(TheUnitname, Item: Pointer): integer;
function GetCompiledDate: string;
function GetCompiledFPCVersion: string;
function GetCompiledTargetOS: string;
function GetCompiledTargetCPU: string;
implementation implementation
function CompareCompilerFilesPasFile(Item1, Item2: Pointer): integer; function CompareCompilerFilesPasFile(Item1, Item2: Pointer): integer;
@ -469,6 +476,27 @@ begin
Result:=CompareText(anUnitname,aFile.PasUnitName); Result:=CompareText(anUnitname,aFile.PasUnitName);
end; end;
function GetCompiledDate: string;
begin
Result:={$I %Date%};
end;
function GetCompiledFPCVersion: string;
begin
Result:={$I %FPCVERSION%};
end;
function GetCompiledTargetOS: string;
begin
Result:=lowerCase({$I %FPCTARGETOS%});
end;
function GetCompiledTargetCPU: string;
begin
Result:=lowerCase({$I %FPCTARGETCPU%});
end;
{ TPas2jsMacroEngine } { TPas2jsMacroEngine }
function TPas2jsMacroEngine.GetMacros(Index: integer): TPas2jsMacro; function TPas2jsMacroEngine.GetMacros(Index: integer): TPas2jsMacro;
@ -2042,6 +2070,13 @@ procedure TPas2jsCompiler.ReadParam(Param: string; Quick, FromCmdLine: boolean);
ParamFatal('unknown parameter "'+Param+'". Use -h for help.'); ParamFatal('unknown parameter "'+Param+'". Use -h for help.');
end; end;
procedure AppendInfo(var Value: string; Add: string);
begin
if Value<>'' then
Value:=Value+' ';
Value:=Value+Add;
end;
var var
p: PChar; p: PChar;
EnabledFlags, DisabledFlags, Identifier, Value, aFilename, ErrorMsg: string; EnabledFlags, DisabledFlags, Identifier, Value, aFilename, ErrorMsg: string;
@ -2074,16 +2109,57 @@ begin
'i': 'i':
begin begin
// write information and halt // write information and halt
for i:=3 to length(Param) do begin inc(p);
case Param[i] of Value:='';
repeat
case p^ of
#0:
if p-PChar(Param)=length(Param) then
begin
if length(Param)=2 then
WriteInfo;
break;
end;
'D': // wite compiler date
AppendInfo(Value,GetCompiledDate);
'V': // write short version 'V': // write short version
Log.LogRaw(GetVersion(true)); AppendInfo(Value,GetVersion(true));
'W': // write long version 'W': // write long version
Log.LogRaw(GetVersion(false)); AppendInfo(Value,GetVersion(false));
'S':
begin
inc(p);
case p^ of
#0:
ParamFatal('missing info option after S in "'+Param+'".');
'O': // write source OS
AppendInfo(Value,GetCompiledTargetOS);
'P': // write source processor
AppendInfo(Value,GetCompiledTargetCPU);
else
ParamFatal('unknown info option S"'+p^+'" in "'+Param+'".');
end;
end;
'T':
begin
inc(p);
case p^ of
#0:
ParamFatal('missing info option after T in "'+Param+'".');
'O': // write target platform
AppendInfo(Value,PasToJsPlatformNames[TargetPlatform]);
'P': // write target processor
AppendInfo(Value,PasToJsProcessorNames[TargetProcessor]);
else
ParamFatal('unknown info option S"'+p^+'" in "'+Param+'".');
end;
end;
else else
ParamFatal('unknown info option "'+Param[i]+'" in "'+Param+'".'); ParamFatal('unknown info option "'+p^+'" in "'+Param+'".');
end; end;
end; inc(p);
until false;
Log.LogRaw(Value);
Terminate(0); Terminate(0);
end; end;
'B','l','n': 'B','l','n':
@ -2911,7 +2987,12 @@ begin
l(' @<x> : Read compiler options from file <x> in addition to the default '+DefaultConfigFile); l(' @<x> : Read compiler options from file <x> in addition to the default '+DefaultConfigFile);
l(' -B : Rebuild all'); l(' -B : Rebuild all');
l(' -d<x> : Defines the symbol <x>. Optional: -d<x>:=<value>'); l(' -d<x> : Defines the symbol <x>. Optional: -d<x>:=<value>');
l(' -i<x> : Write information and halt. <x> is a combination of the following letters:'); l(' -i<x> : Write information and halt. <x> is a combination of the following:');
l(' D : Write compiler date');
l(' SO : Write compiler OS');
l(' SP : Write compiler host processor');
l(' TO : Write target platform');
l(' TP : Write target processor');
l(' V : Write short compiler version'); l(' V : Write short compiler version');
l(' W : Write full compiler version'); l(' W : Write full compiler version');
l(' -F... Set file names and paths:'); l(' -F... Set file names and paths:');
@ -2992,10 +3073,15 @@ procedure TPas2jsCompiler.WriteLogo;
begin begin
if FHasShownLogo then exit; if FHasShownLogo then exit;
FHasShownLogo:=true; FHasShownLogo:=true;
Log.LogRaw('Pas2JS Compiler version '+GetVersion(false)); WriteVersionLine;
Log.LogRaw('Copyright (c) 2017 Mattias Gaertner and others'); Log.LogRaw('Copyright (c) 2017 Mattias Gaertner and others');
end; end;
procedure TPas2jsCompiler.WriteVersionLine;
begin
Log.LogRaw('Pas2JS Compiler version '+GetVersion(false));
end;
procedure TPas2jsCompiler.WriteOptions; procedure TPas2jsCompiler.WriteOptions;
var var
co: TP2jsCompilerOption; co: TP2jsCompilerOption;
@ -3062,6 +3148,43 @@ begin
Log.LogMsgIgnoreFilter(nNameValue,['output file',FileCache.MainJSFile]); Log.LogMsgIgnoreFilter(nNameValue,['output file',FileCache.MainJSFile]);
end; end;
procedure TPas2jsCompiler.WriteInfo;
begin
WriteVersionLine;
Log.LogLn;
Log.LogRaw('Compiler date : '+GetCompiledDate);
Log.LogRaw('Compiler CPU target: '+GetCompiledTargetCPU);
Log.LogLn;
Log.LogRaw('Supported targets (targets marked with ''{*}'' are under development):');
Log.LogRaw([' ',PasToJsPlatformNames[PlatformBrowser],': webbrowser']);
Log.LogRaw([' ',PasToJsPlatformNames[PlatformNodeJS],': Node.js']);
Log.LogLn;
Log.LogRaw('Supported CPU instruction sets:');
Log.LogRaw(' ECMAScript5, ECMAScript6');
Log.LogLn;
Log.LogRaw('Recognized compiler and RTL features:');
Log.LogRaw(' RTTI,CLASSES,EXCEPTIONS,EXITCODE,RANDOM,DYNARRAYS,COMMANDARGS,');
Log.LogRaw(' UNICODESTRINGS');
Log.LogLn;
Log.LogRaw('Supported Optimizations:');
Log.LogRaw(' EnumNumbers');
Log.LogRaw(' RemoveNotUsedPrivates');
Log.LogLn;
Log.LogRaw('Supported Whole Program Optimizations:');
Log.LogRaw(' RemoveNotUsedDeclarations');
Log.LogLn;
Log.LogRaw('This program comes under the Library GNU General Public License');
Log.LogRaw('For more information read COPYING.FPC, included in this distribution');
Log.LogLn;
Log.LogRaw('Please report bugs in our bug tracker on:');
Log.LogRaw(' http://bugs.freepascal.org');
Log.LogLn;
Log.LogRaw('More information may be found on our WWW pages (including directions');
Log.LogRaw('for mailing lists useful for asking questions or discussing potential');
Log.LogRaw('new features, etc.):');
Log.LogRaw(' http://www.freepascal.org');
end;
function TPas2jsCompiler.GetShownMsgTypes: TMessageTypes; function TPas2jsCompiler.GetShownMsgTypes: TMessageTypes;
begin begin
Result:=[mtFatal]; Result:=[mtFatal];