Hi all,
I'm trying to figure out how to set packages for
installation/compilation in Lazbuild.
Goal: add packages to user IDE from command line using lazbuild.
I've looked around the code and started a rough hack to try and install the rx component when rebuilding the IDE.
I added this in TLazBuildApplication.BuildLazarusIDE:
var
..
raotestpackage: TLazPackage;
PkgName: string;
APackage: TLazPackage;
ConflictDep: TPkgDependency;
...
// try loading install packages
PackageGraph.LoadAutoInstallPackages(BuildLazProfiles.StaticAutoInstallPackages);
// my modifications start
//rao: testing: add rx
// adapted from addtoinstall
PkgName:='rx';
raotestpackage:=TLazPackage.Create;
//todo: replace 'rx' with package name
if not raotestpackage.StringToID(PkgName) then
begin
debugln('Invalid ID: ', PkgName);
exit;
end;
APackage:=PackageGraph.FindPackageWithID(raotestpackage);
if APackagenil then begin
// check if package is loaded and has some attributes that prevents
// installation in the IDE
if APackage.PackageType in [lptRunTime,lptRunTimeOnly] then begin
writeln(lisNotADesigntimePackage,
Format(lisThePackageIsNotADesignTimePackageItCanNotBeInstall, [
APackage.IDAsString]));
exit;
end;
ConflictDep:=PackageGraph.FindRuntimePkgOnlyRecursively(
APackage.FirstRequiredDependency);
if ConflictDepnil then begin
writeln(lisNotADesigntimePackage,
Format(lisThePackageCanNotBeInstalledBecauseItRequiresWhichI, [
APackage.Name, ConflictDep.AsString]));
exit;
end;
end; //apackagenil
// Mark package for installation - is this the right way?
raotestpackage.AutoInstall:=pitStatic;
// Add our new package to the packages we've currently loaded
PackageGraph.AddPackage(raotestpackage);
// I thought this would save the list of user-defined packages, is
this correct?
PackageGraph.SaveAutoInstallConfig;
// Do I need something like this to save the list of packages?:
//PkgManager.InstallPackages(pkgidlist, [piiifQuiet]);
// save target directory //existing code resumes
TargetDir:=CurProf.TargetDirectory;
IDEMacros.SubstituteMacros(TargetDir);While the code runs, nothing happens... and I'm sure just copy/pasting code from other parts without understanding what's going on isn't the fastest/surest way of getting things working.
Questions:
1. Am I on the right track?
2. Is packagegraph a representation of all packages present in the IDE?
3. What do the package .AutoInstall types mean? None: not installed, dynamic: needed as a dependency for other packages, static: always installed in IDE (e.g. because it is selected by the user)? Am I right in manipulating this property?
Thanks,
Reinier
