A while back on the ClarionLive skype chat I mentioned this template and promised to upload a version. I completely forgot all about it a few days later but here it is finally!
This template just calls up SubWCRev.exe which is shipped with TortoiseSVN. After that it is up to you to arrange to compile the details into your EXE or DLL. This is very easy to do using the VersionRes.TPL shipped with Clarion but it should also work fine with any other similar template designed to include values from an external file.
At this point I don’t intend to ship a fully working example but hopefully the following explanation will be enough to get you going.
The Template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#TEMPLATE(ClarionEdge_GenerateSubVersion, 'ClarionEdge Generate Sub Version'), FAMILY('ABC'),FAMILY('CW20') #!********************************************************************************************************* #EXTENSION(ce_EnableGenerateSubVersion,'Generate SubVersion Revision Number'),APPLICATION,FIRST #!********************************************************************************************************* #SHEET #TAB('General') #DISPLAY('Generate SubVersion'), AT(10,,,30), PROP(PROP:FontStyle, FONT:bold), PROP(PROP:FontSize, 14) #DISPLAY('This Extension Template will enable automatic generating of the SubVersion Revision Number for the specified working copy.'), AT(10,,150, 30), PROP(PROP:FontStyle, FONT:italic) #DISPLAY('') #PROMPT('Activate Generate Subversion',CHECK), %GenerateSubVersionON, DEFAULT(0), AT(10) #DISPLAY('') #BOXED(''), WHERE(%GenerateSubVersionON=1) #PROMPT('Location of SubWCRev:',OPENDIALOG( 'Select SubWCRev', 'SubWCRev.exe|SubWCRev.exe' )),%RunSubWCRev,DEFAULT('%ProgramFiles%\TortoiseSVN\bin\SubWCRev.exe') #DISPLAY('Can be found in "%ProgramFiles%\TortoiseSVN\bin\"'), PROP(PROP:FontStyle, FONT:italic), PROP(PROP:FontColor, 00808080h) #DISPLAY('') #PROMPT('Working copy root:',@s255),%RunParamRoot,DEFAULT('.\') #PROMPT('Source version file:',OPENDIALOG( 'Source Version File', 'Source Version Information|*.in|All Files|*.*' )),%RunParamSource,DEFAULT('SubVersion.in') #PROMPT('Destination version file:',OPENDIALOG( 'Destination Version File', 'Source Version Information|*.in|All Files|*.*' )),%RunParamDest,DEFAULT('SubVersion') #DISPLAY('e.g. Use this destination file as the input for versionres.tpl'), PROP(PROP:FontStyle, FONT:italic), PROP(PROP:FontColor, 00808080h) #DISPLAY('') #DISPLAY('Run Command Used (refreshed after generation):'), PROP(PROP:FontStyle, FONT:italic), PROP(PROP:FontColor, 00808080h) #PROMPT('Run Command:',TEXT),%RunCommand,PROP(PROP:READONLY,1), PROP(PROP:Background, 00808080h) #ENDBOXED #ENDTAB #ENDSHEET #! #AT(%AfterGeneratedApplication), WHERE(%GenerateSubVersionON=%TRUE) #IF( NOT FILEEXISTS( %RunParamDest ) ) #INSERT(%BuildCommand) #ENDIF #ENDAT #! #AT(%ShipList), WHERE(%GenerateSubVersionON=%TRUE) #REPLACE(%RunParamDest & '.version' , %RunParamDest) #REMOVE(%RunParamDest) #ENDAT #! #!**************************************************************** #GROUP(%BuildCommand) #!**************************************************************** #DECLARE(%ThisRootParam) #SET(%ThisRootParam, %RunParamRoot) #SET(%RunCommand, '"' & %RunSubWCRev & '" ' & %ThisRootParam & ' ' & %RunParamSource & ' ' & %RunParamDest) #! Update 26-01-2011 - now uses a batch file because #RUN is broken again PTSS#37470 #CREATE('GenerateSubVersion.bat') %RunCommand #CLOSE('GenerateSubVersion.bat') #RUN('GenerateSubVersion.bat'),WAIT #REPLACE(%RunParamDest & '.version' , %RunParamDest) #!**************************************************************** |
This template has only been tested with Clarion7 ABC but it should work fine in C6 as well as legacy applications.
Some screenshots that should explain how I use it:
1. Add the global extension to your application
Note the name of the “Source version file”. This is the template used as the input for SubWCRev. Here is an example of how you might want to use it:
You will need to create this “SubVersion.in” file yourself. The destination file “SubVersion” is generated for you)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
! These values are compiled into the application version file. ! The indenting is intended to match the indenting already in the destination file. PRODUCTVERSION 1,1,0,$WCREV$ VALUE "ProductName", "TestGenerateSubVersion\0" VALUE "ProductVersion", "5.1.$WCREV$.$WCDATE=%d %B %Y$" ================================== Format options for $WCDATE$: strftime Syntax: #include <ctime> size_t strftime( char *str, size_t maxsize, const char *fmt, struct tm *time ); The function strftime() formats date and time information from time to a format specified by fmt, then stores the result in str (up to maxsize characters). Certain codes may be used in fmt to specify different types of time: Code Meaning %a abbreviated weekday name (e.g. Fri) %A full weekday name (e.g. Friday) %b abbreviated month name (e.g. Oct) %B full month name (e.g. October) %c the standard date and time string %d day of the month, as a number (1-31) %H hour, 24 hour format (0-23) %I hour, 12 hour format (1-12) %j day of the year, as a number (1-366) %m month as a number (1-12). Note: some versions of Microsoft Visual C++ may use values that range from 0-11. %M minute as a number (0-59) %p locale's equivalent of AM or PM %S second as a number (0-59) %U week of the year, (0-53), where week 1 has the first Sunday %w weekday as a decimal (0-6), where Sunday is 0 %W week of the year, (0-53), where week 1 has the first Monday %x standard date string %X standard time string %y year in decimal, without the century (0-99) %Y year in decimal, with the century %Z time zone name %% a percent sign The strftime() function returns the number of characters put into str, or zero if an error occurs. Related topics: gmtime localtime time |
2. Add the global Version Resource template and configure it to use the destination file specified in the GenerateSubVersion template:
3. Compile your application and if all goes well you should now have your SubVersion build compiled into your version resource!
The SVN revision in this example is "2" and as you can see I have chosen to include the rev date as well. The date could be useful to automatically include the Copyright year for example…