fpcmake: started using FPCDIR

This commit is contained in:
mattias 2024-01-19 12:18:21 +01:00
parent 4d5d6a8e03
commit 9d6c3d3af9
2 changed files with 54 additions and 46 deletions

View File

@ -106,13 +106,14 @@ begin
Addln('# If you don''t want so much verbosity use');
Addln('#-vw');
Addln('');
Addln('# Allow C-operators');
Addln('-Sc');
Addln('');
Addln('#IFDEF FPC_SUBTARGET_NAMESPACED');
AddPath('-Fu',BaseDir,'namespaced');
AddPath('-Fi',BaseDir,'src');
// needed for system unit.
AddPath('-Fu',BaseDir+'rtl'+PathDelim+'src','');
AddPath('-Fu',BaseDir,'*/namespaced');
AddPath('-Fi',BaseDir,'*/src');
AddLn('#else');
AddPath('-Fu',BaseDir,'src');
AddPath('-Fu',BaseDir,'*/src');
AddLn('#endif');
if rtl_js_dir<>'' then
AddPath('-Fu',rtl_js_dir,'');
@ -178,8 +179,15 @@ Var
P : TPackage;
UnitDir,DemoDir,BD, TmpCfg, TmpCfg2: String;
T: TTarget;
FPCSrcDir: String;
begin
FPCSrcDir:=GetEnvironmentVariable('FPCDIR');
if FPCSrcDir<>'' then
FPCSrcDir:=IncludeTrailingPathDelimiter(ExpandFileName(FPCSrcDir));
if FPCSrcDir='' then
FPCSrcDir:=IncludeTrailingPathDelimiter(GetCurrentDir)+'compiler'+PathDelim;
With Installer do
begin
P:=AddPackage('pas2js');
@ -190,26 +198,26 @@ begin
P.Email := 'michael@freepascal.org';
P.NeedLibC:= false;
P.Version:='3.3.1';
P.SourcePath.Add('compiler/utils/pas2js');
P.UnitPath.Add('compiler/utils/pas2js');
P.UnitPath.Add('compiler/packages/pastojs/src');
P.UnitPath.Add('compiler/packages/fcl-passrc/src');
P.UnitPath.Add('compiler/packages/fcl-js/src');
P.UnitPath.Add('compiler/packages/fcl-json/src');
P.SourcePath.Add(FPCSrcDir+'utils/pas2js');
P.UnitPath.Add(FPCSrcDir+'utils/pas2js');
P.UnitPath.Add(FPCSrcDir+'packages/pastojs/src');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-passrc/src');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-js/src');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-json/src');
{$IF FPC_FULLVERSION>=30301}
P.UnitPath.Add('compiler/packages/fcl-base/src');
P.UnitPath.Add('compiler/packages/fcl-web/src/base');
P.UnitPath.Add('compiler/packages/fcl-net/src');
P.IncludePath.Add('compiler/packages/fcl-net/src/unix',AllUnixOSes);
P.IncludePath.Add('compiler/packages/fcl-net/src/win',AllWindowsOSes);
P.IncludePath.Add('compiler/packages/fcl-net/src/os2',[EMX]);
P.IncludePath.Add('compiler/packages/fcl-net/src/amiga',[morphos]);
P.IncludePath.Add('compiler/packages/fcl-net/src/$(OS)',AllOSes-AllWindowsOSes-AllUnixOSes-[EMX]);
P.UnitPath.Add('compiler/packages/fcl-base/src');
P.IncludePath.Add('compiler/packages/fcl-base/src/dummy');
P.UnitPath.Add('compiler/packages/webidl/src');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-base/src');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-web/src/base');
P.UnitPath.Add(FPCSrcDir+'packages/fcl-net/src');
P.IncludePath.Add(FPCSrcDir+'packages/fcl-net/src/unix',AllUnixOSes);
P.IncludePath.Add(FPCSrcDir+'packages/fcl-net/src/win',AllWindowsOSes);
P.IncludePath.Add(FPCSrcDir+'packages/fcl-net/src/os2',[EMX]);
P.IncludePath.Add(FPCSrcDir+'packages/fcl-net/src/amiga',[morphos]);
P.IncludePath.Add(FPCSrcDir+'packages/fcl-net/src/$(OS)',AllOSes-AllWindowsOSes-AllUnixOSes-[EMX]);
P.UnitPath.Add(FPCSrcDir+'packages/fcl-base/src');
P.IncludePath.Add(FPCSrcDir+'packages/fcl-base/src/dummy');
P.UnitPath.Add(FPCSrcDir+'packages/webidl/src');
{$ENDIF}
P.IncludePath.Add('compiler/packages/pastojs/src');
P.IncludePath.Add(FPCSrcDir+'packages/pastojs/src');
P.Dependencies.Clear;
Defaults.Options.Add('-Sc');
P.Targets.AddProgram('pas2js.pp');
@ -264,14 +272,14 @@ begin
{$ELSE}
BD:=IncludeTrailingPathDelimiter(P.GetBinOutputDir(Defaults.BuildCPU,Defaults.BuildOS));
{$ENDIF}
TmpCfg:='compiler/utils/pas2js/dist/pas2js.cfg';
TmpCfg2:='compiler/utils/pas2js/dist/pas2js-namespaced.cfg';
TmpCfg:=FPCSrcDir+'utils/pas2js/dist/pas2js.cfg';
TmpCfg2:=FPCSrcDir+'utils/pas2js/dist/pas2js-namespaced.cfg';
Case Installer.RunMode of
rmCompile,rmBuild:
begin
if not FileExists(BD+'pas2js.cfg') then
CreateConfigFile(BD+'pas2js.cfg',SetDirSeparators('../../packages'),
SetDirSeparators('../../compiler/utils/pas2js/dist/'));
SetDirSeparators(FPCSrcDir+'utils/pas2js/dist/'));
if not FileExists(BD+'pas2js-namespaced.cfg') then
CreateNameSpacedConfigFile(BD+'pas2js-namespaced.cfg');
end;
@ -289,7 +297,7 @@ begin
CreateNamespacedConfigFile(TmpCfg2);
P.InstallFiles.Add(TmpCfg,Defaults.BinInstallDir);
P.InstallFiles.Add(TmpCfg2,Defaults.BinInstallDir);
P.InstallFiles.Add('compiler/utils/pas2js/dist/rtl.js',IncludeTrailingPathDelimiter(UnitDir)+'rtl');
P.InstallFiles.Add(FPCSrcDir+'utils/pas2js/dist/rtl.js',IncludeTrailingPathDelimiter(UnitDir)+'rtl');
AddPackageFiles(P.InstallFiles,'chartjs',UnitDir);
AddPackageFiles(P.InstallFiles,'dataabstract',UnitDir);
AddPackageFiles(P.InstallFiles,'fcl-base',UnitDir);

View File

@ -41,7 +41,7 @@ type
Pas2jsVersion: string;
Simulate: boolean;
SourceDir: string; // cloned git release
FPCDir: string;
FPCSrcDir: string;
Verbosity: integer;
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -133,7 +133,7 @@ begin
SourceDir:=GetOption_Directory('s','sourcedir',nil);
if SourceDir='' then
Err('missing source directory');
FPCDir:=GetOption_Directory(' ','fpcdir',nil);
FPCSrcDir:=GetOption_Directory(' ','fpcdir',nil);
FPCReleaseFilename:=GetOption_Executable(' ','fpcrelease',nil);
FPCDevelFilename:=GetOption_Executable(' ','fpcdevel',nil);
FPC2Filename:=GetOption_Executable(' ','fpc2',nil);
@ -142,16 +142,16 @@ begin
MakeFilename:=GetOption_Executable(' ','make',@GetDefaultMake);
ZipFilename:=GetOption_Executable(' ','zip',@GetDefaultZip);
if FPCDir='' then
FPCDir:=GetEnvironmentVariable('FPCDIR');
if FPCDir='' then
FPCDir:=SourceDir+'compiler'+PathDelim;
if FPCSrcDir='' then
FPCSrcDir:=GetEnvironmentVariable('FPCDIR');
if FPCSrcDir='' then
FPCSrcDir:=SourceDir+'compiler'+PathDelim;
// write options
if Verbosity>=0 then begin
Log(etInfo,'SourceDir: "'+SourceDir+'"');
Log(etInfo,'BuildDir: "'+BuildDir+'"');
Log(etInfo,'FPCDir: "'+FPCDir+'"');
Log(etInfo,'FPCDir: "'+FPCSrcDir+'"');
Log(etInfo,'FPCRelease: "'+FPCReleaseFilename+'"');
Log(etInfo,'FPCDevel: "'+FPCDevelFilename+'"');
Log(etInfo,'FPC2: "'+FPC2Filename+'"');
@ -171,8 +171,8 @@ begin
Err('BuildDir missing: "'+BuildDir+'"');
if not DirectoryExists(SourceDir) then
Err('SourceDir missing: "'+SourceDir+'"');
if not DirectoryExists(FPCDir) then
Err('FPCDir missing: "'+FPCDir+'"');
if not DirectoryExists(FPCSrcDir) then
Err('FPCDir missing: "'+FPCSrcDir+'"');
CheckExecutable(FPCReleaseFilename,'fpcrelease');
CheckExecutable(FPCDevelFilename,'fpcdevel');
if FPC2Filename<>'' then
@ -305,7 +305,7 @@ begin
sl:=TStringList.Create;
try
// read pas2js version number from Pascal sources
Filename:=FPCDir+SetDirSeparators('packages/pastojs/src/pas2jscompiler.pp');
Filename:=FPCSrcDir+SetDirSeparators('packages/pastojs/src/pas2jscompiler.pp');
if Verbosity>0 then
Log(etInfo,'Reading version from "'+Filename+'" ...');
if not FileExists(Filename) then
@ -338,7 +338,7 @@ begin
Log(etInfo,'Pas2js version is '+Pas2jsVersion);
// read version number from rtl.js
Filename:=FPCDir+SetDirSeparators('utils/pas2js/dist/rtl.js');
Filename:=FPCSrcDir+SetDirSeparators('utils/pas2js/dist/rtl.js');
if Verbosity>0 then
Log(etInfo,'Reading version from "'+Filename+'" ...');
if not FileExists(Filename) then
@ -372,11 +372,11 @@ procedure TPas2jsReleaseCreator.CheckForgottenWriteln;
end;
begin
Check(FPCDir+'packages'+PathDelim+'fcl-js'+PathDelim+'src');
Check(FPCDir+'packages'+PathDelim+'fcl-json'+PathDelim+'src');
Check(FPCDir+'packages'+PathDelim+'fcl-passrc'+PathDelim+'src');
Check(FPCDir+'packages'+PathDelim+'pastojs'+PathDelim+'src');
Check(FPCDir+'utils'+PathDelim+'pas2js');
Check(FPCSrcDir+'packages'+PathDelim+'fcl-js'+PathDelim+'src');
Check(FPCSrcDir+'packages'+PathDelim+'fcl-json'+PathDelim+'src');
Check(FPCSrcDir+'packages'+PathDelim+'fcl-passrc'+PathDelim+'src');
Check(FPCSrcDir+'packages'+PathDelim+'pastojs'+PathDelim+'src');
Check(FPCSrcDir+'utils'+PathDelim+'pas2js');
end;
procedure TPas2jsReleaseCreator.ParseFPCTargetOption(const LongOpt: string; out
@ -480,9 +480,9 @@ begin
SharedParams:=TStringList.Create;
TheParams:=TStringList.Create;
try
WorkDir:=FPCDir+'utils'+PathDelim+'pas2js';
WorkDir:=FPCSrcDir+'utils'+PathDelim+'pas2js';
PkgSrcDir:=FPCDir+'packages'+PathDelim;
PkgSrcDir:=FPCSrcDir+'packages'+PathDelim;
SharedParams.Add('-Fu'+PkgSrcDir+'fcl-js'+PathDelim+'src');
SharedParams.Add('-Fu'+PkgSrcDir+'fcl-json'+PathDelim+'src');
SharedParams.Add('-Fu'+PkgSrcDir+'fcl-passrc'+PathDelim+'src');
@ -602,7 +602,7 @@ procedure TPas2jsReleaseCreator.CopyRTLjs;
var
SrcFilename, DestFilename: String;
begin
SrcFilename:=FPCDir+SetDirSeparators('utils/pas2js/dist/rtl.js');
SrcFilename:=FPCSrcDir+SetDirSeparators('utils/pas2js/dist/rtl.js');
DestFilename:=BuildDir_Sources+SetDirSeparators('packages/rtl/src/rtl.js');
if Simulate then begin
Log(etInfo,'Simulate: Copying "'+SrcFilename+'" -> "'+DestFilename+'"');