'touch' command

Sysprogs forums Forums VisualGDB 'touch' command

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #26272
    Ancaritha
    Participant

    I recently upgraded my work computer and I have only installed the SysProgs toolchain for compiling projects.  In our make files, we use the ‘touch’, which SysProgs doesn’t support.  My old computer had the WinAVR, WinARM and AVR32 compilers installed, which are all processors we used to use but not need anymore.  Is there a way to get ‘touch’ functionality using VisualGDB?  I can manually grab touch.exe from my old computer, but having a native way to do it with VisualGDB or without having to install a toolchain I don’t actually need anymore.

    Is there any easy way to replicate this functionality?  (Note, it doesn’t have to be the touch command, just something that does the equivalent and updates the files timestamp).  I looked through the other packages available under “Manage VisualGDB Packages” but not of them immediately stood out as probably containing a version of touch.

    Note: I tried using the windows command of  “copy FILEHERE +,,”, but thus far I haven’t been able to get it to work quite right, it just keeps copying a version of the file to where the makefile is rather than leaving it in it’s proper directory.  I also have a feeling it’ll throw up if I try to do more than one file at once.

     

    Thanks!

    #26278
    support
    Keymaster

    Thanks for confirming your support status. Please find the answer to your inquiry below.

    The ‘touch’ command is part of the coreutils package and is typically used to reset the last modification time of a certain file without actually changing its contents. Normally, if you are moving away from an older toolchain, we would advise converting the Make-based projects to MSBuild, as it abstracts out many low-level commands and is better integrated into VS (e.g. it will automatically rebuild the files affected by a change in compiler flags, eliminating the need to manually manipulate timestamps).

    Feel free to let us know why you need to use the touch command in your Makefiles and we will try to suggest a better way to do it with VisualGDB and MSBuild.

    If you absolutely need to use the ‘touch’ command, it should be OK to simply copy it from the original toolchain and check it into your source control system. It should not have any dependencies on the other toolchain components, so you don’t need to copy the entire toolchain. Also the “cmd /c copy /b filename.ext +,,” should work as long as you prefix it with “cmd /c” and run it in the correct directory.

    #26281
    Ancaritha
    Participant

    One of our source files, contain the GCC commands __DATE and __TIME__.  These only get updated when the file is changed (which makes sense, otherwise it’s not building it).  Since this is a low level file that we seldom change, we need a way to force GCC to rebuild it to get the updated date and time.  That’s what we use touch for.  It fills in a variable that we can access over our communication system to get the buildstamp for the code running on a device.  We can also display it on the system UI and whatnot.

    Making a binaries folder somewhere in our source tree and storing touch there is probably the easiest solution; don’t have to modify the system PATH file or do any extra weird copies when setting up a new computer that could be easy to miss/forget about or install antiquated toolchains.

    Touch does actually rely on 2 other files in the toolchain (libicon2.dll and libintl3.dll), but those are both also in the toolchain /bin directories so they’re easy to get.

    Thanks!

    #26282
    support
    Keymaster

    Thanks for clarifying this. Indeed, depending on the way the toolchain was built, the touch.exe command might depend on some other DLLs.

    That said, if your Makefile track file dependencies properly, you can simply use the “cmd /c echo “//This file was updated” > trigger.h” command and include trigger.h from your main file. This will override the contents  of trigger.h with the “//This file was updated” string, but will be otherwise equivalent to using the touch command. Also please consider setting up a custom VisualGDB shortcut for this operation, so you can conveniently trigger it via the VisualGDB menus when needed.

    #26283
    Ancaritha
    Participant

    For the time being I’ve updated the project I’m working on to use the touch in our repository I’ve added but that echo idea might be worth looking into just so I can remove external dependencies.  It might take some work to get right if I ever have to touch more than one file.  We haven’t had to do that on more recent projects but it’s always a possibility that the need for it might pop up again.  I suppose I could probably just be lazy and make multiple ‘echo’ lines in the makefile 🙂

     

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.