Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Visual Studio Add-In for checking if file is up-to-date

Visual Studio Add-In for checking if file is up-to-date

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiocsharpdebugginghelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Code o mat
    wrote on last edited by
    #1

    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<

    T D 2 Replies Last reply
    0
    • C Code o mat

      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<

      T Offline
      T Offline
      TheGreatAndPowerfulOz
      wrote on last edited by
      #2

      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

      C 1 Reply Last reply
      0
      • T TheGreatAndPowerfulOz

        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

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        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<

        T 1 Reply Last reply
        0
        • C Code o mat

          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<

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • C Code o mat

            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<

            T Offline
            T Offline
            TheGreatAndPowerfulOz
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • D David Crow

              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

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              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<

              D 1 Reply Last reply
              0
              • C Code o mat

                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<

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                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

                C 1 Reply Last reply
                0
                • D David Crow

                  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

                  C Offline
                  C Offline
                  Code o mat
                  wrote on last edited by
                  #8

                  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<

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups