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

View File

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