146 Commits

Author SHA1 Message Date
Mark O'Neill
cfd808ff19 cmLocalNinjaGenerator: Prevent echoing of lines in ninja generated batch files 2018-12-06 16:53:07 +00:00
Mark O'Neill
2c3f2dfa5a cmLocalNinjaGenerator: Report line of failure in ninja generated batch file
Fixes: 18676
2018-12-06 16:53:06 +00:00
Mark O'Neill
2295040e85 cmLocalNinjaGenerator: Propagate failures from batch file back to ninja
Fixes: #18676
2018-12-06 16:01:24 +00:00
Regina Pfeifer
3e60580784 clang-tidy: Fix readability-static-accessed-through-instance
Enable the check in .clang-tidy and fix all warnings.
2018-11-22 00:11:37 +01:00
Mateusz Zych
3eebe28ef4 cmLocalNinjaGenerator: Simplify CreateRulePlaceholderExpander
Re-use the derived class implementation instead of duplicating it.
2018-10-26 11:31:37 -04:00
Brad King
3e125c0c01 Ninja,Makefile: Drop extra space after RULE_LAUNCH_CUSTOM value
The Ninja and Makefile generators were adding a space to the value both
before and after expanding rule variables.  Only the latter is needed.

While at it, revise some outdated comments since the rule variable
expansion is no longer responsible for inserting the launcher.

Suggested-by: Mate Pek <mate.pek@gmail.com>
Fixes: #18340
2018-09-11 14:18:10 -04:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Brad King
5650ba1d6a Ninja: Drop unnecessary ident encoding logic for paths
The only uses of `EncodeIdent` are surrounding `EncodePath`, but the
special ident encoding is not needed for path contexts in a ninja build
manifest.
2018-04-19 08:17:39 -04:00
Shane Parris
3f4b81f540 Add glob verify support to XCode, VS, Ninja, and Makefile generators 2018-04-01 23:16:12 -04:00
Roger Leigh
22e8b3af04 Ninja: Generate scripts for long custom command sequences
Ninja runs just one command line for every build statement, so the Ninja
generator needs to `&&`-chain multiple commands together into one long
string.  For long custom command sequences this can exceed the maximum
command-line length for the operating system.  In such cases, write the
commands out to a script instead, and then run the script from Ninja's
one command line.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #15612
2018-02-06 13:24:46 -05:00
Brad King
79f22e8408 Makefile,Ninja: De-duplicate ComputeObjectFilenames method
Move the method implementation up to `cmLocalCommonGenerator`
to avoid duplicating it in each generator.
2018-01-29 10:51:22 -05:00
Matt McCormick
07185055d5 Ninja: add CMAKE_JOB_POOLS variable as default for JOBS_POOLS
This enables configuration of build parallelism with the Ninja generator by
passing arguments on the command line to CMake. For example,

  cmake \
    '-DCMAKE_JOB_POOLS:STRING=compile=5;link=2' \
    -DCMAKE_JOB_POOL_COMPILE:STRING=compile \
    -DCMAKE_JOB_POOL_LINK:STRING=link \
      ~/src/MyProject
2017-11-29 15:13:36 -05:00
Matthias Maennich
f0489856e3 Retire std::auto_ptr and its macro CM_AUTO_PTR
Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-26 00:07:19 +02:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03:00
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Aaron Orenstein
af3fd6f22f Performance: Add an index to Change cmLocalGenerator::GeneratorTargets.
Add an index to Change cmLocalGenerator::GeneratorTargets for faster lookup by
name.

Also changed a bunch of uses of cmLocalGenerator::GetGeneratorTargets() to take
const references instead of copying the vector.

Represent generator targets as a map (name -> target) to make name lookups more
efficient instead of looping through the entire vector to find the desired one.
2017-08-16 15:35:38 -07:00
Pavel Solodovnikov
86dc86dd6c Add const-reference qualifications 2017-05-26 19:50:11 +03:00
Brad King
eeb47fbeb2 cmLocalCommonGenerator: Save CMAKE_BUILD_TYPE on construction
Copy the value to our `ConfigName` member on construction to ensure it
is available even to code paths that run before `Generate`.  We once
needed to delay this lookup until `Generate` because the local
generators were at one time created before `Configure`.  Now they are
created at generate time which is late enough to expect
`CMAKE_BUILD_TYPE` to be available.

Without this, `cmGlobalUnixMakefileGenerator3::WriteConvenienceRules`
causes use of `ConfigName` before it is populated which breaks use of
source files that depend on the `$<CONFIG>` generator expression.

Fixes: #16889
2017-05-15 11:51:57 -04:00
Brad King
8e2f3582eb Merge topic 'split-sysroot'
53e89b6a Add options for separate compile and link sysroots

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !819
2017-05-11 10:00:12 -04:00
Brad King
53e89b6ab0 Add options for separate compile and link sysroots
Add `CMAKE_SYSROOT_COMPILE` and `CMAKE_SYSROOT_LINK` variables to as
operation-specific alternatives to `CMAKE_SYSROOT`.  This will be useful
for Android NDKs that compile and link with different sysroot values
(e.g. `r14` with unified headers).

Co-Author: Florent Castelli <florent.castelli@gmail.com>
2017-05-09 14:21:54 -04:00
Bernhard Burgermeister
5e0e03d953 Ninja: Fix command concatenation on Windows
Put commands that contain `||` into brackets to avoid early abort of
execution by `cmd.exe` because `||` has higher precedence than `&&` in
`cmd.exe`.

Add test to check for command execution after `||` as part of a
parameter and as command separator.

Fixes: #16850
2017-05-09 11:34:42 -04:00
Brad King
305e628284 Merge topic 'loosen-object-deps'
d96e5d9a Tests: use BYPRODUCTS in the CustomCommandWorkingDirectory test
664591ce RunCMake.Ninja: add a test for assumed sources
adf60b28 ninja: break unnecessary target dependencies
01c5bb95 RunCMake.Ninja: support passing arguments when running ninja
7f947b60 ninja: remove duplicate order-only dependencies
e9827eba ninja: describe the intermediate order depends target better
b57b7d8e Ninja: Order Fortran dyndep file generation explicitly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !430
2017-04-24 09:31:49 -04:00
Ben Boeckel
adf60b2838 ninja: break unnecessary target dependencies
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
2017-04-21 08:57:40 -04:00
Robert Maynard
23691d789e CUDA: Allow sources to be compiled to .ptx files
When the target property `CUDA_PTX_COMPILATION` is enabled CUDA OBJECT
libraries will generate ptx files instead of object files.
2017-04-20 13:25:38 -04:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Brad King
353f6362ba Ninja: Fix POST_BUILD noop on Windows
Use `cd .` instead of `:` in a Windows shell.

Closes: #16393
2016-10-28 15:44:04 -04:00
Stephen Kelly
e6eecec761 cmListFileCache: Remove cmState header include
Include it in dependents which have previously relied on it
transitively.
2016-10-19 15:41:00 +02:00
Stephen Kelly
a91eaf3872 cmState: Port dependents to new cmStateTypes header 2016-10-19 15:40:59 +02:00
Stephen Kelly
a49751fb2e cmState: Move TargetType enum to separate namespace 2016-10-19 15:40:58 +02:00
Stephen Kelly
b59b6dd9d2 cmRulePlaceholderExpander: Port clients to direct-use
Add a factory function to cmLocalGenerator so that variableMappings can
be provided from it, and so that Ninja can always have a hard-coded
TargetImpLib.
2016-10-15 11:25:12 +02:00
Stephen Kelly
46ad0d2183 cmLocalGenerator: Use a converter in rule replacement API
The rule replacement API should not really be in cmLocalGenerator, but
it was historically, and this coupled many other things together here
too, such as output conversion.  Make the output converter a parameter
so that rule replacement can be removed from cmLocalGenerator.
2016-10-15 11:25:12 +02:00
Stephen Kelly
425cd1670f cmLocalGenerator: Remove the launcher from RuleVariables
This one is not like the others as it doesn't participate in
substitutions.  Keep ExpandRuleVariables doing only one thing and make
callers responsible for inserting a launcher prefix, simplifying the
code all-around.

Remove now-obsolete InsertRuleLauncher method.
2016-10-15 11:25:12 +02:00
Stephen Kelly
5b361fdda0 cmLinkLineComputer: Extract from cmLocalGenerator
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.
2016-10-10 20:38:53 +02:00
Stephen Kelly
cc5e6b82c2 Ninja: Extract identical code from condition 2016-10-08 11:36:02 +02:00
Stephen Kelly
d9fde87d1a Ninja: Replace array access with local variable 2016-10-07 21:37:38 +02:00
Stephen Kelly
d92c160db3 Ninja: Separate two coupled calls 2016-10-07 21:37:38 +02:00
Stephen Kelly
20e62f74c5 cmLocalGenerator: Simplify ConvertToLinkReference
Make conversion to output format the caller responsibility, so that the
method only 'converts to a link reference'.
2016-10-06 20:02:10 +02:00
Brad King
86578eccf2 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 15:14:44 -04:00
Stephen Kelly
ad79061720 Convert: Inline uses of START_OUTPUT 2016-09-19 21:36:14 +02:00
Stephen Kelly
e7c8956746 Convert: Inline uses of HOME_OUTPUT 2016-09-19 21:36:14 +02:00
Stephen Kelly
dc51091944 Common: Use a string instead of enum for WorkingDirectory 2016-09-19 21:36:14 +02:00
Stephen Kelly
34c6e995f9 Convert: Avoid HOME_OUTPUT enum when converting to relative paths 2016-09-19 21:36:13 +02:00
Daniel Pfeifer
efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -04:00
Brad King
e3a4c2e02c Merge topic 'cleanup-Convert'
4332131d Convert: Make variables a bit more clear
5aca066c Convert: Remove UNCHANGED enum value
146bf926 Convert: Remove 'FULL' conversion
58ba87f8 Convert: Replace Convert(FULL) with equivalent
e80314d7 Ninja: Replace ternary with if()
563ac22a Convert: Replace trivial conversion with new method
08be47cf Convert: Replace UNCHANGED conversions with new API call
564d3a1d Convert: Extract ConvertToRelativePath from Convert()
95a659f1 Convert: Replace FULL conversions with equivalent
a8c7ccb1 VS: Replace FULL/UNCHANGED conversion with equivalent
5ad25ef4 Convert: Remove NONE conversion
ac463841 Convert: Replace uses of Convert(NONE)
998d9ee9 VS: Replace variable with an if()
ee49f006 Makefiles: Replace ternaries with if()s
51f7dcb0 Makefiles: Inline MakeLauncher into only caller
ba4ba7c3 Makefiles: Simplify MakeLauncher return value
...
2016-08-30 09:29:53 -04:00
Kulla Christoph
048d1adb4e add_custom_command: Add DEPFILE option for Ninja
Provide a way for custom commands to inform the ninja build tool about
their implicit dependencies.  For now simply make use of the option an
error on other generators.

Closes: #15479
2016-08-30 09:05:18 -04:00
Stephen Kelly
58ba87f892 Convert: Replace Convert(FULL) with equivalent
This is more explicit than funnelling everything through the Convert
method.
2016-08-27 15:41:17 +02:00
Stephen Kelly
e80314d7a8 Ninja: Replace ternary with if()
On principle of segregating the interface.
2016-08-27 15:26:38 +02:00
Stephen Kelly
563ac22a16 Convert: Replace trivial conversion with new method 2016-08-27 15:26:37 +02:00
Stephen Kelly
ac46384171 Convert: Replace uses of Convert(NONE)
These are equivalent to ConvertToOutputFormat.
2016-08-27 15:26:36 +02:00
Stephen Kelly
ee49f006cf Makefiles: Replace ternaries with if()s 2016-08-27 15:21:24 +02:00