mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-18 02:49:09 +02:00
releasecreator: compile pas2js exe
This commit is contained in:
parent
540d11094a
commit
60e35a24ad
@ -5,6 +5,7 @@
|
|||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<MainUnitHasCreateFormStatements Value="False"/>
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
<MainUnitHasScaledStatement Value="False"/>
|
<MainUnitHasScaledStatement Value="False"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
@ -48,9 +49,19 @@
|
|||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<Checks>
|
||||||
|
<IOChecks Value="True"/>
|
||||||
|
<RangeChecks Value="True"/>
|
||||||
|
<OverflowChecks Value="True"/>
|
||||||
|
<StackChecks Value="True"/>
|
||||||
|
</Checks>
|
||||||
|
<VerifyObjMethodCallValidity Value="True"/>
|
||||||
|
</CodeGeneration>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<DebugInfoType Value="dsDwarf2"/>
|
<DebugInfoType Value="dsDwarf2"/>
|
||||||
|
<TrashVariables Value="True"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
</Linking>
|
</Linking>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
@ -41,9 +41,12 @@ type
|
|||||||
procedure ReadVersion;
|
procedure ReadVersion;
|
||||||
procedure CheckForgottenWriteln;
|
procedure CheckForgottenWriteln;
|
||||||
procedure CleanSources;
|
procedure CleanSources;
|
||||||
procedure CreateBuildSourceDir;
|
procedure CreateBuildSourceDir(const TargetOS, TargetCPU: string);
|
||||||
procedure BuildPas2js;
|
procedure BuildPas2js(const TargetOS, TargetCPU: string);
|
||||||
procedure RunTool(WorkDir, Exe: string; const ProcParams: TStringDynArray);
|
procedure RunTool(WorkDir, Exe: string; const ProcParams: TStringDynArray); overload;
|
||||||
|
procedure RunTool(WorkDir, Exe: string; ProcParams: TStringList); overload;
|
||||||
|
procedure ForceDir(Dir, DirTitle: string);
|
||||||
|
function Quote(const s: string): string;
|
||||||
function GetDefaultCfgFilename: string;
|
function GetDefaultCfgFilename: string;
|
||||||
function GetDefaultBuildDir: string;
|
function GetDefaultBuildDir: string;
|
||||||
function GetDefaultLazBuild: string;
|
function GetDefaultLazBuild: string;
|
||||||
@ -72,6 +75,7 @@ end;
|
|||||||
procedure TPas2jsReleaseCreator.DoRun;
|
procedure TPas2jsReleaseCreator.DoRun;
|
||||||
var
|
var
|
||||||
ErrorMsg: String;
|
ErrorMsg: String;
|
||||||
|
TargetOS, TargetCPU: String;
|
||||||
begin
|
begin
|
||||||
// quick check parameters
|
// quick check parameters
|
||||||
ErrorMsg:=CheckOptions('hb:c:s:l:qvx', ['help', 'config:', 'lazbuild:',
|
ErrorMsg:=CheckOptions('hb:c:s:l:qvx', ['help', 'config:', 'lazbuild:',
|
||||||
@ -146,8 +150,11 @@ begin
|
|||||||
|
|
||||||
// build
|
// build
|
||||||
CleanSources;
|
CleanSources;
|
||||||
CreateBuildSourceDir;
|
|
||||||
BuildPas2js;
|
TargetOS:=lowercase({$i %FPCTargetOS%});
|
||||||
|
TargetCPU:=lowercase({$i %FPCTargetCPU%});
|
||||||
|
CreateBuildSourceDir(TargetOS,TargetCPU);
|
||||||
|
BuildPas2js(TargetOS,TargetCPU);
|
||||||
|
|
||||||
// stop program loop
|
// stop program loop
|
||||||
Terminate;
|
Terminate;
|
||||||
@ -315,6 +322,7 @@ procedure TPas2jsReleaseCreator.CleanSources;
|
|||||||
end;
|
end;
|
||||||
until FindNext(Info)<>0;
|
until FindNext(Info)<>0;
|
||||||
end;
|
end;
|
||||||
|
FindClose(Info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -324,9 +332,10 @@ begin
|
|||||||
Clean(SourceDir);
|
Clean(SourceDir);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPas2jsReleaseCreator.CreateBuildSourceDir;
|
procedure TPas2jsReleaseCreator.CreateBuildSourceDir(const TargetOS,
|
||||||
|
TargetCPU: string);
|
||||||
begin
|
begin
|
||||||
BuildSourceDir:=BuildDir+'pas2js-'+lowercase({$i %FPCTargetOS%})+'-'+lowercase({$i %FPCTargetCPU%})+'-'+Pas2jsVersion;
|
BuildSourceDir:=BuildDir+'pas2js-'+TargetOS+'-'+TargetCPU+'-'+Pas2jsVersion;
|
||||||
if DirectoryExists(BuildSourceDir) then begin
|
if DirectoryExists(BuildSourceDir) then begin
|
||||||
if Verbosity>=0 then
|
if Verbosity>=0 then
|
||||||
Log(etInfo,'Deleting directory "'+BuildSourceDir+'"');
|
Log(etInfo,'Deleting directory "'+BuildSourceDir+'"');
|
||||||
@ -340,16 +349,67 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
if not ForceDirectory(BuildSourceDir) then
|
if not ForceDirectory(BuildSourceDir) then
|
||||||
Err('Unable to create directory "'+BuildSourceDir+'"');
|
Err('Unable to create directory "'+BuildSourceDir+'"');
|
||||||
|
Log(etInfo,'Created directory "'+BuildSourceDir+'"')
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPas2jsReleaseCreator.BuildPas2js;
|
procedure TPas2jsReleaseCreator.BuildPas2js(const TargetOS, TargetCPU: string);
|
||||||
|
var
|
||||||
|
WorkDir, SrcCompilerDir, PkgSrcDir, UnitOutDir, BinOutDir: String;
|
||||||
|
ProcParams: TStringList;
|
||||||
begin
|
begin
|
||||||
|
ProcParams:=TStringList.Create;
|
||||||
|
try
|
||||||
|
SrcCompilerDir:=SourceDir+'compiler'+PathDelim;
|
||||||
|
|
||||||
|
WorkDir:=SrcCompilerDir+'utils'+PathDelim+'pas2js';
|
||||||
|
|
||||||
|
PkgSrcDir:=SrcCompilerDir+'packages'+PathDelim;
|
||||||
|
ProcParams.Add('-Fu'+PkgSrcDir+'fcl-js'+PathDelim+'src');
|
||||||
|
ProcParams.Add('-Fu'+PkgSrcDir+'fcl-json'+PathDelim+'src');
|
||||||
|
ProcParams.Add('-Fu'+PkgSrcDir+'fcl-passrc'+PathDelim+'src');
|
||||||
|
ProcParams.Add('-Fu'+PkgSrcDir+'pastojs'+PathDelim+'src');
|
||||||
|
|
||||||
|
ProcParams.Add('-B');
|
||||||
|
ProcParams.Add('-MObjFPC');
|
||||||
|
ProcParams.Add('-O1');
|
||||||
|
ProcParams.Add('-Schi');
|
||||||
|
ProcParams.Add('-vew');
|
||||||
|
|
||||||
|
UnitOutDir:=SourceDir+'units'+PathDelim+TargetCPU+'-'+TargetOS;
|
||||||
|
ForceDir(UnitOutDir,'unit output');
|
||||||
|
ProcParams.Add('-FU'+UnitOutDir);
|
||||||
|
|
||||||
|
BinOutDir:=SourceDir+'bin'+PathDelim+TargetCPU+'-'+TargetOS;
|
||||||
|
ForceDir(BinOutDir,'binary output');
|
||||||
|
ProcParams.Add('-FE'+BinOutDir);
|
||||||
|
|
||||||
|
ProcParams.Add('pas2js.pp');
|
||||||
|
|
||||||
|
RunTool(WorkDir,FPCReleaseFilename,ProcParams);
|
||||||
|
finally
|
||||||
|
ProcParams.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPas2jsReleaseCreator.RunTool(WorkDir, Exe: string;
|
procedure TPas2jsReleaseCreator.RunTool(WorkDir, Exe: string;
|
||||||
const ProcParams: TStringDynArray);
|
const ProcParams: TStringDynArray);
|
||||||
|
var
|
||||||
|
sl: TStringList;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
sl:=TStringList.Create;
|
||||||
|
try
|
||||||
|
for i:=0 to length(ProcParams)-1 do
|
||||||
|
sl.Add(ProcParams[i]);
|
||||||
|
RunTool(WorkDir,Exe,sl);
|
||||||
|
finally
|
||||||
|
sl.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPas2jsReleaseCreator.RunTool(WorkDir, Exe: string;
|
||||||
|
ProcParams: TStringList);
|
||||||
var
|
var
|
||||||
TheProcess: TProcess;
|
TheProcess: TProcess;
|
||||||
i, OutLen, LineStart: Integer;
|
i, OutLen, LineStart: Integer;
|
||||||
@ -357,21 +417,22 @@ var
|
|||||||
begin
|
begin
|
||||||
if not FileIsExecutable(Exe) then
|
if not FileIsExecutable(Exe) then
|
||||||
Err('Not an executable: '+Exe);
|
Err('Not an executable: '+Exe);
|
||||||
|
if DirectoryExists(Exe) then
|
||||||
|
Err('Not an executable: '+Exe);
|
||||||
if (not Simulate) and (not DirectoryExists(WorkDir)) then
|
if (not Simulate) and (not DirectoryExists(WorkDir)) then
|
||||||
Err('Workdir missing: '+WorkDir);
|
Err('Workdir missing: '+WorkDir);
|
||||||
|
|
||||||
TheProcess:=TProcess.Create(nil);
|
TheProcess:=TProcess.Create(nil);
|
||||||
try
|
try
|
||||||
TheProcess.Executable := Exe;
|
TheProcess.Executable := Exe;
|
||||||
CmdLine:=QuotedStr(Exe);
|
TheProcess.Parameters := ProcParams;
|
||||||
for i:=0 to length(ProcParams)-1 do begin
|
TheProcess.Options := [poUsePipes, poStdErrToOutput];
|
||||||
CmdLine+=' '+QuotedStr(ProcParams[i]);
|
|
||||||
TheProcess.Parameters.Add(ProcParams[i]);
|
|
||||||
end;
|
|
||||||
TheProcess.Options:= [poUsePipes, poStdErrToOutPut];
|
|
||||||
TheProcess.ShowWindow := swoHide;
|
TheProcess.ShowWindow := swoHide;
|
||||||
TheProcess.CurrentDirectory:=WorkDir;
|
TheProcess.CurrentDirectory := WorkDir;
|
||||||
|
|
||||||
|
CmdLine:=Quote(Exe);
|
||||||
|
for i:=0 to ProcParams.Count-1 do
|
||||||
|
CmdLine+=' '+Quote(ProcParams[i]);
|
||||||
if Simulate then begin
|
if Simulate then begin
|
||||||
Log(etInfo,'Simulate Running: WorkDir="'+WorkDir+'" Cmd: '+CmdLine);
|
Log(etInfo,'Simulate Running: WorkDir="'+WorkDir+'" Cmd: '+CmdLine);
|
||||||
exit;
|
exit;
|
||||||
@ -393,8 +454,7 @@ begin
|
|||||||
OutputLine:=OutputLine+copy(Buf,LineStart,i-LineStart);
|
OutputLine:=OutputLine+copy(Buf,LineStart,i-LineStart);
|
||||||
writeln(OutputLine);
|
writeln(OutputLine);
|
||||||
OutputLine:='';
|
OutputLine:='';
|
||||||
if (i<OutLen) and (Buf[i+1] in [#10,#13]) and (Buf[i]<>Buf[i+1])
|
if (i<OutLen) and (Buf[i+1] in [#10,#13]) and (Buf[i]<>Buf[i+1]) then
|
||||||
then
|
|
||||||
inc(i);
|
inc(i);
|
||||||
LineStart:=i+1;
|
LineStart:=i+1;
|
||||||
end;
|
end;
|
||||||
@ -405,11 +465,30 @@ begin
|
|||||||
if OutputLine<>'' then
|
if OutputLine<>'' then
|
||||||
writeln(OutputLine);
|
writeln(OutputLine);
|
||||||
TheProcess.WaitOnExit;
|
TheProcess.WaitOnExit;
|
||||||
|
if TheProcess.ExitStatus<>0 then
|
||||||
|
Err('ExitStatus: '+IntToStr(TheProcess.ExitStatus));
|
||||||
|
if TheProcess.ExitCode<>0 then
|
||||||
|
Err('ExitCode: '+IntToStr(TheProcess.ExitCode));
|
||||||
finally
|
finally
|
||||||
TheProcess.Free;
|
TheProcess.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPas2jsReleaseCreator.ForceDir(Dir, DirTitle: string);
|
||||||
|
begin
|
||||||
|
if DirectoryExists(Dir) then exit;
|
||||||
|
if Simulate then exit;
|
||||||
|
if ForceDirectories(Dir) then exit;
|
||||||
|
Err('Unable to create '+DirTitle+' directory "'+Dir+'"');
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPas2jsReleaseCreator.Quote(const s: string): string;
|
||||||
|
begin
|
||||||
|
Result:=s;
|
||||||
|
if Pos(' ',Result)<1 then exit;
|
||||||
|
Result:=QuotedStr(s);
|
||||||
|
end;
|
||||||
|
|
||||||
function TPas2jsReleaseCreator.GetDefaultCfgFilename: string;
|
function TPas2jsReleaseCreator.GetDefaultCfgFilename: string;
|
||||||
begin
|
begin
|
||||||
Result:=ExpandFileName(DefaultCfgFilename);
|
Result:=ExpandFileName(DefaultCfgFilename);
|
||||||
|
@ -266,6 +266,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
until FindNext(Info)<>0;
|
until FindNext(Info)<>0;
|
||||||
end;
|
end;
|
||||||
|
FindClose(Info);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user