CMake/Source/cmNinjaTypes.h

65 lines
1.2 KiB
C
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 19:01:08 +00:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2011-11-11 05:00:49 +00:00
#ifndef cmNinjaTypes_h
#define cmNinjaTypes_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
Ninja: Improve performance with deeply-dependent custom targets The commit v3.7.0-rc1~339^2 (Ninja: Fix inter-target order-only dependencies of custom command, 2016-07-20) might cause performance degradations for larger projects. Especially when using custom commands as an input for each compilation rule (e.g. generated headers). For reference in the following I am referring to Source/cmGlobalNinjaGenerator.cxx: -> cmGlobalNinjaGenerator::AppendTargetDependsClosure -> cmGlobalNinjaGenerator::ComputeTargetDependsClosure It turned out that the mentioned commit is doing (indirectly) some redundant work that might impact performance when generating large projects. Imagine the dependency tree of custom targets: A \ C - D - E / B For each target the transitive closure is calculated recursively, but as the TargetDependsClosures are only cached on the top most level, everything downstream has to be recalculated. I.e. A->C->D->E B->C->D->E This ultimately leads to a lot of redundant calls to AppendTargetOutputs. The recursive nature of the algorithm itself is not significant to the problem, but reducing the work to actually to be done work, eliminates the performance problem. This patch changes the way, intermediate results are cached. Rather than caching the closure of targets, we cache the closure of outputs. Such that in the example above at B->C the cache already would kick in. Caching the outputs has one disadvantage that the patch takes care of. In case of such a structure A E \ / \ C - D G / \ / B F the calling order for A would be A->C->D->E->G (at which time G is seen to the recursion) then the recursion returns until it reaches A->C->D->F (at which the seen G would prevent to recurse down to G) But this would poison the cache for F with a wrong value (without G). Hence we use a local result set to ensure the cache is still consistently populated. For a large C++ project with around 25k targets this reduced the CMake configure / generate time from ~40s to ~29s. Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-08-31 21:48:02 +00:00
#include <set>
#include <string>
2019-05-29 09:48:22 +00:00
#include <utility>
#include <vector>
2011-11-11 05:00:49 +00:00
enum cmNinjaTargetDepends
{
DependOnTargetArtifact,
DependOnTargetOrdering
};
2019-08-23 21:25:56 +00:00
using cmNinjaDeps = std::vector<std::string>;
using cmNinjaOuts = std::set<std::string>;
using cmNinjaVars = std::map<std::string, std::string>;
2011-11-11 05:00:49 +00:00
2019-05-29 09:48:22 +00:00
class cmNinjaRule
{
public:
cmNinjaRule(std::string name)
: Name(std::move(name))
{
}
std::string Name;
std::string Command;
std::string Description;
std::string Comment;
std::string DepFile;
std::string DepType;
std::string RspFile;
std::string RspContent;
std::string Restat;
bool Generator = false;
};
2019-05-30 09:08:56 +00:00
class cmNinjaBuild
{
public:
cmNinjaBuild() = default;
cmNinjaBuild(std::string rule)
: Rule(std::move(rule))
{
}
std::string Comment;
std::string Rule;
cmNinjaDeps Outputs;
cmNinjaDeps ImplicitOuts;
cmNinjaDeps ExplicitDeps;
cmNinjaDeps ImplicitDeps;
cmNinjaDeps OrderOnlyDeps;
cmNinjaVars Variables;
std::string RspFile;
};
2011-11-11 05:00:49 +00:00
#endif // ! cmNinjaTypes_h