cloudy trunk
Loading...
Searching...
No Matches
version.cpp
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2 * others. For conditions of distribution and use see copyright notice in license.txt */
3
4#include "cddefines.h"
5#include "date.h"
6#include "version.h"
7
8static const int CLD_MAJOR = 13;
9static const int CLD_MINOR = 5;
10static const int CLD_PATCH = 0;
11
12#ifdef SVN_REVISION
13static const char* svn_revision = SVN_REVISION;
14#else
15static const char* svn_revision = "rev_not_set";
16#endif
17
18static const string Url = "$HeadURL: svn://svn.nublado.org/cloudy/tags/release/c13.05/source/version.cpp $";
19
21{
22 static const char chMonth[12][4] =
23 { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
24
25 // first analyze the URL to determine where we live, the chVersion string is derived from that
26 // the code below is based on the following naming scheme:
27 //
28 // /branches/c08_branch -- release branch, all bug fixes are submitted here
29 //
30 // /tags/develop/c08.00_rc1 -- release candidates go here
31 //
32 // /tags/release/c08.00 -- first official release
33 // /tags/release/c08.01 -- first bug-fix rollup, etc...
34 //
35 // /tags/patch_versions/c08.00_pl00 -- identical to /tags/release/c08.00
36 // /tags/patch_versions/c08.00_pl01 -- first patch update, etc...
37 //
38 // /trunk -- this will be labeled as "experimental"
39 // /tags/stable -- ditto
40 // /branches/* -- ditto, note that "*" can be anything except c??_branch
41
42 vector<string> Part;
43 Split( Url, "/", Part, SPM_RELAX );
44 if( Part.size() >= 3 )
45 {
46 // the last two parts are "source" and "version.h $", we don't need them...
47 // the one before is the relevant identifier (e.g. "trunk", "newmole", "c08.01")
48 // for conciseness we will refer to it below as the "branch"
49 string Branch = Part[Part.size()-3];
50
51 bool lgReleaseTag = ( Url.find("/tags/release/") != string::npos );
52 bool lgPatchTag = ( Url.find("/tags/patch_versions/") != string::npos );
53 bool lgDevelopTag = ( Url.find("/tags/develop/") != string::npos );
54 // this expects a branch name like "c08_branch"
55 lgReleaseBranch = ( Url.find("/branches/") != string::npos &&
56 Branch.size() == 10 && Branch[0] == 'c' &&
57 Branch.find("_branch") != string::npos );
58
59 lgRelease = ( lgReleaseTag || lgPatchTag );
60
61 // determine if this is a beta version
62 string::size_type ptr;
63 if( lgDevelopTag && ( ptr = Branch.find( "_rc" ) ) != string::npos )
64 // this expects a branch name like "c08.00_rc1"
65 sscanf( Branch.substr( ptr+3 ).c_str(), "%ld", &nBetaVer );
66 else
67 nBetaVer = 0;
68
69 int nMajorLevel=0, nMinorLevel=0, nPatchLevel=0;
70
71 if( lgReleaseBranch || lgRelease || nBetaVer > 0 )
72 {
73 // this expects a branch name starting with "c08"
74 sscanf( Branch.substr(1,2).c_str(), "%d", &nMajorLevel );
75 if( nMajorLevel != CLD_MAJOR )
76 fprintf( ioQQQ, "PROBLEM - CLD_MAJOR mismatch, please check version.h\n" );
77 }
78
79 if( lgRelease || nBetaVer > 0 )
80 {
81 // this expects a branch name starting with "c08.01"
82 sscanf( Branch.substr(4,2).c_str(), "%d", &nMinorLevel );
83 if( nMinorLevel != CLD_MINOR )
84 fprintf( ioQQQ, "PROBLEM - CLD_MINOR mismatch, please check version.h\n" );
85 }
86
87 if( lgPatchTag )
88 {
89 // this expects a branch name like "c08.01_pl02"
90 sscanf( Branch.substr(9,2).c_str(), "%d", &nPatchLevel );
91 if( nPatchLevel != CLD_PATCH )
92 fprintf( ioQQQ, "PROBLEM - CLD_PATCH mismatch, please check version.h\n" );
93 // c08.00_pl00 is identical to release c08.00, so pass it off as the latter...
94 if( nPatchLevel == 0 )
95 lgReleaseTag = true;
96 }
97
98 string pps = ( isdigit(svn_revision[0]) ) ? "r" : "";
99
100 if( lgReleaseTag )
101 // this expects a branch name like "c08.01"
102 strncpy( chVersion, Branch.substr(1,5).c_str(), INPUT_LINE_LENGTH );
103 else if( lgPatchTag )
104 // this expects a branch name like "c08.01_pl02"
105 sprintf( chVersion, "%s (patch level %d)", Branch.substr(1,5).c_str(), nPatchLevel );
106 else if( nBetaVer > 0 )
107 // this expects a branch name like "c08.00_rc1"
108 sprintf( chVersion, "%s beta %ld (prerelease)", Branch.substr(1,5).c_str(), nBetaVer );
109 else if( lgReleaseBranch )
110 // this expects a branch name like "c08_branch"
111 sprintf( chVersion, "(%s, %s%s, prerelease)", Branch.c_str(), pps.c_str(), svn_revision );
112 else
113 // the branch name can be anything except "c??_branch"
114 sprintf( chVersion, "(%s, %s%s, experimental)", Branch.c_str(), pps.c_str(), svn_revision );
115 }
116 else
117 {
118 // create a default version string in case HeadURL was not expanded
119
120 /* is this a release branch? */
121 lgReleaseBranch = true;
122 /* is this a release version? */
123 lgRelease = true;
124
125 /* is this a beta version? 0 for no
126 * if this is non-zero then lgRelease above should be false */
127 nBetaVer = 0;
128
129 if( lgRelease )
130 {
131 if( CLD_PATCH > 0 )
132 sprintf( chVersion, "%2.2i.%2.2i (patch level %d)",
134 else
135 sprintf( chVersion, "%2.2i.%2.2i", CLD_MAJOR, CLD_MINOR );
136 }
137 else if( nBetaVer > 0 )
138 {
139 sprintf( chVersion, "%2.2i.%2.2i beta %ld (prerelease)",
141 }
142 else
143 {
144 sprintf( chVersion, "%2.2i.%2.2i.%2.2i", YEAR%100, MONTH+1, DAY );
145 }
146 }
147
148 sprintf( chDate, "%2.2i%3.3s%2.2i", YEAR%100, chMonth[MONTH], DAY );
149
150 char mode[8];
151 if( sizeof(int) == 4 && sizeof(long) == 4 && sizeof(long*) == 4 )
152 strncpy( mode, "ILP32", sizeof(mode) );
153 else if( sizeof(int) == 4 && sizeof(long) == 4 && sizeof(long*) == 8 )
154 strncpy( mode, "IL32P64", sizeof(mode) );
155 else if( sizeof(int) == 4 && sizeof(long) == 8 && sizeof(long*) == 8 )
156 strncpy( mode, "I32LP64", sizeof(mode) );
157 else if( sizeof(int) == 8 && sizeof(long) == 8 && sizeof(long*) == 8 )
158 strncpy( mode, "ILP64", sizeof(mode) );
159 else
160 strncpy( mode, "UNKN", sizeof(mode) );
161
162 bool flag[2];
163 flag[0] = ( cpu.i().min_float()/2.f > 0.f );
164 flag[1] = ( cpu.i().min_double()/2. > 0. );
165
166 /* now generate info on how we were compiled, including compiler version */
167 sprintf( chInfo,
168 "Cloudy compiled on %s in OS %s using the %s %i compiler. Mode %s, "
169 "denormalized float: %c double: %c.",
170 __DATE__, __OS, __COMP, __COMP_VER, mode, TorF(flag[0]), TorF(flag[1]) );
171}
FILE * ioQQQ
Definition cddefines.cpp:7
const int INPUT_LINE_LENGTH
Definition cddefines.h:254
char TorF(bool l)
Definition cddefines.h:710
void Split(const string &str, const string &sep, vector< string > &lst, split_mode mode)
Definition service.cpp:106
@ SPM_RELAX
Definition cddefines.h:1321
char chVersion[INPUT_LINE_LENGTH]
Definition version.h:19
char chDate[INPUT_LINE_LENGTH]
Definition version.h:16
long int nBetaVer
Definition version.h:22
bool lgRelease
Definition version.h:28
bool lgReleaseBranch
Definition version.h:25
char chInfo[INPUT_LINE_LENGTH]
Definition version.h:32
#define __OS
Definition cpu.h:555
static t_cpu cpu
Definition cpu.h:355
#define __COMP
Definition cpu.h:479
#define __COMP_VER
Definition cpu.h:480
#define MONTH
Definition date.h:16
#define DAY
Definition date.h:18
#define YEAR
Definition date.h:14
static const string Url
Definition version.cpp:18
static const int CLD_MAJOR
Definition version.cpp:8
static const int CLD_PATCH
Definition version.cpp:10
static const char * svn_revision
Definition version.cpp:15
static const int CLD_MINOR
Definition version.cpp:9