summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Reduce raw string pointers usage.Pavel Solodovnikov2018-01-311-2/+2
| | | | | | | | | | * Change some functions to take `std::string` instead of `const char*` in the following classes: `cmMakeFile`, `cmake`, `cmCoreTryCompile`, `cmSystemTools`, `cmState`, `cmLocalGenerator` and a few others. * Greatly reduce using of `const char*` overloads for `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`. * Remove many redundant `c_str()` conversions throughout the code.
* Reduce allocation of temporary values on heap.Pavel Solodovnikov2018-01-261-1/+1
| | | | | - Use `std::move` while inserting temporary results into vectors. - Change `push_back` to `emplace_back` where appropriate.
* cmGlobalNinjaGenerator: Avoid using deprecated std::ptr_funBrad King2017-12-211-2/+1
| | | | It was deprecated by C++11 and removed by C++17. Use a C++11 lambda.
* Retire std::auto_ptr and its macro CM_AUTO_PTRMatthias Maennich2017-09-251-5/+6
| | | | Signed-off-by: Matthias Maennich <matthias@maennich.net>
* Ninja: Cache ConvertToNinjaPath results to avoid repeat workMatthias Maennich2017-09-191-4/+10
| | | | | | | | | | | | Calls to this method may dominate generation time in some cases. Measurements for configuring cmake itself show a cache hit rate of ~57% (7753 total calls, 4453 cache hits). For a larger project (that also makes use of custom targets as prerequisite for all compile targets), the measured cache hit ratio is ~96% (2530827 total calls, 2433124 cache hits). For this project the observable cmake runtime could be reduced from 40s to 30s. Signed-off-by: Matthias Maennich <matthias@maennich.net>
* Ninja: Improve performance with deeply-dependent custom targetsMatthias Maennich2017-09-191-23/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Meta: modernize old-fashioned loops to range-based `for`.Pavel Solodovnikov2017-09-121-170/+113
| | | | | | Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
* clang-format: format all code as Cpp11Daniel Pfeifer2017-08-301-2/+2
|
* Replace C-style castsDaniel Pfeifer2017-08-271-1/+1
|
* Use C++11 nullptrDaniel Pfeifer2017-08-241-10/+10
|
* Pass large types by const&, small types by valueDaniel Pfeifer2017-06-031-1/+2
|
* Ninja: Fix CMP0058 on MinGWBrad King2017-05-311-2/+2
| | | | | | | | | | | | For CMP0058 we identify dependencies that have no rules to generate them by collecting a set of all dependencies and a set of all files CMake knows are generated by something, and then computing a set difference. Fix construction of these sets to use the same form for each path. This is after ConvertToNinjaPath but before EncodePath. Without this, the slash conversion done by EncodePath for the GNU compiler on Windows results in a mismatch, triggering an incorrect CMP0058 warning.
* Ninja: Fix escaping of path to depfileBrad King2017-05-301-7/+0
| | | | | Replace the dedicated and non-portable escaping code with use of our standard escaping logic.
* Remove unnecessary operator<< usagePavel Solodovnikov2017-05-261-1/+1
|
* Ninja: List compile_commands.json as generated by CMakeKevin Puetz2017-05-161-0/+4
| | | | | | | | This fixes a false-positive `CMP0058` warning if any custom rules depend on `compile_commands.json` (e.g. to trigger rerunning clang-tooling utilities). Fixes: #16444
* cmake: initialize with Role that controls which commands to registerDaniel Pfeifer2017-05-081-1/+1
|
* Merge topic 'ninja-dyndep-response-file'Brad King2017-04-251-1/+5
|\ | | | | | | | | | | | | 594d3d6f Ninja: support response file for cmake_ninja_depends on Windows Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !722
| * Ninja: support response file for cmake_ninja_depends on WindowsBernhard Burgermeister2017-04-251-1/+5
| | | | | | | | | | | | | | The internal tool "cmake_ninja_depends" now supports reading the list of ddi files from a reponse file to circumvent Windows command line length limits. Use this response file for dyndep rule on Windows.
* | ninja: break unnecessary target dependenciesBen Boeckel2017-04-211-5/+24
|/ | | | | | | | | | | | | | | | | | Previously, given two libraries, X and Y where X depends on Y, all object compilations of X would require the Y library to have been linked before being compiled. This is not necessary and can instead be loosened such that object compilations of X only depend on the order-only dependencies of Y to be completed. This is to ensure that generated sources, headers, custom commands, etc. are completed before X starts to compile its objects. This should help build performance in projects with many libraries which cause a deep library dependency chain. Previously, a library at the bottom would not start compilation until after all other libraries completed, but now only its link step needs to wait and its compilation jobs can be run in parallel with other tasks. Fixes: #15555
* Merge topic '16760-refactor-get-mac-content-directory'Brad King2017-04-211-2/+2
|\ | | | | | | | | | | | | cf320f7c Replace boolean `implib` parameters with enum Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !662
| * Replace boolean `implib` parameters with enumGregor Jasny2017-04-201-2/+2
| | | | | | | | | | Named enumeration values are much clearer at call sites and add more type safety.
* | Ninja,Makefile: Unify command line limit logicChristian Pfeiffer2017-04-191-1/+1
|/ | | | | | Move the logic to cmSystemTools to be shared among the generators. Revise the implementation and add comments justifying each possible source for a limit.
* Use quotes for non-system includesDaniel Pfeifer2017-04-111-4/+4
| | | | | | | | | | | | | Automate with: git grep -l '#include <cm_' -- Source \ | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g' git grep -l '#include <cmsys/' -- Source \ | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g' git grep -l '#include <cm[A-Z]' -- Source \ | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
* Merge topic 'include-what-you-use'Brad King2016-11-081-9/+15
|\ | | | | | | | | 2e620f0b Fix several include-what-you-use findings
| * Fix several include-what-you-use findingsDaniel Pfeifer2016-11-081-9/+15
| |
* | cmGlobalNinjaGenerator: Suppress clang-tidy warningDaniel Pfeifer2016-11-051-2/+2
|/
* Ninja: Fix POST_BUILD noop on WindowsBrad King2016-10-281-0/+5
| | | | | | Use `cd .` instead of `:` in a Windows shell. Closes: #16393
* Ninja: Use binary dir for `$subdir/all` targetsAlexis Murzeau2016-10-241-28/+16
| | | | | | | | | | The targets added by commit v3.6.0-rc1~240^2~2 (Ninja: Add `$subdir/all` targets, 2016-03-11) use as `$subdir` the relative path from the top of the source tree to the current source directory. This is not correct when using `add_subdirectory(test test_bin)`. Instead we need to use the relative path from the top of the binary tree to the current binary directory as was done for related targets by commit v3.7.0-rc1~268^2 (Ninja: Add `$subdir/{test,install,package}` targets, 2016-08-05).
* Merge topic 'ninja-encoding'Brad King2016-10-211-2/+16
|\ | | | | | | | | ced77d2b Ninja: Use ANSI encoding for Ninja build files on Windows
| * Ninja: Use ANSI encoding for Ninja build files on WindowsDāvis Mosāns2016-10-201-2/+16
| | | | | | | | | | Pass ANSI encoding to cmGeneratedFileStream for use with Ninja generator.
* | Ninja: Fail early on when ninja build tool does not runBrad King2016-10-201-2/+11
| | | | | | | | | | | | | | | | Diagnose failure to run `ninja --version` and abort early. Otherwise we end up aborting with a confusing message about ninja version "" being too old. Closes: #16378
* | cmGlobalGenerator: Allow FindMakeProgram to failBrad King2016-10-201-2/+5
|/ | | | | Revise its signature to return `bool` so that it can fail and abort configuration early.
* cmState: Port dependents to new cmStateTypes headerStephen Kelly2016-10-191-1/+1
|
* cmState: Port dependent code to new cmStateSnapshot nameStephen Kelly2016-10-191-4/+3
|
* cmState: Port dependent code to new cmStateDirectory nameStephen Kelly2016-10-191-1/+1
|
* cmState: Move TargetType enum to separate namespaceStephen Kelly2016-10-191-15/+17
|
* cmLinkLineComputer: Move ComputeLinkLibs from cmLocalGeneratorStephen Kelly2016-10-101-1/+2
| | | | | | | | | | | | | | | Add a cmOutputConverter to the cmLinkLineComputer and factory methods to facilitate shell escapes. Add state to the cmLinkLineComputer to record whether outputting for response files or for watcom, to satisfy the cmOutputConverter API. These are constant for the lifetime of the cmLinkLineComputer, even when its functionality is extended in the future. This also keeps the signatures of cmLinkLineComputer relatively simple. Pass the cmComputeLinkInformation as a method parameter so that cmLinkLineComputer is free from target-specific state. An instance should be usable for all targets in a directory.
* cmLinkLineComputer: Extract from cmLocalGeneratorStephen Kelly2016-10-101-0/+8
| | | | | | | | | | | CMake has several classes which have too many responsibilities. cmLocalGenerator is one of them. Start to extract the link line computation. Create generator-specific implementations of the interface to account for generator-specific behavior. Unfortunately MSVC60 has different behavior to everything else and CMake still generates makefiles for it. Isolate it with MSVC60-specific names.
* Ninja: ConstifyStephen Kelly2016-10-101-2/+4
|
* Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Ninja: Conditionally allow Fortran based on ninja 'dyndep' supportBrad King2016-09-221-4/+39
| | | | | Detect from the version of Ninja whether it supports the dynamically discovered dependencies (dyndep) feature needed to support Fortran.
* Ninja: Add internal tool to produce a ninja dyndep file for FortranBrad King2016-09-221-0/+220
| | | | | | | Create an internal `cmake -E cmake_ninja_dyndep` tool to read the "ddi" files generated by `cmake -E cmake_ninja_depends` from all sources in a target and generate a ninja dyndep file that tells Ninja about Fortran module dependencies within the target and on target dependencies.
* Ninja: Add internal tool to scan Fortran code for module dependenciesBrad King2016-09-221-0/+125
| | | | | | | | Create an internal `cmake -E cmake_ninja_depends` tool to scan an already-preprocessed Fortran translation unit for modules that it provides or requires. Save the information in a "ddi" file with a CMake-private format for intermediate dynamic dependency information. This file may the be loaded by another tool to be added later.
* Ninja: Add comment with Fortran dependency design documentationBrad King2016-09-221-0/+78
|
* Ninja: Add API to check for dyndep supportBrad King2016-09-221-0/+11
| | | | | | | Kitware maintains a branch of Ninja with support for dynamically discovered dependencies (dyndep) that has not yet been accepted upstream. Add an internal API to check whether the Ninja version in use for the build supports this feature.
* Ninja: Refactor ninja feature detectionBrad King2016-09-221-6/+15
| | | | | Check for features as soon as we know the ninja version. Save the results so we do not have to re-compare versions every time.
* Ninja: Refactor Fortran rejection logicBrad King2016-09-221-3/+13
| | | | | | | | | Delay rejection of Fortran until after we've determined the version of the `ninja` tool to be used. This will later allow us to enable Fortran support based on the version of ninja. While at it, make the rejection an immediate fatal error. Also provide a stack trace so readers know what code tried to enable Fortran.
* cmGlobalNinjaGenerator: Add API to check for implicit outputs supportBrad King2016-09-201-0/+7
| | | | | | Ninja 1.7 introduced support for implicit outputs on build statements. Add an internal API to check whether the Ninja version in use for the build supports this feature.
* cmGlobalNinjaGenerator: Teach WriteBuild about implicit outputsBrad King2016-09-201-7/+20
| | | | | | | | Ninja 1.7 introduced support for implicit outputs on build statements. Teach WriteBuild to generate the corresponding syntax. Leave it up to callers to decide whether implicit outputs are supported by the Ninja version in use. For now simply update all call sites to pass an empty list of implicit outputs.
* Convert: Avoid HOME_OUTPUT enum when converting to relative pathsStephen Kelly2016-09-191-2/+2
|