mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 18:01:29 +02:00
lazbuild: added parameter: --add-package-link
git-svn-id: trunk@50966 -
This commit is contained in:
parent
99eff01e21
commit
83664400c7
@ -315,7 +315,7 @@ var
|
|||||||
i : integer;
|
i : integer;
|
||||||
AValue : String;
|
AValue : String;
|
||||||
begin
|
begin
|
||||||
for i:= 1 to ParamsAndCfgCount do
|
for i:=1 to ParamsAndCfgCount do
|
||||||
begin
|
begin
|
||||||
//DebugLn(['ParseNoGuiCmdLineParams ',i,' "',ParamsAndCfgStr(i),'"']);
|
//DebugLn(['ParseNoGuiCmdLineParams ',i,' "',ParamsAndCfgStr(i),'"']);
|
||||||
if ParamIsOptionPlusValue(i, PrimaryConfPathOptLong, AValue) then
|
if ParamIsOptionPlusValue(i, PrimaryConfPathOptLong, AValue) then
|
||||||
|
@ -5730,6 +5730,8 @@ resourcestring
|
|||||||
dlgNoAvailableUnits = 'No available units to add.';
|
dlgNoAvailableUnits = 'No available units to add.';
|
||||||
lisInsteadOfCompilePackageCreateASimpleMakefile = 'Instead of compile '
|
lisInsteadOfCompilePackageCreateASimpleMakefile = 'Instead of compile '
|
||||||
+'package create a simple Makefile.';
|
+'package create a simple Makefile.';
|
||||||
|
lisOnlyRegisterTheLazarusPackageFilesLpkDoNotBuild = 'Only register the '
|
||||||
|
+'Lazarus package files (.lpk). Do not build.';
|
||||||
|
|
||||||
// Custom form editor
|
// Custom form editor
|
||||||
lisCFEAnExceptionOccuredDuringDeletionOf = 'An exception occured during '
|
lisCFEAnExceptionOccuredDuringDeletionOf = 'An exception occured during '
|
||||||
|
158
ide/lazbuild.lpr
158
ide/lazbuild.lpr
@ -46,29 +46,34 @@ uses
|
|||||||
BuildProfileManager, BuildManager, BaseBuildManager, ModeMatrixOpts;
|
BuildProfileManager, BuildManager, BaseBuildManager, ModeMatrixOpts;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TPkgAction = (
|
||||||
|
lpaBuild, // build package, default
|
||||||
|
lpaInstall, // install package
|
||||||
|
lpaAddPkgLinks // register, no build
|
||||||
|
);
|
||||||
|
|
||||||
{ TLazBuildApplication }
|
{ TLazBuildApplication }
|
||||||
|
|
||||||
TLazBuildApplication = class(TCustomApplication)
|
TLazBuildApplication = class(TCustomApplication)
|
||||||
private
|
private
|
||||||
FAddPackage: boolean;
|
|
||||||
FBuildAll: boolean;
|
FBuildAll: boolean;
|
||||||
FBuildIDE: boolean;
|
FBuildIDE: boolean;
|
||||||
FBuildIDEOptions: string;
|
FBuildIDEOptions: string;
|
||||||
FBuildModeOverride: String;
|
FBuildModeOverride: String;
|
||||||
FBuildRecursive: boolean;
|
FBuildRecursive: boolean;
|
||||||
fCompilerOverride: String;
|
|
||||||
fCompilerInCfg: string;
|
fCompilerInCfg: string;
|
||||||
FCreateMakefile: boolean;
|
fCompilerOverride: String;
|
||||||
fLazarusDirOverride : String;
|
|
||||||
fLazarusDirInCfg: string;
|
|
||||||
fCPUOverride: String;
|
fCPUOverride: String;
|
||||||
FMaxProcessCount: integer;
|
FCreateMakefile: boolean;
|
||||||
fOSOverride: String;
|
|
||||||
FPkgGraphVerbosity: TPkgVerbosityFlags;
|
|
||||||
FSkipDependencies: boolean;
|
|
||||||
fInitialized: boolean;
|
fInitialized: boolean;
|
||||||
fInitResult: boolean;
|
fInitResult: boolean;
|
||||||
|
fLazarusDirInCfg: string;
|
||||||
|
fLazarusDirOverride : String;
|
||||||
|
FMaxProcessCount: integer;
|
||||||
|
fOSOverride: String;
|
||||||
|
FPackageAction: TPkgAction;
|
||||||
|
FPkgGraphVerbosity: TPkgVerbosityFlags;
|
||||||
|
FSkipDependencies: boolean;
|
||||||
fWidgetsetOverride: String;
|
fWidgetsetOverride: String;
|
||||||
|
|
||||||
// codetools
|
// codetools
|
||||||
@ -123,6 +128,7 @@ type
|
|||||||
// Adding packages to list of to-be-installed packages in the IDE.
|
// Adding packages to list of to-be-installed packages in the IDE.
|
||||||
// The packages can then be installed by recompiling the IDE (because we're using static packages)
|
// The packages can then be installed by recompiling the IDE (because we're using static packages)
|
||||||
function AddPackagesToInstallList(const PackageNamesOrFiles: TStringList): boolean;
|
function AddPackagesToInstallList(const PackageNamesOrFiles: TStringList): boolean;
|
||||||
|
function AddCmdLinePackageLinks(const PackageNamesOrFiles: TStringList): boolean;
|
||||||
|
|
||||||
// IDE
|
// IDE
|
||||||
function BuildLazarusIDE: boolean;
|
function BuildLazarusIDE: boolean;
|
||||||
@ -149,7 +155,7 @@ type
|
|||||||
procedure WriteUsage;
|
procedure WriteUsage;
|
||||||
procedure Error(ErrorCode: Byte; const ErrorMsg: string);
|
procedure Error(ErrorCode: Byte; const ErrorMsg: string);
|
||||||
|
|
||||||
property AddPackage: boolean read FAddPackage write FAddPackage; // add package to installed pacakge in IDE (UserIDE)
|
property PackageAction: TPkgAction read FPackageAction write FPackageAction;
|
||||||
property BuildAll: boolean read FBuildAll write FBuildAll;// build all files of project/package
|
property BuildAll: boolean read FBuildAll write FBuildAll;// build all files of project/package
|
||||||
property BuildRecursive: boolean read FBuildRecursive // apply BuildAll flag to dependencies
|
property BuildRecursive: boolean read FBuildRecursive // apply BuildAll flag to dependencies
|
||||||
write FBuildRecursive;
|
write FBuildRecursive;
|
||||||
@ -365,6 +371,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
// Check for packages if the specified name is a valid identifier
|
// Check for packages if the specified name is a valid identifier
|
||||||
if IsValidIdent(OriginalFileName) then begin
|
if IsValidIdent(OriginalFileName) then begin
|
||||||
|
if PackageAction=lpaAddPkgLinks then begin
|
||||||
|
Error(ErrorFileNotFound,'lpk file expected, but '+OriginalFilename+' found');
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// Initialize package graph with base packages etc:
|
// Initialize package graph with base packages etc:
|
||||||
if not Init then exit;
|
if not Init then exit;
|
||||||
// Apparently not found, could be a known but not installed package
|
// Apparently not found, could be a known but not installed package
|
||||||
@ -376,12 +387,10 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
// We found a package link
|
// We found a package link
|
||||||
if AddPackage then begin
|
case PackageAction of
|
||||||
// this is handled in AddPackagesToInstallList
|
lpaBuild: Result:=BuildPackage(Package.LPKFilename);
|
||||||
Result:=true;
|
lpaInstall: Result:=true; // this is handled in AddPackagesToInstallList
|
||||||
end
|
end;
|
||||||
else
|
|
||||||
Result:=BuildPackage(Package.LPKFilename)
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
@ -392,14 +401,13 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
// File exists:
|
// File exists:
|
||||||
if CompareFileExt(Filename,'.lpk')=0 then
|
if CompareFileExt(Filename,'.lpk')=0 then begin
|
||||||
if AddPackage then begin
|
case PackageAction of
|
||||||
// this is handled in AddPackagesToInstallList
|
lpaBuild: Result:=BuildPackage(Filename);
|
||||||
Result:=true;
|
lpaInstall: Result:=true; // this is handled in AddPackagesToInstallList
|
||||||
end
|
lpaAddPkgLinks: Result:=true;
|
||||||
else
|
end;
|
||||||
Result:=BuildPackage(Filename)
|
end else if CompareFileExt(Filename,'.lpi')=0 then
|
||||||
else if CompareFileExt(Filename,'.lpi')=0 then
|
|
||||||
Result:=BuildProject(Filename)
|
Result:=BuildProject(Filename)
|
||||||
else if CompareFileExt(Filename,'.lpr')=0 then begin
|
else if CompareFileExt(Filename,'.lpr')=0 then begin
|
||||||
Filename:=ChangeFileExt(Filename,'.lpi');
|
Filename:=ChangeFileExt(Filename,'.lpi');
|
||||||
@ -1042,7 +1050,7 @@ begin
|
|||||||
PackageName:='';
|
PackageName:='';
|
||||||
PkgFilename:='';
|
PkgFilename:='';
|
||||||
if CompareFileExt(PackageNamesOrFiles[i],'.lpk')=0 then
|
if CompareFileExt(PackageNamesOrFiles[i],'.lpk')=0 then
|
||||||
PkgFilename:=PackageNamesOrFiles[i]
|
PkgFilename:=ExpandFileNameUTF8(PackageNamesOrFiles[i])
|
||||||
else if IsValidIdent(PackageNamesOrFiles[i]) then begin
|
else if IsValidIdent(PackageNamesOrFiles[i]) then begin
|
||||||
PackageLink:=PkgLinks.FindLinkWithPkgName(PackageNamesOrFiles[i]);
|
PackageLink:=PkgLinks.FindLinkWithPkgName(PackageNamesOrFiles[i]);
|
||||||
if PackageLink=nil then
|
if PackageLink=nil then
|
||||||
@ -1086,6 +1094,48 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazBuildApplication.AddCmdLinePackageLinks(
|
||||||
|
const PackageNamesOrFiles: TStringList): boolean;
|
||||||
|
var
|
||||||
|
ErrorMsg, PkgFilename: String;
|
||||||
|
i, ErrCode: Integer;
|
||||||
|
Package: TLazPackage;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if not Init then exit;
|
||||||
|
|
||||||
|
ErrorMsg:='';
|
||||||
|
ErrCode:=ErrorLoadPackageFailed;
|
||||||
|
for i:=0 to PackageNamesOrFiles.Count -1 do
|
||||||
|
begin
|
||||||
|
// Look for package name in all known packages
|
||||||
|
PkgFilename:=PackageNamesOrFiles[i];
|
||||||
|
if CompareFileExt(PkgFilename,'.lpk')<>0 then begin
|
||||||
|
ErrorMsg+=PkgFilename+' is not a package, so it is not registered.'+LineEnding;
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
PkgFilename:=ExpandFileNameUTF8(PkgFilename);
|
||||||
|
|
||||||
|
Package:=LoadPackage(PkgFilename);
|
||||||
|
if Package=nil then
|
||||||
|
begin
|
||||||
|
ErrorMsg+='Could not load '+PkgFilename+', so it is not registered.'+LineEnding;
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
|
if ConsoleVerbosity>=0 then
|
||||||
|
debugln(['Hint: (lazarus) registering package link "'+PkgFilename+'".']);
|
||||||
|
PkgLinks.AddUserLink(Package);
|
||||||
|
end;
|
||||||
|
if ErrorMsg<>'' then begin
|
||||||
|
ErrorMsg:=UTF8Trim(ErrorMsg);
|
||||||
|
Error(ErrCode,ErrorMsg);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PkgLinks.SaveUserLinks(true);
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
function TLazBuildApplication.Init: boolean;
|
function TLazBuildApplication.Init: boolean;
|
||||||
begin
|
begin
|
||||||
if fInitialized then exit(fInitResult);
|
if fInitialized then exit(fInitResult);
|
||||||
@ -1421,10 +1471,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Add user-requested packages to IDE install list:
|
// Add user-requested packages to IDE install list:
|
||||||
if AddPackage then begin
|
case PackageAction of
|
||||||
|
lpaInstall:
|
||||||
if not AddPackagesToInstallList(Files) then begin
|
if not AddPackagesToInstallList(Files) then begin
|
||||||
if ConsoleVerbosity>=-1 then
|
if ConsoleVerbosity>=-1 then
|
||||||
debugln('Error (lazarus) Adding package(s) failed: ',Files.Text);
|
debugln('Error: (lazarus) Installing package(s) failed: ',Files.Text);
|
||||||
|
ExitCode := ErrorBuildFailed;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
lpaAddPkgLinks:
|
||||||
|
if not AddCmdLinePackageLinks(Files) then begin
|
||||||
|
if ConsoleVerbosity>=-1 then
|
||||||
|
debugln('Error: (lazarus) Adding package(s) links failed: ',Files.Text);
|
||||||
ExitCode := ErrorBuildFailed;
|
ExitCode := ErrorBuildFailed;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -1446,6 +1504,7 @@ var
|
|||||||
LongOptions: TStringList;
|
LongOptions: TStringList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
p: String;
|
p: String;
|
||||||
|
FilesNeeded: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if (ToolParamCount<=0)
|
if (ToolParamCount<=0)
|
||||||
@ -1489,6 +1548,7 @@ begin
|
|||||||
LongOptions.Add('scp:');
|
LongOptions.Add('scp:');
|
||||||
LongOptions.Add('language:');
|
LongOptions.Add('language:');
|
||||||
LongOptions.Add('add-package');
|
LongOptions.Add('add-package');
|
||||||
|
LongOptions.Add('add-package-link');
|
||||||
LongOptions.Add('build-all');
|
LongOptions.Add('build-all');
|
||||||
LongOptions.Add('build-ide:');
|
LongOptions.Add('build-ide:');
|
||||||
LongOptions.Add('recursive');
|
LongOptions.Add('recursive');
|
||||||
@ -1511,32 +1571,54 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
FilesNeeded:=true;
|
||||||
|
|
||||||
if HasOption('verbose-pkgsearch') then
|
if HasOption('verbose-pkgsearch') then
|
||||||
Include(fPkgGraphVerbosity,pvPkgSearch);
|
Include(fPkgGraphVerbosity,pvPkgSearch);
|
||||||
|
|
||||||
|
// PackageAction: register lpk files
|
||||||
|
if HasOption('add-package-link') then begin
|
||||||
|
if ConsoleVerbosity>=0 then
|
||||||
|
writeln('Parameter: add-package-link');
|
||||||
|
if PackageAction<>lpaBuild then begin
|
||||||
|
writeln('Error: invalid combination of package actions');
|
||||||
|
WriteUsage;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FilesNeeded:=false;
|
||||||
|
PackageAction:=lpaAddPkgLinks;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// PackageAction: install lpk files
|
||||||
|
if HasOption('add-package') then begin
|
||||||
|
if ConsoleVerbosity>=0 then
|
||||||
|
writeln('Parameter: add-package');
|
||||||
|
if PackageAction<>lpaBuild then begin
|
||||||
|
writeln('Error: invalid combination of package actions');
|
||||||
|
WriteUsage;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
PackageAction:=lpaInstall;
|
||||||
|
FilesNeeded:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
// building IDE
|
// building IDE
|
||||||
if HasOption('build-ide') then begin
|
if HasOption('build-ide') then begin
|
||||||
BuildIDE:=true;
|
BuildIDE:=true;
|
||||||
BuildIDEOptions:=GetOptionValue('build-ide');
|
BuildIDEOptions:=GetOptionValue('build-ide');
|
||||||
|
FilesNeeded:=false;
|
||||||
if ConsoleVerbosity>=0 then
|
if ConsoleVerbosity>=0 then
|
||||||
writeln('Parameter: build-ide=',BuildIDEOptions);
|
writeln('Parameter: build-ide=',BuildIDEOptions);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// files
|
// files
|
||||||
Files.Assign(NonOptions);
|
Files.Assign(NonOptions);
|
||||||
if (Files.Count=0) and (not BuildIDE) then begin
|
if FilesNeeded and (Files.Count=0) then begin
|
||||||
writeln('Error: missing file');
|
writeln('Error: missing file');
|
||||||
WriteUsage;
|
WriteUsage;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Add package to list of to be installed packages
|
|
||||||
if HasOption('add-package') then begin
|
|
||||||
AddPackage:=true;
|
|
||||||
if ConsoleVerbosity>=0 then
|
|
||||||
writeln('Parameter: add-package');
|
|
||||||
end;
|
|
||||||
|
|
||||||
// primary config path
|
// primary config path
|
||||||
if HasOption('primary-config-path') then begin
|
if HasOption('primary-config-path') then begin
|
||||||
SetPrimaryConfigPath(GetOptionValue('primary-config-path'));
|
SetPrimaryConfigPath(GetOptionValue('primary-config-path'));
|
||||||
@ -1649,7 +1731,7 @@ begin
|
|||||||
CreateMakefile := true;
|
CreateMakefile := true;
|
||||||
if ConsoleVerbosity>=0 then
|
if ConsoleVerbosity>=0 then
|
||||||
writeln('Parameter: create-makefile');
|
writeln('Parameter: create-makefile');
|
||||||
if AddPackage then
|
if PackageAction<>lpaBuild then
|
||||||
Error(ErrorPackageNameInvalid,'You can not combine --create-makefile and --add-package');
|
Error(ErrorPackageNameInvalid,'You can not combine --create-makefile and --add-package');
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -1704,6 +1786,8 @@ begin
|
|||||||
|
|
||||||
writeln('--add-package');
|
writeln('--add-package');
|
||||||
w(space+lisAddPackageSToListOfInstalledPackagesCombineWithBui);
|
w(space+lisAddPackageSToListOfInstalledPackagesCombineWithBui);
|
||||||
|
writeln('--add-package-link=<.lpk file>');
|
||||||
|
w(space+lisOnlyRegisterTheLazarusPackageFilesLpkDoNotBuild);
|
||||||
writeln('--create-makefile');
|
writeln('--create-makefile');
|
||||||
w(space+lisInsteadOfCompilePackageCreateASimpleMakefile);
|
w(space+lisInsteadOfCompilePackageCreateASimpleMakefile);
|
||||||
writeln('');
|
writeln('');
|
||||||
@ -1754,7 +1838,7 @@ end;
|
|||||||
|
|
||||||
procedure TLazBuildApplication.Error(ErrorCode: Byte; const ErrorMsg: string);
|
procedure TLazBuildApplication.Error(ErrorCode: Byte; const ErrorMsg: string);
|
||||||
begin
|
begin
|
||||||
writeln('ERROR: ',LineBreaksToSystemLineBreaks(ErrorMsg));
|
writeln('Error: (lazbuild) ',LineBreaksToSystemLineBreaks(ErrorMsg));
|
||||||
Halt(ErrorCode);
|
Halt(ErrorCode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ type
|
|||||||
procedure IteratePackages(MustExist: boolean; Event: TIteratePackagesEvent;
|
procedure IteratePackages(MustExist: boolean; Event: TIteratePackagesEvent;
|
||||||
Origins: TPkgLinkOrigins = AllPkgLinkOrigins);
|
Origins: TPkgLinkOrigins = AllPkgLinkOrigins);
|
||||||
function AddUserLink(APackage: TLazPackage): TPackageLink;
|
function AddUserLink(APackage: TLazPackage): TPackageLink;
|
||||||
function AddUserLink(const PkgFilename, PkgName: string): TPackageLink;// do not this use if package is open in IDE
|
function AddUserLink(const PkgFilename, PkgName: string): TPackageLink;// do not use this if package is open in IDE
|
||||||
procedure RemoveUserLink(Link: TPackageLink);
|
procedure RemoveUserLink(Link: TPackageLink);
|
||||||
procedure RemoveUserLinks(APackageID: TLazPackageID);
|
procedure RemoveUserLinks(APackageID: TLazPackageID);
|
||||||
procedure IncreaseChangeStamp;
|
procedure IncreaseChangeStamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user