implemented creating Makefile.fpc for packages

git-svn-id: trunk@7815 -
This commit is contained in:
mattias 2005-09-24 17:53:32 +00:00
parent dcdfa8de52
commit 80cf1894eb
5 changed files with 249 additions and 68 deletions

View File

@ -6,7 +6,6 @@
<CompilerOptions> <CompilerOptions>
<Version Value="5"/> <Version Value="5"/>
<SearchPaths> <SearchPaths>
<OtherUnitFiles Value="$(LazarusDir)/components/units/$(TargetCPU)/$(TargetOS)/"/>
<UnitOutputDirectory Value="lib/"/> <UnitOutputDirectory Value="lib/"/>
</SearchPaths> </SearchPaths>
<CodeGeneration> <CodeGeneration>

View File

@ -174,11 +174,15 @@ type
TCompilationToolClass = class of TCompilationTool; TCompilationToolClass = class of TCompilationTool;
TBaseCompilerOptionsClass = class of TBaseCompilerOptions; TBaseCompilerOptionsClass = class of TBaseCompilerOptions;
{ TBaseCompilerOptions }
TBaseCompilerOptions = class(TLazCompilerOptions) TBaseCompilerOptions = class(TLazCompilerOptions)
private private
FBaseDirectory: string; FBaseDirectory: string;
FDefaultMakeOptionsFlags: TCompilerCmdLineOptions; FDefaultMakeOptionsFlags: TCompilerCmdLineOptions;
fInheritedOptions: TInheritedCompOptsStrings; fInheritedParsedOptions: TInheritedCompOptsStrings;
fInheritedUnparsedOptions: TInheritedCompOptsStrings;
fInheritedOptParseStamps: integer; fInheritedOptParseStamps: integer;
fInheritedOptGraphStamps: integer; fInheritedOptGraphStamps: integer;
fLoaded: Boolean; fLoaded: Boolean;
@ -237,17 +241,26 @@ type
procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual; procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual;
function GetOwnerName: string; virtual; function GetOwnerName: string; virtual;
function GetInheritedOption(Option: TInheritedCompilerOption; function GetInheritedOption(Option: TInheritedCompilerOption;
RelativeToBaseDir: boolean): string; virtual; RelativeToBaseDir: boolean;
Parsed: boolean = true): string; virtual;
function GetDefaultMainSourceFileName: string; virtual; function GetDefaultMainSourceFileName: string; virtual;
function NeedsLinkerOpts: boolean; function NeedsLinkerOpts: boolean;
function GetUnitPath(RelativeToBaseDir: boolean): string; function GetUnitPath(RelativeToBaseDir: boolean;
function GetIncludePath(RelativeToBaseDir: boolean): string; Parsed: boolean = true): string;
function GetSrcPath(RelativeToBaseDir: boolean): string; function GetIncludePath(RelativeToBaseDir: boolean;
function GetLibraryPath(RelativeToBaseDir: boolean): string; Parsed: boolean = true): string;
function GetUnitOutPath(RelativeToBaseDir: boolean): string; function GetSrcPath(RelativeToBaseDir: boolean;
Parsed: boolean = true): string;
function GetLibraryPath(RelativeToBaseDir: boolean;
Parsed: boolean = true): string;
function GetUnitOutPath(RelativeToBaseDir: boolean;
Parsed: boolean = true): string;
function GetParsedPath(Option: TParsedCompilerOptString; function GetParsedPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption; InheritedOption: TInheritedCompilerOption;
RelativeToBaseDir: boolean): string; RelativeToBaseDir: boolean): string;
function GetUnparsedPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption;
RelativeToBaseDir: boolean): string;
function ShortenPath(const SearchPath: string; function ShortenPath(const SearchPath: string;
MakeAlwaysRelative: boolean): string; MakeAlwaysRelative: boolean): string;
function GetCustomOptions: string; function GetCustomOptions: string;
@ -277,6 +290,8 @@ type
or a package or the IDE needs to use the package. or a package or the IDE needs to use the package.
} }
{ TAdditionalCompilerOptions }
TAdditionalCompilerOptions = class TAdditionalCompilerOptions = class
private private
FBaseDirectory: string; FBaseDirectory: string;
@ -287,6 +302,7 @@ type
FObjectPath: string; FObjectPath: string;
fOwner: TObject; fOwner: TObject;
FParsedOpts: TParsedCompilerOptions; FParsedOpts: TParsedCompilerOptions;
FSrcPath: string;
FUnitPath: string; FUnitPath: string;
protected protected
procedure SetBaseDirectory(const AValue: string); virtual; procedure SetBaseDirectory(const AValue: string); virtual;
@ -296,6 +312,7 @@ type
procedure SetLinkerOptions(const AValue: string); virtual; procedure SetLinkerOptions(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); virtual; procedure SetObjectPath(const AValue: string); virtual;
procedure SetUnitPath(const AValue: string); virtual; procedure SetUnitPath(const AValue: string); virtual;
procedure SetSrcPath(const AValue: string); virtual;
public public
constructor Create(TheOwner: TObject); constructor Create(TheOwner: TObject);
destructor Destroy; override; destructor Destroy; override;
@ -304,10 +321,12 @@ type
AdjustPathDelims: boolean); AdjustPathDelims: boolean);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
function GetOwnerName: string; virtual; function GetOwnerName: string; virtual;
function GetOption(AnOption: TInheritedCompilerOption): string;
public public
property Owner: TObject read fOwner; property Owner: TObject read fOwner;
property UnitPath: string read FUnitPath write SetUnitPath; property UnitPath: string read FUnitPath write SetUnitPath;
property IncludePath: string read FIncludePath write SetIncludePath; property IncludePath: string read FIncludePath write SetIncludePath;
property SrcPath: string read FSrcPath write SetSrcPath;
property ObjectPath: string read FObjectPath write SetObjectPath; property ObjectPath: string read FObjectPath write SetObjectPath;
property LibraryPath: string read FLibraryPath write SetLibraryPath; property LibraryPath: string read FLibraryPath write SetLibraryPath;
property LinkerOptions: string read FLinkerOptions write SetLinkerOptions; property LinkerOptions: string read FLinkerOptions write SetLinkerOptions;
@ -344,7 +363,7 @@ procedure IncreaseCompilerGraphStamp;
function ParseString(Options: TParsedCompilerOptions; function ParseString(Options: TParsedCompilerOptions;
const UnparsedValue: string): string; const UnparsedValue: string): string;
procedure GatherInheritedOptions(AddOptionsList: TList; procedure GatherInheritedOptions(AddOptionsList: TList; Parsed: boolean;
var InheritedOptionStrings: TInheritedCompOptsStrings); var InheritedOptionStrings: TInheritedCompOptsStrings);
function InheritedOptionsToCompilerParameters( function InheritedOptionsToCompilerParameters(
var InheritedOptionStrings: TInheritedCompOptsStrings; var InheritedOptionStrings: TInheritedCompOptsStrings;
@ -395,7 +414,7 @@ begin
Result:=OnParseString(Options,UnparsedValue); Result:=OnParseString(Options,UnparsedValue);
end; end;
procedure GatherInheritedOptions(AddOptionsList: TList; procedure GatherInheritedOptions(AddOptionsList: TList; Parsed: boolean;
var InheritedOptionStrings: TInheritedCompOptsStrings); var InheritedOptionStrings: TInheritedCompOptsStrings);
var var
i: Integer; i: Integer;
@ -406,6 +425,7 @@ begin
AddOptions:=TAdditionalCompilerOptions(AddOptionsList[i]); AddOptions:=TAdditionalCompilerOptions(AddOptionsList[i]);
if (not (AddOptions is TAdditionalCompilerOptions)) then continue; if (not (AddOptions is TAdditionalCompilerOptions)) then continue;
if Parsed then begin
// unit search path // unit search path
InheritedOptionStrings[icoUnitPath]:= InheritedOptionStrings[icoUnitPath]:=
MergeSearchPaths(InheritedOptionStrings[icoUnitPath], MergeSearchPaths(InheritedOptionStrings[icoUnitPath],
@ -434,6 +454,36 @@ begin
InheritedOptionStrings[icoCustomOptions]:= InheritedOptionStrings[icoCustomOptions]:=
MergeCustomOptions(InheritedOptionStrings[icoCustomOptions], MergeCustomOptions(InheritedOptionStrings[icoCustomOptions],
AddOptions.ParsedOpts.GetParsedValue(pcosCustomOptions)); AddOptions.ParsedOpts.GetParsedValue(pcosCustomOptions));
end else begin
// unit search path
InheritedOptionStrings[icoUnitPath]:=
MergeSearchPaths(InheritedOptionStrings[icoUnitPath],
AddOptions.GetOption(icoUnitPath));
// include search path
InheritedOptionStrings[icoIncludePath]:=
MergeSearchPaths(InheritedOptionStrings[icoIncludePath],
AddOptions.GetOption(icoUnitPath));
// src search path
InheritedOptionStrings[icoSrcPath]:=
MergeSearchPaths(InheritedOptionStrings[icoSrcPath],
AddOptions.GetOption(icoUnitPath));
// object search path
InheritedOptionStrings[icoObjectPath]:=
MergeSearchPaths(InheritedOptionStrings[icoObjectPath],
AddOptions.GetOption(icoUnitPath));
// library search path
InheritedOptionStrings[icoLibraryPath]:=
MergeSearchPaths(InheritedOptionStrings[icoLibraryPath],
AddOptions.GetOption(icoUnitPath));
// linker options
InheritedOptionStrings[icoLinkerOptions]:=
MergeLinkerOptions(InheritedOptionStrings[icoLinkerOptions],
AddOptions.GetOption(icoUnitPath));
// custom options
InheritedOptionStrings[icoCustomOptions]:=
MergeCustomOptions(InheritedOptionStrings[icoCustomOptions],
AddOptions.GetOption(icoUnitPath));
end;
end; end;
end; end;
end; end;
@ -1111,7 +1161,10 @@ begin
fInheritedOptParseStamps:=InvalidParseStamp; fInheritedOptParseStamps:=InvalidParseStamp;
fInheritedOptGraphStamps:=InvalidParseStamp; fInheritedOptGraphStamps:=InvalidParseStamp;
for i:=Low(TInheritedCompilerOption) to High(TInheritedCompilerOption) do for i:=Low(TInheritedCompilerOption) to High(TInheritedCompilerOption) do
fInheritedOptions[i]:=''; begin
fInheritedParsedOptions[i]:='';
fInheritedUnparsedOptions[i]:='';
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1175,10 +1228,12 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TBaseCompilerOptions.GetInheritedOption( function TBaseCompilerOptions.GetInheritedOption(
Option: TInheritedCompilerOption; RelativeToBaseDir: boolean): string; Option: TInheritedCompilerOption; RelativeToBaseDir: boolean;
Parsed: boolean = true): string;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TBaseCompilerOptions.GetInheritedOption( function TBaseCompilerOptions.GetInheritedOption(
Option: TInheritedCompilerOption; RelativeToBaseDir: boolean): string; Option: TInheritedCompilerOption; RelativeToBaseDir: boolean;
Parsed: boolean): string;
var var
OptionsList: TList; OptionsList: TList;
begin begin
@ -1190,13 +1245,17 @@ begin
OptionsList:=nil; OptionsList:=nil;
GetInheritedCompilerOptions(OptionsList); GetInheritedCompilerOptions(OptionsList);
if OptionsList<>nil then begin if OptionsList<>nil then begin
GatherInheritedOptions(OptionsList,fInheritedOptions); GatherInheritedOptions(OptionsList,true,fInheritedParsedOptions);
GatherInheritedOptions(OptionsList,false,fInheritedUnparsedOptions);
OptionsList.Free; OptionsList.Free;
end; end;
fInheritedOptParseStamps:=CompilerParseStamp; fInheritedOptParseStamps:=CompilerParseStamp;
fInheritedOptGraphStamps:=CompilerGraphStamp; fInheritedOptGraphStamps:=CompilerGraphStamp;
end; end;
Result:=fInheritedOptions[Option]; if Parsed then
Result:=fInheritedParsedOptions[Option]
else
Result:=fInheritedUnparsedOptions[Option];
if RelativeToBaseDir then begin if RelativeToBaseDir then begin
if Option in [icoUnitPath,icoIncludePath,icoObjectPath,icoLibraryPath] then if Option in [icoUnitPath,icoIncludePath,icoObjectPath,icoLibraryPath] then
Result:=CreateRelativeSearchPath(Result,BaseDirectory); Result:=CreateRelativeSearchPath(Result,BaseDirectory);
@ -1213,32 +1272,49 @@ begin
Result:=not (ccloNoLinkerOpts in fDefaultMakeOptionsFlags); Result:=not (ccloNoLinkerOpts in fDefaultMakeOptionsFlags);
end; end;
function TBaseCompilerOptions.GetUnitPath(RelativeToBaseDir: boolean): string; function TBaseCompilerOptions.GetUnitPath(RelativeToBaseDir: boolean;
Parsed: boolean): string;
begin begin
Result:=GetParsedPath(pcosUnitPath,icoUnitPath,RelativeToBaseDir); if Parsed then
Result:=GetParsedPath(pcosUnitPath,icoUnitPath,RelativeToBaseDir)
else
Result:=GetUnparsedPath(pcosUnitPath,icoUnitPath,RelativeToBaseDir)
end; end;
function TBaseCompilerOptions.GetIncludePath(RelativeToBaseDir: boolean function TBaseCompilerOptions.GetIncludePath(RelativeToBaseDir: boolean;
): string; Parsed: boolean): string;
begin begin
Result:=GetParsedPath(pcosIncludePath,icoIncludePath,RelativeToBaseDir); if Parsed then
Result:=GetParsedPath(pcosIncludePath,icoIncludePath,RelativeToBaseDir)
else
Result:=GetUnparsedPath(pcosIncludePath,icoIncludePath,RelativeToBaseDir);
end; end;
function TBaseCompilerOptions.GetSrcPath(RelativeToBaseDir: boolean): string; function TBaseCompilerOptions.GetSrcPath(RelativeToBaseDir: boolean;
Parsed: boolean): string;
begin begin
Result:=GetParsedPath(pcosSrcPath,icoSrcPath,RelativeToBaseDir); if Parsed then
Result:=GetParsedPath(pcosSrcPath,icoSrcPath,RelativeToBaseDir)
else
Result:=GetUnparsedPath(pcosSrcPath,icoSrcPath,RelativeToBaseDir);
end; end;
function TBaseCompilerOptions.GetLibraryPath(RelativeToBaseDir: boolean function TBaseCompilerOptions.GetLibraryPath(RelativeToBaseDir: boolean;
): string; Parsed: boolean): string;
begin begin
Result:=GetParsedPath(pcosLibraryPath,icoLibraryPath,RelativeToBaseDir); if Parsed then
Result:=GetParsedPath(pcosLibraryPath,icoLibraryPath,RelativeToBaseDir)
else
Result:=GetUnparsedPath(pcosLibraryPath,icoLibraryPath,RelativeToBaseDir);
end; end;
function TBaseCompilerOptions.GetUnitOutPath(RelativeToBaseDir: boolean function TBaseCompilerOptions.GetUnitOutPath(RelativeToBaseDir: boolean;
): string; Parsed: boolean = true): string;
begin begin
Result:=ParsedOpts.GetParsedValue(pcosOutputDir); if Parsed then
Result:=ParsedOpts.GetParsedValue(pcosOutputDir)
else
Result:=ParsedOpts.UnparsedValues[pcosOutputDir];
if (not RelativeToBaseDir) then if (not RelativeToBaseDir) then
CreateAbsolutePath(Result,BaseDirectory); CreateAbsolutePath(Result,BaseDirectory);
end; end;
@ -1265,7 +1341,7 @@ begin
{$ENDIF} {$ENDIF}
// inherited path // inherited path
InheritedPath:=GetInheritedOption(InheritedOption,RelativeToBaseDir); InheritedPath:=GetInheritedOption(InheritedOption,RelativeToBaseDir,true);
{$IFDEF VerbosePkgUnitPath} {$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetParsedPath Inherited ',dbgsName(Self),' InheritedPath="',InheritedPath,'"'); debugln('TBaseCompilerOptions.GetParsedPath Inherited ',dbgsName(Self),' InheritedPath="',InheritedPath,'"');
@ -1278,6 +1354,41 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TBaseCompilerOptions.GetUnparsedPath(Option: TParsedCompilerOptString;
InheritedOption: TInheritedCompilerOption; RelativeToBaseDir: boolean
): string;
var
CurrentPath: String;
InheritedPath: String;
begin
// current path
CurrentPath:=ParsedOpts.UnparsedValues[Option];
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetUnparsedPath GetParsedValue ',dbgsName(Self),' RelativeToBaseDir=',dbgs(RelativeToBaseDir),' CurrentPath="',CurrentPath,'"');
{$ENDIF}
if (not RelativeToBaseDir) then
CreateAbsolutePath(CurrentPath,BaseDirectory);
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetUnparsedPath CreateAbsolutePath ',dbgsName(Self),' CurrentPath="',CurrentPath,'"');
{$ENDIF}
// inherited path
InheritedPath:=GetInheritedOption(InheritedOption,RelativeToBaseDir,false);
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetUnparsedPath Inherited ',dbgsName(Self),' InheritedPath="',InheritedPath,'"');
{$ENDIF}
Result:=MergeSearchPaths(CurrentPath,InheritedPath);
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetUnparsedPath Total ',dbgsName(Self),' Result="',Result,'"');
{$ENDIF}
end;
function TBaseCompilerOptions.GetCustomOptions: string; function TBaseCompilerOptions.GetCustomOptions: string;
var var
CurCustomOptions: String; CurCustomOptions: String;
@ -1286,7 +1397,7 @@ begin
// custom options // custom options
CurCustomOptions:=ParsedOpts.GetParsedValue(pcosCustomOptions); CurCustomOptions:=ParsedOpts.GetParsedValue(pcosCustomOptions);
// inherited custom options // inherited custom options
InhCustomOptions:=GetInheritedOption(icoCustomOptions,true); InhCustomOptions:=GetInheritedOption(icoCustomOptions,true,true);
// concatenate // concatenate
if CurCustomOptions<>'' then if CurCustomOptions<>'' then
Result:=CurCustomOptions+' '+InhCustomOptions Result:=CurCustomOptions+' '+InhCustomOptions
@ -1695,7 +1806,7 @@ Processor specific options:
// inherited Linker options // inherited Linker options
if (not (ccloNoLinkerOpts in Flags)) then begin if (not (ccloNoLinkerOpts in Flags)) then begin
InhLinkerOpts:=GetInheritedOption(icoLinkerOptions,true); InhLinkerOpts:=GetInheritedOption(icoLinkerOptions,true,true);
if InhLinkerOpts<>'' then if InhLinkerOpts<>'' then
switches := switches + ' ' + ConvertOptionsToCmdLine(' ','-k', InhLinkerOpts); switches := switches + ' ' + ConvertOptionsToCmdLine(' ','-k', InhLinkerOpts);
end; end;
@ -1787,7 +1898,7 @@ Processor specific options:
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', CurObjectPath); switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', CurObjectPath);
// inherited object path // inherited object path
InhObjectPath:=GetInheritedOption(icoObjectPath,true); InhObjectPath:=GetInheritedOption(icoObjectPath,true,true);
if (InhObjectPath <> '') then if (InhObjectPath <> '') then
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', InhObjectPath); switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fo', InhObjectPath);
@ -2193,6 +2304,13 @@ begin
ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions); ParsedOpts.SetUnparsedValue(pcosCustomOptions,fCustomOptions);
end; end;
procedure TAdditionalCompilerOptions.SetSrcPath(const AValue: string);
begin
if FSrcPath=AValue then exit;
FSrcPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosSrcPath,FSrcPath);
end;
procedure TAdditionalCompilerOptions.SetBaseDirectory(const AValue: string); procedure TAdditionalCompilerOptions.SetBaseDirectory(const AValue: string);
begin begin
if FBaseDirectory=AValue then exit; if FBaseDirectory=AValue then exit;
@ -2295,6 +2413,22 @@ begin
Result:='Has no owner'; Result:='Has no owner';
end; end;
function TAdditionalCompilerOptions.GetOption(AnOption: TInheritedCompilerOption
): string;
begin
case AnOption of
icoUnitPath: Result:=UnitPath;
icoIncludePath: Result:=IncludePath;
icoObjectPath: Result:=ObjectPath;
icoLibraryPath: Result:=LibraryPath;
icoSrcPath: Result:=SrcPath;
icoLinkerOptions: Result:=LinkerOptions;
icoCustomOptions: Result:=CustomOptions;
else
RaiseGDBException(''); // inconsistency detected
end;
end;
{ TParsedCompilerOptions } { TParsedCompilerOptions }
constructor TParsedCompilerOptions.Create; constructor TParsedCompilerOptions.Create;

View File

@ -5495,7 +5495,6 @@ begin
if Result<>mrOk then exit; if Result<>mrOk then exit;
if Handled then exit; if Handled then exit;
end; end;
debugln('TMainIDE.DoOpenEditorFile ',NewUnitInfo.Filename,' ',NewUnitInfo.UnitName);
// check readonly // check readonly
NewUnitInfo.FileReadOnly:=FileExists(NewUnitInfo.Filename) NewUnitInfo.FileReadOnly:=FileExists(NewUnitInfo.Filename)

View File

@ -389,6 +389,7 @@ type
procedure SetLinkerOptions(const AValue: string); override; procedure SetLinkerOptions(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override; procedure SetObjectPath(const AValue: string); override;
procedure SetUnitPath(const AValue: string); override; procedure SetUnitPath(const AValue: string); override;
procedure SetSrcPath(const AValue: string); override;
public public
constructor Create(ThePackage: TLazPackage); constructor Create(ThePackage: TLazPackage);
function GetOwnerName: string; override; function GetOwnerName: string; override;
@ -608,7 +609,6 @@ type
procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string; procedure OnMacroListSubstitution(TheMacro: TTransferMacro; var s: string;
var Handled, Abort: boolean); var Handled, Abort: boolean);
procedure SetUserReadOnly(const AValue: boolean); procedure SetUserReadOnly(const AValue: boolean);
function SubstitutePkgMacro(const s: string): string;
procedure GetWritableOutputDirectory(var AnOutDir: string); procedure GetWritableOutputDirectory(var AnOutDir: string);
procedure Clear; procedure Clear;
procedure UpdateSourceDirectories; procedure UpdateSourceDirectories;
@ -645,6 +645,7 @@ type
function GetUnitPath(RelativeToBaseDir: boolean): string; function GetUnitPath(RelativeToBaseDir: boolean): string;
function GetIncludePath(RelativeToBaseDir: boolean): string; function GetIncludePath(RelativeToBaseDir: boolean): string;
function NeedsDefineTemplates: boolean; function NeedsDefineTemplates: boolean;
function SubstitutePkgMacro(const s: string): string;
// files // files
function IndexOfPkgFile(PkgFile: TPkgFile): integer; function IndexOfPkgFile(PkgFile: TPkgFile): integer;
function SearchFile(const ShortFilename: string; function SearchFile(const ShortFilename: string;
@ -3405,6 +3406,13 @@ begin
LazPackage.Modified:=true; LazPackage.Modified:=true;
end; end;
procedure TPkgAdditionalCompilerOptions.SetSrcPath(const AValue: string);
begin
if AValue=SrcPath then exit;
inherited SetSrcPath(AValue);
LazPackage.Modified:=true;
end;
constructor TPkgAdditionalCompilerOptions.Create(ThePackage: TLazPackage); constructor TPkgAdditionalCompilerOptions.Create(ThePackage: TLazPackage);
begin begin
inherited Create(ThePackage); inherited Create(ThePackage);

View File

@ -1172,19 +1172,61 @@ begin
end; end;
function TPkgManager.DoWriteMakefile(APackage: TLazPackage): TModalResult; function TPkgManager.DoWriteMakefile(APackage: TLazPackage): TModalResult;
procedure Replace(var s: string; const SearchTxt, ReplaceTxt: string);
var
p: LongInt;
begin
repeat
p:=Pos(SearchTxt,s);
if p<=1 then break;
s:=copy(s,1,p-1)+ReplaceTxt+copy(s,p+length(SearchTxt),length(s));
until false;
end;
function ConvertLazarusToMakefileMakros(const s: string): string;
begin
Result:=s;
Replace(Result,'$(TargetCPU)','%(CPU_TARGET)');
Replace(Result,'$(TargetOS)','%(OS_TARGET)');
Result:=APackage.SubstitutePkgMacro(Result);
Result:=ParseString(APackage.CompilerOptions.ParsedOpts,Result);
Replace(Result,'%(CPU_TARGET)','$(CPU_TARGET)');
Replace(Result,'%(OS_TARGET)','$(OS_TARGET)');
end;
function ConvertLazarusToMakefileSearchPath(const s: string): string;
begin
Result:=CreateRelativeSearchPath(
TrimSearchPath(ConvertLazarusToMakefileMakros(s),''),
APackage.Directory);
Replace(Result,';',' ');
end;
function ConvertLazarusToMakefileDirectory(const s: string): string;
begin
Result:=CreateRelativePath(TrimFilename(
ConvertLazarusToMakefileMakros(s)),APackage.Directory);
end;
var var
s: String; s: String;
e: string; e: string;
SrcFilename: String; SrcFilename: String;
MainUnitName: String; MainUnitName: String;
MakefileFPCFilename: String; MakefileFPCFilename: String;
BaseDir: String; UnitOutputPath: String;
UnitPath: String;
begin begin
Result:=mrCancel; Result:=mrCancel;
SrcFilename:=APackage.GetSrcFilename; SrcFilename:=APackage.GetSrcFilename;
MainUnitName:=lowercase(ExtractFileNameOnly((SrcFilename))); MainUnitName:=lowercase(ExtractFileNameOnly((SrcFilename)));
BaseDir:=APackage.Directory; UnitPath:=APackage.CompilerOptions.GetUnitPath(false,false)+';.';
UnitOutputPath:=APackage.CompilerOptions.GetUnitOutPath(false,false);
UnitPath:=ConvertLazarusToMakefileSearchPath(UnitPath);
UnitOutputPath:=ConvertLazarusToMakefileDirectory(UnitOutputPath);
e:=LineEnding; e:=LineEnding;
s:=''; s:='';
@ -1195,9 +1237,8 @@ begin
s:=s+'version='+APackage.Version.AsString+e; s:=s+'version='+APackage.Version.AsString+e;
s:=s+''+e; s:=s+''+e;
s:=s+'[compiler]'+e; s:=s+'[compiler]'+e;
s:=s+'unittargetdir='+CreateRelativePath( s:=s+'unittargetdir='+UnitOutputPath+e;
APackage.CompilerOptions.GetUnitOutPath(true),BaseDir)+e; s:=s+'unitdir='+UnitPath+e;
s:=s+'unitdir='+APackage.CompilerOptions.GetUnitPath(true)+';.'+e;
s:=s+'options=-gl'+e; // ToDo do the other options s:=s+'options=-gl'+e; // ToDo do the other options
s:=s+''+e; s:=s+''+e;
s:=s+'[target]'+e; s:=s+'[target]'+e;
@ -3865,7 +3906,7 @@ begin
PkgList.Free; PkgList.Free;
if AddOptionsList<>nil then begin if AddOptionsList<>nil then begin
// combine options of same type // combine options of same type
GatherInheritedOptions(AddOptionsList,InheritedOptionStrings); GatherInheritedOptions(AddOptionsList,true,InheritedOptionStrings);
AddOptionsList.Free; AddOptionsList.Free;
end; end;