Automatically adding date and time of compilation

Automatically adding date and time of compilation

Postby xProgrammer » Mon Jul 14, 2008 11:16 am

I wanted some automatic way of including the build date and time in my complied xHarbour/FiveLinux code. The method I came up with is as follows:

In the shell script that builds the application I get the system date and time and then pass it to the xHarbour compiler as a #define by using the -d compiler option.

The option is built as follows:

Code: Select all  Expand view
builddate=$(date +"%d/%m/%Y@%T")
strBD=""
strBD+='-dkBDATE="'
strBD+=${builddate}
strBD+='"'


and applied as follows. Note that ${1} is the parameter containing the name of the source file to be compiled.

Code: Select all  Expand view
  ./../../xharbour/bin/harbour ${1}.prg -n -I./../include -I./../../xharbour/include -q0 ${strBD}


Then you can use kBDATE in your program as you wish - in my case I include it in the title of the main window.

Regards
xProgrammer
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Mon Jul 14, 2008 11:20 am

Doug,

Nice solution, thanks for sharing it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41306
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 1 guest