Add analogue to _concat for writable directories #4380
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The regular
_concat
function, when processing a list of strings, adds a prefix+suffix to each, possibly after expanding the list through a call to a function. The function is oftenRDirs
, which can add additional paths (repositories, usually). This is used for things like path-to-include dir, so we get"-Iinclude"
without storing the compiler-specific syntax.When used for a directory which we tell the compiler to write to, as opposed to just search, this can give the wrong result. For example, for
$FORTRANMODIR
, which describes where to put generated module files, we only want to write to the target directory (and in fact, for gfortran, it's an error to specify the module-write-dir more than once), but we might want to still search the backing directories - any repository, and in case of non-duplicating variantdir, the directory of the original source - in case there were already module files there that can be used.This new function wraps the first string from the expanded list in the
prefix
/suffix
, and any remaining strings in theextra_prefix
andextra_suffix
arguments, for example to produce"-Jtargetmoddir -Isourcemoddir -Irepository"
instead of"-Jtargetmoddir -Jsourcemoddir -Jrepository"
. The latter would abort the Fortran compiler with an error, and the equivalent for the D compilers would ignore the first (correct) directory and select the last one for use. In any case, we're not allowed to write to the repository, so the previous behavior using_concat
was definitely wrong.Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)