diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 47375ecf54..56ae640abc 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -401,8 +401,8 @@ type class procedure MergeXMLConfig(ParentDefTempl: TDefineTemplate; var FirstSibling, LastSibling:TDefineTemplate; XMLConfig: TXMLConfig; const Path, NewNamePrefix: string); - constructor Create(const AName, ADescription, AVariable, AValue: string; - AnAction: TDefineAction); + constructor Create(const AName, ADescription, AVariable: string; + AValue: string; AnAction: TDefineAction); constructor Create; destructor Destroy; override; procedure ConsistencyCheck; @@ -4629,8 +4629,9 @@ begin inherited Create; end; -constructor TDefineTemplate.Create(const AName, ADescription, AVariable, +constructor TDefineTemplate.Create(const AName, ADescription, AVariable: string; AValue: string; AnAction: TDefineAction); +// Don't use "const" for AValue parameter. begin inherited Create; Name:=AName; diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 92af9e5352..3b8f4b2112 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -261,7 +261,7 @@ const CompilerOptionMacroPlatformIndependent = 1; type - TLocalSubstitutionEvent = function(const s: string; + TLocalSubstitutionEvent = function(s: string; PlatformIndependent: boolean): string of object; TInheritedCompOptsParseTypesStrings = @@ -303,7 +303,7 @@ type function GetParsedPIValue(Option: TParsedCompilerOptString): string;// platform independent procedure SetUnparsedValue(Option: TParsedCompilerOptString; const NewValue: string); - function DoParseOption(const OptionText: string; + function DoParseOption(OptionText: string; Option: TParsedCompilerOptString; PlatformIndependent: boolean): string; procedure Assign(Src: TParsedCompilerOptions); @@ -3858,8 +3858,9 @@ begin Values[Option].UnparsedValue:=NewValue; end; -function TParsedCompilerOptions.DoParseOption(const OptionText: string; +function TParsedCompilerOptions.DoParseOption(OptionText: string; Option: TParsedCompilerOptString; PlatformIndependent: boolean): string; +// Don't use "const" for OptionText parameter. function GetBaseDir: string; begin @@ -3878,67 +3879,67 @@ function TParsedCompilerOptions.DoParseOption(const OptionText: string; aFilename:=TrimFilename(aFilename); if (aFilename<>'') and (not FilenameIsAbsolute(aFilename)) then begin BaseDirectory:=GetBaseDir; - if (BaseDirectory<>'') then aFilename:=TrimFilename(BaseDirectory+aFilename); + if (BaseDirectory<>'') then + aFilename:=TrimFilename(BaseDirectory+aFilename); end; end; var - s: String; BaseDirectory, h: String; begin - s:=OptionText; + Result:=OptionText; // apply overrides if not PlatformIndependent then begin if Option=pcosOutputDir then begin if Assigned(OnGetOutputDirectoryOverride) then - OnGetOutputDirectoryOverride(Self,s,bmgtAll); + OnGetOutputDirectoryOverride(Self,Result,bmgtAll); end; end; // parse locally (macros depending on owner, like pkgdir and build macros) if Assigned(OnLocalSubstitute) then begin - //DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']); - s:=OnLocalSubstitute(s,PlatformIndependent) + //DebugLn(['TParsedCompilerOptions.DoParseOption local "',Result,'" ...']); + Result:=OnLocalSubstitute(Result,PlatformIndependent) end else begin - //DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']); - s:=ParseString(Self,s,PlatformIndependent); + //DebugLn(['TParsedCompilerOptions.DoParseOption global "',Result,'" ...']); + Result:=ParseString(Self,Result,PlatformIndependent); end; - //DebugLn(['TParsedCompilerOptions.DoParseOption complete "',s,'" ...']); + //DebugLn(['TParsedCompilerOptions.DoParseOption complete "',Result,'" ...']); // improve if Option=pcosBaseDir then // base directory - s:=AppendPathDelim(TrimFilename(s)) + Result:=AppendPathDelim(TrimFilename(Result)) else if Option in ParsedCompilerFilenames then begin // make filename absolute - //debugln(['TParsedCompilerOptions.DoParseOption ',ParsedCompilerOptsVars[Option],' s="',s,'"']); - if (Option in ParsedCompilerExecutables) and (ExtractFilePath(s)='') then + //debugln(['TParsedCompilerOptions.DoParseOption ',ParsedCompilerOptsVars[Option],' Result="',Result,'"']); + if (Option in ParsedCompilerExecutables) and (ExtractFilePath(Result)='') then begin - h:=FileUtil.FindDefaultExecutablePath(s,GetBaseDir); - if h<>'' then s:=h; + h:=FileUtil.FindDefaultExecutablePath(Result,GetBaseDir); + if h<>'' then + Result:=h; end; - MakeFilenameAbsolute(s); + MakeFilenameAbsolute(Result); end else if Option in ParsedCompilerDirectories then begin // make directory absolute - s:=TrimFilename(s); + Result:=TrimFilename(Result); if Option<>pcosBaseDir then - MakeFilenameAbsolute(s); - s:=AppendPathDelim(s); + MakeFilenameAbsolute(Result); + Result:=AppendPathDelim(Result); end else if Option in ParsedCompilerSearchPaths then begin // make search paths absolute BaseDirectory:=GetBaseDir; - s:=TrimSearchPath(s,BaseDirectory); + Result:=TrimSearchPath(Result,BaseDirectory); end else if Option=pcosCustomOptions then begin - s:=SpecialCharsToSpaces(s,true); + Result:=SpecialCharsToSpaces(Result,true); end; - Result:=s; end; procedure TParsedCompilerOptions.Assign(Src: TParsedCompilerOptions); diff --git a/ide/project.pp b/ide/project.pp index 09a97cc27a..c2b7b75891 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -554,7 +554,7 @@ type procedure SetUnitPaths(const AValue: string); override; procedure SetUnitOutputDir(const AValue: string); override; procedure SetConditionals(AValue: string); override; - function SubstituteProjectMacros(const s: string; + function SubstituteProjectMacros(s: string; PlatformIndependent: boolean): string; public constructor Create(const AOwner: TObject); override; @@ -6526,8 +6526,9 @@ begin inherited SetConditionals(AValue); end; -function TProjectCompilerOptions.SubstituteProjectMacros(const s: string; +function TProjectCompilerOptions.SubstituteProjectMacros(s: string; PlatformIndependent: boolean): string; +// Don't use "const" for s parameter. begin Result:=s; if LazProject=nil then exit; diff --git a/packager/fppkghelper.pas b/packager/fppkghelper.pas index ea9b999190..d86253b237 100644 --- a/packager/fppkghelper.pas +++ b/packager/fppkghelper.pas @@ -34,7 +34,7 @@ type class function Instance: TFppkgHelper; function HasPackage(const PackageName: string): Boolean; procedure ListPackages(AList: TStringList); - function GetPackageUnitPath(const PackageName: string): string; + function GetPackageUnitPath(PackageName: string): string; function IsProperlyConfigured(out Message: string): Boolean; function GetCompilerFilename: string; function GetConfigurationFileName: string; @@ -154,7 +154,8 @@ begin end; end; -function TFppkgHelper.GetPackageUnitPath(const PackageName: string): string; +function TFppkgHelper.GetPackageUnitPath(PackageName: string): string; +// Don't use "const" for PackageName parameter. var FppkgPackage: TFPPackage; {$IF not (FPC_FULLVERSION>30300)} diff --git a/packager/packagedefs.pas b/packager/packagedefs.pas index e0026c0d9f..b278e2c0bc 100644 --- a/packager/packagedefs.pas +++ b/packager/packagedefs.pas @@ -652,7 +652,7 @@ type function GetSrcPath(RelativeToBaseDir: boolean): string; function GetFPDocPackageName: string; function NeedsDefineTemplates: boolean; - function SubstitutePkgMacros(const s: string; PlatformIndependent: boolean): string; + function SubstitutePkgMacros(s: string; PlatformIndependent: boolean): string; procedure WriteInheritedUnparsedOptions; function GetActiveBuildMethod: TBuildMethod; // files @@ -2235,8 +2235,8 @@ begin FUserReadOnly:=AValue; end; -function TLazPackage.SubstitutePkgMacros(const s: string; - PlatformIndependent: boolean): string; +function TLazPackage.SubstitutePkgMacros(s: string; PlatformIndependent: boolean): string; +// Don't use "const" for s parameter. begin Result:=s; if PlatformIndependent then @@ -3840,11 +3840,10 @@ end; function TLazPackage.GetOutputDirectory(UseOverride: boolean = true): string; begin if HasDirectory then begin - if GetActiveBuildMethod = bmFPMake then begin - Result :=TFppkgHelper.Instance.GetPackageUnitPath(name); - end else begin + if GetActiveBuildMethod = bmFPMake then + Result :=TFppkgHelper.Instance.GetPackageUnitPath(name) + else Result:=CompilerOptions.ParsedOpts.GetParsedValue(pcosOutputDir,UseOverride); - end; end else Result:=''; end;