summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
authorKai Wang <wangkai86@huawei.com>2020-12-18 06:47:37 (GMT)
committerBrad King <brad.king@kitware.com>2021-01-05 12:48:27 (GMT)
commitb696f7807303b421c3f59ff2bf8229c96f09f1fa (patch)
tree246f99b964b4cf5b43178adde879025dc01c4c37 /Source/cmDependsC.cxx
parentda2474626b8a02e957021b30453f5afc8d7246b9 (diff)
downloadCMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.zip
CMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.tar.gz
CMake-b696f7807303b421c3f59ff2bf8229c96f09f1fa.tar.bz2
cmDepends: merge dependers of depend makefile
Since one depender has multiple dependees, depend makefile generated same depender line by line, to reduce file size and refine make file parse speed, merge same dependers to one. And add a testcase for large depend.make which generated source file includes 20000 header files and run build and incremental build Signed-off-by: Wangkai <wangkai86@huawei.com> Signed-off-by: Zhaoyingdong <zhaoyingdong@huawei.com>
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx31
1 files changed, 22 insertions, 9 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index e6aef92..60e8cbf 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -7,6 +7,7 @@
#include "cmsys/FStream.hxx"
#include "cmFileTime.h"
+#include "cmGlobalUnixMakefileGenerator3.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmProperty.h"
@@ -215,16 +216,28 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// directory. We must do the same here.
std::string obj_m = this->LocalGenerator->ConvertToMakefilePath(obj_i);
internalDepends << obj_i << '\n';
-
- for (std::string const& dep : dependencies) {
- makeDepends << obj_m << ": "
- << this->LocalGenerator->ConvertToMakefilePath(
- this->LocalGenerator->MaybeConvertToRelativePath(binDir,
- dep))
- << '\n';
- internalDepends << ' ' << dep << '\n';
+ if (!dependencies.empty()) {
+ const auto& lineContinue = static_cast<cmGlobalUnixMakefileGenerator3*>(
+ this->LocalGenerator->GetGlobalGenerator())
+ ->LineContinueDirective;
+ bool supportLongLineDepend = static_cast<cmGlobalUnixMakefileGenerator3*>(
+ this->LocalGenerator->GetGlobalGenerator())
+ ->SupportsLongLineDependencies();
+ if (supportLongLineDepend) {
+ makeDepends << obj_m << ':';
+ }
+ for (std::string const& dep : dependencies) {
+ std::string dependee = this->LocalGenerator->ConvertToMakefilePath(
+ this->LocalGenerator->MaybeConvertToRelativePath(binDir, dep));
+ if (supportLongLineDepend) {
+ makeDepends << ' ' << lineContinue << ' ' << dependee;
+ } else {
+ makeDepends << obj_m << ": " << dependee << '\n';
+ }
+ internalDepends << ' ' << dep << '\n';
+ }
+ makeDepends << '\n';
}
- makeDepends << '\n';
return true;
}