Index: genbuild.cpp =================================================================== RCS file: /cvs/cvsnt/genbuild/genbuild.cpp,v retrieving revision 1.1.2.8.4.1 diff -c -r1.1.2.8.4.1 genbuild.cpp *** genbuild.cpp 14 Mar 2007 03:57:43 -0000 1.1.2.8.4.1 --- genbuild.cpp 23 Sep 2011 04:51:58 -0000 *************** *** 24,29 **** --- 24,48 ---- #endif #include #include + #include + #include + #ifdef _WIN32 + #include + #else + #define _tfopen(x,y) fopen(x,y) + #define _ftprintf fprintf + #define _tprintf printf + #define _ftscanf fscanf + #define _tcsstr(x,y) strstr(x,y) + #define _tcschr(x,y) strchr(x,y) + #define _tcscat(x,y) strcat(x,y) + #define _tcscpy(x,y) strcpy(x,y) + #define _T(x) x + #define TCHAR char + #endif + #include + #include "../version_no.h" + // Increase this if two releases get sent out in the same day #define BUILD_FROB 0 *************** *** 46,67 **** days -= (365*30); days += BUILD_FROB; ! FILE *f=fopen("c:\\forcebuild.txt","r"); if(f) { ! fscanf(f,"%d",&days); ! printf("Forcing build to %d\n",days); fclose(f); } else { ! printf("Generated build number %d\n",days); } FILE *fh=fopen(lpCmdLine,"r"); if (fh!=NULL) { ! fscanf(fh,"#define CVSNT_PRODUCT_BUILD %d\n",&daysin); fclose(fh); } if ((daysin!=days)||(f)) --- 65,97 ---- days -= (365*30); days += BUILD_FROB; ! FILE *f=_tfopen( ! #ifdef _WIN32 ! _T("c:\\forcebuild.txt"), ! #else ! _T("~/forcebuild.txt"), ! #endif ! _T("r") ! ); if(f) { ! _ftscanf(f,"%d",&days); ! _tprintf(_T("Forcing build to %d\n"),days); fclose(f); } else { ! _tprintf(_T("Generated build number %d\n"),days); } + if (*lpCmdLine != 0) + { + + LPTSTR lpxcconfig = (LPTSTR)malloc(sizeof(TCHAR)*(strlen(lpCmdLine)+255)); FILE *fh=fopen(lpCmdLine,"r"); if (fh!=NULL) { ! _ftscanf(fh,_T("#define CVSNT_PRODUCT_BUILD %d\n"),&daysin); fclose(fh); } if ((daysin!=days)||(f)) *************** *** 69,89 **** #ifdef _DEBUG if ((!f)&&(daysin!=0)) { ! printf("Not writing a new build number because it's a debug build\n"); } else { #endif ! fh=fopen(lpCmdLine,"w"); ! fprintf(fh,"#define CVSNT_PRODUCT_BUILD %d\n",days); fclose(fh); #ifdef _DEBUG } #endif } else ! printf("Not modifying the file because it hasn't changed\n"); return 0; } --- 99,147 ---- #ifdef _DEBUG if ((!f)&&(daysin!=0)) { ! _tprintf(_T("Not writing a new build number because it's a debug build\n")); } else { #endif ! fh=_tfopen(lpCmdLine,_T("w")); ! _ftprintf(fh,_T("#define CVSNT_PRODUCT_BUILD %d\n"),days); fclose(fh); + + if (lpxcconfig) + { + _tcscpy(lpxcconfig,lpCmdLine); + LPTSTR lpbuildh; + lpbuildh = _tcsstr(lpxcconfig,_T("build.h")); + if (lpbuildh) + { + *lpbuildh=(TCHAR)0; + _tcscat(lpxcconfig,"\\osx\\BuildNo.xcconfig"); + fh=_tfopen(lpxcconfig,_T("w")); + _ftprintf(fh,_T("//\n")); + _ftprintf(fh,_T("// BuildNo.xcconfig\n")); + _ftprintf(fh,_T("// cvsnt\n")); + _ftprintf(fh,_T("//\n")); + struct tm *tgmt = gmtime( &t ); + _ftprintf(fh,_T("// Created by genbuild on %2.2d.%2.2d.%4.4d\n"), tgmt->tm_mday, tgmt->tm_mon, tgmt->tm_year+1900); + _ftprintf(fh,_T("//\n")); + _ftprintf(fh,_T("CVSNT_Version_Buildnumber = %d\n"),days); + _ftprintf(fh,_T("CVSNT_Version_Major = %d\n"),CVSNT_PRODUCT_MAJOR); + _ftprintf(fh,_T("CVSNT_Version_Minor = %d\n"),CVSNT_PRODUCT_MINOR); + _ftprintf(fh,_T("CVSNT_Version_Rel = %02.2d\n"),CVSNT_PRODUCT_PATCHLEVEL); + fclose(fh); + } + } #ifdef _DEBUG } #endif } else ! _tprintf("Not modifying the file because it hasn't changed\n"); + } + else + _tprintf("No filename supplied\n"); return 0; }