Visual Studio Add-In for checking if file is up-to-date
-
Hello folks! Am not sure where to ask this so i thought i ask here, maybe you fellas know the answer. If i write a Visual Studio Add-in in VC++, is there any way to "hook" the up-to-date check VS does when compiling files? When you hit "Build", VS checks what files have changed and what files are up-to-date and builds only the ones that are outdated. VS seems to be also using the pch file and perhaps pdb file to determine this, i guess it is needed when using precompiled headers. What i would like to do is handle the up-to-date check for certain files a bit differently than others. E.g. the project has a file called "source.cpp", when the up-to-date check is done, i'd like my method to be called with the name (or full path) of "source.cpp" and the corresponding pch, e.g. "c:\vsprojects\theproject\debug\vc70.pch", then for some files i'd just like to pass this along to the "default" handler but for certain files i'd like to "redirect" the path to the pch to somewhere else. Anyone knows how this could be done? Thanks in advance for any pointers (preferably not NULL pointers :) ).
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
-
Hello folks! Am not sure where to ask this so i thought i ask here, maybe you fellas know the answer. If i write a Visual Studio Add-in in VC++, is there any way to "hook" the up-to-date check VS does when compiling files? When you hit "Build", VS checks what files have changed and what files are up-to-date and builds only the ones that are outdated. VS seems to be also using the pch file and perhaps pdb file to determine this, i guess it is needed when using precompiled headers. What i would like to do is handle the up-to-date check for certain files a bit differently than others. E.g. the project has a file called "source.cpp", when the up-to-date check is done, i'd like my method to be called with the name (or full path) of "source.cpp" and the corresponding pch, e.g. "c:\vsprojects\theproject\debug\vc70.pch", then for some files i'd just like to pass this along to the "default" handler but for certain files i'd like to "redirect" the path to the pch to somewhere else. Anyone knows how this could be done? Thanks in advance for any pointers (preferably not NULL pointers :) ).
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
the "up-to-date" check is done by the compiler / linker by comparing the timestamp of the exe/dll to that of it's component .obj files, the .obj files timestamps are compared to those of the associated .c or .cpp files, the .c / .cpp files are compared to those of it's included files. If any of the timestamps are greater that triggers a build of the appropriate .c/.cpp file(s), then the .obj files are then linked to make the target .exe/.dll file. So, if you want a .cpp file to be built based on some other file's timestamp you need to find a way to tell the compiler (or Visual Studio) to do so. There is a way to hook into the build process in the way you describe by making a Visual Studio extension. Look here[^] for info about that.
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
-
the "up-to-date" check is done by the compiler / linker by comparing the timestamp of the exe/dll to that of it's component .obj files, the .obj files timestamps are compared to those of the associated .c or .cpp files, the .c / .cpp files are compared to those of it's included files. If any of the timestamps are greater that triggers a build of the appropriate .c/.cpp file(s), then the .obj files are then linked to make the target .exe/.dll file. So, if you want a .cpp file to be built based on some other file's timestamp you need to find a way to tell the compiler (or Visual Studio) to do so. There is a way to hook into the build process in the way you describe by making a Visual Studio extension. Look here[^] for info about that.
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
I've been experimenting a bit and what i see is that VS passes only those .cpp files to the compiler which need to be updated in the first place so the up-to-date check isn't done by the compiler (could be that the compiler itself also does some check against the boject files, i don't know that, but as said, it gets the list of outdated files in the first place). Also, if the pch file is removed, VS passes all(?) the files to the compiler even tough the obj files are still there and the sources are not modified. I supose this is done because if a header changes this is the way for VS to know what cpp files include it and need to be rebuilt, but if the pch is missing then it falls back to rebuilding everything to reproduce the pch file. Ah, and another thing, i'm talking VS2003 (i know, it's old, but i have no other options). Thanks for the link, i will check it out.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
-
Hello folks! Am not sure where to ask this so i thought i ask here, maybe you fellas know the answer. If i write a Visual Studio Add-in in VC++, is there any way to "hook" the up-to-date check VS does when compiling files? When you hit "Build", VS checks what files have changed and what files are up-to-date and builds only the ones that are outdated. VS seems to be also using the pch file and perhaps pdb file to determine this, i guess it is needed when using precompiled headers. What i would like to do is handle the up-to-date check for certain files a bit differently than others. E.g. the project has a file called "source.cpp", when the up-to-date check is done, i'd like my method to be called with the name (or full path) of "source.cpp" and the corresponding pch, e.g. "c:\vsprojects\theproject\debug\vc70.pch", then for some files i'd just like to pass this along to the "default" handler but for certain files i'd like to "redirect" the path to the pch to somewhere else. Anyone knows how this could be done? Thanks in advance for any pointers (preferably not NULL pointers :) ).
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
Have you checked nmake?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
I've been experimenting a bit and what i see is that VS passes only those .cpp files to the compiler which need to be updated in the first place so the up-to-date check isn't done by the compiler (could be that the compiler itself also does some check against the boject files, i don't know that, but as said, it gets the list of outdated files in the first place). Also, if the pch file is removed, VS passes all(?) the files to the compiler even tough the obj files are still there and the sources are not modified. I supose this is done because if a header changes this is the way for VS to know what cpp files include it and need to be rebuilt, but if the pch is missing then it falls back to rebuilding everything to reproduce the pch file. Ah, and another thing, i'm talking VS2003 (i know, it's old, but i have no other options). Thanks for the link, i will check it out.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
You are right as pertains to VS passing only those files needing to be recompiled. The reason for passing all of the files in the case of the deleted / missing .PCH file is it is the compiler that builds it.
"If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
-
Have you checked nmake?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
Now i did, but it doesn't seem to be involved, isn't nmake used only for makefile projects?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
-
Now i did, but it doesn't seem to be involved, isn't nmake used only for makefile projects?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<
Code-o-mat wrote:
...but it doesn't seem to be involved, isn't nmake used only for makefile projects?
Yes, but I was just giving you something else to consider. I often times do not solve problems directly, but give folks ideas and suggestions that they can then take a step further and decide if its right for them or not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
Code-o-mat wrote:
...but it doesn't seem to be involved, isn't nmake used only for makefile projects?
Yes, but I was just giving you something else to consider. I often times do not solve problems directly, but give folks ideas and suggestions that they can then take a step further and decide if its right for them or not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
The idea was good, thank you. Indeed sometimes all people need is a kick in the right direction and then they can tumble down the stairs themselfs. :) Most of the time i am just looking for that kick when asking questions, getting the complete solution on a plate is no fun.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > //TODO: Implement signature here<