Wumpf / IncludeToolbox

Visual Studio extension to format, prune, and inspect include directives.
https://marketplace.visualstudio.com/items?itemName=Wumpf.IncludeToolbox
MIT License
50 stars 22 forks source link

Can't compile file: The given document is not a compileable VC++ file. #51

Open kreuzerkrieg opened 6 years ago

kreuzerkrieg commented 6 years ago

It stops the whole process when cleaning the project using "Trial and Error". when iterating the project for files (VCFile) you can check it for type to know if it is compilable entry. Something like oFile.FileType == eFileType.eFileTypeCppCode

dakotahawkins commented 6 years ago

It might also be necessary to make sure the file isn't excluded from the build. I think you can set that per-file (and I know you can set it per-project -- you can have projects that don't build in any configuration).

Based on recent experience, checking for this is pretty slow (time spent in the Visual Studio API).

I can't say I've tried to use the trial and error feature, but could you give any more information about the error you get? Does it fail trying to compile (MSVC error)? If it's an error that could just be caught and logged (as opposed to failing everything) would that be OK? That might actually be faster than trying to check all your files ahead of time.

kreuzerkrieg commented 6 years ago

Correct, exclusion from build can be set per single file. Moreover, user can set "content type" on a file, so, you cant trust file extension. Thats it, there were no other diagnostic messages, it was the last one in tool output console, before it there were messages stating about include removal. So, I dont know even which file caused the problem. Does the tool have any log file written somewhere?

gjaegy commented 6 years ago

Hi, I am having the same issue. I have removed the "excluded files" from solution, however, I still get the error messages after two files have been successfully processed.

my log is as follow:


Could not remove #include: 'imnode.h'
Could not remove #include: 'imDisplayApplicationPathManager.h'
Removed 0 #include directives from 'imCoreNodesManager.cpp'
Could not remove #include: 'imCommandLineParametersDisplay.h'
Removed 0 #include directives from 'imDisplayApplicationPathManager.cpp'
Removed 0 #include directives from 'imDisplayEvents.cpp'
Removed 0 #include directives from 'imDisplayPlugin.cpp'
Could not remove #include: 'imDisplayPluginManager.h'
Could not remove #include: 'imImmediateGUI.h'
Could not remove #include: 'imShaderCacheDictionnary.h'
Could not remove #include: 'imAutoDebug.h'
Could not remove #include: 'imEditorManager.h'
Could not remove #include: 'imTerrain.h'
Could not remove #include: 'imImageDataCache.h'
Could not remove #include: 'imguiprogressbar.h'
Could not remove #include: 'imNodeExternal.h'
Could not remove #include: 'imLibRocketWrapper.h'
Could not remove #include: 'imNodeSceneRoot.h'
Could not remove #include: 'imGraphicAllocationInformation.h'
Could not remove #include: 'imScene.h'
Could not remove #include: 'imISoundEngine.h'
Could not remove #include: 'imSpacenavigatorwrapper.h'
Could not remove #include: 'imGameManager.h'
Could not remove #include: 'imTreeModelsLibrary.h'
Could not remove #include: 'imTerrainStreamingDynamicTexturesManager.h'
Could not remove #include: 'imTextureManager.h'
Could not remove #include: 'imObjectImportPluginsManager.h'
Could not remove #include: 'imCoreNodesManager.h'
Could not remove #include: 'imTraversalUpdate.h'
Could not remove #include: 'imVisualPerfMonitor.h'
Could not remove #include: 'imInputManager.h'
Could not remove #include: 'imScriptinterface.h'
Could not remove #include: 'imDisplayApplicationPathManager.h'
Could not remove #include: 'imLeapMotionWrapper.h'
Could not remove #include: 'ShellScalingAPI.h'
Could not remove #include: 'imCommandLineParametersDisplay.h'
Removed 0 #include directives from 'imDisplayApp.cpp'
Removed 0 #include directives from 'imProgressBar.cpp'
Can't compile file: The given document is not a compileable VC++ file.

Any idea ?

pifopi commented 6 years ago

I had the same issue. I removed the header files from my projects and it worked ^^ I'm not sure it's the right way to do it but I use this workaround :)

gjaegy commented 6 years ago

I will try to remove the headers. I assume I can simply restore the original .vcxproj file once the process is completed (in the case it works). I will try (although we have quite a lot of headers in the project, so that will take some time to remove them all).

bytefactory73 commented 6 years ago

i fixed that with my pull request. i have no idea to to attach that to my submit.

gjaegy commented 6 years ago

excellent, that's great ! I assume I will have to recompile from source then, or any idea when an official release is planned with the fix included ?

Wumpf commented 6 years ago

This PR does not fix completely fix this issue: The failures are still there, but running TrialAndErrorRemoval on a project won't choke on a single error anymore. Also, the error output was improved.

Wumpf commented 6 years ago

@gjaegy yes, I'd like to wait to accumulate a few more things before I put out a new version. However, the sln should compile out of the box if you install the VS2017 Extension tools. Hope that's not too much trouble

gjaegy commented 6 years ago

Understood, that makes sense.

In that case, I have another request :) Right now, it seems the plugin can only remove unused header from .cpp - since it gives an error as soon as I have a .h in the project.

Now, would it be a big deal to also proceed the same work on header files ? This would definitively help speeding up compilation time in my project.

Thanks a lot, great work in any case !!

bytefactory73 commented 6 years ago

my fix skips all non-cpp files. also header files. i thought the same that it would be cool to have .h optimization. but i'm not sure if the api allows to compile a header file directly. if not we would need to create a dummy ".cpp" file with only this one header included... but reducing the header and compiling the dummy cpp....

Wumpf commented 6 years ago

Removing a header B file from a header A would require recompiling all source files that include A - including transitive includes. In theory this is doable - just create the entire dependency graph and look at all the cpp that are connected to a given header file. Practically, this takes very long and requires full knowledge of all all dependent projects which is often not the case.

On top of that I would argue that this is pretty useless being able to predeclare symbols as we go. Headers find its way usually into header because some symbol is missing which can't be predeclared. This is what Include-What-You-Use tries, somewhat successful.. sometimes ;)

gjaegy commented 6 years ago

Yes, but after several years of development, some includes are “forgotten” in other headers and remain there for no reason… And that’s pretty hard to discover by hand.

But I agree, the trial process will last quite some time, perfect for an over-night taks :)

From: Wumpf notifications@github.com Sent: mercredi 14 mars 2018 22:28 To: Wumpf/IncludeToolbox IncludeToolbox@noreply.github.com Cc: gjaegy g.jaegy@imagine3d.fr; Mention mention@noreply.github.com Subject: Re: [Wumpf/IncludeToolbox] Can't compile file: The given document is not a compileable VC++ file. (#51)

Removing a header B file from a header A would require recompiling all source files that include A - including transitive includes. In theory this is doable - just create the entire dependency graph and look at all the cpp that are connected to a given header file. Practically, this takes very long and requires full knowledge of all all dependent projects which is often not the case.

On top of that I would argue that this is pretty useless being able to predeclare symbols as we go. Headers find its way usually into header because some symbol is missing which can't be predeclared. This is what Include-What-You-Use tries, somewhat successful.. sometimes ;)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Wumpf/IncludeToolbox/issues/51#issuecomment-373180819 , or mute the thread https://github.com/notifications/unsubscribe-auth/AA280cq-Sno66BaZFzOj_v91NneyUd8dks5teYtogaJpZM4QFfym . https://github.com/notifications/beacon/AA280Un0dV5dRR6yfYSkjOWrWI36PRBVks5teYtogaJpZM4QFfym.gif

surana4u commented 5 years ago

Is this issue already solved? I get this error for my c++ project "Can't compile file: The given document is not a compileable VC++ file." I tried to use ignore list to make it work. How to know which document is causing the problem?

surana4u commented 5 years ago

Simple Use case on VS2017:

  1. File > New > Project
  2. Visual C++ > Windows Desktop > Windows Console Application
  3. Run "Trial and Error" on ConsoleApplication1

--> Can't compile file: The given document is not a compileable VC++ file.

surana4u commented 5 years ago

I found the solution. Current version available on Marketplace (https://marketplace.visualstudio.com/items?itemName=Wumpf.IncludeToolbox) is 2.2.0 and this issue was fixed in 2.3.0. It would be nice if someone can update to latest one on Marketplace. Thanks!

Btw I found 2.3.0 in the repository.