[Lazarus] Installing packages using lazbuild - am I on the right path?

Reinier Olislagers reinierolislagers at gmail.com
Mon May 21 09:58:36 CEST 2012


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 APackage<>nil 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 ConflictDep<>nil then begin
  	  writeln(lisNotADesigntimePackage,  	
Format(lisThePackageCanNotBeInstalledBecauseItRequiresWhichI, [
  		  APackage.Name, ConflictDep.AsString]));
  	  exit;
  	end;
  end; //apackage<>nil
  // 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




More information about the Lazarus mailing list