mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 00:39:10 +02:00
added tool to update all makefiles for lpk
git-svn-id: trunk@36026 -
This commit is contained in:
parent
ba4396d5cc
commit
243b6475c1
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -6579,6 +6579,8 @@ tools/snapshots/testmonitorcfg.pas svneol=native#text/plain
|
|||||||
tools/svn2revisioninc.lpi svneol=native#text/plain
|
tools/svn2revisioninc.lpi svneol=native#text/plain
|
||||||
tools/svn2revisioninc.pas svneol=native#text/plain
|
tools/svn2revisioninc.pas svneol=native#text/plain
|
||||||
tools/update_pkgfileslcl_inc.sh svneol=native#text/plain
|
tools/update_pkgfileslcl_inc.sh svneol=native#text/plain
|
||||||
|
tools/updatemakefiles.lpi svneol=native#text/plain
|
||||||
|
tools/updatemakefiles.lpr svneol=native#text/plain
|
||||||
tools/updatepofiles.lpi svneol=native#text/plain
|
tools/updatepofiles.lpi svneol=native#text/plain
|
||||||
tools/updatepofiles.pas svneol=native#text/pascal
|
tools/updatepofiles.pas svneol=native#text/pascal
|
||||||
tools/xpm_to_png/convert.bat svneol=native#text/x-msdos-program
|
tools/xpm_to_png/convert.bat svneol=native#text/x-msdos-program
|
||||||
|
84
tools/updatemakefiles.lpi
Normal file
84
tools/updatemakefiles.lpi
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InIDEConfig"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="project1"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<i18n>
|
||||||
|
<EnableI18N LFM="False"/>
|
||||||
|
</i18n>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
|
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="3">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="CodeTools"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<PackageName Value="LCLBase"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<PackageName Value="LazUtils"/>
|
||||||
|
</Item3>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="updatemakefiles.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="updatemakefiles"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="updatemakefiles"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Other>
|
||||||
|
<CompilerMessages>
|
||||||
|
<MsgFileName Value=""/>
|
||||||
|
</CompilerMessages>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
154
tools/updatemakefiles.lpr
Normal file
154
tools/updatemakefiles.lpr
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
{ Tool to update all Makefiles for lazarus packages.
|
||||||
|
|
||||||
|
Copyright (C) 2012 Mattias Gaertner mattias@freepascal.org
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Library General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version with the following modification:
|
||||||
|
|
||||||
|
As a special exception, the copyright holders of this library give you
|
||||||
|
permission to link this library with independent modules to produce an
|
||||||
|
executable, regardless of the license terms of these independent modules,and
|
||||||
|
to copy and distribute the resulting executable under terms of your choice,
|
||||||
|
provided that you also meet, for each linked independent module, the terms
|
||||||
|
and conditions of the license of that module. An independent module is a
|
||||||
|
module which is not derived from or based on this library. If you modify
|
||||||
|
this library, you may extend this exception to your version of the library,
|
||||||
|
but you are not obligated to do so. If you do not wish to do so, delete this
|
||||||
|
exception statement from your version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
}
|
||||||
|
|
||||||
|
program updatemakefiles;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, sysutils, LazFileUtils, Laz2_XMLCfg, FileProcs, DefineTemplates,
|
||||||
|
UTF8Process;
|
||||||
|
|
||||||
|
var
|
||||||
|
LazarusDir: String;
|
||||||
|
|
||||||
|
function FindLPK(Dir,MainSrc: string; out HasConditionals: boolean): string;
|
||||||
|
var
|
||||||
|
FileInfo: TSearchRec;
|
||||||
|
LPK: TXMLConfig;
|
||||||
|
i: Integer;
|
||||||
|
Path: String;
|
||||||
|
FileType: String;
|
||||||
|
CurFilename: String;
|
||||||
|
Fits: Boolean;
|
||||||
|
LPKFilename: TFilename;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
Dir:=AppendPathDelim(Dir);
|
||||||
|
Fits:=false;
|
||||||
|
HasConditionals:=false;
|
||||||
|
if FindFirstUTF8(Dir+'*.lpk',faAnyFile,FileInfo)=0 then begin
|
||||||
|
repeat
|
||||||
|
LPKFilename:=Dir+FileInfo.Name;
|
||||||
|
LPK:=TXMLConfig.Create(LPKFilename);
|
||||||
|
try
|
||||||
|
Fits:=false;
|
||||||
|
if sysutils.CompareText(ExtractFileNameOnly(FileInfo.Name),ExtractFileNameOnly(MainSrc))=0 then
|
||||||
|
Fits:=true;
|
||||||
|
//writeln('FindLPK ',LPKFilename);
|
||||||
|
for i:=1 to LPK.GetValue('Package/Files/Count',0) do begin
|
||||||
|
Path:='Package/Files/Item'+IntToStr(i)+'/';
|
||||||
|
FileType:=LPK.GetValue(Path+'Type/Value','');
|
||||||
|
if FileType='' then continue;
|
||||||
|
CurFilename:=LPK.GetValue(Path+'Filename/Value','');
|
||||||
|
//writeln('FindLPK ',CurFilename,' ',FileType);
|
||||||
|
if FileType='Main Unit' then begin
|
||||||
|
//writeln('FindLPK MainUnit=',CurFilename);
|
||||||
|
if CompareFilenames(CurFilename,MainSrc)=0 then begin
|
||||||
|
Fits:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if Fits then begin
|
||||||
|
Result:=LPKFilename;
|
||||||
|
HasConditionals:=LPK.GetValue('Package/CompilerOptions/Conditionals/Value','')<>'';
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
LPK.Free;
|
||||||
|
end;
|
||||||
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
|
end;
|
||||||
|
FindCloseUTF8(FileInfo);
|
||||||
|
if not Fits then
|
||||||
|
writeln('NOTE: no lpk found in ',CreateRelativePath(Dir,LazarusDir),' for ',MainSrc,'. Probably this requires a custom Makefile.');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure CheckMakefileCompiled(MakefileCompiledFilename: string; LPKFiles: TStrings);
|
||||||
|
var
|
||||||
|
MakefileCompiled: TXMLConfig;
|
||||||
|
MainSrcFilename: String;
|
||||||
|
p: Integer;
|
||||||
|
LPKFilename: String;
|
||||||
|
HasConditionals: boolean;
|
||||||
|
begin
|
||||||
|
//writeln('CheckMakefileCompiled ',MakefileCompiledFilename);
|
||||||
|
MakefileCompiled:=TXMLConfig.Create(MakefileCompiledFilename);
|
||||||
|
try
|
||||||
|
// extract main source file name from compiler options
|
||||||
|
MainSrcFilename:=MakefileCompiled.GetValue('Params/Value','');
|
||||||
|
p:=length(MainSrcFilename);
|
||||||
|
while (p>1) and (MainSrcFilename[p-1]<>' ') do dec(p);
|
||||||
|
MainSrcFilename:=copy(MainSrcFilename,p,length(MainSrcFilename));
|
||||||
|
LPKFilename:=FindLPK(ExtractFilePath(MakefileCompiledFilename),MainSrcFilename,HasConditionals);
|
||||||
|
//writeln(' MakefileCompiled=',CreateRelativePath(MakefileCompiledFilename,LazarusDir),' MainSrc=',MainSrcFilename,' lpk=',CreateRelativePath(LPKFilename,LazarusDir),' HasConditionals=',HasConditionals);
|
||||||
|
if (LPKFilename<>'') and (not HasConditionals) then
|
||||||
|
LPKFiles.Add(LPKFilename);
|
||||||
|
finally
|
||||||
|
MakefileCompiled.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure FindLPKFilesWithMakefiles(Dir: string; LPKFiles: TStrings);
|
||||||
|
var
|
||||||
|
FileInfo: TSearchRec;
|
||||||
|
begin
|
||||||
|
Dir:=AppendPathDelim(Dir);
|
||||||
|
if FindFirstUTF8(Dir+AllFilesMask,faAnyFile,FileInfo)=0 then begin
|
||||||
|
repeat
|
||||||
|
if (FileInfo.Name='') or (FileInfo.Name='.') or (FileInfo.Name='..') then
|
||||||
|
continue;
|
||||||
|
if (FileInfo.Attr and faDirectory)<>0 then
|
||||||
|
FindLPKFilesWithMakefiles(Dir+FileInfo.Name,LPKFiles)
|
||||||
|
else if FileInfo.Name='Makefile.compiled' then
|
||||||
|
CheckMakefileCompiled(Dir+FileInfo.Name,LPKFiles);
|
||||||
|
until FindNextUTF8(FileInfo)<>0;
|
||||||
|
end;
|
||||||
|
FindCloseUTF8(FileInfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
LPKFiles: TStringList;
|
||||||
|
LazbuildOut: TStringList;
|
||||||
|
begin
|
||||||
|
LazarusDir:=CleanAndExpandDirectory(GetCurrentDirUTF8);
|
||||||
|
if ExtractFileName(ChompPathDelim(LazarusDir))='tools' then
|
||||||
|
LazarusDir:=ExtractFilePath(ChompPathDelim(LazarusDir));
|
||||||
|
LPKFiles:=TStringList.Create;
|
||||||
|
FindLPKFilesWithMakefiles(LazarusDir,LPKFiles);
|
||||||
|
writeln(LPKFiles.Text);
|
||||||
|
LPKFiles.StrictDelimiter:=true;
|
||||||
|
LPKFiles.Delimiter:=' ';
|
||||||
|
LazbuildOut:=RunTool(SetDirSeparators('./lazbuild'+ExeExt),'--create-makefile '+LPKFiles.DelimitedText,LazarusDir);
|
||||||
|
writeln(LazbuildOut.Text);
|
||||||
|
LPKFiles.Free;
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user