pas2js: added option -Jmabsolute

git-svn-id: trunk@41066 -
This commit is contained in:
Mattias Gaertner 2019-01-25 08:31:36 +00:00
parent 29bcef2825
commit 06e821b07b
2 changed files with 32 additions and 7 deletions

View File

@ -136,6 +136,7 @@ type
// source map // source map
coSourceMapCreate, coSourceMapCreate,
coSourceMapInclude, coSourceMapInclude,
coSourceMapFilenamesAbsolute,
coSourceMapXSSIHeader coSourceMapXSSIHeader
); );
TP2jsCompilerOptions = set of TP2jsCompilerOption; TP2jsCompilerOptions = set of TP2jsCompilerOption;
@ -184,6 +185,7 @@ const
'Keep not used declarations (WPO)', 'Keep not used declarations (WPO)',
'Create source map', 'Create source map',
'Include Pascal sources in source map', 'Include Pascal sources in source map',
'Do not shorten filenames in source map',
'Prepend XSSI protection )]} to source map' 'Prepend XSSI protection )]} to source map'
); );
@ -505,6 +507,7 @@ type
function GetSkipDefaultConfig: Boolean; inline; function GetSkipDefaultConfig: Boolean; inline;
function GetSrcMapEnable: boolean; function GetSrcMapEnable: boolean;
function GetSrcMapInclude: boolean; function GetSrcMapInclude: boolean;
function GetSrcMapFilenamesAbsolute: boolean;
function GetSrcMapXSSIHeader: boolean; function GetSrcMapXSSIHeader: boolean;
function GetTargetPlatform: TPasToJsPlatform; function GetTargetPlatform: TPasToJsPlatform;
function GetTargetProcessor: TPasToJsProcessor; function GetTargetProcessor: TPasToJsProcessor;
@ -532,6 +535,7 @@ type
procedure SetSrcMapBaseDir(const AValue: string); procedure SetSrcMapBaseDir(const AValue: string);
procedure SetSrcMapEnable(const AValue: boolean); procedure SetSrcMapEnable(const AValue: boolean);
procedure SetSrcMapInclude(const AValue: boolean); procedure SetSrcMapInclude(const AValue: boolean);
procedure SetSrcMapFilenamesAbsolute(const AValue: boolean);
procedure SetSrcMapXSSIHeader(const AValue: boolean); procedure SetSrcMapXSSIHeader(const AValue: boolean);
procedure SetTargetPlatform(const AValue: TPasToJsPlatform); procedure SetTargetPlatform(const AValue: TPasToJsPlatform);
procedure SetTargetProcessor(const AValue: TPasToJsProcessor); procedure SetTargetProcessor(const AValue: TPasToJsProcessor);
@ -659,6 +663,7 @@ type
property SrcMapSourceRoot: string read FSrcMapSourceRoot write FSrcMapSourceRoot; property SrcMapSourceRoot: string read FSrcMapSourceRoot write FSrcMapSourceRoot;
property SrcMapInclude: boolean read GetSrcMapInclude write SetSrcMapInclude; property SrcMapInclude: boolean read GetSrcMapInclude write SetSrcMapInclude;
property SrcMapXSSIHeader: boolean read GetSrcMapXSSIHeader write SetSrcMapXSSIHeader; property SrcMapXSSIHeader: boolean read GetSrcMapXSSIHeader write SetSrcMapXSSIHeader;
property SrcMapFilenamesAbsolute: boolean read GetSrcMapFilenamesAbsolute write SetSrcMapFilenamesAbsolute;
property ShowDebug: boolean read GetShowDebug write SetShowDebug; property ShowDebug: boolean read GetShowDebug write SetShowDebug;
property ShowFullPaths: boolean read GetShowFullPaths write SetShowFullPaths; property ShowFullPaths: boolean read GetShowFullPaths write SetShowFullPaths;
property ShowLogo: Boolean read GetShowLogo write SetShowLogo; property ShowLogo: Boolean read GetShowLogo write SetShowLogo;
@ -2009,7 +2014,7 @@ begin
SrcMap.SourceContents[i]:=aFile.Source; SrcMap.SourceContents[i]:=aFile.Source;
end; end;
// translate local file name // translate local file name
if BaseDir<>'' then if (BaseDir<>'') and not SrcMapFilenamesAbsolute then
begin begin
if not FS.TryCreateRelativePath(LocalFilename,BaseDir,true,MapFilename) then if not FS.TryCreateRelativePath(LocalFilename,BaseDir,true,MapFilename) then
begin begin
@ -2023,11 +2028,15 @@ begin
end; end;
// the source is included, do not translate the filename // the source is included, do not translate the filename
MapFilename:=LocalFilename; MapFilename:=LocalFilename;
end; end
{$IFNDEF Unix} else
// use / as PathDelim MapFilename:=LocalFilename;
{$IFNDEF Unix}
// use / as PathDelim
if PathDelim<>'/' then
MapFilename:=StringReplace(MapFilename,PathDelim,'/',[rfReplaceAll]); MapFilename:=StringReplace(MapFilename,PathDelim,'/',[rfReplaceAll]);
{$ENDIF} {$ENDIF}
if LocalFilename<>MapFilename then
SrcMap.SourceTranslatedFiles[i]:=MapFilename; SrcMap.SourceTranslatedFiles[i]:=MapFilename;
end; end;
end; end;
@ -2483,6 +2492,11 @@ begin
Result:=coSourceMapInclude in FOptions; Result:=coSourceMapInclude in FOptions;
end; end;
function TPas2jsCompiler.GetSrcMapFilenamesAbsolute: boolean;
begin
Result:=coSourceMapFilenamesAbsolute in FOptions;
end;
function TPas2jsCompiler.GetSrcMapXSSIHeader: boolean; function TPas2jsCompiler.GetSrcMapXSSIHeader: boolean;
begin begin
Result:=coSourceMapXSSIHeader in FOptions; Result:=coSourceMapXSSIHeader in FOptions;
@ -2588,6 +2602,11 @@ begin
SetOption(coSourceMapInclude,AValue); SetOption(coSourceMapInclude,AValue);
end; end;
procedure TPas2jsCompiler.SetSrcMapFilenamesAbsolute(const AValue: boolean);
begin
SetOption(coSourceMapFilenamesAbsolute,AValue);
end;
procedure TPas2jsCompiler.SetSrcMapXSSIHeader(const AValue: boolean); procedure TPas2jsCompiler.SetSrcMapXSSIHeader(const AValue: boolean);
begin begin
SetOption(coSourceMapXSSIHeader,AValue); SetOption(coSourceMapXSSIHeader,AValue);
@ -3084,6 +3103,10 @@ begin
SrcMapInclude:=true; SrcMapInclude:=true;
'include-': 'include-':
SrcMapInclude:=false; SrcMapInclude:=false;
'absolute':
SrcMapFilenamesAbsolute:=true;
'absolute-':
SrcMapFilenamesAbsolute:=false;
'xssiheader': 'xssiheader':
SrcMapXSSIHeader:=true; SrcMapXSSIHeader:=true;
'xssiheader-': 'xssiheader-':
@ -4214,8 +4237,9 @@ begin
w(' -Jl : lower case identifiers'); w(' -Jl : lower case identifiers');
w(' -Jm : generate source maps'); w(' -Jm : generate source maps');
w(' -Jmsourceroot=<x>: use x as "sourceRoot", prefix URL for source file names.'); w(' -Jmsourceroot=<x>: use x as "sourceRoot", prefix URL for source file names.');
w(' -Jmbasedir=<x>: write source file names relative to directory x.'); w(' -Jmbasedir=<x>: write source file names relative to directory x, default is map file folder.');
w(' -Jminclude: include Pascal sources in source map.'); w(' -Jminclude: include Pascal sources in source map.');
w(' -Jmabsolute: store absolute filenames, not relative.');
w(' -Jmxssiheader: start source map with XSSI protection )]}'', default.'); w(' -Jmxssiheader: start source map with XSSI protection )]}'', default.');
w(' -Jm-: disable generating source maps'); w(' -Jm-: disable generating source maps');
w(' -Jo<x>: Enable or disable extra option. The x is case insensitive:'); w(' -Jo<x>: Enable or disable extra option. The x is case insensitive:');

View File

@ -158,8 +158,9 @@ Put + after a boolean switch option to enable it, - to disable it
-Jl : lower case identifiers -Jl : lower case identifiers
-Jm : generate source maps -Jm : generate source maps
-Jmsourceroot=&lt;x&gt; : use x as "sourceRoot", prefix URL for source file names. -Jmsourceroot=&lt;x&gt; : use x as "sourceRoot", prefix URL for source file names.
-Jmbasedir=&lt;x&gt; : write source file names relative to directory x. -Jmbasedir=&lt;x&gt; : write source file names relative to directory x, default is map file folder.
-Jminclude : include Pascal sources in source map. -Jminclude : include Pascal sources in source map.
-Jmabsolute: store absolute filenames, not relative.
-Jmxssiheader : start source map with XSSI protection )]}. -Jmxssiheader : start source map with XSSI protection )]}.
-Jm- : disable generating source maps -Jm- : disable generating source maps
-Jo&lt;x&gt; : Enable or disable extra option. The x is case insensitive: -Jo&lt;x&gt; : Enable or disable extra option. The x is case insensitive: