summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-12 10:05:50 -0400
committerBrad King <brad.king@kitware.com>2021-05-12 10:15:43 -0400
commit3a7153440282148233c7dff33538fd3b46a3175d (patch)
tree5f7b01ef5ec62f850f93091083469055385ba35e
parentb2f1345aaf5114b897d1cb15453a0dd12af269c9 (diff)
downloadcmake-3a7153440282148233c7dff33538fd3b46a3175d.tar.gz
Ninja: Restore support for Fortran in a symlinked build tree
Since commit f3eed2c49d (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
-rw-r--r--Source/cmScanDepFormat.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/cmScanDepFormat.cxx b/Source/cmScanDepFormat.cxx
index e0460694e0..f988fe45f9 100644
--- a/Source/cmScanDepFormat.cxx
+++ b/Source/cmScanDepFormat.cxx
@@ -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));