diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index d5357ee572..aba7bbcde3 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -926,7 +926,7 @@ procedure TEnvironmentOptions.CreateConfig; var ConfFileName: string; begin - ConfFileName:=SetDirSeparators(GetPrimaryConfigPath+'/'+EnvOptsConfFileName); + ConfFileName:=TrimFilename(SetDirSeparators(GetPrimaryConfigPath+'/'+EnvOptsConfFileName)); CopySecondaryConfigFile(EnvOptsConfFileName); if (not FileExistsUTF8(ConfFileName)) then begin //DebugLn('Note: environment config file not found - using defaults'); diff --git a/ide/lazbuild.lpr b/ide/lazbuild.lpr index ae3ff33280..3e44c67974 100644 --- a/ide/lazbuild.lpr +++ b/ide/lazbuild.lpr @@ -53,8 +53,10 @@ type FBuildModeOverride: String; FBuildRecursive: boolean; fCompilerOverride: String; + fCompilerInCfg: string; FCreateMakefile: boolean; fLazarusDirOverride : String; + fLazarusDirInCfg: string; fCPUOverride: String; fOSOverride: String; FSkipDependencies: boolean; @@ -121,6 +123,7 @@ type procedure SetupCodetools; procedure SetupPackageSystem; procedure SetupDialogs; + procedure StoreBaseSettings; function RepairedCheckOptions(Const ShortOptions : String; Const Longopts : TStrings; Opts,NonOpts : TStrings) : String; public @@ -825,6 +828,8 @@ begin SetupOutputFilter; MainBuildBoss.SetupCompilerInterface; + StoreBaseSettings; + // load static base packages PackageGraph.LoadStaticBasePackages; @@ -838,6 +843,9 @@ begin with EnvironmentOptions do begin CreateConfig; Load(false); + fCompilerInCfg:=CompilerFilename; + fLazarusDirInCfg:=LazarusDirectory; + if Application.HasOption('language') then begin debugln('TLazBuildApplication.Init overriding language with command line: ', Application.GetOptionValue('language')); @@ -906,6 +914,39 @@ begin IDEQuestionDialog:=@OnIDEQuestionDialog; end; +procedure TLazBuildApplication.StoreBaseSettings; +var + StoreLazDir: Boolean; + StoreCompPath: Boolean; + Cfg: TXMLConfig; +begin + StoreLazDir:=(fLazarusDirInCfg='') and (EnvironmentOptions.LazarusDirectory<>''); + StoreCompPath:=(fCompilerInCfg='') and (EnvironmentOptions.CompilerFilename<>''); + if (not StoreLazDir) and (not StoreCompPath) then exit; + + try + dbgout('storing'); + if StoreLazDir then + dbgout(' Lazarus directory "',EnvironmentOptions.LazarusDirectory,'"'); + if StoreCompPath then + dbgout(' Compiler path "',EnvironmentOptions.CompilerFilename,'"'); + debugln(' in "',EnvironmentOptions.Filename,'"'); + Cfg:=TXMLConfig.Create(EnvironmentOptions.Filename); + try + if StoreLazDir then + Cfg.SetValue('EnvironmentOptions/LazarusDirectory/Value', + EnvironmentOptions.LazarusDirectory); + if StoreCompPath then + Cfg.SetValue('EnvironmentOptions/CompilerFilename/Value', + EnvironmentOptions.CompilerFilename); + Cfg.Flush; + finally + Cfg.Free; + end; + except + end; +end; + function TLazBuildApplication.RepairedCheckOptions(const ShortOptions: String; const Longopts: TStrings; Opts, NonOpts: TStrings): String;