| Index: buildtool/buildtool.cpp |
| — | — | @@ -1,331 +0,0 @@ |
| 2 | | -// DXGL
|
| 3 | | -// Copyright (C) 2012-2013 William Feely
|
| 4 | | -
|
| 5 | | -// This library is free software; you can redistribute it and/or
|
| 6 | | -// modify it under the terms of the GNU Lesser General Public
|
| 7 | | -// License as published by the Free Software Foundation; either
|
| 8 | | -// version 2.1 of the License, or (at your option) any later version.
|
| 9 | | -
|
| 10 | | -// This library is distributed in the hope that it will be useful,
|
| 11 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | | -// Lesser General Public License for more details.
|
| 14 | | -
|
| 15 | | -// You should have received a copy of the GNU Lesser General Public
|
| 16 | | -// License along with this library; if not, write to the Free Software
|
| 17 | | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | | -
|
| 19 | | -#define _CRT_SECURE_NO_DEPRECATE
|
| 20 | | -#include <cstdio>
|
| 21 | | -#include <iostream>
|
| 22 | | -#include <windows.h>
|
| 23 | | -#include "../common/releasever.h"
|
| 24 | | -
|
| 25 | | -using namespace std;
|
| 26 | | -
|
| 27 | | -int GetSVNRev(char *path)
|
| 28 | | -{
|
| 29 | | - char pathbase[FILENAME_MAX+1];
|
| 30 | | - char pathin[FILENAME_MAX+1];
|
| 31 | | - char pathout[FILENAME_MAX+1];
|
| 32 | | - strncpy(pathbase,path,FILENAME_MAX);
|
| 33 | | - strncpy(pathin,path,FILENAME_MAX);
|
| 34 | | - pathin[FILENAME_MAX] = 0;
|
| 35 | | - strncpy(pathout,path,FILENAME_MAX);
|
| 36 | | - pathout[FILENAME_MAX] = 0;
|
| 37 | | - pathbase[strlen(pathbase)-7] = 0;
|
| 38 | | - strncat(pathin,"\\rev.in",FILENAME_MAX-strlen(pathin));
|
| 39 | | - pathin[FILENAME_MAX] = 0;
|
| 40 | | - strncat(pathout,"\\rev",FILENAME_MAX-strlen(pathin));
|
| 41 | | - pathout[FILENAME_MAX] = 0;
|
| 42 | | - HKEY hKey;
|
| 43 | | - char svnpath[(MAX_PATH+1)*4];
|
| 44 | | - bool foundsvn = false;
|
| 45 | | - DWORD buffersize = MAX_PATH+1;
|
| 46 | | - if(RegOpenKeyExA(HKEY_LOCAL_MACHINE,"Software\\TortoiseSVN",0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
| 47 | | - {
|
| 48 | | - if(RegQueryValueExA(hKey,"Directory",NULL,NULL,(LPBYTE)svnpath,&buffersize) == ERROR_SUCCESS)
|
| 49 | | - {
|
| 50 | | - foundsvn = true;
|
| 51 | | - strcat(svnpath,"bin\\subwcrev.exe ");
|
| 52 | | - strcat(svnpath,pathbase);
|
| 53 | | - strcat(svnpath," ");
|
| 54 | | - strcat(svnpath,pathin);
|
| 55 | | - strcat(svnpath," ");
|
| 56 | | - strcat(svnpath,pathout);
|
| 57 | | - STARTUPINFOA startinfo;
|
| 58 | | - ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| 59 | | - startinfo.cb = sizeof(STARTUPINFO);
|
| 60 | | - PROCESS_INFORMATION process;
|
| 61 | | - cout << svnpath << endl;
|
| 62 | | - if(CreateProcessA(NULL,svnpath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| 63 | | - {
|
| 64 | | - WaitForSingleObject(process.hProcess,INFINITE);
|
| 65 | | - CloseHandle(process.hProcess);
|
| 66 | | - CloseHandle(process.hThread);
|
| 67 | | - FILE *revfile = fopen(pathout,"r");
|
| 68 | | - if(!revfile)
|
| 69 | | - {
|
| 70 | | - cout << "WARNING: Failed to create revision file" << endl;
|
| 71 | | - RegCloseKey(hKey);
|
| 72 | | - return 0;
|
| 73 | | - }
|
| 74 | | - char revstring[32];
|
| 75 | | - fgets(revstring,32,revfile);
|
| 76 | | - fclose(revfile);
|
| 77 | | - RegCloseKey(hKey);
|
| 78 | | - return atoi(revstring);
|
| 79 | | - }
|
| 80 | | - else foundsvn = false;
|
| 81 | | - }
|
| 82 | | - RegCloseKey(hKey);
|
| 83 | | - }
|
| 84 | | - if(!foundsvn)
|
| 85 | | - {
|
| 86 | | - int result = MessageBoxA(NULL,"Could not find subwcrev.exe, would you like to download TortoiseSVN?","TortoiseSVN not found",
|
| 87 | | - MB_YESNO|MB_ICONWARNING);
|
| 88 | | - if(result == IDYES)
|
| 89 | | - {
|
| 90 | | - cout << "ERROR: Please try again after installing TortoiseSVN." << endl;
|
| 91 | | - ShellExecuteA(NULL,"open","http://tortoisesvn.net/",NULL,NULL,SW_SHOWNORMAL);
|
| 92 | | - exit(-1);
|
| 93 | | - }
|
| 94 | | - else return 0;
|
| 95 | | - }
|
| 96 | | - return 0;
|
| 97 | | -}
|
| 98 | | -
|
| 99 | | -int ProcessHeaders(char *path)
|
| 100 | | -{
|
| 101 | | - char pathin[FILENAME_MAX+1];
|
| 102 | | - char pathout[FILENAME_MAX+1];
|
| 103 | | - char buffer[1024];
|
| 104 | | - char verbuffer[20];
|
| 105 | | - char numstring[16];
|
| 106 | | - char *findptr;
|
| 107 | | - int revision = GetSVNRev(path);
|
| 108 | | - strncpy(pathin,path,FILENAME_MAX);
|
| 109 | | - pathin[FILENAME_MAX] = 0;
|
| 110 | | - strncpy(pathout,path,FILENAME_MAX);
|
| 111 | | - pathout[FILENAME_MAX] = 0;
|
| 112 | | - strncat(pathin,"\\version.h.in",FILENAME_MAX-strlen(pathin));
|
| 113 | | - pathin[FILENAME_MAX] = 0;
|
| 114 | | - strncat(pathout,"\\version.h",FILENAME_MAX-strlen(pathin));
|
| 115 | | - pathout[FILENAME_MAX] = 0;
|
| 116 | | - FILE *filein = fopen(pathin,"r");
|
| 117 | | - if(!filein)
|
| 118 | | - {
|
| 119 | | - cout << "ERROR: Cannot read file " << pathin << endl;
|
| 120 | | - return errno;
|
| 121 | | - }
|
| 122 | | - FILE *fileout = fopen(pathout,"w");
|
| 123 | | - if(!fileout)
|
| 124 | | - {
|
| 125 | | - cout << "ERROR: Cannot create file " << pathin << endl;
|
| 126 | | - return errno;
|
| 127 | | - }
|
| 128 | | - while(fgets(buffer,1024,filein))
|
| 129 | | - {
|
| 130 | | - findptr = strstr(buffer,"$MAJOR");
|
| 131 | | - if(findptr) strncpy(findptr,STR(DXGLMAJORVER) "\n",6);
|
| 132 | | - findptr = strstr(buffer,"$MINOR");
|
| 133 | | - if(findptr) strncpy(findptr,STR(DXGLMINORVER) "\n",6);
|
| 134 | | - findptr = strstr(buffer,"$POINT");
|
| 135 | | - if(findptr) strncpy(findptr,STR(DXGLPOINTVER) "\n",6);
|
| 136 | | - findptr = strstr(buffer,"$REVISION");
|
| 137 | | - if(findptr)
|
| 138 | | - {
|
| 139 | | - _itoa(revision,verbuffer,10);
|
| 140 | | - strcat(verbuffer,"\n");
|
| 141 | | - strncpy(findptr,verbuffer,9);
|
| 142 | | - }
|
| 143 | | - findptr = strstr(buffer,"$VERSTRING");
|
| 144 | | - if(findptr)
|
| 145 | | - {
|
| 146 | | - if(revision)
|
| 147 | | - {
|
| 148 | | - strcpy(verbuffer, "\"");
|
| 149 | | - strcat(verbuffer,DXGLSTRVER);
|
| 150 | | - strcat(verbuffer," r");
|
| 151 | | - _itoa(revision,numstring,10);
|
| 152 | | - strcat(verbuffer,numstring);
|
| 153 | | - strcat(verbuffer,"\"");
|
| 154 | | - strncpy(findptr,verbuffer,22);
|
| 155 | | - }
|
| 156 | | - else strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
|
| 157 | | - }
|
| 158 | | - fputs(buffer,fileout);
|
| 159 | | - }
|
| 160 | | - fclose(filein);
|
| 161 | | - filein = NULL;
|
| 162 | | - fclose(fileout);
|
| 163 | | - fileout = NULL;
|
| 164 | | - strncpy(pathin,path,FILENAME_MAX);
|
| 165 | | - pathin[FILENAME_MAX] = 0;
|
| 166 | | - strncpy(pathout,path,FILENAME_MAX);
|
| 167 | | - pathout[FILENAME_MAX] = 0;
|
| 168 | | - strncat(pathin,"\\version.nsh.in",FILENAME_MAX-strlen(pathin));
|
| 169 | | - pathin[FILENAME_MAX] = 0;
|
| 170 | | - strncat(pathout,"\\version.nsh",FILENAME_MAX-strlen(pathin));
|
| 171 | | - pathout[FILENAME_MAX] = 0;
|
| 172 | | - filein = fopen(pathin,"r");
|
| 173 | | - if(!filein)
|
| 174 | | - {
|
| 175 | | - cout << "ERROR: Cannot read file " << pathin << endl;
|
| 176 | | - return errno;
|
| 177 | | - }
|
| 178 | | - fileout = fopen(pathout,"w");
|
| 179 | | - if(!fileout)
|
| 180 | | - {
|
| 181 | | - cout << "ERROR: Cannot create file " << pathin << endl;
|
| 182 | | - return errno;
|
| 183 | | - }
|
| 184 | | - while(fgets(buffer,1024,filein))
|
| 185 | | - {
|
| 186 | | - findptr = strstr(buffer,"$PRODUCTVERSTRING");
|
| 187 | | - if(findptr) strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
|
| 188 | | - findptr = strstr(buffer,"$PRODUCTREVISION");
|
| 189 | | - if(findptr)
|
| 190 | | - {
|
| 191 | | - if(revision)
|
| 192 | | - {
|
| 193 | | - strcpy(verbuffer,"\"");
|
| 194 | | - _itoa(revision,numstring,10);
|
| 195 | | - strcat(verbuffer,numstring);
|
| 196 | | - strcat(verbuffer,"\"\n");
|
| 197 | | - strncpy(findptr,verbuffer,17);
|
| 198 | | - }
|
| 199 | | - else strncpy(findptr,"\"\"\n",17);
|
| 200 | | - }
|
| 201 | | -#ifdef _DEBUG
|
| 202 | | - if(strstr(buffer,";!define _DEBUG")) strcpy(buffer,"!define _DEBUG");
|
| 203 | | -#endif
|
| 204 | | - fputs(buffer,fileout);
|
| 205 | | - }
|
| 206 | | - fclose(filein);
|
| 207 | | - filein = NULL;
|
| 208 | | - fclose(fileout);
|
| 209 | | - fileout = NULL;
|
| 210 | | - return 0;
|
| 211 | | -}
|
| 212 | | -
|
| 213 | | -int MakeHelp(char *path)
|
| 214 | | -{
|
| 215 | | - HKEY hKey;
|
| 216 | | - bool foundhhc = false;
|
| 217 | | - char hhcpath[(MAX_PATH+1)*2];
|
| 218 | | - DWORD buffersize = MAX_PATH+1;
|
| 219 | | - if(RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\HTML Help Workshop",0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
| 220 | | - {
|
| 221 | | - if(RegQueryValueExA(hKey,"InstallDir",NULL,NULL,(LPBYTE)hhcpath,&buffersize) == ERROR_SUCCESS)
|
| 222 | | - {
|
| 223 | | - strcat(hhcpath,"\\hhc.exe");
|
| 224 | | - PROCESS_INFORMATION process;
|
| 225 | | - STARTUPINFOA startinfo;
|
| 226 | | - ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| 227 | | - startinfo.cb = sizeof(STARTUPINFOA);
|
| 228 | | - strcat(hhcpath," ");
|
| 229 | | - strcat(hhcpath,path);
|
| 230 | | - if(CreateProcessA(NULL,hhcpath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| 231 | | - {
|
| 232 | | - foundhhc = true;
|
| 233 | | - WaitForSingleObject(process.hProcess,INFINITE);
|
| 234 | | - CloseHandle(process.hProcess);
|
| 235 | | - CloseHandle(process.hThread);
|
| 236 | | - }
|
| 237 | | - }
|
| 238 | | - RegCloseKey(hKey);
|
| 239 | | - }
|
| 240 | | - if(!foundhhc)
|
| 241 | | - {
|
| 242 | | - int result = MessageBoxA(NULL,"Could not find HTML Help Workshop, would you like to download it?","HTML Help Workshop not found",
|
| 243 | | - MB_YESNO|MB_ICONERROR);
|
| 244 | | - if(result == IDYES) ShellExecuteA(NULL,"open", "http://www.microsoft.com/en-us/download/details.aspx?id=21138"
|
| 245 | | - ,NULL,NULL,SW_SHOWNORMAL);
|
| 246 | | - cout << "ERROR: HTML Help Compiler not found." << endl;
|
| 247 | | - return -1;
|
| 248 | | - }
|
| 249 | | - return 0;
|
| 250 | | -}
|
| 251 | | -
|
| 252 | | -int MakeInstaller(char *path)
|
| 253 | | -{
|
| 254 | | - HKEY hKey;
|
| 255 | | - bool foundnsis = false;
|
| 256 | | - char nsispath[(MAX_PATH+1)*2];
|
| 257 | | - DWORD buffersize = MAX_PATH+1;
|
| 258 | | - if(RegOpenKeyExA(HKEY_LOCAL_MACHINE,"Software\\NSIS",0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
| 259 | | - {
|
| 260 | | - if(RegQueryValueExA(hKey,"",NULL,NULL,(LPBYTE)nsispath,&buffersize) == ERROR_SUCCESS)
|
| 261 | | - {
|
| 262 | | - strcat(nsispath,"\\makensis.exe");
|
| 263 | | - PROCESS_INFORMATION process;
|
| 264 | | - STARTUPINFOA startinfo;
|
| 265 | | - ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| 266 | | - startinfo.cb = sizeof(STARTUPINFOA);
|
| 267 | | - strcat(nsispath," ");
|
| 268 | | - strcat(nsispath,path);
|
| 269 | | - if(CreateProcessA(NULL,nsispath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| 270 | | - {
|
| 271 | | - foundnsis = true;
|
| 272 | | - WaitForSingleObject(process.hProcess,INFINITE);
|
| 273 | | - CloseHandle(process.hProcess);
|
| 274 | | - CloseHandle(process.hThread);
|
| 275 | | - }
|
| 276 | | - }
|
| 277 | | - RegCloseKey(hKey);
|
| 278 | | - }
|
| 279 | | - if(!foundnsis)
|
| 280 | | - {
|
| 281 | | - int result = MessageBoxA(NULL,"Could not find NSIS, would you like to download it?","NSIS not found",
|
| 282 | | - MB_YESNO|MB_ICONERROR);
|
| 283 | | - if(result == IDYES) ShellExecuteA(NULL,"open","http://nsis.sourceforge.net/Main_Page",NULL,NULL,SW_SHOWNORMAL);
|
| 284 | | - cout << "ERROR: NSIS not found." << endl;
|
| 285 | | - return -1;
|
| 286 | | - }
|
| 287 | | - return 0;
|
| 288 | | -}
|
| 289 | | -
|
| 290 | | -
|
| 291 | | -int main(int argc, char *argv[])
|
| 292 | | -{
|
| 293 | | -
|
| 294 | | - cout << "DXGL Build Tool, version " << DXGLSTRVER << endl;
|
| 295 | | -#ifdef _DEBUG
|
| 296 | | - cout << "Debug version." << endl;
|
| 297 | | -#endif
|
| 298 | | - if(argc > 1)
|
| 299 | | - {
|
| 300 | | - if(!strcmp(argv[1],"makeheader"))
|
| 301 | | - {
|
| 302 | | - if(argc < 3)
|
| 303 | | - {
|
| 304 | | - cout << "ERROR: No working directory specified." << endl;
|
| 305 | | - return 1;
|
| 306 | | - }
|
| 307 | | - return ProcessHeaders(argv[2]);
|
| 308 | | - }
|
| 309 | | - if(!strcmp(argv[1],"makehelp"))
|
| 310 | | - {
|
| 311 | | - if(argc < 3)
|
| 312 | | - {
|
| 313 | | - cout << "ERROR: No working directory specified." << endl;
|
| 314 | | - return 1;
|
| 315 | | - }
|
| 316 | | - return MakeHelp(argv[2]);
|
| 317 | | - }
|
| 318 | | - if(!strcmp(argv[1],"makeinstaller"))
|
| 319 | | - {
|
| 320 | | - if(argc < 3)
|
| 321 | | - {
|
| 322 | | - cout << "ERROR: No working directory specified." << endl;
|
| 323 | | - return 1;
|
| 324 | | - }
|
| 325 | | - return MakeInstaller(argv[2]);
|
| 326 | | - }
|
| 327 | | - }
|
| 328 | | - else
|
| 329 | | - {
|
| 330 | | - }
|
| 331 | | - return 0;
|
| 332 | | -}
|
| Index: buildtool/buildtool.c |
| — | — | @@ -0,0 +1,337 @@ |
| | 2 | +// DXGL
|
| | 3 | +// Copyright (C) 2012-2013 William Feely
|
| | 4 | +
|
| | 5 | +// This library is free software; you can redistribute it and/or
|
| | 6 | +// modify it under the terms of the GNU Lesser General Public
|
| | 7 | +// License as published by the Free Software Foundation; either
|
| | 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| | 9 | +
|
| | 10 | +// This library is distributed in the hope that it will be useful,
|
| | 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| | 13 | +// Lesser General Public License for more details.
|
| | 14 | +
|
| | 15 | +// You should have received a copy of the GNU Lesser General Public
|
| | 16 | +// License along with this library; if not, write to the Free Software
|
| | 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| | 18 | +
|
| | 19 | +#define _CRT_SECURE_NO_DEPRECATE
|
| | 20 | +#include <stdio.h>
|
| | 21 | +#include <windows.h>
|
| | 22 | +#include "../common/releasever.h"
|
| | 23 | +
|
| | 24 | +
|
| | 25 | +int GetSVNRev(char *path)
|
| | 26 | +{
|
| | 27 | + char pathbase[FILENAME_MAX+1];
|
| | 28 | + char pathin[FILENAME_MAX+1];
|
| | 29 | + char pathout[FILENAME_MAX+1];
|
| | 30 | + HKEY hKey;
|
| | 31 | + BOOL foundsvn = FALSE;
|
| | 32 | + char svnpath[(MAX_PATH + 1) * 4];
|
| | 33 | + DWORD buffersize = MAX_PATH + 1;
|
| | 34 | + STARTUPINFOA startinfo;
|
| | 35 | + PROCESS_INFORMATION process;
|
| | 36 | + FILE *revfile;
|
| | 37 | + char revstring[32];
|
| | 38 | + strncpy(pathbase, path, FILENAME_MAX);
|
| | 39 | + strncpy(pathin,path,FILENAME_MAX);
|
| | 40 | + pathin[FILENAME_MAX] = 0;
|
| | 41 | + strncpy(pathout,path,FILENAME_MAX);
|
| | 42 | + pathout[FILENAME_MAX] = 0;
|
| | 43 | + pathbase[strlen(pathbase)-7] = 0;
|
| | 44 | + strncat(pathin,"\\rev.in",FILENAME_MAX-strlen(pathin));
|
| | 45 | + pathin[FILENAME_MAX] = 0;
|
| | 46 | + strncat(pathout,"\\rev",FILENAME_MAX-strlen(pathin));
|
| | 47 | + pathout[FILENAME_MAX] = 0;
|
| | 48 | + if(RegOpenKeyExA(HKEY_LOCAL_MACHINE,"Software\\TortoiseSVN",0,KEY_READ,&hKey) == ERROR_SUCCESS)
|
| | 49 | + {
|
| | 50 | + if(RegQueryValueExA(hKey,"Directory",NULL,NULL,(LPBYTE)svnpath,&buffersize) == ERROR_SUCCESS)
|
| | 51 | + {
|
| | 52 | + foundsvn = TRUE;
|
| | 53 | + strcat(svnpath,"bin\\subwcrev.exe ");
|
| | 54 | + strcat(svnpath,pathbase);
|
| | 55 | + strcat(svnpath," ");
|
| | 56 | + strcat(svnpath,pathin);
|
| | 57 | + strcat(svnpath," ");
|
| | 58 | + strcat(svnpath,pathout);
|
| | 59 | + ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| | 60 | + startinfo.cb = sizeof(STARTUPINFO);
|
| | 61 | + puts(svnpath);
|
| | 62 | + if(CreateProcessA(NULL,svnpath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| | 63 | + {
|
| | 64 | + WaitForSingleObject(process.hProcess,INFINITE);
|
| | 65 | + CloseHandle(process.hProcess);
|
| | 66 | + CloseHandle(process.hThread);
|
| | 67 | + revfile = fopen(pathout,"r");
|
| | 68 | + if(!revfile)
|
| | 69 | + {
|
| | 70 | + puts("WARNING: Failed to create revision file");
|
| | 71 | + RegCloseKey(hKey);
|
| | 72 | + return 0;
|
| | 73 | + }
|
| | 74 | + fgets(revstring,32,revfile);
|
| | 75 | + fclose(revfile);
|
| | 76 | + RegCloseKey(hKey);
|
| | 77 | + return atoi(revstring);
|
| | 78 | + }
|
| | 79 | + else foundsvn = FALSE;
|
| | 80 | + }
|
| | 81 | + RegCloseKey(hKey);
|
| | 82 | + }
|
| | 83 | + if(!foundsvn)
|
| | 84 | + {
|
| | 85 | + int result = MessageBoxA(NULL,"Could not find subwcrev.exe, would you like to download TortoiseSVN?","TortoiseSVN not found",
|
| | 86 | + MB_YESNO|MB_ICONWARNING);
|
| | 87 | + if(result == IDYES)
|
| | 88 | + {
|
| | 89 | + puts("ERROR: Please try again after installing TortoiseSVN.");
|
| | 90 | + ShellExecuteA(NULL,"open","http://tortoisesvn.net/",NULL,NULL,SW_SHOWNORMAL);
|
| | 91 | + exit(-1);
|
| | 92 | + }
|
| | 93 | + else return 0;
|
| | 94 | + }
|
| | 95 | + return 0;
|
| | 96 | +}
|
| | 97 | +
|
| | 98 | +int ProcessHeaders(char *path)
|
| | 99 | +{
|
| | 100 | + char pathin[FILENAME_MAX+1];
|
| | 101 | + char pathout[FILENAME_MAX+1];
|
| | 102 | + char buffer[1024];
|
| | 103 | + char verbuffer[20];
|
| | 104 | + char numstring[16];
|
| | 105 | + char *findptr;
|
| | 106 | + FILE *filein;
|
| | 107 | + FILE *fileout;
|
| | 108 | + int revision = GetSVNRev(path);
|
| | 109 | + strncpy(pathin,path,FILENAME_MAX);
|
| | 110 | + pathin[FILENAME_MAX] = 0;
|
| | 111 | + strncpy(pathout,path,FILENAME_MAX);
|
| | 112 | + pathout[FILENAME_MAX] = 0;
|
| | 113 | + strncat(pathin,"\\version.h.in",FILENAME_MAX-strlen(pathin));
|
| | 114 | + pathin[FILENAME_MAX] = 0;
|
| | 115 | + strncat(pathout,"\\version.h",FILENAME_MAX-strlen(pathin));
|
| | 116 | + pathout[FILENAME_MAX] = 0;
|
| | 117 | + filein = fopen(pathin,"r");
|
| | 118 | + if(!filein)
|
| | 119 | + {
|
| | 120 | + fputs("ERROR: Cannot read file ", stdout);
|
| | 121 | + puts(pathin);
|
| | 122 | + return errno;
|
| | 123 | + }
|
| | 124 | + fileout = fopen(pathout,"w");
|
| | 125 | + if(!fileout)
|
| | 126 | + {
|
| | 127 | + fputs("ERROR: Cannot create file ", stdout);
|
| | 128 | + puts(pathin);
|
| | 129 | + return errno;
|
| | 130 | + }
|
| | 131 | + while(fgets(buffer,1024,filein))
|
| | 132 | + {
|
| | 133 | + findptr = strstr(buffer,"$MAJOR");
|
| | 134 | + if(findptr) strncpy(findptr,STR(DXGLMAJORVER) "\n",6);
|
| | 135 | + findptr = strstr(buffer,"$MINOR");
|
| | 136 | + if(findptr) strncpy(findptr,STR(DXGLMINORVER) "\n",6);
|
| | 137 | + findptr = strstr(buffer,"$POINT");
|
| | 138 | + if(findptr) strncpy(findptr,STR(DXGLPOINTVER) "\n",6);
|
| | 139 | + findptr = strstr(buffer,"$REVISION");
|
| | 140 | + if(findptr)
|
| | 141 | + {
|
| | 142 | + _itoa(revision,verbuffer,10);
|
| | 143 | + strcat(verbuffer,"\n");
|
| | 144 | + strncpy(findptr,verbuffer,9);
|
| | 145 | + }
|
| | 146 | + findptr = strstr(buffer,"$VERSTRING");
|
| | 147 | + if(findptr)
|
| | 148 | + {
|
| | 149 | + if(revision)
|
| | 150 | + {
|
| | 151 | + strcpy(verbuffer, "\"");
|
| | 152 | + strcat(verbuffer,DXGLSTRVER);
|
| | 153 | + strcat(verbuffer," r");
|
| | 154 | + _itoa(revision,numstring,10);
|
| | 155 | + strcat(verbuffer,numstring);
|
| | 156 | + strcat(verbuffer,"\"");
|
| | 157 | + strncpy(findptr,verbuffer,22);
|
| | 158 | + }
|
| | 159 | + else strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
|
| | 160 | + }
|
| | 161 | + fputs(buffer,fileout);
|
| | 162 | + }
|
| | 163 | + fclose(filein);
|
| | 164 | + filein = NULL;
|
| | 165 | + fclose(fileout);
|
| | 166 | + fileout = NULL;
|
| | 167 | + strncpy(pathin,path,FILENAME_MAX);
|
| | 168 | + pathin[FILENAME_MAX] = 0;
|
| | 169 | + strncpy(pathout,path,FILENAME_MAX);
|
| | 170 | + pathout[FILENAME_MAX] = 0;
|
| | 171 | + strncat(pathin,"\\version.nsh.in",FILENAME_MAX-strlen(pathin));
|
| | 172 | + pathin[FILENAME_MAX] = 0;
|
| | 173 | + strncat(pathout,"\\version.nsh",FILENAME_MAX-strlen(pathin));
|
| | 174 | + pathout[FILENAME_MAX] = 0;
|
| | 175 | + filein = fopen(pathin,"r");
|
| | 176 | + if(!filein)
|
| | 177 | + {
|
| | 178 | + fputs("ERROR: Cannot read file ", stdout);
|
| | 179 | + puts(pathin);
|
| | 180 | + return errno;
|
| | 181 | + }
|
| | 182 | + fileout = fopen(pathout,"w");
|
| | 183 | + if(!fileout)
|
| | 184 | + {
|
| | 185 | + fputs("ERROR: Cannot create file ", stdout);
|
| | 186 | + puts(pathin);
|
| | 187 | + return errno;
|
| | 188 | + }
|
| | 189 | + while(fgets(buffer,1024,filein))
|
| | 190 | + {
|
| | 191 | + findptr = strstr(buffer,"$PRODUCTVERSTRING");
|
| | 192 | + if(findptr) strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
|
| | 193 | + findptr = strstr(buffer,"$PRODUCTREVISION");
|
| | 194 | + if(findptr)
|
| | 195 | + {
|
| | 196 | + if(revision)
|
| | 197 | + {
|
| | 198 | + strcpy(verbuffer,"\"");
|
| | 199 | + _itoa(revision,numstring,10);
|
| | 200 | + strcat(verbuffer,numstring);
|
| | 201 | + strcat(verbuffer,"\"\n");
|
| | 202 | + strncpy(findptr,verbuffer,17);
|
| | 203 | + }
|
| | 204 | + else strncpy(findptr,"\"\"\n",17);
|
| | 205 | + }
|
| | 206 | +#ifdef _DEBUG
|
| | 207 | + if(strstr(buffer,";!define _DEBUG")) strcpy(buffer,"!define _DEBUG");
|
| | 208 | +#endif
|
| | 209 | + fputs(buffer,fileout);
|
| | 210 | + }
|
| | 211 | + fclose(filein);
|
| | 212 | + filein = NULL;
|
| | 213 | + fclose(fileout);
|
| | 214 | + fileout = NULL;
|
| | 215 | + return 0;
|
| | 216 | +}
|
| | 217 | +
|
| | 218 | +int MakeHelp(char *path)
|
| | 219 | +{
|
| | 220 | + HKEY hKey;
|
| | 221 | + BOOL foundhhc = FALSE;
|
| | 222 | + char hhcpath[(MAX_PATH+1)*2];
|
| | 223 | + DWORD buffersize = MAX_PATH+1;
|
| | 224 | + PROCESS_INFORMATION process;
|
| | 225 | + STARTUPINFOA startinfo;
|
| | 226 | + if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\HTML Help Workshop", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
| | 227 | + {
|
| | 228 | + if(RegQueryValueExA(hKey,"InstallDir",NULL,NULL,(LPBYTE)hhcpath,&buffersize) == ERROR_SUCCESS)
|
| | 229 | + {
|
| | 230 | + strcat(hhcpath,"\\hhc.exe");
|
| | 231 | + ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| | 232 | + startinfo.cb = sizeof(STARTUPINFOA);
|
| | 233 | + strcat(hhcpath," ");
|
| | 234 | + strcat(hhcpath,path);
|
| | 235 | + if(CreateProcessA(NULL,hhcpath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| | 236 | + {
|
| | 237 | + foundhhc = TRUE;
|
| | 238 | + WaitForSingleObject(process.hProcess,INFINITE);
|
| | 239 | + CloseHandle(process.hProcess);
|
| | 240 | + CloseHandle(process.hThread);
|
| | 241 | + }
|
| | 242 | + }
|
| | 243 | + RegCloseKey(hKey);
|
| | 244 | + }
|
| | 245 | + if(!foundhhc)
|
| | 246 | + {
|
| | 247 | + int result = MessageBoxA(NULL,"Could not find HTML Help Workshop, would you like to download it?","HTML Help Workshop not found",
|
| | 248 | + MB_YESNO|MB_ICONERROR);
|
| | 249 | + if(result == IDYES) ShellExecuteA(NULL,"open", "http://www.microsoft.com/en-us/download/details.aspx?id=21138"
|
| | 250 | + ,NULL,NULL,SW_SHOWNORMAL);
|
| | 251 | + puts("ERROR: HTML Help Compiler not found.");
|
| | 252 | + return -1;
|
| | 253 | + }
|
| | 254 | + return 0;
|
| | 255 | +}
|
| | 256 | +
|
| | 257 | +int MakeInstaller(char *path)
|
| | 258 | +{
|
| | 259 | + HKEY hKey;
|
| | 260 | + BOOL foundnsis = FALSE;
|
| | 261 | + char nsispath[(MAX_PATH+1)*2];
|
| | 262 | + DWORD buffersize = MAX_PATH+1;
|
| | 263 | + PROCESS_INFORMATION process;
|
| | 264 | + STARTUPINFOA startinfo;
|
| | 265 | + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\NSIS", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
| | 266 | + {
|
| | 267 | + if(RegQueryValueExA(hKey,"",NULL,NULL,(LPBYTE)nsispath,&buffersize) == ERROR_SUCCESS)
|
| | 268 | + {
|
| | 269 | + strcat(nsispath,"\\makensis.exe");
|
| | 270 | + ZeroMemory(&startinfo,sizeof(STARTUPINFOA));
|
| | 271 | + startinfo.cb = sizeof(STARTUPINFOA);
|
| | 272 | + strcat(nsispath," ");
|
| | 273 | + strcat(nsispath,path);
|
| | 274 | + if(CreateProcessA(NULL,nsispath,NULL,NULL,FALSE,0,NULL,NULL,&startinfo,&process))
|
| | 275 | + {
|
| | 276 | + foundnsis = TRUE;
|
| | 277 | + WaitForSingleObject(process.hProcess,INFINITE);
|
| | 278 | + CloseHandle(process.hProcess);
|
| | 279 | + CloseHandle(process.hThread);
|
| | 280 | + }
|
| | 281 | + }
|
| | 282 | + RegCloseKey(hKey);
|
| | 283 | + }
|
| | 284 | + if(!foundnsis)
|
| | 285 | + {
|
| | 286 | + int result = MessageBoxA(NULL,"Could not find NSIS, would you like to download it?","NSIS not found",
|
| | 287 | + MB_YESNO|MB_ICONERROR);
|
| | 288 | + if(result == IDYES) ShellExecuteA(NULL,"open","http://nsis.sourceforge.net/Main_Page",NULL,NULL,SW_SHOWNORMAL);
|
| | 289 | + puts("ERROR: NSIS not found.");
|
| | 290 | + return -1;
|
| | 291 | + }
|
| | 292 | + return 0;
|
| | 293 | +}
|
| | 294 | +
|
| | 295 | +
|
| | 296 | +int main(int argc, char *argv[])
|
| | 297 | +{
|
| | 298 | +
|
| | 299 | + fputs("DXGL Build Tool, version ", stdout);
|
| | 300 | + puts(DXGLSTRVER);
|
| | 301 | +#ifdef _DEBUG
|
| | 302 | + puts("Debug version.");
|
| | 303 | +#endif
|
| | 304 | + if(argc > 1)
|
| | 305 | + {
|
| | 306 | + if(!strcmp(argv[1],"makeheader"))
|
| | 307 | + {
|
| | 308 | + if(argc < 3)
|
| | 309 | + {
|
| | 310 | + puts("ERROR: No working directory specified.");
|
| | 311 | + return 1;
|
| | 312 | + }
|
| | 313 | + return ProcessHeaders(argv[2]);
|
| | 314 | + }
|
| | 315 | + if(!strcmp(argv[1],"makehelp"))
|
| | 316 | + {
|
| | 317 | + if(argc < 3)
|
| | 318 | + {
|
| | 319 | + puts("ERROR: No working directory specified.");
|
| | 320 | + return 1;
|
| | 321 | + }
|
| | 322 | + return MakeHelp(argv[2]);
|
| | 323 | + }
|
| | 324 | + if(!strcmp(argv[1],"makeinstaller"))
|
| | 325 | + {
|
| | 326 | + if(argc < 3)
|
| | 327 | + {
|
| | 328 | + puts("ERROR: No working directory specified.");
|
| | 329 | + return 1;
|
| | 330 | + }
|
| | 331 | + return MakeInstaller(argv[2]);
|
| | 332 | + }
|
| | 333 | + }
|
| | 334 | + else
|
| | 335 | + {
|
| | 336 | + }
|
| | 337 | + return 0;
|
| | 338 | +}
|
| Index: buildtool/buildtool.vcxproj |
| — | — | @@ -165,7 +165,7 @@ |
| 166 | 166 | <ResourceCompile Include="buildtool.rc" />
|
| 167 | 167 | </ItemGroup>
|
| 168 | 168 | <ItemGroup>
|
| 169 | | - <ClCompile Include="buildtool.cpp" />
|
| | 169 | + <ClCompile Include="buildtool.c" />
|
| 170 | 170 | </ItemGroup>
|
| 171 | 171 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
| 172 | 172 | <ImportGroup Label="ExtensionTargets">
|
| Index: buildtool/buildtool.vcxproj.filters |
| — | — | @@ -15,11 +15,6 @@ |
| 16 | 16 | </Filter>
|
| 17 | 17 | </ItemGroup>
|
| 18 | 18 | <ItemGroup>
|
| 19 | | - <ClCompile Include="buildtool.cpp">
|
| 20 | | - <Filter>Source Files</Filter>
|
| 21 | | - </ClCompile>
|
| 22 | | - </ItemGroup>
|
| 23 | | - <ItemGroup>
|
| 24 | 19 | <ResourceCompile Include="buildtool.rc">
|
| 25 | 20 | <Filter>Resource Files</Filter>
|
| 26 | 21 | </ResourceCompile>
|
| — | — | @@ -29,4 +24,9 @@ |
| 30 | 25 | <Filter>Header Files</Filter>
|
| 31 | 26 | </ClInclude>
|
| 32 | 27 | </ItemGroup>
|
| | 28 | + <ItemGroup>
|
| | 29 | + <ClCompile Include="buildtool.c">
|
| | 30 | + <Filter>Source Files</Filter>
|
| | 31 | + </ClCompile>
|
| | 32 | + </ItemGroup>
|
| 33 | 33 | </Project> |
| \ No newline at end of file |