mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-30 10:19:12 +02:00
* global config logging and writing
git-svn-id: trunk@6417 -
This commit is contained in:
parent
8ff402109f
commit
af466b4219
@ -71,9 +71,21 @@ procedure TMakeTool.LoadGlobalDefaults;
|
||||
var
|
||||
SL : TStringList;
|
||||
i : integer;
|
||||
cfgfile : String;
|
||||
GeneratedConfig : boolean;
|
||||
begin
|
||||
cfgfile:=GetConfigFileName;
|
||||
GeneratedConfig:=false;
|
||||
FDefaults:=TPackagerOptions.Create;
|
||||
FDefaults.LoadGlobalFromFile(GetConfigFileName);
|
||||
// Load file or create new default configuration
|
||||
if FileExists(cfgfile) then
|
||||
FDefaults.LoadGlobalFromFile(cfgfile)
|
||||
else
|
||||
begin
|
||||
ForceDirectories(ExtractFilePath(cfgfile));
|
||||
FDefaults.SaveGlobalToFile(cfgfile);
|
||||
GeneratedConfig:=true;
|
||||
end;
|
||||
// Load default verbosity from config
|
||||
SL:=TStringList.Create;
|
||||
SL.CommaText:=FDefaults.DefaultVerbosity;
|
||||
@ -81,6 +93,11 @@ begin
|
||||
Include(Verbosity,StringToVerbosity(SL[i]));
|
||||
SL.Free;
|
||||
FCompilerConfig:=FDefaults.DefaultCompilerConfig;
|
||||
// Tracing of what we've done above, need to be done after the verbosity is set
|
||||
if GeneratedConfig then
|
||||
Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile])
|
||||
else
|
||||
Log(vDebug,SLogLoadingGlobalConfig,[cfgfile])
|
||||
end;
|
||||
|
||||
|
||||
@ -141,7 +158,7 @@ procedure TMakeTool.ShowUsage;
|
||||
begin
|
||||
Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
|
||||
Writeln('Options:');
|
||||
Writeln(' -r --compiler Set compiler');
|
||||
Writeln(' -c --config Set compiler configuration to use');
|
||||
Writeln(' -h --help This help');
|
||||
Writeln(' -v --verbose Set verbosity');
|
||||
Writeln('Actions:');
|
||||
@ -217,8 +234,8 @@ begin
|
||||
begin
|
||||
Inc(I);
|
||||
// Check options.
|
||||
if CheckOption(I,'r','compiler') then
|
||||
FDefaults.Compiler:=OptionArg(I)
|
||||
if CheckOption(I,'c','config') then
|
||||
FCompilerConfig:=OptionArg(I)
|
||||
else if CheckOption(I,'v','verbose') then
|
||||
Include(Verbosity,StringToVerbosity(OptionArg(I)))
|
||||
else if CheckOption(I,'h','help') then
|
||||
|
@ -37,7 +37,9 @@ Resourcestring
|
||||
SLogRunAction = 'Action: "%s %s"';
|
||||
SLogExecute = 'Executing: "%s %s"';
|
||||
SLogChangeDir = 'CurrentDir: "%s"';
|
||||
SLogLoadingGlobalConfig = 'Loading global configuration from "%s"';
|
||||
SLogLoadingCompilerConfig = 'Loading compiler configuration from "%s"';
|
||||
SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"';
|
||||
SLogGeneratingCompilerConfig = 'Generating default compiler configuration in "%s"';
|
||||
SLogLoadingRepository = 'Loading repository data from "%s"';
|
||||
SLogLoadingVersions = 'Loading versions data from "%s"';
|
||||
|
@ -32,8 +32,7 @@ Type
|
||||
FLocalRepository : String;
|
||||
FCompilerConfigDir,
|
||||
FPackagesDir,
|
||||
FBuildDir,
|
||||
FLocalDir : String;
|
||||
FBuildDir : String;
|
||||
FDefaultVerbosity,
|
||||
FDefaultCompilerConfig : String;
|
||||
// Compiler specific options
|
||||
@ -46,8 +45,6 @@ Type
|
||||
procedure SetOptString(Index: integer; const AValue: String);
|
||||
procedure SetCompilerCPU(const AValue: TCPU);
|
||||
procedure SetCompilerOS(const AValue: TOS);
|
||||
protected
|
||||
Property LocalDir : String Read FLocalDir;
|
||||
Public
|
||||
Constructor Create;
|
||||
Procedure InitGlobalDefaults;
|
||||
@ -100,10 +97,10 @@ Const
|
||||
KeyRemoteMirrorsLocation = 'RemoteMirrors';
|
||||
KeyRemoteRepository = 'RemoteRepository';
|
||||
KeyLocalRepository = 'LocalRepository';
|
||||
KeyDefaultConfig = 'DefaultCompilerConfig';
|
||||
KeyCompilerConfigDir = 'CompilerConfigDir';
|
||||
KeyPackagesDir = 'PackagesDir';
|
||||
KeyBuildDir = 'BuildDir';
|
||||
KeyCompilerConfig = 'CompilerConfig';
|
||||
KeyVerbosity = 'Verbosity';
|
||||
// Compiler dependent config
|
||||
KeyInstallDir = 'InstallDir';
|
||||
@ -207,23 +204,28 @@ end;
|
||||
|
||||
|
||||
Procedure TPackagerOptions.InitGlobalDefaults;
|
||||
var
|
||||
LocalDir : String;
|
||||
begin
|
||||
FRemoteMirrorsLocation:=DefaultMirrorsLocation;
|
||||
FRemoteRepository:=DefaultRemoteRepository;
|
||||
{$ifdef unix}
|
||||
if (fpGetUID=0) then
|
||||
FLocalDir:=DefaultUnixPrefix
|
||||
LocalDir:=DefaultUnixPrefix
|
||||
else
|
||||
FLocalDir:=IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'))+'.fppkg/';
|
||||
LocalDir:=IncludeTrailingPathDelimiter(GetEnvironmentVariable('HOME'))+'.fppkg/';
|
||||
{$else}
|
||||
// Change as needed on all OS-es...
|
||||
FLocalDir:=ExtractFilePath(Paramstr(0))+'fppkg'+PathDelim;
|
||||
LocalDir:=ExtractFilePath(Paramstr(0))+'fppkg'+PathDelim;
|
||||
{$endif}
|
||||
FBuildDir:=FLocalDir+'build'+PathDelim;
|
||||
FPackagesDir:=FLocalDir+'packages'+PathDelim;
|
||||
FCompilerConfigDir:=FLocalDir+'config'+PathDelim;
|
||||
FLocalMirrorsLocation:=FLocalDir+DefaultMirrors;
|
||||
FLocalRepository:=FLocalDir+DefaultRepository;
|
||||
// Directories
|
||||
FBuildDir:=LocalDir+'build'+PathDelim;
|
||||
FPackagesDir:=LocalDir+'packages'+PathDelim;
|
||||
FCompilerConfigDir:=LocalDir+'config'+PathDelim;
|
||||
FLocalMirrorsLocation:=LocalDir+DefaultMirrors;
|
||||
FLocalRepository:=LocalDir+DefaultRepository;
|
||||
// Remote
|
||||
FRemoteMirrorsLocation:=DefaultMirrorsLocation;
|
||||
FRemoteRepository:=DefaultRemoteRepository;
|
||||
// Other config
|
||||
FDefaultCompilerConfig:='default';
|
||||
FDefaultVerbosity:='error,info,debug,commands';
|
||||
end;
|
||||
@ -270,7 +272,10 @@ begin
|
||||
FRemoteRepository:=ReadString(SDefaults,KeyRemoteRepository,FRemoteRepository);
|
||||
FLocalRepository:=ReadString(SDefaults,KeyLocalRepository,FLocalRepository);
|
||||
FBuildDir:=FixPath(ReadString(SDefaults,KeyBuildDir,FBuildDir));
|
||||
FDefaultCompilerConfig:=ReadString(SDefaults,KeyDefaultConfig,FDefaultCompilerConfig);
|
||||
FPackagesDir:=FixPath(ReadString(SDefaults,KeyPackagesDir,FPackagesDir));
|
||||
FCompilerConfigDir:=FixPath(ReadString(SDefaults,KeyCompilerConfigDir,FCompilerConfigDir));
|
||||
FDefaultCompilerConfig:=ReadString(SDefaults,KeyCompilerConfig,FDefaultCompilerConfig);
|
||||
FDefaultVerbosity:=ReadString(SDefaults,KeyVerbosity,FDefaultVerbosity);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -279,12 +284,15 @@ procedure TPackagerOptions.SaveGlobalToIni(Ini: TCustomIniFile);
|
||||
begin
|
||||
With Ini do
|
||||
begin
|
||||
WriteString(SDefaults,KeyBuildDir,FBuildDir);
|
||||
WriteString(SDefaults,KeyPackagesDir,FPackagesDir);
|
||||
WriteString(SDefaults,KeyCompilerConfigDir,FCompilerConfigDir);
|
||||
WriteString(SDefaults,KeyLocalRepository,FLocalRepository);
|
||||
WriteString(SDefaults,KeyLocalMirrorsLocation,FLocalMirrorsLocation);
|
||||
WriteString(SDefaults,KeyRemoteMirrorsLocation,FRemoteMirrorsLocation);
|
||||
WriteString(SDefaults,KeyRemoteRepository,FRemoteRepository);
|
||||
WriteString(SDefaults,KeyLocalRepository,FLocalRepository);
|
||||
WriteString(SDefaults,KeyBuildDir,FBuildDir);
|
||||
WriteString(SDefaults,KeyDefaultConfig,FDefaultCompilerConfig);
|
||||
WriteString(SDefaults,KeyCompilerConfig,FDefaultCompilerConfig);
|
||||
WriteString(SDefaults,KeyVerbosity,FDefaultVerbosity);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user