-
Notifications
You must be signed in to change notification settings - Fork 99
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
Library configuration: allow multiple source directories #847
Conversation
Support for multiple source file paths seems to be a new feature, and it seems good to create an example for it in |
Great suggestion @zoziha, thank you. So:
OK for trunk? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading the submission code, I found that this PR did three main things:
- Multiple source file paths are supported.
- Add multi-source file paths support and a sample package.
- The path logic of example, app, and test is changed.
The first two are clear and understandable, but the third seems to break the old fpm source file scoping specification (my fault, I'll update this specification in fpm-doc, see fortran-lang/fpm-docs#95).
@@ -473,14 +473,22 @@ end subroutine add_dependency | |||
!> a source file in the package of the correct scope, then a __fatal error__ | |||
!> is returned by the procedure and model construction fails. | |||
!> | |||
subroutine resolve_module_dependencies(targets,external_modules,error) | |||
subroutine resolve_module_dependencies(targets,external_modules,source_dirs,error) | |||
type(build_target_ptr), intent(inout), target :: targets(:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic of adding source_dirs
argument breaks the fpm source file scoping specification. For details, see:
There may be some discussion or improvement needed to the source file scope of app
, example
, and test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoziha Thank you for the thorough review - this was not entirely clear to me when I read the code, thank you for documenting it. I will work on some modifications, because like you're pointing out, right now a unique directory search list is built for all targets
As pointed out in #821 (comment), #821 (comment) and by yourself #821 (comment), I'm rather skeptical of the changes made in this PR. What is the benefit of having multiple
Or this:
Then having to read the manifest to know which modules are app, source, executable and test modules? Here are some suggested project structures in other languages/frameworks:
I think it is quite apparent that people have been moving away from "collect your source code that's all over the place using complicated build tools" to streamlined processes, while those are visually highlighted by having a clear project structure with dedicated folders for each process. Having to have a single |
I think I agree with @minhqdao's comment, I also think we should keep the structure simple. We can always relax it later, but we can't restrict it later without breaking backwards compatibility. There is great advantage of having restrictive layout, because it makes projects look uniform and easy to understand, and it's easy for us to maintain and test fpm. Regarding existing projects with a complicated build systems, I think to support those all we need is to provide an escape hatch, such as allowing to call a build script (which can then call cmake or make or build things by hand), so that the user can build any project. I believe that's how Cargo does it. |
@certik @minhqdao Thanks for your comments. Let me summarize fpm's current state of the art:
The CLI help: Lines 270 to 281 in b364bd8
has been saying that multiple source folders should be possible for about 3 years (they're currently not), that's what originated this issue I guess, and why it seemed reasonable to me, and in line with the current fpm scope, to go ahead with coding what was part of the original design. I agree it's a design decision: does the fpm community want it to be a full build system that can handle complex folder structures, or a simpler handler of smaller packages? |
This PR fixes #821 .
Library configurations already allow multiple
include-dir
directories, but only allowed 1source-dir
.This patch extends fpm to specify multiple source dirs for library configurations:
I think it would make sense to also extend this to executable configurations? @fortran-lang/admins
Or, it's better if we restrict all sources to be inside a single root directory, whichever named?