Sign in Join

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

Mailing lists / lazarus / 2015-05

FPC config file inheritance issue

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Péter Gábor

Hi!

Today I tried to compile (on linux) an old project written on windows. This project has some FPC settings stored in its local folder. The configuration file is named "fpc.cfg" (without dot on the beginning).

FPC reported an error: Can't find unit system
Any other projects can be compiled without error.

After some headache I found that the project's local "fpc.cfg" (without dot on the beginning) is parsed by FPC but the global ".fpc.cfg (with dot on the beginning) is ignored or just seems to be so.

So I renamed the project's local configuration file from "fpc.cfg" to ".fpc.cfg" and now everything goes right...

I think that the expected behaviour of configuration parser is to parse local and the global configuration files regardless of its naming convention.

P?ter G?bor

Reply by email

Mattias Gaertner
to Péter Gábor
Show quoted text 19 lines
Hi! Today I tried to compile (on linux) an old project written on windows. This project has some FPC settings stored in its local folder. The configuration file is named "fpc.cfg" (without dot on the beginning). FPC reported an error: Can't find unit system Any other projects can be compiled without error. After some headache I found that the project's local "fpc.cfg" (without dot on the beginning) is parsed by FPC but the global ".fpc.cfg (with dot on the beginning) is ignored or just seems to be so. So I renamed the project's local configuration file from "fpc.cfg" to ".fpc.cfg" and now everything goes right... I think that the expected behaviour of configuration parser is to parse local and the global configuration files regardless of its naming convention.

fpc only reads the first config file it finds. If you want to read more pass them via parameter "@filename".

Mattias

Reply by email

Péter Gábor
to Mattias Gaertner

2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta:

fpc only reads the first config file it finds.

I know this, but when the compilation aborted I was thinking that something was changed in the configuration parser.

Now the problem seems to be different for me:

If FPC finds project's local "fpc.cfg" (without dot) first and then stops searching for others, why does not find ".fpc.cfg" (with dot) in the same directory (or ignores it) and searches for others?

Again: I am on Linux and having global ".fpc.cfg" (with dot) in my home directory and another "fpc.cfg" stored locally in the project's directory.

P?ter G?bor

Reply by email

Mattias Gaertner
to Péter Gábor
Show quoted text 6 lines
2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta: > fpc only reads the first config file it finds. [...]why does not find ".fpc.cfg" (with dot) in the same directory (or ignores it) and searches for others?

You can see what it searches by compiling with -vt.

Again: I am on Linux and having global ".fpc.cfg" (with dot) in my home directory and another "fpc.cfg" stored locally in the project's directory.

Mattias

Reply by email

Péter Gábor
to Mattias Gaertner: On Mon, 18 May 2015 17:18:25 +0200 fpc only reads the first config file it finds. If you…

2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta:

fpc only reads the first config file it finds. If you want to read more pass them via parameter "@filename". Mattias

As I remember project's local "fpc.cfg" (no dot) with a limited set of options was working (in 2011) on Linux and windows:

# Set exe output path
-FE../
# Set unit output path
-FU../ppu/

P?ter G?bor

Reply by email

Péter Gábor
to Mattias Gaertner: On Mon, 18 May 2015 18:04:58 +0200 You can see what it searches by compiling with -vt.…

2015-05-18 18:30 keltez?ssel, Mattias Gaertner ?rta:

On Mon, 18 May 2015 18:04:58 +0200 You can see what it searches by compiling with -vt. Mattias
If project's local config file is named "fpc.cfg" then
  Reading options from file fpc.cfg
If project's local config file is named ".fpc.cfg" then
  Configfile search: /home/gabor/.fpc.cfg
  Reading options from file /home/gabor/.fpc.cfg

FPC was started from project's local directory.

P?ter G?bor

Reply by email

Sven Barth
to Péter Gábor: 2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta: I know this, but when the…
P?ter G?bor wrote 12 lines
2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta: > fpc only reads the first config file it finds. I know this, but when the compilation aborted I was thinking that something was changed in the configuration parser. Now the problem seems to be different for me: If FPC finds project's local "fpc.cfg" (without dot) first and then stops searching for others, why does not find ".fpc.cfg" (with dot) in the same directory (or ignores it) and searches for others?

FPC looks for a configuration file in this order and uses the first (this is the Unix case):
- fpc.cfg in current directory
- .fpc.cfg in $HOME
- fpc.cfg in $PPC_CONFIG_PATH (if it is empty then it is the compiler's location + '../etc/')
- fpc.cfg in /etc/

Regards,
Sven

Reply by email

Péter Gábor
to Sven Barth

2015-05-18 19:43 keltez?ssel, Sven Barth ?rta:

Show quoted text 25 lines
On 18.05.2015 18:04, P?ter G?bor wrote: > > > 2015-05-18 17:31 keltez?ssel, Mattias Gaertner ?rta: >> fpc only reads the first config file it finds. > I know this, but when the compilation aborted I was thinking that > something was changed in the configuration parser. > > Now the problem seems to be different for me: > > If FPC finds project's local "fpc.cfg" (without dot) first and then > stops searching for others, why does not find ".fpc.cfg" (with dot) in > the same directory (or ignores it) and searches for others? FPC looks for a configuration file in this order and uses the first (this is the Unix case): - fpc.cfg in current directory - .fpc.cfg in $HOME - fpc.cfg in $PPC_CONFIG_PATH (if it is empty then it is the compiler's location + '../etc/') - fpc.cfg in /etc/ Regards, Sven

This search order leads to compilation error (e.g. System unit not found) if the local fpc.cfg exists but does not contain all required options (i.e. paths to fpc units).

In old times (2011) I was able to successfully compile the project with the following minimalist local fpc.cfg, but now it fails:

# Set exe output path
-FE../
# Set unit output path
-FU../ppu/

P?ter G?bor

Reply by email

Sven Barth
to Péter Gábor
"P?ter G?bor" wrote 5 lines
This search order leads to compilation error (e.g. System unit not found) if the local fpc.cfg exists but does not contain all required options (i.e. paths to fpc units).

It works this way since 2006. If it worked for you earlier then that was merely by chance.
Solution: rename the fpc.cfg and pass it by using the @ parameter.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150519/7166eb2c/attachment.html>

Reply by email

Péter Gábor
to Sven Barth

2015-05-19 14:10 keltez?ssel, Sven Barth ?rta:

Show quoted text 6 lines
Am 19.05.2015 08:29 schrieb "P?ter G?bor" < > This search order leads to compilation error (e.g. System unit not > found) if the local fpc.cfg exists but does not contain all required > options (i.e. paths to fpc units). It works this way since 2006. If it worked for you earlier then that was merely by chance.

An old version of a project I compiled "merely by chance" is still available on sf.net (flashpascal), but it can not be compiled this way now.

In my opinion the following would be a correct solution and a better approach of configuration parsing:
At first compiler would read the global configuration file (with system dependant settings) and then project's local configuration file with project related settings. This two steps would be done automatically if the project's configuration file is fpc.cfg. Configuration files with other names still must be passed with @ as you say:

Solution: rename the fpc.cfg and pass it by using the @ parameter.

I did and will do it...
Thanks!

P?ter G?bor

Reply by email