mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:59:42 +02:00
* quoted parameters
* workaround broken fpc.exe in 2.2.0, retreive real compiler binary instead * fppkg requires at least 2.2.1 to be compiled, because of broken sysutils and zipper git-svn-id: trunk@10132 -
This commit is contained in:
parent
2400207ead
commit
dd1a7ce8e3
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,10 @@ program fppkg;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$if defined(VER2_2) and (FPC_PATCH<1)}
|
||||
{$fatal At least FPC 2.2.1 is required to compile fppkg}
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
// General
|
||||
{$ifdef unix}
|
||||
|
@ -114,6 +114,8 @@ end;
|
||||
{ TFPMakeCompiler }
|
||||
|
||||
Procedure TFPMakeCompiler.CompileFPMake;
|
||||
var
|
||||
OOptions : string;
|
||||
|
||||
function CheckUnitDir(const AUnitName:string;Out AUnitDir:string):boolean;
|
||||
begin
|
||||
@ -136,17 +138,24 @@ Procedure TFPMakeCompiler.CompileFPMake;
|
||||
AUnitDir:='';
|
||||
end;
|
||||
|
||||
procedure AddOption(const s:string);
|
||||
begin
|
||||
if OOptions<>'' then
|
||||
OOptions:=OOptions+' ';
|
||||
OOptions:=OOptions+maybequoted(s);
|
||||
end;
|
||||
|
||||
const
|
||||
TempBuildDir = 'build-fpmake';
|
||||
Var
|
||||
i : Integer;
|
||||
OOptions,
|
||||
DepDir,
|
||||
FPMakeBin,
|
||||
FPMakeSrc : string;
|
||||
NeedFPMKUnitSource,
|
||||
HaveFpmake : boolean;
|
||||
begin
|
||||
OOptions:='';
|
||||
SetCurrentDir(PackageBuildPath);
|
||||
// Check for fpmake source
|
||||
FPMakeBin:='fpmake'+ExeExt;
|
||||
@ -164,13 +173,13 @@ begin
|
||||
begin
|
||||
if Not HaveFPMake then
|
||||
Error(SErrMissingFPMake);
|
||||
OOptions:='-n';
|
||||
AddOption('-n');
|
||||
for i:=1 to FPMKUnitDepCount do
|
||||
begin
|
||||
if FPMKUnitDepAvailable[i] then
|
||||
begin
|
||||
if CheckUnitDir(FPMKUnitDeps[i].package,DepDir) then
|
||||
OOptions:=OOptions+' -Fu'+DepDir
|
||||
AddOption(maybequoted('-Fu'+DepDir))
|
||||
else
|
||||
Error(SErrMissingInstallPackage,[FPMKUnitDeps[i].package]);
|
||||
end
|
||||
@ -180,26 +189,27 @@ begin
|
||||
if FPMKUnitDeps[i].package='fpmkunit' then
|
||||
begin
|
||||
NeedFPMKUnitSource:=true;
|
||||
OOptions:=OOptions+' -Fu'+TempBuildDir;
|
||||
AddOption('-Fu'+TempBuildDir);
|
||||
end;
|
||||
if FPMKUnitDeps[i].undef<>'' then
|
||||
OOptions:=OOptions+' -d'+FPMKUnitDeps[i].undef;
|
||||
AddOption('-d'+FPMKUnitDeps[i].undef);
|
||||
end;
|
||||
end;
|
||||
// Add RTL unit dir
|
||||
if not CheckUnitDir('rtl',DepDir) then
|
||||
Error(SErrMissingInstallPackage,['rtl']);
|
||||
OOptions:=OOptions+' -Fu'+DepDir;
|
||||
AddOption('-Fu'+DepDir);
|
||||
// Units in a directory for easy cleaning
|
||||
DeleteDir(TempBuildDir);
|
||||
ForceDirectories(TempBuildDir);
|
||||
OOptions:=OOptions+' -FU'+TempBuildDir;
|
||||
AddOption('-FU'+TempBuildDir);
|
||||
// Compile options
|
||||
// -- default is to optimize, smartlink and strip to reduce
|
||||
// the executable size (there can be 100's of fpmake's on a system)
|
||||
if vlInfo in LogLevels then
|
||||
OOptions:=OOptions+' -vi';
|
||||
OOptions:=OOptions+' -O2 -XXs';
|
||||
AddOption('-vi');
|
||||
AddOption('-O2');
|
||||
AddOption('-XXs');
|
||||
// Create fpmkunit.pp if needed
|
||||
if NeedFPMKUnitSource then
|
||||
CreateFPMKUnitSource(TempBuildDir+PathDelim+'fpmkunit.pp');
|
||||
@ -228,27 +238,36 @@ Function TFPMakeRunner.RunFPMake(const Command:string) : Integer;
|
||||
Var
|
||||
FPMakeBin,
|
||||
OOptions : string;
|
||||
|
||||
procedure AddOption(const s:string);
|
||||
begin
|
||||
if OOptions<>'' then
|
||||
OOptions:=OOptions+' ';
|
||||
OOptions:=OOptions+maybequoted(s);
|
||||
end;
|
||||
|
||||
begin
|
||||
OOptions:='';
|
||||
{ Maybe compile fpmake executable? }
|
||||
ExecuteAction(CurrentPackage,'compilefpmake');
|
||||
{ Create options }
|
||||
OOptions:=' --nofpccfg';
|
||||
AddOption('--nofpccfg');
|
||||
if vlInfo in LogLevels then
|
||||
OOptions:=OOptions+' --verbose';
|
||||
OOptions:=OOptions+' --compiler='+CompilerOptions.Compiler;
|
||||
OOptions:=OOptions+' --cpu='+CPUToString(CompilerOptions.CompilerCPU);
|
||||
OOptions:=OOptions+' --os='+OSToString(CompilerOptions.CompilerOS);
|
||||
AddOption('--verbose');
|
||||
AddOption('--compiler='+CompilerOptions.Compiler);
|
||||
AddOption('--cpu='+CPUToString(CompilerOptions.CompilerCPU));
|
||||
AddOption('--os='+OSToString(CompilerOptions.CompilerOS));
|
||||
if IsSuperUser or GlobalOptions.InstallGlobal then
|
||||
OOptions:=OOptions+' --baseinstalldir='+CompilerOptions.GlobalInstallDir
|
||||
AddOption('--baseinstalldir='+CompilerOptions.GlobalInstallDir)
|
||||
else
|
||||
OOptions:=OOptions+' --baseinstalldir='+CompilerOptions.LocalInstallDir;
|
||||
AddOption('--baseinstalldir='+CompilerOptions.LocalInstallDir);
|
||||
if CompilerOptions.LocalInstallDir<>'' then
|
||||
OOptions:=OOptions+' --localunitdir='+CompilerOptions.LocalUnitDir;
|
||||
OOptions:=OOptions+' --globalunitdir='+CompilerOptions.GlobalUnitDir;
|
||||
AddOption('--localunitdir='+CompilerOptions.LocalUnitDir);
|
||||
AddOption('--globalunitdir='+CompilerOptions.GlobalUnitDir);
|
||||
{ Run FPMake }
|
||||
FPMakeBin:='fpmake'+ExeExt;
|
||||
SetCurrentDir(PackageBuildPath);
|
||||
Result:=ExecuteProcess(FPMakeBin,Command+OOptions);
|
||||
Result:=ExecuteProcess(FPMakeBin,Command+' '+OOptions);
|
||||
if Result<>0 then
|
||||
Error(SErrExecutionFPMake,[Command]);
|
||||
end;
|
||||
|
@ -5,6 +5,9 @@ unit pkgglobals;
|
||||
interface
|
||||
|
||||
uses
|
||||
{$ifdef unix}
|
||||
baseunix,
|
||||
{$endif}
|
||||
SysUtils,
|
||||
Classes;
|
||||
|
||||
@ -53,11 +56,6 @@ const
|
||||
type
|
||||
EPackagerError = class(Exception);
|
||||
|
||||
{$if defined(VER2_2) and defined(WINDOWS)}
|
||||
Function GetAppConfigDir(Global : Boolean) : String;
|
||||
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
|
||||
{$endif VER2_2 AND WINDOWS}
|
||||
|
||||
// Logging
|
||||
Function StringToLogLevels (S : String) : TLogLevels;
|
||||
Function LogLevelsToString (V : TLogLevels): String;
|
||||
@ -93,9 +91,6 @@ Implementation
|
||||
|
||||
uses
|
||||
typinfo,
|
||||
{$ifdef unix}
|
||||
baseunix,
|
||||
{$endif}
|
||||
{$IFNDEF USE_SHELL}
|
||||
process,
|
||||
{$ENDIF USE_SHELL}
|
||||
@ -124,43 +119,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{$if defined(VER2_2) and defined(WINDOWS)}
|
||||
Function SHGetFolderPath(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT;
|
||||
stdcall;external 'shfolder' name 'SHGetFolderPathA';
|
||||
|
||||
Function GetAppConfigDir(Global : Boolean) : String;
|
||||
Const
|
||||
CSIDL_LOCAL_APPDATA = $001C; { %USERPROFILE%\Local Settings\Application Data (non roaming) }
|
||||
CSIDL_COMMON_APPDATA = $0023; { %PROFILESPATH%\All Users\Application Data }
|
||||
CSIDL_FLAG_CREATE = $8000; { (force creation of requested folder if it doesn't exist yet) }
|
||||
Var
|
||||
APath : Array[0..MAX_PATH] of char;
|
||||
ID : integer;
|
||||
begin
|
||||
If Global then
|
||||
ID:=CSIDL_COMMON_APPDATA
|
||||
else
|
||||
ID:=CSIDL_LOCAL_APPDATA;
|
||||
if SHGetFolderPath(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
|
||||
Result:=IncludeTrailingPathDelimiter(StrPas(@APath[0]))
|
||||
If (Result<>'') then
|
||||
begin
|
||||
if FPPkgGetVendorName<>'' then
|
||||
Result:=IncludeTrailingPathDelimiter(Result+FPPkgGetVendorName);
|
||||
Result:=Result+ApplicationName;
|
||||
end
|
||||
else
|
||||
Result:=DGetAppConfigDir(Global);
|
||||
end;
|
||||
|
||||
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
|
||||
begin
|
||||
Result:=IncludeTrailingPathDelimiter(GetAppConfigDir(Global));
|
||||
if SubDir then
|
||||
Result:=IncludeTrailingPathDelimiter(Result+'Config');
|
||||
Result:=Result+ApplicationName+ConfigExtension;
|
||||
end;
|
||||
{$endif VER2_2 AND WINDOWS}
|
||||
|
||||
function StringToLogLevels(S: String): TLogLevels;
|
||||
Var
|
||||
@ -410,9 +368,7 @@ end;
|
||||
|
||||
|
||||
initialization
|
||||
{$ifndef VER2_2}
|
||||
OnGetVendorName:=@FPPkgGetVendorName;
|
||||
{$endif}
|
||||
OnGetApplicationName:=@FPPkgGetApplicationName;
|
||||
|
||||
end.
|
||||
|
@ -426,6 +426,10 @@ begin
|
||||
FCompilerVersion:=infosl[0];
|
||||
FCompilerCPU:=StringToCPU(infosl[1]);
|
||||
FCompilerOS:=StringToOS(infosl[2]);
|
||||
// Temporary hack to workaround bug in fpc.exe that doesn't support spaces
|
||||
// We retrieve the real binary
|
||||
if FCompilerVersion='2.2.0' then
|
||||
FCompiler:=GetCompilerInfo(FCompiler,'-PB');
|
||||
Log(vlDebug,SLogDetectedCompiler,[FCompiler,FCompilerVersion,MakeTargetString(FCompilerCPU,FCompilerOS)]);
|
||||
// Use the same algorithm as the compiler, see options.pas
|
||||
{$ifdef Unix}
|
||||
|
Loading…
Reference in New Issue
Block a user