Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fpm should search in directories above current directory for fpm.toml file #172

Closed
urbanjost opened this issue Sep 13, 2020 · 8 comments
Closed
Labels
enhancement New feature or request

Comments

@urbanjost
Copy link
Contributor

I find the fpm(1) command much nicer to use if it searches for the fpm.toml file instead of requiring it to be executed in the directorin containing the fpm.toml file. For example, if I am working on files in the src, app, and test directories and my current directory is one of those directories I have to cd(1) up one directory and run fpm(1) and then cd back into the working directory or stay in the directory with the fpm.toml file and use long path names. I have been trying that with a personal version and it makes it MUCH nicer to use on larger projects with many directories, especially since each executable source has to be kept in a seperate directory.

@LKedward
Copy link
Member

I like this idea! I have noticed the same thing while working with fpm, having to switch back and forth between two terminal panes when building. This is also exactly how git(1) works.

... especially since each executable source has to be kept in a seperate directory.

There is discussion in #164 (Automatically discover tests and executables) to remove this restriction and further simplify user-effort.

@awvwgk awvwgk added the enhancement New feature or request label Oct 31, 2020
@urbanjost
Copy link
Contributor Author

This is trivial if CHDIR(3f) is supported. Note that a quick survey of three compilers (GCC/gfortran, Intel, PGI) shows all support a CHDIR(3f) extension; and it is easily supported via ISO_C_BINDING interfaces on POSIX machines. It almost certainly will be part of stdlib at some point. Since it is such a common extension, would greatly simplify implementation of the feature, and currently Fortran fpm is assumed to be being built with gfortran perhaps some of the gfortran POSIX-like extensions (in this case CHDIR(3f)) can be used directly?

@arjenmarkus
Copy link
Member

arjenmarkus commented Nov 19, 2020 via email

@MarDiehl
Copy link

@urbanjost: I agree with @arjenmarkus, relying on certain extensions is not a good long-term strategy. When os/os_path works on Windows (Cygwin, MinGW, and MSYS) and on POSIX (currently tested on Mac OS and Linux), it should be straight forward to include other system routines from C. We (i.e. mainly @arjenmarkus) almost found a suitable setup that works on all OS flavors.

@urbanjost
Copy link
Contributor Author

I have a list of methods for handling platform-specific options. One of the easiest that does not require a preprocessor is to use a generic name like my_routine and then have a directory for each platform that has a source for my_routine. Instead of a preprocessor you just select the correct directory to build. If each solution contains very similar code or if there is a strong reason for keeping all the code in a single file a preprocessor can be more appropriate. I generally use POSIX platforms and have found the ISO_C_BINDING interface to work very well on Mac/CygWin/Unix/GNU-Linux; and in a few cases on windows I was able to make C routines that looked like the POSIX routines that called the MSWindows equivalents. I do not know of a public version of a POSIX look-alike for MSWindows like CygWin provides but that would be very useful if it exists.

Some Fortran extensions are so common they are as standard as the standard implementation is itself; CHDIR seems to fall in or close to that. It would seem like a low maintenance issue to make a wrapper library that had something like STDLIB_CHDIR in it that called the vendor routine if it existed. If it did not call a ISO_C_BINDING to the POSIX routine if the platform is POSIX, and then a custom solution. In general it would seem reasonable to use vendor extensions if they exist behind such a wrapper and leave the maintenance to the compiler supplier.

@arjenmarkus
Copy link
Member

arjenmarkus commented Nov 20, 2020 via email

@ivan-pi
Copy link
Member

ivan-pi commented May 26, 2021

Can we define some rules for how fpm is to stop the search?

When I run git status in a folder inside WSL which is not a repository I get the following fatal error:

$ git status
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

The environment variables which affect git can be found here.

@LKedward
Copy link
Member

LKedward commented Jun 7, 2021

Implemented in #483.

@LKedward LKedward closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants