Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --output option to export report to file #888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

insilications
Copy link

If tests are necessary, I could add them.

@kimgr
Copy link
Contributor

kimgr commented Mar 12, 2021

Why is this preferable to include-what-you-use t.c > x.log 2>&1?

@insilications
Copy link
Author

insilications commented Mar 14, 2021

@kimgr Using IWYU with CMake, for example:

set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "/usr/bin/include-what-you-use;-Xiwyu;--verbose=1;-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_15.imp;-Xiwyu;--cxx17ns;>fixes.log2>&1")
cmake --build /insilications/apps/Test/Test_Clang-Debug --target all --parallel 16

Doesn't work. The output is never redirected to fixes.log.

set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "/usr/bin/include-what-you-use;-Xiwyu;--verbose=1;-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_15.imp;-Xiwyu;--cxx17ns;-Xiwyu;>fixes.log2>&1")

Doesn't work either.

With my solution, the intended behavior is perfect:

set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "/usr/bin/include-what-you-use;-Xiwyu;--verbose=1;-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_15.imp;-Xiwyu;--cxx17ns;-Xiwyu;--output=fixes.log")

@storoj
Copy link
Contributor

storoj commented Apr 23, 2021

Hi @insilications, if I understand it right CMAKE_CXX_INCLUDE_WHAT_YOU_USE command is being applied to every file in the project. If so then every IWYU run will overwrite the same file with an output for every source file. It seems that you open the output file for appending (std::ios::app), but how do you guarantee that the file will be empty before cmake starts calling IWYU? I am also wondering if appending the file from multiple IWYU processes can work reliably.

@kimgr
Copy link
Contributor

kimgr commented May 1, 2021

@insilications I think @storoj makes some good points wrt concurrency.

The patch is nice and simple, but on plain gut feeling it seems weird to me that IWYU would need file-output if compilers in general don't, so I'd prefer not to do it this way.

As for running with cmake -- the question then becomes: why not just cmake --build . > fixes.log 2>&1?

@insilications
Copy link
Author

Hi guys, sorry for the delay. I'm having some real life problems right now. I agree with the problems wrt concurrency, although in my current use case they haven't showed up. But they are definitely real and need to be addressed. I'll be answering you guys later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants