Skip to content
Snippets Groups Projects
Commit 3a715344 authored by Brad King's avatar Brad King
Browse files

Ninja: Restore support for Fortran in a symlinked build tree

Since commit f3eed2c4 (cmGlobalNinjaGenerator: use P1689 dependency
file format for Fortran, 2019-03-12, v3.20.0-rc1~454^2), Fortran stopped
working in a build tree whose path contains a symlink.  The reason is
that the P1689r3 format's `work-directory` field gets populated with the
realpath (via `getcwd`) of the build tree instead of the logical path to
the build tree used for generating relative paths in `build.ninja`.
This causes the `Fortran.dd` file to get absolute (real)paths to `.o`
files, and Ninja does not match them with the relative `.o` file paths
in `build.ninja`.

Fix this by dropping use of the `work-directory` field.  This restores
our prior approach of generating paths in the dyndep file using the same
forms of paths received from the buildsystem generator.  The P1689r3
paper's format may need to be revised to account for this.

Fixes: #21683
parent b2f1345a
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ static Json::Value EncodeFilename(std::string const& path)
return false; \
} \
\
if (!cmSystemTools::FileIsFullPath(res)) { \
if (!work_directory.empty() && !cmSystemTools::FileIsFullPath(res)) { \
res = cmStrCat(work_directory, '/', res); \
} \
} while (0)
......@@ -105,15 +105,16 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp, cmSourceInfo* info)
}
for (auto const& rule : rules) {
std::string work_directory;
Json::Value const& workdir = rule["work-directory"];
if (!workdir.isString()) {
if (workdir.isString()) {
PARSE_BLOB(workdir, work_directory);
} else if (!workdir.isNull()) {
cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
arg_pp,
": work-directory is not a string"));
return false;
}
std::string work_directory;
PARSE_BLOB(workdir, work_directory);
Json::Value const& depends = rule["depends"];
if (depends.isArray()) {
......@@ -203,8 +204,6 @@ bool cmScanDepFormat_P1689_Write(std::string const& path,
Json::Value& rules = ddi["rules"] = Json::arrayValue;
Json::Value rule(Json::objectValue);
rule["work-directory"] =
EncodeFilename(cmSystemTools::GetCurrentWorkingDirectory());
Json::Value& inputs = rule["inputs"] = Json::arrayValue;
inputs.append(EncodeFilename(input));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment