Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Build version numbers

wgriggdraper_com
Beginner
992 Views

Hi All,

what is a good way to handle version numbers for builds of FortranSolutuonsin Visual Studio? Is there a tool that will automatically increment a version number each time?

TIA,

Bill

0 Kudos
5 Replies
DavidWhite
Valued Contributor II
992 Views

Hi All,

what is a good way to handle version numbers for builds of FortranSolutuonsin Visual Studio? Is there a tool that will automatically increment a version number each time?

TIA,

Bill

I have created my own app that edits the .rc file for the project. I set this up to run as a prebuild command whenever I build the release version of my project. I think I got the idea off the net somewhere, but not sure of all the details (documentation ;-/)

David

0 Kudos
rase
New Contributor I
992 Views

That's what I want for a long time. Could you be so kind and get more specific? What are you adding to the resource file? How is the preprocessing done? Thanks a lot, Wolf

0 Kudos
Steve_Nuchia
New Contributor I
992 Views
Quoting - rase

That's what I want for a long time. Could you be so kind and get more specific? What are you adding to the resource file? How is the preprocessing done? Thanks a lot, Wolf


This is a frequently discussed topic in the context of Visual Studio Team System "Team Build" and MSBuild in general. I suggest you scan the forums for those products for ideas.

Our FORTRAN is all compiled into static libraries and then linked with C++ into DLLs, the C++ projects manage the versioning. But my solution is to have the build script write an include file with #defines for the verion info which is then included by the ".rc2" files in each project. I thought about having the project files map the version number info into command-line preprocessor defines but I'd inherited the framework of the include-based solution so I kept it in place.

Be forewared: a lot of the chatter on this subject is .NET oriented, you'll have to clean what you need from the noise. And there's no consensus on one right way to do it. Real policy variations and unfortunate "culture wars" seem to drive a lot of different solutions.

-swn

0 Kudos
DavidWhite
Valued Contributor II
993 Views
Quoting - rase

That's what I want for a long time. Could you be so kind and get more specific? What are you adding to the resource file? How is the preprocessing done? Thanks a lot, Wolf

I have uploaded my source file - not sure if it got added.

Also, as stated previously, I don't know where this came from, so apologies if I have plagarised someone else's code.

To use this in VS, I add a prebuild event, like c:DevBuildIncrReleaseBuildIncr.exe ..projectfolderproject.rc

BuildIncr increments the 4th field in the version number.

Regards,

David

0 Kudos
DavidWhite
Valued Contributor II
993 Views
Third try lucky!
Program BuildIncr

USE IFPORT
IMPLICIT NONE
CHARACTER(LEN=255) :: COMMAND, FILE1, FILE2, STRING, FILE3
CHARACTER(LEN=20) :: VERSION, VER, VER2
CHARACTER(LEN=11) :: TODAY
INTEGER :: I,J,K, IERR, BUILD,V1,V2,V3,V4
LOGICAL ERROR
CALL GETARG(1,COMMAND)
FILE1=COMMAND
FILE2=TRIM(COMMAND)//"2"
ERROR = DELFILESQQ(TRIM(COMMAND)//"old")
I=INDEX(COMMAND,".",.TRUE.)
FILE3=COMMAND(1:I)//"inc"
OPEN(1,FILE=FILE1,STATUS="OLD",IOSTAT=IERR)
IF(IERR==0) THEN
OPEN(2,FILE=FILE2,IOSTAT=IERR)
IF(IERR==0) THEN
DO
READ(1,'(A)',IOSTAT=IERR) STRING
IF (IERR/=0) EXIT
I=INDEX(STRING," FILEVERSION ")
IF (I>0) THEN
VERSION=STRING(13+I:)
J=INDEX(VERSION,",",.TRUE.)
READ(VERSION(J+1:),*) BUILD
BUILD=BUILD+1
SELECT CASE(BUILD)
CASE(0:9)
WRITE(VERSION(J+1:J+1),'(I1)') BUILD
CASE(10:99)
WRITE(VERSION(J+1:J+2),'(I2)') BUILD
CASE(100:999)
WRITE(VERSION(J+1:J+3),'(I3)') BUILD
CASE(1000:)
WRITE(VERSION(J+1:J+4),'(I4)') BUILD
END SELECT
STRING(13+I:)=TRIM(VERSION)
READ(VERSION,*) V1,V2,V3,V4
J=0
SELECT CASE(V1)
CASE(0:9)
WRITE(VER(J+1:J+1),'(I1)') V1
J=J+1
CASE(10:99)
WRITE(VER(J+1:J+2),'(I2)') V1
J=J+2
CASE(100:999)
WRITE(VER(J+1:J+3),'(I3)') V1
J=J+3
CASE(1000:)
WRITE(VER(J+1:J+4),'(I4)') V1
J=J+4
END SELECT
VER(J+1:J+1)="."
J=J+1
SELECT CASE(V2)
CASE(0:9)
WRITE(VER(J+1:J+1),'(I1)') V2
J=J+1
CASE(10:99)
WRITE(VER(J+1:J+2),'(I2)') V2
J=J+2
CASE(100:999)
WRITE(VER(J+1:J+3),'(I3)') V2
J=J+3
CASE(1000:)
WRITE(VER(J+1:J+4),'(I4)') V2
J=J+4
END SELECT
VER(J+1:J+1)="."
J=J+1
SELECT CASE(V3)
CASE(0:9)
WRITE(VER(J+1:J+1),'(I1)') V3
J=J+1
CASE(10:99)
WRITE(VER(J+1:J+2),'(I2)') V3
J=J+2
CASE(100:999)
WRITE(VER(J+1:J+3),'(I3)') V3
J=J+3
CASE(1000:)
WRITE(VER(J+1:J+4),'(I4)') V3
J=J+4
END SELECT
OPEN(3,FILE=FILE3)
WRITE(3,'(A)') ' version = "'//TRIM(VER(1:J))//'"'
CALL DATE4 (TODAY)
WRITE(3,'(A)') ' CREATED = "'//TRIM(TODAY)//'"'
WRITE(3,'(A,I4)') ' BUILD = ', BUILD
CLOSE(3)
END IF
I=INDEX(STRING," PRODUCTVERSION ")
IF (I>0) THEN
STRING(16+I:)=TRIM(VERSION)
END IF
I=INDEX(STRING,'VALUE "FileVersion", "')
IF (I>0) THEN
STRING(22+I:)=TRIM(VERSION)//'"'
END IF
I=INDEX(STRING,'VALUE "ProductVersion", "')
IF (I>0) THEN
STRING(25+I:)=TRIM(VERSION)//'"'
END IF
WRITE(2,'(A)') TRIM(STRING)
END DO
CLOSE(1)
CLOSE(2)
ERROR = RENAMEFILEQQ(FILE1,TRIM(FILE1)//"old")
ERROR = RENAMEFILEQQ(FILE2,FILE1)
END IF
END IF
EndProgram BuildIncr


0 Kudos
Reply