Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-05

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

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

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

Reply by email

Mattias Gaertner
to Reinier Olislagers
Show quoted text 19 lines
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; ...

If the parameter is a file name, open the package. If the parameter is a name, check it with IsValidIdent.

Add the package name to the list:

BuildLazProfiles.StaticAutoInstallPackages.Add('rx');
// try loading install packages PackageGraph.LoadAutoInstallPackages(BuildLazProfiles.StaticAutoInstallPackages);

This searches the lpk files and loads them.
The rest should already work.

Show quoted text 7 lines
[...] 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?

It is easier than you think.

2. Is packagegraph a representation of all packages present in the IDE?

Yes. All loaded packages.
Additionally there are some lists of all lpk files the IDE has ever seen. So it can load more if needed.

3. What do the package .AutoInstall types mean?

How the package is installed in the IDE.
At the moment you can only link a package statically. I hope eventually fpc supports dynamic packages. So currently you can only use "none" and "static".

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?

Not needed here.

Mattias

Reply by email

Zaher Dirkey
to Reinier Olislagers: I'm trying to figure out how to set packages for installation/compilation in Lazbuild.…

On Mon, May 21, 2012 at 9:58 AM, Reinier Olislagers <

Show quoted text 84 lines
wrote: 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

Good feature,

I think it is related my my old ask,
http://comments.gmane.org/gmane.comp.ide.lazarus.general/53455

Best Regards
Zaher Dirkey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120523/fd057398/attachment-0001.html>

Reply by email

Reinier Olislagers
to Zaher Dirkey
Zaher Dirkey wrote 14 lines
On Mon, May 21, 2012 at 9:58 AM, Reinier Olislagers < <mailto:>> wrote: 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. Good feature, I think it is related my my old ask, http://comments.gmane.org/gmane.comp.ide.lazarus.general/53455

Yep, seems like a handy thing to have...

Am making progress thanks to Mattias and Ludo (off list).

Will get back when I have something useful...

Thanks,
Reinier

Reply by email

Reinier Olislagers
to Zaher Dirkey: On Mon, May 21, 2012 at 9:58 AM, Reinier Olislagers < I think it is related my my old ask,
Zaher Dirkey wrote 9 lines
On Mon, May 21, 2012 at 9:58 AM, Reinier Olislagers < <mailto:>> wrote: 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.

<snip>

Good feature, I think it is related my my old ask, http://comments.gmane.org/gmane.comp.ide.lazarus.general/53455

Patch in mantis 22128

Thanks,
Reinier

Reply by email