mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 19:05:54 +02:00
fcl-js: added example srcmapdump
git-svn-id: trunk@37263 -
This commit is contained in:
parent
5e2ebcd019
commit
4b4e40c98e
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2507,6 +2507,8 @@ packages/fcl-js/Makefile.fpc svneol=native#text/plain
|
|||||||
packages/fcl-js/Makefile.fpc.fpcmake svneol=native#text/plain
|
packages/fcl-js/Makefile.fpc.fpcmake svneol=native#text/plain
|
||||||
packages/fcl-js/README.TXT svneol=native#text/plain
|
packages/fcl-js/README.TXT svneol=native#text/plain
|
||||||
packages/fcl-js/examples/fpjsmin.pp svneol=native#text/plain
|
packages/fcl-js/examples/fpjsmin.pp svneol=native#text/plain
|
||||||
|
packages/fcl-js/examples/srcmapdump.lpi svneol=native#text/plain
|
||||||
|
packages/fcl-js/examples/srcmapdump.lpr svneol=native#text/plain
|
||||||
packages/fcl-js/fpmake.pp svneol=native#text/plain
|
packages/fcl-js/fpmake.pp svneol=native#text/plain
|
||||||
packages/fcl-js/src/jsbase.pp svneol=native#text/plain
|
packages/fcl-js/src/jsbase.pp svneol=native#text/plain
|
||||||
packages/fcl-js/src/jsminifier.pp svneol=native#text/plain
|
packages/fcl-js/src/jsminifier.pp svneol=native#text/plain
|
||||||
|
60
packages/fcl-js/examples/srcmapdump.lpi
Normal file
60
packages/fcl-js/examples/srcmapdump.lpi
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="10"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasScaledStatement Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="SrcMapDump"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="srcmapdump.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="srcmapdump"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
119
packages/fcl-js/examples/srcmapdump.lpr
Normal file
119
packages/fcl-js/examples/srcmapdump.lpr
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
program srcmapdump;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Classes, SysUtils, CustApp, JSSrcMap;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TSrcMapDump }
|
||||||
|
|
||||||
|
TSrcMapDump = class(TCustomApplication)
|
||||||
|
protected
|
||||||
|
procedure DoRun; override;
|
||||||
|
procedure DumpSrcMap(SrcMapFile, aGeneratedFilename: string);
|
||||||
|
public
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure WriteHelp; virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TSrcMapDump }
|
||||||
|
|
||||||
|
procedure TSrcMapDump.DoRun;
|
||||||
|
var
|
||||||
|
ErrorMsg, SrcMapFilename, GeneratedFilename: String;
|
||||||
|
begin
|
||||||
|
// quick check parameters
|
||||||
|
ErrorMsg:=CheckOptions('hs:g:', 'help srcmap: generatedfile:');
|
||||||
|
if ErrorMsg<>'' then begin
|
||||||
|
ShowException(Exception.Create(ErrorMsg));
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// parse parameters
|
||||||
|
if HasOption('h', 'help') then begin
|
||||||
|
WriteHelp;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not HasOption('s','srcmap') then begin
|
||||||
|
writeln('missing -s >srcmap>');
|
||||||
|
WriteHelp;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
SrcMapFilename:=ExpandFileName(GetOptionValue('s','srcmap'));
|
||||||
|
|
||||||
|
if not HasOption('g','generatedfile') then begin
|
||||||
|
writeln('missing -g <generatedfile>');
|
||||||
|
WriteHelp;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
GeneratedFilename:=ExpandFileName(GetOptionValue('g','generatedfile'));
|
||||||
|
|
||||||
|
DumpSrcMap(SrcMapFilename,GeneratedFilename);
|
||||||
|
|
||||||
|
// stop program loop
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSrcMapDump.DumpSrcMap(SrcMapFile, aGeneratedFilename: string);
|
||||||
|
var
|
||||||
|
SrcMap: TSourceMap;
|
||||||
|
GenSrc: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
GenSrcLine, InfoLine: String;
|
||||||
|
begin
|
||||||
|
GenSrc:=TStringList.Create;
|
||||||
|
SrcMap:=TSourceMap.Create(aGeneratedFilename);
|
||||||
|
try
|
||||||
|
SrcMap.LoadFromFile(SrcMapFile);
|
||||||
|
GenSrc.LoadFromFile(aGeneratedFilename);
|
||||||
|
for i:=1 to GenSrc.Count do begin
|
||||||
|
GenSrcLine:=GenSrc[i-1];
|
||||||
|
DebugSrcMapLine(i,GenSrcLine,SrcMap,InfoLine);
|
||||||
|
writeln(GenSrcLine);
|
||||||
|
writeln(InfoLine);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
SrcMap.Free;
|
||||||
|
GenSrc.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TSrcMapDump.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
StopOnException:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSrcMapDump.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSrcMapDump.WriteHelp;
|
||||||
|
begin
|
||||||
|
writeln('Usage: ', ExeName, ' -h');
|
||||||
|
writeln;
|
||||||
|
writeln('-s <srcmap>');
|
||||||
|
writeln('-g <generatedfile>');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Application: TSrcMapDump;
|
||||||
|
begin
|
||||||
|
Application:=TSrcMapDump.Create(nil);
|
||||||
|
Application.Title:='SrcMapDump';
|
||||||
|
Application.Run;
|
||||||
|
Application.Free;
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user