Excluding files, not a pattern but a specific filename

Hi,

Is it possible to have a list of files in fpm.toml to be excluded?

thanks a lot
Alireza

Hi Alireza,

Can you elaborate on the part why you want to ignore the files? Is it for compilation, or preprocessing?

Thanks
Arteev Raina

It is for compilation. It is a library inside my code that I do not want to touch it but it contains duplicated modules in different files. I know which file should be excluded to avoid duplication of the module.

Thanks for your reply.

There is another reason as well. I have files such as fftw3.f that are included in other files and I do not want them to be compiled separately. I know that one can change the extension, however, being able to have an exclude list would be useful e.g. for the reason given above.

The short answer is no. By default if a file ends in a standard suffix it is scanned and compiled.
You can turn off auto-scanning in the fpm.toml file and compile specific executable programs.
It is generally easier to move or rename the files. Moving include files to end in something like “.inc” is clearer and I generally do that anyway, but may mean USE statements in the include files are not scanned for, and could cause the compile to shake out a needed module from the compile the last time I tested.

There have been several related discussions

Just last night I was looking at that as I have a globbing routine and a procedure that does #if/#else/#endif processing without doing a full preprocessing of a file that might be useful in a new feature like that; and was looking at the syntax used by git(1) for the .gitignore to see if it was a reasonable model that was popular enough to warrant emulation, but had not actually started anything.

Another alternative is to use preprocessing to conditionally compile, but it has drawbacks regarding scanning as hit upon above.

Basically, you will currently be happiest with fpm if only the files you want compiled end in .f90/.F90. That is also the easiest for someone else to understand when looking at your package source IMHO.

This does seem to have been coming up as a common issue; but is more complicated due to auto scanning and shaking the code than it first appears as a general problem (and those are some of my favorite features of fpm).

So would a simple [ignore] feature in fpm.toml suffice? Would it need to support globbing? Should it follow the syntax used by git(1) where ** and * are used in different ways to allow ignoring directory names?

A clean ISDIR function is required, which either needs calling an external command, C, or a compiler extension (most Fortran compilers have an extension) as there is no standard portable way to do that, and the slash /backslash colon problems between Posix systems and everything else, and it would take some rework of anything I know of that currently exists to emulate the git() .gitignore suffix; so curious what others currently do in other package managers, and whether
the opposite approach more make(1)-like is preferable, where instead you explicitly name all the target files is desirable.

Thanks for your reply and referring to the related discussions.