[Lazarus] Projects in a directory hierarchy - what is allowed?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Projects in a directory hierarchy - what is allowed?

Free Pascal - Lazarus mailing list
I have encountered a strange problem that was discovered when I moved
sources between Windows 10 and Raspbian Buster.
It appears that my directory structure does not behave like when I
used Delphi...

I am using Lazarus 2.0.6 and FPC 3.0.2 in both Windows 10 and Raspbian
Buster (on an RPi4B with 4GB RAM).

I am working on a webapp (command line program supplying webpages on
demand from Apache) as part of a larger system of programs to control
hardware through the RPi4.

I have used a directory structure where the main control app resides
in a top directory with subdirectories for various utilities (like the
webapp for configuration purposes).

It was started on Raspbian, but I had problems with the Lazarus IDE
(it crashes regularly several times a day and then I lose all edits
since the last save). So I moved over to Windows and got the sources
via Subversion. On Windows Lazarus never crashes.

Then I could develop here and use the IDE to check that it builds. I
could not use the exe file with Apache because I don't have apache on
Windows, but I could work around it and check the output of the webapp
anyway using environment variables when I run the executable.

So far so good, but to do the tests properly through Apache I moved
back to RPi4 (via SVN) and it worked just fine there too. I could make
adjustments etc and test via apache that the webapp worked.

Then I did a new cycle back to Windows and now something has happened
that is a showstopper.

If I now open the project in Lazarus and command Compile, build or
Quick compile an error is triggered telling me that a file not used by
my project cannot find its Linux-only units in the uses clause....
Here the show stops!

It complains that it cannot find some unix-only units inside the
sourcefile PiGpio.pas, which is used by another project residing one
level up in the tree from the working dir of the current project.

I have had to add a path to the parent dir (../) in the project
options because I need a few common units which define some used
classes and these units reside one level up.
But these are only 3 units and definitely NOT the units that use
PiGpio.pas!!!
The unit where PiGpio is in the uses clause is a completely separate
source file for another project.

Questions:
1) Is it not allowed to use source files *above* the current project
dir?

2) If I add a path .. via project properties does this really mean
that Lazarus will try to compile ALL source files found there even if
only a couple are part of the current project?

3) What can I do to remedy this problem?


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Projects in a directory hierarchy - what is allowed?

Free Pascal - Lazarus mailing list
Two steps i would try:

A) File/Clean Directory

B) Run/Clean and rebuild

I have a german Lazarus IDE, so the commands perhaps called different!

.. never had these sort of issue, never uesed

Raspbian Buster

good luck

John


Am 02.02.20 um 23:50 schrieb Bo Berglund via lazarus:

> I have encountered a strange problem that was discovered when I moved
> sources between Windows 10 and Raspbian Buster.
> It appears that my directory structure does not behave like when I
> used Delphi...
>
> I am using Lazarus 2.0.6 and FPC 3.0.2 in both Windows 10 and Raspbian
> Buster (on an RPi4B with 4GB RAM).
>
> I am working on a webapp (command line program supplying webpages on
> demand from Apache) as part of a larger system of programs to control
> hardware through the RPi4.
>
> I have used a directory structure where the main control app resides
> in a top directory with subdirectories for various utilities (like the
> webapp for configuration purposes).
>
> It was started on Raspbian, but I had problems with the Lazarus IDE
> (it crashes regularly several times a day and then I lose all edits
> since the last save). So I moved over to Windows and got the sources
> via Subversion. On Windows Lazarus never crashes.
>
> Then I could develop here and use the IDE to check that it builds. I
> could not use the exe file with Apache because I don't have apache on
> Windows, but I could work around it and check the output of the webapp
> anyway using environment variables when I run the executable.
>
> So far so good, but to do the tests properly through Apache I moved
> back to RPi4 (via SVN) and it worked just fine there too. I could make
> adjustments etc and test via apache that the webapp worked.
>
> Then I did a new cycle back to Windows and now something has happened
> that is a showstopper.
>
> If I now open the project in Lazarus and command Compile, build or
> Quick compile an error is triggered telling me that a file not used by
> my project cannot find its Linux-only units in the uses clause....
> Here the show stops!
>
> It complains that it cannot find some unix-only units inside the
> sourcefile PiGpio.pas, which is used by another project residing one
> level up in the tree from the working dir of the current project.
>
> I have had to add a path to the parent dir (../) in the project
> options because I need a few common units which define some used
> classes and these units reside one level up.
> But these are only 3 units and definitely NOT the units that use
> PiGpio.pas!!!
> The unit where PiGpio is in the uses clause is a completely separate
> source file for another project.
>
> Questions:
> 1) Is it not allowed to use source files *above* the current project
> dir?
>
> 2) If I add a path .. via project properties does this really mean
> that Lazarus will try to compile ALL source files found there even if
> only a couple are part of the current project?
>
> 3) What can I do to remedy this problem?
>
>

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Projects in a directory hierarchy - what is allowed?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Sun, 02 Feb 2020 23:50:59 +0100
Bo Berglund via lazarus <[hidden email]> wrote:

>[...]
> It was started on Raspbian, but I had problems with the Lazarus IDE
> (it crashes regularly several times a day and then I lose all edits
> since the last save).

Can you create stacktraces of the crashes?

>[...]
> If I now open the project in Lazarus and command Compile, build or
> Quick compile an error is triggered telling me that a file not used by
> my project cannot find its Linux-only units in the uses clause....
> Here the show stops!

Does a clean build work? For example "Run / Clean up and build ..."?

 
> It complains that it cannot find some unix-only units inside the
> sourcefile PiGpio.pas, which is used by another project residing one
> level up in the tree from the working dir of the current project.

Compile with flag -vt to find out why the compiler uses PiGpio.pas.

Or in Lazarus use View  / Unit Dependencies.
Click left on PiGpio.pas and look on the right for "used by ...".

 
>[...]
> Questions:
> 1) Is it not allowed to use source files *above* the current project
> dir?

Of course it is allowed.

 
> 2) If I add a path .. via project properties does this really mean
> that Lazarus will try to compile ALL source files found there even if
> only a couple are part of the current project?

No. FPC will compile only sources used by your project - direct and
indirect. Maybe you have some indirect dependency or some old ppu file.

 
> 3) What can I do to remedy this problem?

1. compile clean and check if this makes a difference
2. Compile with -vt flag.
3. Check View / Unit dependencies
4. Since you are using Windows and Unix and have mixed case unit names,
you must make sure, that all uses sections use the correct case.
5. give us more information, e.g. directory listings

Mattias


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Projects in a directory hierarchy - what is allowed?

Free Pascal - Lazarus mailing list
On Mon, 3 Feb 2020 11:29:15 +0100, Mattias Gaertner via lazarus
<[hidden email]> wrote:

>On Sun, 02 Feb 2020 23:50:59 +0100
>Bo Berglund via lazarus <[hidden email]> wrote:
>
>>[...]
>> It was started on Raspbian, but I had problems with the Lazarus IDE
>> (it crashes regularly several times a day and then I lose all edits
>> since the last save).
>
>Can you create stacktraces of the crashes?

I think I need to run lazarus from the debugger in that case, right?
I tried this before (see my thread started Nov 1, 2019 about this:
"Lazarus 2.0.6 IDE suddenly disappeared losing a lot of edits...")

>
>>[...]
>> If I now open the project in Lazarus and command Compile, build or
>> Quick compile an error is triggered telling me that a file not used by
>> my project cannot find its Linux-only units in the uses clause....
>> Here the show stops!
>
>Does a clean build work? For example "Run / Clean up and build ..."?

When I start this I get to a dialog where the files that will be
deleted are listed and there is basically everything about lazarus.
Did not dare do that, is there some way to limit the number of files
to "clean"?

>
>
>> It complains that it cannot find some unix-only units inside the
>> sourcefile PiGpio.pas, which is used by another project residing one
>> level up in the tree from the working dir of the current project.
>
>Compile with flag -vt to find out why the compiler uses PiGpio.pas.

How do I set a "flag" like that? I am compiling through use of the
menu command Run/build or run/compile....

>
>Or in Lazarus use View  / Unit Dependencies.
>Click left on PiGpio.pas and look on the right for "used by ...".

You mean after the problem has appeared and PiGpio appears?
After my rename of PiGpio it no longer appears, instead a file uses
PiGpio and which does not belong to my project either...

>
>>[...]
>> Questions:
>> 1) Is it not allowed to use source files *above* the current project
>> dir?
>
>Of course it is allowed.

Can I add a file to uses without also making the directory it is in
available for general browsing by Lazarus or the compiler?
I don't want Lazarus to find a bunch of other files located next to
the two I need....
I tried using ../unitname in my uses clause but then Lazarus barfs at
that syntax instead.

>
>
>> 2) If I add a path .. via project properties does this really mean
>> that Lazarus will try to compile ALL source files found there even if
>> only a couple are part of the current project?
>
>No. FPC will compile only sources used by your project - direct and
>indirect. Maybe you have some indirect dependency or some old ppu file.

Well, I don't know about that, but how could that happen?
I moved the project files between the systems using subversion only.
>
>
>> 3) What can I do to remedy this problem?
>
>1. compile clean and check if this makes a difference
>2. Compile with -vt flag.
>3. Check View / Unit dependencies
>4. Since you are using Windows and Unix and have mixed case unit names,
>you must make sure, that all uses sections use the correct case.

I have noted that when I create a unit in linux and name it say
SomeUnit, it gets saved as someunit.pas but the name still remains
SomeUnit inside Lazarus. THis is very strange to me and I don't know
what to do about it...
Seems to work fine anyway inside raspbian linux based Lazarus.

>5. give us more information, e.g. directory listings

The whole file tree, you mean?
From the top of the master project?



--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Projects in a directory hierarchy - what is allowed?

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Mon, 3 Feb 2020 11:29:15 +0100, Mattias Gaertner via lazarus
<[hidden email]> wrote:

>Or in Lazarus use View  / Unit Dependencies.
>Click left on PiGpio.pas and look on the right for "used by ...".
>
>>[...]
>
>> 2) If I add a path .. via project properties does this really mean
>> that Lazarus will try to compile ALL source files found there even if
>> only a couple are part of the current project?
>
>No. FPC will compile only sources used by your project - direct and
>indirect. Maybe you have some indirect dependency or some old ppu file.
>
>
>> 3) What can I do to remedy this problem?
>
>3. Check View / Unit dependencies

Thanks Mattias!
I did not know about the View / Unit dependencies command and usage.
But now using that I could trace back through the units brought in via
the uses clause and find out why PiGpio was appearing.

It starts from an innocent looking class definition unit in the dir
above the current projects and wanders through 2 more levels before
getting to PiGpio.
Seems like I had not isolated class definitions enough so I edited the
files a bit concerning what should be used and where so I could clean
the class defines to only deal with the appropriate stuff.

After that was done my current project does build on Windows.

Of course I will now have to fix the other project as well, but that
is for a later day.

Thanks again!!!


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus