pastojs: fixed loading precompiled units by default

This commit is contained in:
mattias 2019-03-08 08:57:59 +00:00
parent fc7ed6a8ed
commit f14c29ee04
2 changed files with 10 additions and 13 deletions

View File

@ -129,6 +129,7 @@ type
coUseStrict, coUseStrict,
coWriteDebugLog, coWriteDebugLog,
coWriteMsgToStdErr, coWriteMsgToStdErr,
coPrecompile, // create precompile file
// optimizations // optimizations
coEnumValuesAsNumbers, coEnumValuesAsNumbers,
coKeepNotUsedPrivates, coKeepNotUsedPrivates,
@ -180,6 +181,7 @@ const
'Use strict', 'Use strict',
'Write pas2jsdebug.log', 'Write pas2jsdebug.log',
'Write messages to StdErr', 'Write messages to StdErr',
'Create precompiled units',
'Enum values as numbers', 'Enum values as numbers',
'Keep not used private declarations', 'Keep not used private declarations',
'Keep not used declarations (WPO)', 'Keep not used declarations (WPO)',
@ -1309,7 +1311,6 @@ begin
end; end;
function TPas2jsCompilerFile.IsUnitReadFromPCU: Boolean; function TPas2jsCompilerFile.IsUnitReadFromPCU: Boolean;
begin begin
Result:=Assigned(PCUSupport) and PCUSupport.HasReader; Result:=Assigned(PCUSupport) and PCUSupport.HasReader;
end; end;
@ -1337,7 +1338,8 @@ begin
{$IFDEF ReallyVerbose} {$IFDEF ReallyVerbose}
writeln('TPas2jsCompilerFile.ReaderFinished analyzed ',UnitFilename,' ScopeModule=',GetObjName(UseAnalyzer.ScopeModule)); writeln('TPas2jsCompilerFile.ReaderFinished analyzed ',UnitFilename,' ScopeModule=',GetObjName(UseAnalyzer.ScopeModule));
{$ENDIF} {$ENDIF}
if Assigned(PCUSupport) and Not PCUSupport.HasReader then if Assigned(PCUSupport) and Not PCUSupport.HasReader
and (coPrecompile in Compiler.Options) then
PCUSupport.WritePCU; PCUSupport.WritePCU;
except except
on E: ECompilerTerminate do on E: ECompilerTerminate do
@ -2771,7 +2773,6 @@ end;
procedure TPas2JSConfigSupport.LoadConfig(Const aFileName: String); procedure TPas2JSConfigSupport.LoadConfig(Const aFileName: String);
type type
TSkip = ( TSkip = (
skipNone, skipNone,
skipIf, skipIf,
@ -2982,17 +2983,14 @@ begin
end; end;
procedure TPas2jsCompiler.HandleOptionPCUFormat(aValue: String); procedure TPas2jsCompiler.HandleOptionPCUFormat(aValue: String);
begin begin
ParamFatal('No PCU support in this compiler for '+aValue); ParamFatal('No support in this compiler for precompiled format '+aValue);
end; end;
function TPas2jsCompiler.HandleOptionPaths(C: Char; aValue: String; function TPas2jsCompiler.HandleOptionPaths(C: Char; aValue: String;
FromCmdLine: Boolean): Boolean; FromCmdLine: Boolean): Boolean;
Var Var
ErrorMsg: String; ErrorMsg: String;
begin begin
Result:=True; Result:=True;
case c of case c of
@ -3007,10 +3005,8 @@ begin
end; end;
function TPas2jsCompiler.HandleOptionOptimization(C: Char; aValue: String): Boolean; function TPas2jsCompiler.HandleOptionOptimization(C: Char; aValue: String): Boolean;
Var Var
Enable: Boolean; Enable: Boolean;
begin begin
Result:=True; Result:=True;
case C of case C of
@ -4053,7 +4049,6 @@ begin
RaiseInternalError(20170504161340,'internal error: TPas2jsCompiler.Run FileCount>0'); RaiseInternalError(20170504161340,'internal error: TPas2jsCompiler.Run FileCount>0');
try try
// set working directory, need by all relative filenames // set working directory, need by all relative filenames
SetWorkingDir(aWorkingDir); SetWorkingDir(aWorkingDir);

View File

@ -81,7 +81,8 @@ Type
Protected Protected
procedure WritePrecompiledFormats; override; procedure WritePrecompiledFormats; override;
function CreateCompilerFile(const PasFileName, PCUFilename: String): TPas2jsCompilerFile; override; function CreateCompilerFile(const PasFileName, PCUFilename: String): TPas2jsCompilerFile; override;
procedure HandleOptionPCUFormat(Value: string) ; override; procedure HandleOptionPCUFormat(Value: string); override;
property PrecompileFormat: TPas2JSPrecompileFormat read FPrecompileFormat;
end; end;
implementation implementation
@ -436,6 +437,7 @@ begin
PF:=PrecompileFormats[i]; PF:=PrecompileFormats[i];
if not SameText(Value,PF.Ext) then continue; if not SameText(Value,PF.Ext) then continue;
FPrecompileFormat:=PrecompileFormats[i]; FPrecompileFormat:=PrecompileFormats[i];
Options:=Options+[coPrecompile];
Found:=true; Found:=true;
end; end;
if not Found then if not Found then
@ -445,13 +447,13 @@ end;
{ TPas2jsPCUCompilerFile } { TPas2jsPCUCompilerFile }
function TPas2jsPCUCompilerFile.CreatePCUSupport: TPCUSupport; function TPas2jsPCUCompilerFile.CreatePCUSupport: TPCUSupport;
Var Var
PF: TPas2JSPrecompileFormat; PF: TPas2JSPrecompileFormat;
begin begin
// Note that if no format was preset, no files will be written // Note that if no format was preset, no files will be written
PF:=(Compiler as TPas2jsPCUCompiler).FPrecompileFormat; PF:=(Compiler as TPas2jsPCUCompiler).FPrecompileFormat;
if (PF=nil) and (PrecompileFormats.Count>0) then
PF:=PrecompileFormats[0];
if PF<>Nil then if PF<>Nil then
Result:=TFilerPCUSupport.Create(Self,PF) Result:=TFilerPCUSupport.Create(Self,PF)
else else