Recent

Author Topic: LPI files  (Read 4121 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
LPI files
« on: August 30, 2020, 03:11:37 am »
Hi All,

What is the correct way to open a project? Via lpi or lpr files, or does it matter?

Is it possible to make Lazarus save all project setting in the lpi file? I think is saves only the values that are not set to the default values.

Thanks.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: LPI files
« Reply #1 on: August 30, 2020, 12:45:49 pm »
What is the correct way to open a project? Via lpi or lpr files, or does it matter?
.lpi, .lpr is basically just another .pas. It may not know where to find the units it depend on, this information is normally kept in the .lpi.
Is it possible to make Lazarus save all project setting in the lpi file? I think is saves only the values that are not set to the default values.
Guess you have to change the code that does the saving and submit a patch for it. But I'm not sure if it will be accepted. Some configs are better left default, so it uses whatever the IDE has by default instead of per project. It's kind of contradicting, indeed, because some projects are tailored to specific config. If you can't solve both, usually the incumbent wins, in the name of backward compatibility.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: LPI files
« Reply #2 on: August 30, 2020, 02:08:26 pm »
Hi there, thanks for the answer although I'm still not sure about the lpr / lpi problem.

For example I create a simple project, set Project Options -> Compiler Options -> Debugging -> Generate info for the debugger to of to off, save it and run it, close Lazarus.

If I check the lpi file I find

Quote
      <Debugging>
        <GenerateDebugInfo Value="False"/>
      </Debugging>

which confirms that debug info will NOT be generated. To confirm I reopen the project buy double clicking the lpi file and check in project options that debugger will NOT be generated. All OK. Close Lazarus. Open the project by double clicking the LPR icon. Again check project options to see that debugger info will NOT be created. All OK.

Enable debugger info, save the project and close lazarus.

Check the LPI file and

Quote
      <Debugging>
        <GenerateDebugInfo Value="False"/>
      </Debugging>

is missing - confirming that debug info WILL BE created.

Open the project with the LPR file. Check project options to confirm that debug info WILL BE created. All OK.

This to me means that if I open a project by dbl clicking the LPR file, Lazarus still reads the associated LPI file during the open process. Which to me means I can open a project with the LPR file.

Is this correct? Can you confirm?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 13427
Re: LPI files
« Reply #3 on: August 30, 2020, 03:14:09 pm »
This to me means that if I open a project by dbl clicking the LPR file, Lazarus still reads the associated LPI file during the open process. Which to me means I can open a project with the LPR file.

Is this correct? Can you confirm?
Although I always open the lpi files I am rather sure that both options are rather equivalent normally. I think the primary file is the lpi file because it lists all the files needed by the project. So, when I open the lpi file everything should work correctly. On the other hand, when I open the lpr file, the IDE tries to find the related lpi file and continues this way.

When, on the other hand, a project is damaged and lacks the lpi file, for example because it has been submitted incompletely to the forum here, I open the lpr file and I am prompted to create a default project. Since the created default lpi file does not know about the other files and packages needed by the project these files must be added manually.

BTW, I never open Lazarus project by double-clicking neither lpi nor lpr files because I have so many Lazarus versions on my PC that I cannot control which version is associated to the lpi/lpr extension. I always open projects from the menu (or the Recently-used list).

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: LPI files
« Reply #4 on: August 30, 2020, 03:23:09 pm »
Thanks WP, at least you confirmed  my thoughts.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: LPI files
« Reply #5 on: August 30, 2020, 09:14:16 pm »
Apparently not so difficult to confirm the behavior:
Code: Pascal  [Select][+][-]
  1. procedure OpenProject(aMenuItem: TIDEMenuItem);
  2.           ...
  3.           // check if unit is a program
  4.           SourceType:=CodeToolBoss.GetSourceType(PreReadBuf,false);
  5.           if (SysUtils.CompareText(SourceType,'PROGRAM')=0)
  6.           or (SysUtils.CompareText(SourceType,'LIBRARY')=0)
  7.           then begin
  8.             // source is a program
  9.             // either this is a lazarus project
  10.             // or it is not yet a lazarus project ;)
  11.             LPIFilename:=ChangeFileExt(AFilename,'.lpi');
  12.             if FileExistsCached(LPIFilename) then begin
  13.               if IDEQuestionDialog(lisProjectInfoFileDetected,
  14.                   Format(lisTheFileSeemsToBeTheProgramFileOfAnExistingLazarusP, [AFilename]),
  15.                   mtConfirmation, [mrOk,lisOpenProject2,
  16.                                    mrCancel]) <> mrOk
  17.               then
  18.                 exit;
  19.               AFilename:=LPIFilename;
  20.             end
  21.  

 

TinyPortal © 2005-2018