Commit Graph

65 Commits

Author SHA1 Message Date
Brad King 6e2a4087f2 Ninja: Centralize path conversion in global generator (#15757)
In the Ninja generator we run all build rules from the top of the build
tree rather than changing into each subdirectory.  Therefore we convert
all paths relative to the HOME_OUTPUT directory.  However, the Convert
method on cmLocalGenerator restricts relative path conversions to avoid
leaving the build tree with a "../" sequence.  Therefore conversions
performed for "subdirectories" that are outside the top of the build
tree always use full paths while conversions performed for
subdirectories that are inside the top of the build tree may use
relative paths to refer to the same files.

Since Ninja always runs rules from the top of the build tree we should
convert them using only the top-level cmLocalGenerator in order to
remain consistent.  Also extend the test suite with a case that fails
without this fix.
2015-09-25 14:36:30 -04:00
Stephen Kelly ff8ac8ee6a cmLocalGenerator: Create from already-constructed cmMakefile.
Don't manage the lifetime of the cmMakefile with cmLocalGenerator.
2015-08-28 18:44:39 +02:00
Stephen Kelly 9b6a743b80 cmLocalGenerator: Remove Parent pointer. 2015-08-28 18:44:38 +02:00
Brad King f33ccc270e Merge topic 'rm-Makefile-LocalGenerator'
1689c91d cmMakefile: Remove unused method.
dd11f72c cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget.
2015-08-11 08:47:05 -04:00
James Johnston c5ac2b9df3 Ninja: Centralized required Ninja version numbers and comparisons. 2015-08-09 13:31:24 -04:00
Stephen Kelly dd11f72ced cmGlobalGenerator: Base exclusion computation on cmGeneratorTarget. 2015-08-07 00:32:15 +02:00
Stephen Kelly d568eefe10 cmCustomCommandGenerator: Require cmLocalGenerator in API. 2015-07-27 20:09:38 +02:00
Brad King 9d41f6d87b cmLocalCommonGenerator: Adopt ConfigName member
De-duplicate the member from the local Makefile and Ninja generators.
2015-07-09 09:50:06 -04:00
Brad King 001f9b3617 Add common base classes to Makefile and Ninja generators
Provide a place to move functionality common to both.
2015-07-09 09:50:05 -04:00
Stephen Kelly 8bfaadfa39 cmMakefile: Move IsRoot API from cmLocalGenerator. 2015-06-21 21:14:05 +02:00
Stephen Kelly 363caa2fa5 cmLocalGenerator: De-virtualize Configure().
The generators that override it do so in order to populate
data members which can instead be populated in Generate().
2015-06-04 09:06:40 -04:00
Stephen Kelly 3b880a0741 cmLocalGenerator: Require a valid cmState::Snapshot in the ctor.
Refactor the local generator creation API to accept a
cmState::Snapshot.  Adjust MakeLocalGenerator to use the 'current'
snapshot in cases where there is no parent.  Create the snapshot
for subdirectories in cmMakefile::AddSubdirectory.

This means that snapshots are now created at the point of extending the tree,
as appropriate, and independently of the cmLocalGenerator and cmMakefile they
represent the state for.
2015-05-27 09:18:32 -04:00
Stephen Kelly 6b9e647239 cmMakefile: Port CurrentListFile clients to GetDefinition.
There is no need to store this as a member variable.
2015-05-19 22:36:48 +02:00
Stephen Kelly c5059c9000 cmLocalGenerator: Add abstraction to check if top-level.
Move from the cmLocalNinjaGenerator.  Fix the case of the name.
2015-05-14 20:44:55 +02:00
Stephen Kelly b17686d2bb cmGlobalGenerator: Move some flags from cmLocalGenerator.
These flags are global, and so they belong here instead of being
set on each local generator.
2015-05-14 20:36:28 +02:00
Stephen Kelly 34c9ee2ed7 cmLocalGenerator: Require a global generator in the constructor.
Port generator factory methods to pass it.
2015-05-14 20:36:27 +02:00
Stephen Kelly a48aebcb67 cmLocalGenerator: Require a parent in the constructor.
Pass the parent though cmGlobalGenerator::CreateLocalGenerator.

This will make it easy to initialize state scopes independent of
cmMakefile.
2015-04-28 07:50:52 +02:00
Stephen Kelly 32b8f03acc cmMakefile: Port users of GetStart* methods to new names. 2015-04-21 00:15:20 +02:00
Stephen Kelly 5d056c0dd8 Port Global property interaction to cmState. 2015-04-15 11:43:50 -04:00
Stephen Kelly 0076b5d834 cmake: Remove the happy global property scope pattern.
Global properties are already global in scope, so remove the
overload for specifying it and port users of the API.

The call from cmMakefile::GetProperty can be simplified because
the scope is only used during chaining, and there is no further
chaining after processing global properties.
2015-04-15 11:43:50 -04:00
Brad King a6b0908571 Ninja: Improve internal check for generating at the top-level (#15436)
Simply check for whether the local generator has a parent instead of
depending on a string comparison of directory names.
2015-03-09 13:36:46 -04:00
Stephen Kelly 931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Brad King e15a7075b5 Add an option for explicit BYPRODUCTS of custom commands (#14963)
A common idiom in CMake-based build systems is to have custom commands
that generate files not listed explicitly as outputs so that these
files do not have to be newer than the inputs.  The file modification
times of such "byproducts" are updated only when their content changes.
Then other build rules can depend on the byproducts explicitly so that
their dependents rebuild when the content of the original byproducts
really does change.

This "undeclared byproduct" approach is necessary for Makefile, VS, and
Xcode build tools because if a byproduct were listed as an output of a
rule then the rule would always rerun when the input is newer than the
byproduct but the byproduct may never be updated.

Ninja solves this problem by offering a 'restat' feature to check
whether an output was really modified after running a rule and tracking
the fact that it is up to date separately from its timestamp.  However,
Ninja also stats all dependencies up front and will only restat files
that are listed as outputs of rules with the 'restat' option enabled.
Therefore an undeclared byproduct that does not exist at the start of
the build will be considered missing and the build will fail even if
other dependencies would cause the byproduct to be available before its
dependents build.

CMake works around this limitation by adding 'phony' build rules for
custom command dependencies in the build tree that do not have any
explicit specification of what produces them.  This is not optimal
because it prevents Ninja from reporting an error when an input to a
rule really is missing.  A better approach is to allow projects to
explicitly specify the byproducts of their custom commands so that no
phony rules are needed for them.  In order to work with the non-Ninja
generators, the byproducts must be known separately from the outputs.

Add a new "BYPRODUCTS" option to the add_custom_command and
add_custom_target commands to specify byproducts explicitly.  Teach the
Ninja generator to specify byproducts as outputs of the custom commands.
In the case of POST_BUILD, PRE_LINK, and PRE_BUILD events on targets
that link, the byproducts must be specified as outputs of the link rule
that runs the commands.  Activate 'restat' for such rules so that Ninja
knows it needs to check the byproducts, but not for link rules that have
no byproducts.
2014-11-14 16:16:00 -05:00
Peter Collingbourne f42d86f0b8 Ninja: Implement USES_TERMINAL using the console pool if available 2014-11-14 11:56:33 -05:00
Nils Gladitz cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02:00
Brad King f4c5eade78 Ninja: Fix RC include directories regression
Changes in commit b9aa5041 (cmLocalGenerator: Simplify GetIncludeFlags
output formatting, 2014-03-04) caused Windows Resource Compiler include
directories to be computed as relative paths in the Ninja generator.
This breaks the cmcldeps handling of include paths.  The reason for the
regression is that several cmLocalGenerator::GetIncludeFlags callers
treated the fourth "bool forResponseFile" argument as if it controlled
whether include directories were a full path.  It actually did control
that by accident until the above commit.

Add an explicit "bool forceFullPaths" argument to GetIncludeFlags
and thread the value through ConvertToIncludeReference as needed.
Update GetIncludeFlags call sites that really wanted to control the
forResponseFile setting to be aware of the new argument.  Extend the
VSResource test to cover this case.
2014-10-13 08:20:05 -04:00
Sylvain Joubert 9f32a2411b Ninja: Use 'console' pool for CMake re-run if possible (#14915)
The pre-defined 'console' pool is a non-buffered pool that runs with a
depth of 1.  CMake re-run cannot be run concurrently and it will
eventually output something.  A non-buffered pool allows to get it as
soon as possible

Also, generate the minimal required version of Ninja in the build file.
2014-10-03 08:48:47 -04:00
Ben Boeckel 3c64089117 ninja: Use string parameters 2014-05-02 13:05:44 -04:00
Stephen Kelly f6da044080 cmLocalGenerator: Add ComputeObjectFilenames interface.
Implement it in the local generators and use it in the global
generators.
2014-03-13 15:28:02 +01:00
Brad King bc993f277e Generalize cmCustomCommandGenerator to more fields
Until now the cmCustomCommandGenerator was used only to compute the
command lines of a custom command.  Generalize it to get the comment,
working directory, dependencies, and outputs of custom commands.  Update
use in all generators to support this.
2014-03-12 10:44:01 -04:00
Brad King d45e7f3461 cmCustomCommand: Return std::string from GetWorkingDirectory 2014-03-12 10:44:00 -04:00
Stephen Kelly 21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Brad King 971653b767 cmLocalGenerator: Add format option to ConvertToLinkReference
Replace the hard-coded SHELL output format with an optional argument.
2014-03-04 13:12:47 -05:00
Brad King 0c0ef9e7b7 cmLocalGenerator: Add format option to ConvertToIncludeReference
Replace the hard-coded SHELL output format with an optional argument.
2014-03-04 13:04:02 -05:00
Brad King b80ef72b4d Merge topic 'ninja-compile-link-pool'
7605e37 Ninja: job pool support for compiling and linking
2013-11-26 09:52:35 -05:00
Brad King 779fd10160 Merge topic 'INTERFACE_LIBRARY-property-whitelist'
5ee9e6b cmTarget: Add whitelist of properties on INTERFACE_LIBRARY.
0bfcb45 INTERFACE_LIBRARY: Avoid codepaths which set unneeded properties.
2013-11-26 09:36:58 -05:00
Brad King 48e476c3f4 Merge topic 'ninja-quoted-cmd-commands'
b6f1142 Ninja: multiple commands must be quoted
2013-11-26 09:36:04 -05:00
Peter Kümmel 7605e37aab Ninja: job pool support for compiling and linking
Could be tested by setting the environment
variable NINJA_STATUS=[%r]
2013-11-25 22:23:24 +01:00
Stephen Kelly 0bfcb450e6 INTERFACE_LIBRARY: Avoid codepaths which set unneeded properties.
As an INTERFACE_LIBRARY has no direct link dependencies, we can
short-circuit in cmGeneratorExpressionEvaluator and
in cmGlobalGenerator::CheckLocalGenerators.

As they do not generate any output directly, any generate- or install-
related code acn also be short-circuited. Many of the local generators
already do this.

Because only INTERFACE related properties make sense on INTERFACE_LIBRARY
targets, avoid setting other properties, for example via defaults.
2013-11-25 16:17:50 +01:00
Peter Kümmel b6f1142c8b Ninja: multiple commands must be quoted
Bug 14370
2013-11-25 12:08:10 +01:00
Stephen Kelly c34968a9aa Port some of the generator API to cmGeneratorTarget.
Just enough to reach the BuildMacContentDirectory method and the
NeedRelinkBeforeInstall methods.

In the future, those methods can be moved to cmGeneratorTarget.
2013-11-22 15:06:25 +01:00
Nils Gladitz 05c70424f6 Ninja: run custom commands through launcher if available 2013-10-31 09:28:55 -04:00
Peter Kümmel eeb4aece1c Ninja: use deps = gcc/msvc feature
cmcldeps is now only used for .rc file processing
2013-10-24 19:48:18 +02:00
Stephen Kelly 7cca50cb2f Remove unused include. 2013-09-11 10:07:22 +02:00
Brad King 4bb6e24809 VS,Xcode: Drop incorrect legacy dependency trace (#14291)
Drop the "vsProjectFile" argument from cmTarget::TraceDependencies.  It
appears to be the modern equivalent to a hunk added in commit ba68f771
(...added new custom command support, 2003-06-03):

 +  name = libName;
 +  name += ".dsp.cmake";
 +  srcFilesToProcess.push(name);

but was broken by refactoring at some point.  The current behavior tries
to trace dependencies on a source file named the same as a target, which
makes no sense.  Furthermore, in code of the form

 add_executable(foo foo.c)
 add_custom_command(OUTPUT "${somewhere}/foo" ... DEPENDS foo)

the "vsProjectFile" value "foo" matches source "${somewhere}/foo.rule"
generated to hold the custom command and causes the command to be added
to the "foo" target incorrectly.

Simply drop the incorrect source file trace and supporting logic.
2013-07-15 13:17:29 -04:00
Robert Maynard 874e17120d Ninja: GlobalNinjaGenerator WriteBuild and WritePhonyBuild non static
To properly track the usage of dependencies that are generated at
compile time as the side effect of other build steps we need
to make the WriteBuild and WritePhonyBuild commands non static
2013-07-01 08:59:38 -04:00
Ian Monroe e7c58f6c35 Ninja: use cd /D to set directory on Windows
Add_custom_command was unable to handle build and source directories
existing on different drives.
2013-04-18 14:16:46 -04:00
Peter Kümmel 7751966297 Ninja: remove 'friend' in ninja code 2012-07-18 11:27:49 +02:00
Peter Kuemmel 0c42faf63a Ninja: also consider variables when checking command line length 2012-07-02 00:01:41 +02:00
David Cole 565744bd3d Merge topic 'ninja-cldeps'
eb410e8 Ninja: disable cldeps for bcc32, it's too old, and ninja would also not build
5ead31d Ninja: try work around for bcc32 bug
1333b57 Ninja: build server fixes
9081e3a remove warning about unused parameter
f430bea Ninja: maybe this fixes the bcc32 build
f2c1288 Ninja: msvc6 for-scoping
44b9bbc Ninja: build with old msvc versions
57156a5 Ninja: build server fixes
f1abdce Ninja: some bytes of the rc files couldn't be piped correctly
2de963d Ninja: don't remove space between command and parameters
50b6f33 Ninja: build cmcldeps with mingw
c05653e Ninja: try to make GetProcessId visible
ab245ff Ninja: but cl supports /nologo ...
bf58e9a Ninja: no /nologo option in old rc.exe
2fb07fc Ninja: Eclipse and KDevelop fixes for ninja
518c065 Ninja: don't pollute build dir with preprocessed rc files
...
2012-06-19 14:42:41 -04:00