Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
a5098cad
Commit
a5098cad
authored
Jan 09, 2019
by
Taylor Braun-Jones
Committed by
Brad King
Jan 28, 2019
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmake: Add --ignore-eol option to `-E compare_files` command
Fixes:
#13007
parent
40628b25
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
37 additions
and
7 deletions
+37
-7
Help/manual/cmake.1.rst
Help/manual/cmake.1.rst
+3
-2
Help/release/dev/compare_files-ignore-eol.rst
Help/release/dev/compare_files-ignore-eol.rst
+6
-0
Source/cmcmd.cxx
Source/cmcmd.cxx
+16
-5
Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt
...Make/CommandLine/E_compare_files-different-eol-result.txt
+1
-0
Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt
...Make/CommandLine/E_compare_files-different-eol-stderr.txt
+1
-0
Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt
...andLine/E_compare_files-ignore-eol-nonexistent-result.txt
+1
-0
Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt
...andLine/E_compare_files-ignore-eol-nonexistent-stderr.txt
+1
-0
Tests/RunCMake/CommandLine/RunCMakeTest.cmake
Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+4
-0
Tests/RunCMake/CommandLine/compare_files/.gitattributes
Tests/RunCMake/CommandLine/compare_files/.gitattributes
+2
-0
Tests/RunCMake/CommandLine/compare_files/crlf
Tests/RunCMake/CommandLine/compare_files/crlf
+1
-0
Tests/RunCMake/CommandLine/compare_files/empty1
Tests/RunCMake/CommandLine/compare_files/empty1
+0
-0
Tests/RunCMake/CommandLine/compare_files/empty2
Tests/RunCMake/CommandLine/compare_files/empty2
+0
-0
Tests/RunCMake/CommandLine/compare_files/lf
Tests/RunCMake/CommandLine/compare_files/lf
+1
-0
No files found.
Help/manual/cmake.1.rst
View file @
a5098cad
...
...
@@ -373,9 +373,10 @@ Available commands are:
``chdir <dir> <cmd> [<arg>...]``
Change the current working directory and run a command.
``compare_files <file1> <file2>``
``compare_files
[--ignore-eol]
<file1> <file2>``
Check if ``<file1>`` is same as ``<file2>``. If files are the same,
then returns 0, if not it returns 1.
then returns 0, if not it returns 1. The ``--ignore-eol`` option
implies line-wise comparison and ignores LF/CRLF differences.
``copy <file>... <destination>``
Copy files to ``<destination>`` (either file or directory).
...
...
Help/release/dev/compare_files-ignore-eol.rst
0 → 100644
View file @
a5098cad
compare_files-ignore-eol
------------------------
* The :manual:`cmake(1)` ``-E compare_files`` command learned a new
``--ignore-eol`` option to specify that end-of-line differences (e.g. LF vs
CRLF) should be ignored when comparing files.
Source/cmcmd.cxx
View file @
a5098cad
...
...
@@ -78,7 +78,8 @@ void CMakeCommandUsage(const char* program)
<<
" capabilities - Report capabilities built into cmake "
"in JSON format
\n
"
<<
" chdir dir cmd [args...] - run command in a given directory
\n
"
<<
" compare_files file1 file2 - check if file1 is same as file2
\n
"
<<
" compare_files [--ignore-eol] file1 file2
\n
"
<<
" - check if file1 is same as file2
\n
"
<<
" copy <file>... destination - copy files to destination "
"(either file or directory)
\n
"
<<
" copy_directory <dir>... destination - copy content of <dir>... "
...
...
@@ -540,10 +541,20 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Compare files
if
(
args
[
1
]
==
"compare_files"
&&
args
.
size
()
==
4
)
{
if
(
cmSystemTools
::
FilesDiffer
(
args
[
2
],
args
[
3
]))
{
std
::
cerr
<<
"Files
\"
"
<<
args
[
2
]
<<
"
\"
to
\"
"
<<
args
[
3
]
<<
"
\"
are different.
\n
"
;
if
(
args
[
1
]
==
"compare_files"
&&
(
args
.
size
()
==
4
||
args
.
size
()
==
5
))
{
bool
filesDiffer
;
if
(
args
.
size
()
==
4
)
{
filesDiffer
=
cmSystemTools
::
FilesDiffer
(
args
[
2
],
args
[
3
]);
}
else
if
(
args
[
2
]
==
"--ignore-eol"
)
{
filesDiffer
=
cmsys
::
SystemTools
::
TextFilesDiffer
(
args
[
3
],
args
[
4
]);
}
else
{
::
CMakeCommandUsage
(
args
[
0
].
c_str
());
return
1
;
}
if
(
filesDiffer
)
{
std
::
cerr
<<
"Files
\"
"
<<
args
[
args
.
size
()
-
2
]
<<
"
\"
to
\"
"
<<
args
[
args
.
size
()
-
1
]
<<
"
\"
are different.
\n
"
;
return
1
;
}
return
0
;
...
...
Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt
0 → 100644
View file @
a5098cad
1
Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt
0 → 100644
View file @
a5098cad
^Files ".*/compare_files/lf" to ".*/compare_files/crlf" are different.$
Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt
0 → 100644
View file @
a5098cad
1
Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt
0 → 100644
View file @
a5098cad
^Files "nonexistent_a" to "nonexistent_b" are different.$
Tests/RunCMake/CommandLine/RunCMakeTest.cmake
View file @
a5098cad
...
...
@@ -18,6 +18,10 @@ run_cmake_command(Uno-src ${CMAKE_COMMAND} -B DummyBuildDir -UVAR)
run_cmake_command
(
E-no-arg
${
CMAKE_COMMAND
}
-E
)
run_cmake_command
(
E_capabilities
${
CMAKE_COMMAND
}
-E capabilities
)
run_cmake_command
(
E_capabilities-arg
${
CMAKE_COMMAND
}
-E capabilities --extra-arg
)
run_cmake_command
(
E_compare_files-different-eol
${
CMAKE_COMMAND
}
-E compare_files
${
RunCMake_SOURCE_DIR
}
/compare_files/lf
${
RunCMake_SOURCE_DIR
}
/compare_files/crlf
)
run_cmake_command
(
E_compare_files-ignore-eol-same
${
CMAKE_COMMAND
}
-E compare_files --ignore-eol
${
RunCMake_SOURCE_DIR
}
/compare_files/lf
${
RunCMake_SOURCE_DIR
}
/compare_files/crlf
)
run_cmake_command
(
E_compare_files-ignore-eol-empty
${
CMAKE_COMMAND
}
-E compare_files --ignore-eol
${
RunCMake_SOURCE_DIR
}
/compare_files/empty1
${
RunCMake_SOURCE_DIR
}
/compare_files/empty2
)
run_cmake_command
(
E_compare_files-ignore-eol-nonexistent
${
CMAKE_COMMAND
}
-E compare_files --ignore-eol nonexistent_a nonexistent_b
)
run_cmake_command
(
E_echo_append
${
CMAKE_COMMAND
}
-E echo_append
)
run_cmake_command
(
E_rename-no-arg
${
CMAKE_COMMAND
}
-E rename
)
run_cmake_command
(
E_server-arg
${
CMAKE_COMMAND
}
-E server --extra-arg
)
...
...
Tests/RunCMake/CommandLine/compare_files/.gitattributes
0 → 100644
View file @
a5098cad
crlf eol=crlf
lf eol=lf
Tests/RunCMake/CommandLine/compare_files/crlf
0 → 100644
View file @
a5098cad
line1
Tests/RunCMake/CommandLine/compare_files/empty1
0 → 100644
View file @
a5098cad
Tests/RunCMake/CommandLine/compare_files/empty2
0 → 100644
View file @
a5098cad
Tests/RunCMake/CommandLine/compare_files/lf
0 → 100644
View file @
a5098cad
line1
Brad King
@brad.king
mentioned in commit
a844c724
·
Jan 28, 2019
mentioned in commit
a844c724
mentioned in commit a844c7248d7cfca9569ea8aa6a2147f564a5b2f1
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment