Commit Graph

104 Commits

Author SHA1 Message Date
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
Brad King 1296a0eada Ninja: Fix inter-target order-only dependencies of custom commands
Custom command dependencies are followed for each target's source files
and add their transitive closure to the corresponding target.  This
means that when a custom command in one target has a dependency on a
custom command in another target, both will appear in the dependent
target's sources.  For the Makefile, VS IDE, and Xcode generators this
is not a problem because each target gets its own independent build
system that is evaluated in target dependency order.  By the time the
dependent target is built the custom command that belongs to one of its
dependencies will already have been brought up to date.

For the Ninja generator we need to generate a monolithic build system
covering all targets so we can have only one copy of a custom command.
This means that we need to reconcile the target-level ordering
dependencies from its appearance in multiple targets to include only the
least-dependent common set.  This is done by computing the set
intersection of the dependencies of all the targets containing a custom
command.  However, we previously included only the direct dependencies
so any target-level dependency not directly added to all targets into
which a custom command propagates was discarded.

Fix this by computing the transitive closure of dependencies for each
target and then intersecting those sets.  That will get the common set
of dependencies.  Also add a test to cover a case in which the
incorrectly dropped target ordering dependencies would fail.
2016-07-20 13:12:24 -04:00
Brad King 0392f72bef Refactor Makefile/Ninja tool working directory storage
Move cmCommonTargetGenerator::WorkingDirectory to cmLocalCommonGenerator
and add an access method.
2016-06-17 14:22:28 -04:00
Daniel Pfeifer a16bf141bc Add missing braces around statements.
Apply fixits of clang-tidy's readability-braces-around-statements
checker.
2016-06-10 18:36:24 +02:00
Brad King 6052e4b3bf Merge topic 'improve-character-find-and-replace'
5784747d Improve string find: prefer character overloads.
5cec953e Use std::replace for replacing chars in strings.
2a1a2033 cmExtraEclipseCDT4Generator: use std::replace.
34bc6e1f cmCTestScriptHandler: don't call find repeatedly.
2016-05-25 09:34:29 -04:00
Daniel Pfeifer 25d1ef6424 Use enums defined in cmOutputConverter using their fully qualified name.
Mostly automated:

values=("RelativeRoot" "NONE" "FULL" "HOME" "START" "HOME_OUTPUT" "START_OUTPUT"
        "OutputFormat" "UNCHANGED" "MAKERULE" "SHELL" "WATCOMQUOTE" "RESPONSE"
        "FortranFormat" "FortranFormatNone" "FortranFormatFixed" "FortranFormatFree")
for i in "${values[@]}"; do git grep -l cmLocalGenerator::$i | xargs sed -i "s|cmLocalGenerator::$i|cmOutputConverter::$i|g"; done
2016-05-25 09:20:09 -04:00
Daniel Pfeifer 5784747d1b Improve string find: prefer character overloads.
Apply fix-its from clang-tidy's performance-faster-string-find checker.
Ignore findings in kwsys.
2016-05-24 23:22:24 +02:00
Nicolas Despres 038e7716e5 Ninja: Pass all build paths through a central method
This gives us a central location to revise paths.
2016-05-17 09:34:11 -04:00
Nicolas Despres d4381cb15d Ninja: Convert link library file names like all other output paths
All paths generated on Ninja-invoked command lines should be passed
through ConvertToNinjaPath.  Fix ConvertToLinkReference to call this
instead of partially duplicating its implementation.
2016-05-17 09:34:09 -04:00
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King 180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Brad King f6c5958047 Merge topic 'ninja-restat-custom-command-byproducts'
add7abc8 Ninja: Restat custom command byproducts even with a SYMBOLIC output (#16049)
ff805113 Ninja: Fix detection of custom command symbolic outputs
2016-04-08 09:03:59 -04:00
Brad King add7abc835 Ninja: Restat custom command byproducts even with a SYMBOLIC output (#16049)
The change in commit v3.5.0-rc1~198^2 (Ninja: Always re-run custom
commands that have symbolic dependencies, 2015-11-19) broke the
byproducts feature added by commit v3.2.0-rc1~340^2~2 (Add an option for
explicit BYPRODUCTS of custom commands, 2014-11-13) when SYMBOLIC
outputs also appear.  This case occurs with AUTORCC-generated custom
targets because the output is SYMBOLIC (to always run) and the generated
file is a byproduct (for restat so dependents do not run unnecessarily).

The two use cases conflict because Ninja does not support per-output
restat.  Favor restat whenever byproducts are present because it is
required for byproducts to work correctly.  In use cases where we want
an always-run chain we simply will not be able to also use byproducts.
2016-04-05 16:20:28 -04:00
Brad King ff805113c7 Ninja: Fix detection of custom command symbolic outputs
Fix logic introduced by commit v3.5.0-rc1~198^2 (Ninja: Always re-run
custom commands that have symbolic dependencies, 2015-11-19) to not
consider only the last output.  We need to know if any output is
SYMBOLIC, so stop checking as soon as one is found.
2016-04-05 16:19:52 -04:00
Brad King 59ade844ef Ninja: Fix non-determinism in generated build statement order (#15968)
Generate custom command build statements in the order we encounter
source files specifying them.  Do not depend on pointer values of
internally allocated structures for ordering.
2016-02-11 08:53:37 -05:00
Brad King 3477b26ff6 Ninja: Always re-run custom commands that have symbolic dependencies
If a custom command has a SYMBOLIC output (that is never actually
created) then do not mark the custom command build statement as
'restat'.  Otherwise other custom commands that depend on the symbolic
output may not always re-run because after running the first custom
command Ninja 'restat' will detect that the output timestamp did not
change and skip its dependents.

This was observed with the ExternalProject BUILD_ALWAYS option where
Ninja would not re-run the 'install' step each time 'build' re-runs.
2015-11-19 15:47:41 -05:00
Brad King 7d64a0598d Ninja: Add 'restat' parameter to custom command generation method
Pass 'true' from all call sites to preserve existing behavior.
2015-11-19 15:11:00 -05:00
Brad King 2fd5fd1f4d Merge topic 'minor-cleanups'
13a37f5f cmMakefile: Fix typo in comment
958508bb cmMakefile: Fix style
91a829c1 Makefiles: Remove unused variable
e0213882 cmTarget: Remove obsolete member
0554c2c9 cmTarget: Fix style
b22e5d0a Remove some obsolete declarations
ce43ed2c Use LocalGenerator when possible
d90c9738 Makefiles: Remove some unneeded casts
331023ae Export: Remove unused variable
a03f3d0e cmFunctionBlocker: Constify method
d50c4220 Xcode: Fix typo in comment
803f1901 Xcode: Remove trailing semicolon
2015-10-28 08:48:08 -04:00
Stephen Kelly 00b8c0a8d4 cmLocalGenerator: Add IsRootMakefile API 2015-10-27 07:44:21 +01:00
Stephen Kelly ce43ed2cc1 Use LocalGenerator when possible 2015-10-26 23:50:05 +01:00
Stephen Kelly 80de856bb5 Ninja: Port to cmGeneratorTarget. 2015-10-24 09:19:53 +02:00
Stephen Kelly a8c0fbcc19 cmLocalGenerator: Store a vector of generator targets.
Not a map from cmTarget to cmGeneratorTarget.
2015-10-21 23:21:01 +02:00
Stephen Kelly 400e3d19fc cmLocalGenerator: Don't store imported generator targets
No consumers need them.  This makes GetGeneratorTargets more comparable
to cmMakefile::GetTargets, which does not include imported targets.
2015-10-20 23:58:48 +02:00
Brad King f13521317a Merge topic 'clean-up-cmTarget'
55474e61 cmState: Move GetTargetTypeName from cmTarget.
38df5c36 Remove now-obsolete casts.
4ee2b267 cmGeneratorTarget: Use enum for GetType.
eac15298 cmState: Move TargetType enum from cmTarget.
482b3811 cmTarget: Move link type enum out.
2ee1cb85 cmTarget: Move ImportInfoMap out of internal class.
a48bcabd cmTarget: Move backtrace member out of internal class.
6694d993 cmTarget: Remove unneeded constructors.
983c00f8 Generators: Use GetType from the cmGeneratorTarget.
2015-10-16 09:35:34 -04:00
Stephen Kelly eac15298a8 cmState: Move TargetType enum from cmTarget.
Mostly automated:

 values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType")
 for i in "${values[@]}"; do     git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
2015-10-15 00:41:39 +02:00
Stephen Kelly 983c00f8f9 Generators: Use GetType from the cmGeneratorTarget. 2015-10-15 00:41:19 +02:00
Stephen Kelly 7f5ec9f109 cmLocalGenerator: Port GetTargetDirectory to cmGeneratorTarget. 2015-10-15 00:33:12 +02:00
Stephen Kelly 2293d43d00 cmLocalGenerator: Store cmGeneratorTargets.
Relieve cmMakefile of this responsibility.
2015-10-14 13:32:09 -04:00
Stephen Kelly bbef3c2da8 cmLocalGenerator: Add current binary directory accessor. 2015-10-10 11:04:39 +02:00
Stephen Kelly 4ab2750c54 cmLocalGenerator: Add GetProjectName method. 2015-10-09 00:00:18 +02:00
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