Commit Graph

58 Commits

Author SHA1 Message Date
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* 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.

Issue: #26123
2025-01-23 13:09:50 -05:00
Brad King
5aed3ee49d cmSystemTools: Add GetLogicalWorkingDirectory
Track the current working directory with symbolic links preserved.
2024-11-03 08:26:36 -05:00
Brad King
03080d18eb cmcldeps: Restore support for rc.exe path not fully GetShortPathName-d
In some cases `GetShortPathNameW` may not remove all spaces.  If that
happens with the path to `rc.exe`, cmcldeps needs to explicitly quote
the path in the command it runs.

This was exposed by commit 50a6e78a82 (cmSystemTools::RunSingleCommand():
Replace cmsysProcess with cmUVProcessChain, 2023-07-25, v3.28.0-rc1~138^2~4)
because the underlying process execution library no longer reconstructs the
command line without quotes around commands without spaces.

Fixes: #25355
2023-10-23 17:03:01 -04:00
Brad King
0e1abf7afa cmcldeps: Avoid passing /nologo more than once to RC compiler
`rc /nologo /nologo ...` fails:

    fatal error RC1106: invalid option: -ologo

Fixes: #24974
Inspired-by: Benjamin Buch <benjamin.buch@technoteam.de>
2023-06-07 10:12:57 -04:00
Benjamin Buch
f694e8d9c8 cmcldeps: Do not pass linker flags to cl
Avoid cl `Command line warning D9035`.

Fixes: #24906
Co-authored-by: Brad King <brad.king@kitware.com>
2023-06-07 10:05:39 -04:00
Benjamin Buch
8600fb263b cmcldeps: Remove unused C and CXX support
We never set `CMAKE_NINJA_CMCLDEPS_{C,CXX}` anymore.
2023-06-07 08:16:40 -04:00
Dubach, Joev
9dbcfb8fdd MSVC: Recognize -XYZ as well as /XYZ when parsing MS tool command lines
Fixes: #23772
2022-07-27 16:51:15 -04:00
Orgad Shaneh
1336a76380 cmcldeps: Suppress rc dummy output
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
2021-11-29 09:46:36 +02:00
Rolf Eike Beer
a42d2b099a cmcldeps: replace inefficient std::string::substr usage 2020-03-23 19:47:46 +01:00
Rolf Eike Beer
59d572bb4a replace private startsWith() implementation with cmHasPrefix() 2020-03-23 19:47:46 +01:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Zsolt Parragi
1a281a1acd RC: Pass output file in a way that llvm-rc 7 and below understand
Prior to LLVM 8.0, `llvm-rc` does not recognize `/fo` without a space
after it.  Add the space unconditionally because MS `rc` accepts it too.

Issue: #18957
2019-02-27 08:39:02 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
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'
2017-04-11 22:35:21 +02:00
Ben Boeckel
70e268da3e cmcldeps: prefer the /TC flag
The /TC flag causes all source files to be processed as C source files.
We know that there is only one, so this is safe.
2016-10-14 09:27:43 -04:00
Ben Boeckel
47092d3e80 cmcldeps: append strings as strings 2016-10-14 09:27:43 -04:00
Ben Boeckel
7db671a143 cmcldeps: search for single-byte strings as characters 2016-10-14 09:27:43 -04:00
Daniel Pfeifer
a2af850ba6 fix a batch of include-what-you-use violations 2016-08-17 01:08:13 +02:00
Daniel Pfeifer
24ab29b882 Prefer istringstream and ostringstream over stringstream.
Use istringsream for parsing, ostringstream for generation.
2016-06-14 22:37:36 +02: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
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
356c26ebdf cmSystemTools: Teach RunSingleCommand to separate stdout and stderr
Extend the RunSingleCommand signature to capture stdout and stderr
separately.  Allow both to be captured to the same std::string
to preserve existing behavior.  Update all call sites to do this
so that this refactoring does not introduce functional changes.
2015-04-20 15:47:50 -04:00
Ben Boeckel
270eb96df0 strings: Remove cmStdString references
Casts from std::string -> cmStdString were high on the list of things
taking up time. Avoid such implicit casts across function calls by just
using std::string everywhere.

The comment that the symbol name is too long is no longer relevant since
modern debuggers alias the templates anyways and the size is a
non-issue since the underlying methods are generated since it's
inherited.
2014-03-08 13:05:35 -05:00
Clinton Stimpson
5730710c86 Use cmsys::[io]fstream instead of cmsys_ios::[io]fstream.
Also use SystemTools::Fopen() instead of fopen().
This is to eventually support utf-8 filenames.
2014-01-07 09:27:44 -05:00
Clinton Stimpson
0b9906c2fb Windows: Use wide-character system APIs
Make CMake compile with -DUNICODE.  Make it possible for the 8 bit
encoding to eventually be UTF-8 instead ANSI.
2013-12-09 10:29:43 -05:00
Reid Kleckner
6fa9d0ab40 Ninja: Make cmcldeps depfile output more consistent with 'ninja -t msvc'
Ninja relies on the generator to produce paths that match up with the
paths used in the build.ninja file, which are spelled with backslashes.
Therefore, cmcldeps should canonicalize depfile paths to use backslashes
and relativize paths to the build directory.
2013-07-26 10:12:03 -04:00
Andreas Mohr
f57800d6f5 Fix spelling and typos (product names)
API, Borland, MinGW, UNIX, Mac OS X.
2013-05-07 08:42:20 -04:00
Stephen Kelly
5f6432f253 Resolve warnings about shadowing parameters and local variables. 2012-11-13 13:26:10 -05:00
Peter Kümmel
11a6dac1e3 Ninja: don't suppress warning about compiler options
Warnings about invalid compiler options are printed first
by cl.exe, this line was suppressed when the source file
name didn't contain back slashes.
2012-09-04 20:23:53 +02:00
Peter Kümmel
1cdeef795a Ninja: readd quotes to src file path before patching it 2012-07-16 16:48:32 +02:00
Peter Kümmel
84a18cb5d6 Ninja: also stop when .rc's .d file couldn't be generated
prevents silent disappearing of .d files for resource files.

cmcldeps changes directory for cl call, so relativ include paths do not work.
2012-07-15 18:23:04 +02:00
Peter Kuemmel
24a35cef25 Ninja: print error message when command failed 2012-06-28 13:48:10 +02:00
Bill Hoffman
5f12424ebc Remove process execution code from cmcldeps and have it use cmake code.
This simplifies the code in cmcldeps and avoids having yet another
set of process execution code.
2012-06-27 12:28:12 -04:00
Peter Kuemmel
eb410e8dd8 Ninja: disable cldeps for bcc32, it's too old, and ninja would also not build 2012-06-18 13:39:29 +02:00
Peter Kuemmel
5ead31da63 Ninja: try work around for bcc32 bug 2012-06-17 10:17:19 +02:00
Peter Kuemmel
1333b576b5 Ninja: build server fixes
Why does the other compiler give no error?
Seems there is somewhere a "using".
2012-06-17 10:09:10 +02:00
Peter Kuemmel
f430bea11b Ninja: maybe this fixes the bcc32 build 2012-06-16 12:54:10 +02:00
Peter Kuemmel
f2c12887ba Ninja: msvc6 for-scoping 2012-06-16 12:51:25 +02:00
Peter Kuemmel
44b9bbc89d Ninja: build with old msvc versions 2012-06-16 12:40:59 +02:00
Peter Kuemmel
57156a5d30 Ninja: build server fixes
- disable cldeps on cygwin
- don't "use" namespace std
2012-06-16 12:31:50 +02:00
Peter Kuemmel
f1abdce1cc Ninja: some bytes of the rc files couldn't be piped correctly
Write to a file again but generate it in the object dir
2012-06-15 18:56:34 +02:00
Peter Kuemmel
2de963d996 Ninja: don't remove space between command and parameters 2012-06-15 17:52:17 +02:00
Peter Kuemmel
50b6f33dbc Ninja: build cmcldeps with mingw 2012-06-15 13:46:49 +02:00
Peter Kuemmel
ab245ff3c8 Ninja: but cl supports /nologo ... 2012-06-15 13:07:05 +02:00
Peter Kuemmel
bf58e9adec Ninja: no /nologo option in old rc.exe 2012-06-15 12:49:01 +02:00
Peter Kuemmel
518c06585b Ninja: don't pollute build dir with preprocessed rc files 2012-06-15 10:40:04 +02:00
Peter Kuemmel
6e6886d3bd Ninja: ninja now also could read parentheses in .d files 2012-06-14 14:37:08 +02:00
Peter Kuemmel
220fdc16fc Ninja: cmcldeps
- don't depend on argument order
- update help
2012-06-14 10:48:32 +02:00
Peter Kuemmel
77cb7b502f Ninja: suppress startup logos
Having Ninja's smart printing we are more allergic on
unneeded tool output.
2012-06-14 10:48:31 +02:00