diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 4d0b509834..e3dc25d352 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -213,9 +213,11 @@ const 'FPC', 'ObjFPC', 'Delphi', 'TP', 'MacPas', 'ISO' ); - Pas2jsPlatformNames: array[1..2] of shortstring = ( + Pas2jsPlatformNames: array[1..4] of shortstring = ( 'Browser', - 'NodeJS' + 'NodeJS', + 'Electron', + 'Module' ); Pas2jsProcessorNames: array[1..2] of shortstring = ( 'ECMAScript5', @@ -3927,9 +3929,14 @@ begin end; function IsPas2jsTargetOS(TargetOS: string): boolean; +var + i: Integer; begin - Result:=(CompareText(TargetOS,'browser')=0) - or (CompareText(TargetOS,'nodejs')=0); + TargetOS:=lowercase(TargetOS); + for i:=low(Pas2jsPlatformNames) to high(Pas2jsPlatformNames) do + if Pas2jsPlatformNames[i]=TargetOS then + exit(true); + Result:=false; end; function IsPas2jsTargetCPU(TargetCPU: string): boolean; diff --git a/ide/lazconf.pp b/ide/lazconf.pp index 78a2df48d8..8302a1c35b 100644 --- a/ide/lazconf.pp +++ b/ide/lazconf.pp @@ -326,17 +326,17 @@ function GetExecutableExt(TargetOS: string): string; begin if TargetOS='' then TargetOS:=GetCompiledTargetOS; - if (CompareText(copy(TargetOS,1,3), 'win') = 0) - or (CompareText(copy(TargetOS,1,3), 'dos') = 0) then + TargetOS:=LowerCase(TargetOS); + if (copy(TargetOS,1,3)='win') + or (copy(TargetOS,1,3)='dos') then 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 - Result:=''; + case TargetOS of + 'browser','nodejs','electron','module': Result:='.js'; + 'wasi': Result:='.wasm'; + 'embedded': Result:='.elf'; + else Result:=''; + end; end; function MakeStandardExeFilename(TargetOS, Filename: string): string; @@ -379,9 +379,11 @@ var begin if TargetOS='' then TargetOS:=GetCompiledTargetOS; + TargetOS:=LowerCase(TargetOS); Result:=''; - if SameText(TargetOS, 'browser') or SameText(TargetOS,'nodejs') then - exit('.js'); + case TargetOS of + 'browser','nodejs','electron','module': exit('.js'); + end; SrcOS:=GetDefaultSrcOSForTargetOS(TargetOS); if CompareText(SrcOS, 'unix') = 0 then Result:='lib';