codetools: added pas2js platforms electorn and module

This commit is contained in:
mattias 2022-02-05 16:18:30 +01:00
parent 9ced709010
commit 451ba64bde
2 changed files with 24 additions and 15 deletions

View File

@ -213,9 +213,11 @@ const
'FPC', 'ObjFPC', 'Delphi', 'TP', 'MacPas', 'ISO' 'FPC', 'ObjFPC', 'Delphi', 'TP', 'MacPas', 'ISO'
); );
Pas2jsPlatformNames: array[1..2] of shortstring = ( Pas2jsPlatformNames: array[1..4] of shortstring = (
'Browser', 'Browser',
'NodeJS' 'NodeJS',
'Electron',
'Module'
); );
Pas2jsProcessorNames: array[1..2] of shortstring = ( Pas2jsProcessorNames: array[1..2] of shortstring = (
'ECMAScript5', 'ECMAScript5',
@ -3927,9 +3929,14 @@ begin
end; end;
function IsPas2jsTargetOS(TargetOS: string): boolean; function IsPas2jsTargetOS(TargetOS: string): boolean;
var
i: Integer;
begin begin
Result:=(CompareText(TargetOS,'browser')=0) TargetOS:=lowercase(TargetOS);
or (CompareText(TargetOS,'nodejs')=0); for i:=low(Pas2jsPlatformNames) to high(Pas2jsPlatformNames) do
if Pas2jsPlatformNames[i]=TargetOS then
exit(true);
Result:=false;
end; end;
function IsPas2jsTargetCPU(TargetCPU: string): boolean; function IsPas2jsTargetCPU(TargetCPU: string): boolean;

View File

@ -326,17 +326,17 @@ function GetExecutableExt(TargetOS: string): string;
begin begin
if TargetOS='' then if TargetOS='' then
TargetOS:=GetCompiledTargetOS; TargetOS:=GetCompiledTargetOS;
if (CompareText(copy(TargetOS,1,3), 'win') = 0) TargetOS:=LowerCase(TargetOS);
or (CompareText(copy(TargetOS,1,3), 'dos') = 0) then if (copy(TargetOS,1,3)='win')
or (copy(TargetOS,1,3)='dos') then
Result:='.exe' Result:='.exe'
else if SameText(TargetOS, 'browser') or SameText(TargetOS,'nodejs') then
Result:='.js'
else if SameText(TargetOS, 'wasi') then
Result:='.wasm'
else if SameText(TargetOS, 'embedded') then
Result:='.elf'
else else
Result:=''; case TargetOS of
'browser','nodejs','electron','module': Result:='.js';
'wasi': Result:='.wasm';
'embedded': Result:='.elf';
else Result:='';
end;
end; end;
function MakeStandardExeFilename(TargetOS, Filename: string): string; function MakeStandardExeFilename(TargetOS, Filename: string): string;
@ -379,9 +379,11 @@ var
begin begin
if TargetOS='' then if TargetOS='' then
TargetOS:=GetCompiledTargetOS; TargetOS:=GetCompiledTargetOS;
TargetOS:=LowerCase(TargetOS);
Result:=''; Result:='';
if SameText(TargetOS, 'browser') or SameText(TargetOS,'nodejs') then case TargetOS of
exit('.js'); 'browser','nodejs','electron','module': exit('.js');
end;
SrcOS:=GetDefaultSrcOSForTargetOS(TargetOS); SrcOS:=GetDefaultSrcOSForTargetOS(TargetOS);
if CompareText(SrcOS, 'unix') = 0 then if CompareText(SrcOS, 'unix') = 0 then
Result:='lib'; Result:='lib';