diff --git a/components/cairocanvas/Makefile.compiled b/components/cairocanvas/Makefile.compiled index 0920907bcd..c2aed0699c 100644 --- a/components/cairocanvas/Makefile.compiled +++ b/components/cairocanvas/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/chmhelp/packages/help/Makefile.compiled b/components/chmhelp/packages/help/Makefile.compiled index 0e1f795488..5529bc3ea0 100644 --- a/components/chmhelp/packages/help/Makefile.compiled +++ b/components/chmhelp/packages/help/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/chmhelp/packages/idehelp/Makefile.compiled b/components/chmhelp/packages/idehelp/Makefile.compiled index a4055e28c4..72c1e97b6a 100644 --- a/components/chmhelp/packages/idehelp/Makefile.compiled +++ b/components/chmhelp/packages/idehelp/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/codetools/Makefile.compiled b/components/codetools/Makefile.compiled index b34094a2bc..712bd49b52 100644 --- a/components/codetools/Makefile.compiled +++ b/components/codetools/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/codetools/ide/Makefile.compiled b/components/codetools/ide/Makefile.compiled index a1dbdad1e8..25fad65ff6 100644 --- a/components/codetools/ide/Makefile.compiled +++ b/components/codetools/ide/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/externhelp/Makefile.compiled b/components/externhelp/Makefile.compiled index 87600fa1a5..678ac8d8ae 100644 --- a/components/externhelp/Makefile.compiled +++ b/components/externhelp/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/fpcunit/Makefile.compiled b/components/fpcunit/Makefile.compiled index 7283477989..35e834ccfc 100644 --- a/components/fpcunit/Makefile.compiled +++ b/components/fpcunit/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/fpcunit/ide/Makefile.compiled b/components/fpcunit/ide/Makefile.compiled index fa8e248d68..bf86250d68 100644 --- a/components/fpcunit/ide/Makefile.compiled +++ b/components/fpcunit/ide/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/ideintf/Makefile.compiled b/components/ideintf/Makefile.compiled index ed6ca828bf..5c432ab94f 100644 --- a/components/ideintf/Makefile.compiled +++ b/components/ideintf/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/instantfpc/Makefile.compiled b/components/instantfpc/Makefile.compiled index d5df8aab72..29ed91546e 100644 --- a/components/instantfpc/Makefile.compiled +++ b/components/instantfpc/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/jcf2/IdePlugin/lazarus/Makefile.compiled b/components/jcf2/IdePlugin/lazarus/Makefile.compiled index 1238b49b5f..b012720c6a 100644 --- a/components/jcf2/IdePlugin/lazarus/Makefile.compiled +++ b/components/jcf2/IdePlugin/lazarus/Makefile.compiled @@ -1,5 +1,5 @@ - - + + diff --git a/components/lazcontrols/Makefile.compiled b/components/lazcontrols/Makefile.compiled index 27125cf3ae..1682437782 100644 --- a/components/lazcontrols/Makefile.compiled +++ b/components/lazcontrols/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/lazsvnpkg/Makefile.compiled b/components/lazsvnpkg/Makefile.compiled index d64922037f..937913c7b9 100644 --- a/components/lazsvnpkg/Makefile.compiled +++ b/components/lazsvnpkg/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/lazutils/Makefile.compiled b/components/lazutils/Makefile.compiled index 2d30f4b7ce..44fd64253d 100644 --- a/components/lazutils/Makefile.compiled +++ b/components/lazutils/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/leakview/Makefile.compiled b/components/leakview/Makefile.compiled index eb61842b45..973170f289 100644 --- a/components/leakview/Makefile.compiled +++ b/components/leakview/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/macfiles/Makefile.compiled b/components/macfiles/Makefile.compiled index ef1dc8fa45..1571788701 100644 --- a/components/macfiles/Makefile.compiled +++ b/components/macfiles/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/memds/Makefile.compiled b/components/memds/Makefile.compiled index e099a464e3..1be0d714de 100644 --- a/components/memds/Makefile.compiled +++ b/components/memds/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/printers/Makefile.compiled b/components/printers/Makefile.compiled index d5ce8c4c11..bbbc731a31 100644 --- a/components/printers/Makefile.compiled +++ b/components/printers/Makefile.compiled @@ -1,5 +1,5 @@ - - + + diff --git a/components/printers/design/Makefile.compiled b/components/printers/design/Makefile.compiled index 73a7c1c099..c938c54c4a 100644 --- a/components/printers/design/Makefile.compiled +++ b/components/printers/design/Makefile.compiled @@ -1,5 +1,5 @@ - - + + diff --git a/components/projecttemplates/Makefile.compiled b/components/projecttemplates/Makefile.compiled index a2f61f6626..fbf571a88e 100644 --- a/components/projecttemplates/Makefile.compiled +++ b/components/projecttemplates/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/rtticontrols/Makefile.compiled b/components/rtticontrols/Makefile.compiled index 50d17477b5..7041ec235e 100644 --- a/components/rtticontrols/Makefile.compiled +++ b/components/rtticontrols/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/sdf/Makefile.compiled b/components/sdf/Makefile.compiled index d18449dc55..26100a34ca 100644 --- a/components/sdf/Makefile.compiled +++ b/components/sdf/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/sqldb/Makefile.compiled b/components/sqldb/Makefile.compiled index 1674830743..451c00c0df 100644 --- a/components/sqldb/Makefile.compiled +++ b/components/sqldb/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/synedit/Makefile.compiled b/components/synedit/Makefile.compiled index cd6d2bc4cc..dea9f8d1d9 100644 --- a/components/synedit/Makefile.compiled +++ b/components/synedit/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/synedit/design/Makefile.compiled b/components/synedit/design/Makefile.compiled index f2a1edbd9c..ff2b69b8b0 100644 --- a/components/synedit/design/Makefile.compiled +++ b/components/synedit/design/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/tachart/Makefile.compiled b/components/tachart/Makefile.compiled index d97ecfef9b..02259a1f25 100644 --- a/components/tachart/Makefile.compiled +++ b/components/tachart/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/tdbf/Makefile.compiled b/components/tdbf/Makefile.compiled index 2635a0c01d..1a0e3da798 100644 --- a/components/tdbf/Makefile.compiled +++ b/components/tdbf/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/todolist/Makefile.compiled b/components/todolist/Makefile.compiled index 9bfcd86057..f536744ae2 100644 --- a/components/todolist/Makefile.compiled +++ b/components/todolist/Makefile.compiled @@ -1,5 +1,5 @@ - + - - + + diff --git a/components/turbopower_ipro/Makefile.compiled b/components/turbopower_ipro/Makefile.compiled index 9ed8b2c27d..6c844bfb67 100644 --- a/components/turbopower_ipro/Makefile.compiled +++ b/components/turbopower_ipro/Makefile.compiled @@ -1,5 +1,5 @@ - - + + diff --git a/components/turbopower_ipro/design/Makefile.compiled b/components/turbopower_ipro/design/Makefile.compiled index a8417a9494..adba48f924 100644 --- a/components/turbopower_ipro/design/Makefile.compiled +++ b/components/turbopower_ipro/design/Makefile.compiled @@ -1,5 +1,5 @@ - - + + diff --git a/packager/packagedefs.pas b/packager/packagedefs.pas index e1c8d0c724..7a07669c98 100644 --- a/packager/packagedefs.pas +++ b/packager/packagedefs.pas @@ -3720,9 +3720,9 @@ function TLazPackage.GetLastCompilerParams(o: TPkgOutputDir): string; begin Result:=LastCompile[o].Params; if LastCompile[o].ViaMakefile then begin - Result:=StringReplace(Result,'%(CPU_TARGET)','$(TargetCPU)',[rfReplaceAll]); - Result:=StringReplace(Result,'%(OS_TARGET)','$(TargetOS)',[rfReplaceAll]); - Result:=StringReplace(Result,'%(LCL_PLATFORM)','$(LCLWidgetType)',[rfReplaceAll]); + Result:=StringReplace(Result,'$(CPU_TARGET)','$(TargetCPU)',[rfReplaceAll]); + Result:=StringReplace(Result,'$(OS_TARGET)','$(TargetOS)',[rfReplaceAll]); + Result:=StringReplace(Result,'$(LCL_PLATFORM)','$(LCLWidgetType)',[rfReplaceAll]); Result:=SubstitutePkgMacros(Result,false); end; end; diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index 23209e3ecb..08d86c1be5 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -46,7 +46,7 @@ uses {$ENDIF} // FPC + LCL Classes, SysUtils, FileProcs, FileUtil, LCLProc, Forms, Controls, Dialogs, - Laz2_XMLCfg, InterfaceBase, + Laz2_XMLCfg, LazLogger, InterfaceBase, // codetools AVL_Tree, DefineTemplates, CodeCache, BasicCodeTools, CodeToolsStructs, NonPascalCodeTools, SourceChanger, @@ -61,6 +61,10 @@ uses DialogProcs, IDETranslations, CompilerOptions, PackageLinks, PackageDefs, ComponentReg, ProjectIntf; +const + MakefileCompileVersion = 2; + // 2 : changed macro format from %() to $() + type TFindPackageFlag = ( fpfSearchInInstalledPckgs, @@ -2665,6 +2669,8 @@ var StateFileAge: Integer; stats: PPkgLastCompileStats; o: TPkgOutputDir; + MakefileValue: String; + MakefileVersion: Integer; begin o:=APackage.GetOutputDirType; stats:=@APackage.LastCompile[o]; @@ -2690,7 +2696,18 @@ begin stats^.Params:=XMLConfig.GetValue('Params/Value',''); stats^.Complete:=XMLConfig.GetValue('Complete/Value',true); stats^.MainPPUExists:=XMLConfig.GetValue('Complete/MainPPUExists',true); - stats^.ViaMakefile:=XMLConfig.GetValue('Makefile/Value',false); + MakefileValue:=XMLConfig.GetValue('Makefile/Value',''); + if (MakefileValue='') then + stats^.ViaMakefile:=false + else begin + stats^.ViaMakefile:=true; + MakefileVersion:=StrToIntDef(MakefileValue,0); + if MakefileVersion<2 then begin + // old versions used %( + stats^.CompilerFilename:=StringReplace(stats^.CompilerFilename,'%(','$(',[rfReplaceAll]); + stats^.Params:=StringReplace(stats^.Params,'%(','$(',[rfReplaceAll]); + end; + end; if stats^.ViaMakefile then begin DoDirSeparators(stats^.CompilerFilename); DoDirSeparators(stats^.Params); @@ -3045,6 +3062,8 @@ begin LastParams:=APackage.GetLastCompilerParams(o); if Stats^.ViaMakefile then begin // the package was compiled via Makefile/fpmake + debugln(['TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile Last=',LastParams]); + CurPaths:=nil; LastPaths:=nil; try @@ -3578,7 +3597,7 @@ begin try XMLConfig:=TXMLConfig.Create(TargetCompiledFile); try - XMLConfig.SetValue('Makefile/Value',True); + XMLConfig.SetValue('Makefile/Value',MakefileCompileVersion); s:=''; if UnitPath<>'' then s:=s+' -Fu'+SwitchPathDelims(UnitPath,pdsUnix); @@ -3621,7 +3640,7 @@ var repeat p:=Pos(SearchTxt,s); if p<=1 then break; - s:=copy(s,1,p-1)+ReplaceTxt+copy(s,p+length(SearchTxt),length(s)); + ReplaceSubstring(s,p,length(SearchTxt),ReplaceTxt); until false; end; @@ -3640,6 +3659,14 @@ var Replace(Result,PathDelim,'/'); end; + function ConvertLazarusToMakefileCompiledSearchPath(const s: string): string; + begin + Result:=ConvertPIMacrosToMakefileMacros(s); + Result:=CreateRelativeSearchPath(TrimSearchPath(Result,''),APackage.Directory); + if PathDelimNeedsReplace then + Replace(Result,PathDelim,'/'); + end; + function ConvertLazarusToMakefileDirectory(const s: string): string; begin Result:=ConvertPIMacrosToMakefileMacros(s); @@ -3672,6 +3699,8 @@ var IncPath: String; MakefileCompiledFilename: String; OtherOptions: String; + FormUnitPath: String; + FormIncPath: String; begin Result:=mrCancel; PathDelimNeedsReplace:=PathDelim<>'/'; @@ -3701,13 +3730,6 @@ begin OtherOptions:=APackage.CompilerOptions.MakeOptionsString( [ccloDoNotAppendOutFileOption,ccloNoMacroParams]); - Result:=WriteMakefileCompiled(APackage,MakefileCompiledFilename,UnitPath, - IncPath,OtherOptions); - if Result<>mrOK then exit; - - //DebugLn('TPkgManager.DoWriteMakefile ',APackage.Name,' makefile UnitPath="',UnitPath,'"'); - UnitPath:=ConvertLazarusToMakefileSearchPath(UnitPath); - IncPath:=ConvertLazarusToMakefileSearchPath(IncPath); // remove path delimiter at the end, or else it will fail on windows UnitOutputPath:=ConvertLazarusToMakefileDirectory( ChompPathDelim(UnitOutputPath)); @@ -3722,6 +3744,21 @@ begin OtherOptions:=CustomOptions; debugln(['TLazPackageGraph.WriteMakeFile Other="',OtherOptions,'"']); + // ---- Makefile.compiled ---------------------------------------------------- + + //DebugLn('TPkgManager.DoWriteMakefile ',APackage.Name,' makefile UnitPath="',UnitPath,'"'); + FormUnitPath:=ConvertLazarusToMakefileCompiledSearchPath(UnitPath); + FormIncPath:=ConvertLazarusToMakefileCompiledSearchPath(IncPath); + Result:=WriteMakefileCompiled(APackage,MakefileCompiledFilename,FormUnitPath, + FormIncPath,OtherOptions); + if Result<>mrOK then exit; + + // ---- Makefile.fpc --------------------------------------------------------- + + //DebugLn('TPkgManager.DoWriteMakefile ',APackage.Name,' makefile UnitPath="',UnitPath,'"'); + FormUnitPath:=ConvertLazarusToMakefileSearchPath(UnitPath); + FormIncPath:=ConvertLazarusToMakefileSearchPath(IncPath); + e:=LineEnding; s:=''; s:=s+'# File generated automatically by Lazarus Package Manager'+e; @@ -3737,9 +3774,9 @@ begin s:=s+'[compiler]'+e; s:=s+'unittargetdir='+UnitOutputPath+e; if UnitPath<>'' then - s:=s+'unitdir='+UnitPath+e; + s:=s+'unitdir='+FormUnitPath+e; if IncPath<>'' then - s:=s+'includedir='+IncPath+e; + s:=s+'includedir='+FormIncPath+e; s:=s+'options='+OtherOptions+e; s:=s+''+e; s:=s+'[target]'+e; diff --git a/packager/registration/Makefile.compiled b/packager/registration/Makefile.compiled index 938093e6c0..6d5047a7bf 100644 --- a/packager/registration/Makefile.compiled +++ b/packager/registration/Makefile.compiled @@ -1,5 +1,5 @@ - + - +