Results 1 to 6 of 6

Thread: Subversion Visual Studio Plugin

  1. #1

    Question Subversion Visual Studio Plugin

    Hello All,

    I've been using the subversion Visual Studio Plugin to access code that is stored on a Windows Server. The system itself is working just fine but I was wondering if there is any way to access the version number of the code used in a project as a constant that can be accessed by the code at compile time?

    To be more specific, I'm using AVR Studio 5 (which uses the Visual Studio Shell) to write programs in C for a microcontroller. The environment uses GCC as the compiler, and recently, I have become interested in finding a way to access the current version number of the code in my application. I'm wondering if there is a way for me to create a constant variable that holds the current subversion build number of the project. When our code is run on the microcontroller, we can print the build number of the firmware on an LCD screen to keep track of which version of the firmware it's running.

    This may sound like a long-shot but just thought I would ask in case anyone has any ideas.

    Thanks!
    Jason O

  2. #2
    Senior Member Site ModeratorSite Admin
    Join Date
    Mar 2011
    Location
    Chesterfield, UK
    Posts
    771
    Sure, Subversion itself does exactly this. If you type svn --version at the command line, you can see the repository revision that it was built from.

    This is generally achieved at build time. In the simplest possible case, if you have a header file containing @REV@ you can have your continuous integration system substitute in the correct value at build-time:
    Code:
    svn co http://blah/repo/trunk project
    cd project
    REV=`svn info | grep Revision`
    sed -i s/@REV@/$REV/ version.h
    Mat Booth
    Software Engineer
    WANdisco, Inc.

    I joined the blog-o-web-o-sphere! Linux and Coding Blog

    How To Ask Smart Questions

  3. #3
    Quote Originally Posted by mbooth View Post
    Sure, Subversion itself does exactly this. If you type svn --version at the command line, you can see the repository revision that it was built from.

    This is generally achieved at build time. In the simplest possible case, if you have a header file containing @REV@ you can have your continuous integration system substitute in the correct value at build-time:
    Code:
    svn co http://blah/repo/trunk project
    cd project
    REV=`svn info | grep Revision`
    sed -i s/@REV@/$REV/ version.h
    OK, now do it using Windows- and Visual Studio- native tools so he doesn't have to distribute sed to every system that might do a build.
    I am neither an employee nor customer of WANDisco.

  4. #4
    Senior Member Site ModeratorSite Admin
    Join Date
    Mar 2011
    Location
    Chesterfield, UK
    Posts
    771
    I left that as an exercise for the reader. I have no idea how to configure Visual Studio. </AnEclipseUser>

    If he's using GCC, I thought it reasonable to assume he might have other GNU tools available to him...
    Mat Booth
    Software Engineer
    WANdisco, Inc.

    I joined the blog-o-web-o-sphere! Linux and Coding Blog

    How To Ask Smart Questions

  5. #5
    Quote Originally Posted by mbooth View Post
    Sure, Subversion itself does exactly this. If you type svn --version at the command line, you can see the repository revision that it was built from.

    This is generally achieved at build time. In the simplest possible case, if you have a header file containing @REV@ you can have your continuous integration system substitute in the correct value at build-time:
    Code:
    svn co http://blah/repo/trunk project
    cd project
    REV=`svn info | grep Revision`
    sed -i s/@REV@/$REV/ version.h
    Hello,

    Thank you for the input there. However, as andyl mentioned, I have no idea how to actually integrate that into Visual Studio. As for GCC, I know that is integrated into the IDE and the IDE manages all the make files for you. I'm hoping there is a way I could implement what you are talking about but I have no idea where or how to even start doing that.

    - Jason O

  6. #6
    Quote Originally Posted by Jdo300 View Post
    Hello,

    Thank you for the input there. However, as andyl mentioned, I have no idea how to actually integrate that into Visual Studio. As for GCC, I know that is integrated into the IDE and the IDE manages all the make files for you. I'm hoping there is a way I could implement what you are talking about but I have no idea where or how to even start doing that.

    - Jason O
    Actually, the compiler (csc.exe or vbc.exe) isn't "integrated into Visual Studio" but instead it's a standalone EXE which the IDE calls. You can heavily tweak the build process by customizing the MSBuild script (MSBuild is a rough analog to make), and MSBuild can call other scripts/programs before and after compilation (called "tasks").

    http://msdn.microsoft.com/en-us/library/dd393573.aspx

    What I was pointing out to Mat was that sed doesn't come with Windows or Visual Studio, so you need to find something comparable. WubWCRev, for example.
    I am neither an employee nor customer of WANDisco.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •