Using svnversion with svn:keywords

后端 未结 1 367
离开以前
离开以前 2020-12-21 19:00

I\'m using Visual SVN on my Windows Box.

I have Repository Application, which has Framework as an svn:external. All well and good.

1条回答
  •  生来不讨喜
    2020-12-21 19:30

    To use svnversion, you need to integrate it into the build process. If you run it on a subversion checkout, it will output a string like 73597:73598, indicating what version your tree has (notice that different files may have different versions, plus files may have also local modifications). You put something like

    CFLAGS+=-DSVNVERSION="\"`svnversion`\""  
    

    into your Makefile, and then put

    #define VERSION_STRING "Application version" SVNVERSION ", Framework version" FRAMEWORK_VERSION
    

    into the code. If you don't use Make, or cannot readily have your build process run a command whose output produces a compiler command line option, then you can also use the subwcrev utility that comes with TortoiseSVN. You use that as a pre-build step, and have it transform some file with placeholders into a copy of the file with the placeholders replaced with the actual version; then your compilation will compile and link the new file.

    Edit: For the PHP case, it is not possible to have the revision written automatically into a file on checkout or update. Instead, you could run svnversion on every PHP access, putting its output into the HTML response. If that gets too expensive, you can cache the svnversion result in a file and only regenerate the file if it is older than one hour (say), leaving it up to the user to remember to delete the file after an update to make it recompute the cache right away.

    0 讨论(0)
提交回复
热议问题