DXGL r205 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r204‎ | r205 | r206 >
Date:23:31, 8 July 2012
Author:admin
Status:new
Tags:
Comment:
Build tool: Auto-generate version headers. releasever.h contains product version numbers now
Modified paths:
  • /buildtool/buildtool.cpp (modified) (history)
  • /buildtool/buildtool.rc (modified) (history)
  • /buildtool/buildtool.vcxproj (modified) (history)
  • /buildtool/buildtool.vcxproj.filters (modified) (history)
  • /common/common.vcxproj (modified) (history)
  • /common/common.vcxproj.filters (modified) (history)
  • /common/releasever.h (added) (history)
  • /common/version.h (deleted) (history)
  • /common/version.h.in (added) (history)
  • /common/version.nsh (deleted) (history)
  • /common/version.nsh.in (added) (history)
  • /dxgl.sln (modified) (history)

Diff [purge]

Index: common/version.h
@@ -1,15 +0,0 @@
2 -#pragma once
3 -#ifndef __VERSION_H
4 -#define __VERSION_H
5 -
6 -#define DXGLMAJOR 0
7 -#define DXGLMINOR 2
8 -#define DXGLPOINT 3
9 -#define DXGLBUILD 0
10 -
11 -#define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
12 -#define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
13 -#define DXGLVERSTRING "0.2.3.0"
14 -
15 -
16 -#endif //__VERSION_H
Index: common/version.nsh
@@ -1 +0,0 @@
2 -!define PRODUCT_VERSION "0.2.3"
\ No newline at end of file
Index: buildtool/buildtool.cpp
@@ -15,14 +15,140 @@
1616 // License along with this library; if not, write to the Free Software
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
19 -#include "common.h"
20 -#include "../common/version.h"
 19+#include <cstdio>
 20+#include <iostream>
 21+#include "../common/releasever.h"
2122
2223 using namespace std;
2324
24 -int main(int arg, char *argv[])
 25+int ProcessHeaders(char *path)
2526 {
26 - cout << "DXGL Build Tool, version " << DXGLVERSTRING << endl;
 27+ char pathin[FILENAME_MAX+1];
 28+ char pathout[FILENAME_MAX+1];
 29+ char buffer[1024];
 30+ char verbuffer[20];
 31+ char numstring[16];
 32+ char *findptr;
 33+ int revision = 0; //FIXME: Get SVN Rev.
 34+ strncpy(pathin,path,FILENAME_MAX);
 35+ strncpy(pathout,path,FILENAME_MAX);
 36+ strncat(pathin,"\\version.h.in",FILENAME_MAX-strlen(pathin));
 37+ strncat(pathout,"\\version.h",FILENAME_MAX-strlen(pathin));
 38+ FILE *filein = fopen(pathin,"r");
 39+ if(!filein)
 40+ {
 41+ cout << "ERROR: Cannot read file " << pathin << endl;
 42+ return errno;
 43+ }
 44+ FILE *fileout = fopen(pathout,"w");
 45+ if(!fileout)
 46+ {
 47+ cout << "ERROR: Cannot create file " << pathin << endl;
 48+ return errno;
 49+ }
 50+ while(fgets(buffer,1024,filein))
 51+ {
 52+ findptr = strstr(buffer,"$MAJOR");
 53+ if(findptr) strncpy(findptr,STR(DXGLMAJORVER) "\n",6);
 54+ findptr = strstr(buffer,"$MINOR");
 55+ if(findptr) strncpy(findptr,STR(DXGLMINORVER) "\n",6);
 56+ findptr = strstr(buffer,"$POINT");
 57+ if(findptr) strncpy(findptr,STR(DXGLPOINTVER) "\n",6);
 58+ findptr = strstr(buffer,"$REVISION");
 59+ if(findptr)
 60+ {
 61+ _itoa(revision,verbuffer,10);
 62+ strcat(verbuffer,"\n");
 63+ strncpy(findptr,verbuffer,9);
 64+ }
 65+ findptr = strstr(buffer,"$VERSTRING");
 66+ if(findptr)
 67+ {
 68+ if(revision)
 69+ {
 70+ strcpy(verbuffer, "\"");
 71+ strcat(verbuffer,DXGLSTRVER);
 72+ strcat(verbuffer," r");
 73+ _itoa(revision,numstring,10);
 74+ strcat(verbuffer,numstring);
 75+ strcat(verbuffer,"\"");
 76+ strncpy(findptr,verbuffer,22);
 77+ }
 78+ else strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
 79+ }
 80+ fputs(buffer,fileout);
 81+ }
 82+ fclose(filein);
 83+ filein = NULL;
 84+ fclose(fileout);
 85+ fileout = NULL;
 86+ strncpy(pathin,path,FILENAME_MAX);
 87+ strncpy(pathout,path,FILENAME_MAX);
 88+ strncat(pathin,"\\version.nsh.in",FILENAME_MAX-strlen(pathin));
 89+ strncat(pathout,"\\version.nsh",FILENAME_MAX-strlen(pathin));
 90+ filein = fopen(pathin,"r");
 91+ if(!filein)
 92+ {
 93+ cout << "ERROR: Cannot read file " << pathin << endl;
 94+ return errno;
 95+ }
 96+ fileout = fopen(pathout,"w");
 97+ if(!fileout)
 98+ {
 99+ cout << "ERROR: Cannot create file " << pathin << endl;
 100+ return errno;
 101+ }
 102+ while(fgets(buffer,1024,filein))
 103+ {
 104+ findptr = strstr(buffer,"$PRODUCTVERSTRING");
 105+ if(findptr) strncpy(findptr,"\"" DXGLSTRVER "\"\n",15);
 106+ findptr = strstr(buffer,"$PRODUCTREVISION");
 107+ if(findptr)
 108+ {
 109+ if(revision)
 110+ {
 111+ strcpy(verbuffer,"\"r");
 112+ _itoa(revision,numstring,10);
 113+ strcat(verbuffer,numstring);
 114+ strcat(verbuffer,"\"\n");
 115+ strncpy(findptr,verbuffer,17);
 116+ }
 117+ else strncpy(findptr,"\"\"\n",17);
 118+ }
 119+#ifdef _DEBUG
 120+ if(strstr(buffer,";!define DEBUG")) strcpy(buffer,"!define DEBUG");
 121+#endif
 122+ fputs(buffer,fileout);
 123+ }
 124+ fclose(filein);
 125+ filein = NULL;
 126+ fclose(fileout);
 127+ fileout = NULL;
 128+ return 0;
 129+}
27130
 131+int main(int argc, char *argv[])
 132+{
 133+
 134+ cout << "DXGL Build Tool, version " << DXGLSTRVER << endl;
 135+#ifdef _DEBUG
 136+ cout << "Debug version." << endl;
 137+#endif
 138+ if(argc > 1)
 139+ {
 140+ if(!strcmp(argv[1],"makeheader"))
 141+ {
 142+ if(argc < 3)
 143+ {
 144+ cout << "ERROR: No working directory specified." << endl;
 145+ return 1;
 146+ }
 147+ ProcessHeaders(argv[2]);
 148+ return 0;
 149+ }
 150+ }
 151+ else
 152+ {
 153+ }
28154 return 0;
29155 }
Index: buildtool/buildtool.rc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: buildtool/buildtool.vcxproj
@@ -48,7 +48,6 @@
4949 <WarningLevel>Level3</WarningLevel>
5050 <Optimization>Disabled</Optimization>
5151 <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
52 - <PrecompiledHeader>Use</PrecompiledHeader>
5352 <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
5453 </ClCompile>
5554 <Link>
@@ -56,12 +55,17 @@
5756 <AdditionalDependencies>
5857 </AdditionalDependencies>
5958 </Link>
 59+ <PostBuildEvent>
 60+ <Command>$(OutDir)$(TargetName)$(TargetExt) makeheader $(SolutionDir)common</Command>
 61+ </PostBuildEvent>
 62+ <PostBuildEvent>
 63+ <Message>Build headers</Message>
 64+ </PostBuildEvent>
6065 </ItemDefinitionGroup>
6166 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
6267 <ClCompile>
6368 <WarningLevel>Level3</WarningLevel>
6469 <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
65 - <PrecompiledHeader>Use</PrecompiledHeader>
6670 <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
6771 </ClCompile>
6872 <Link>
@@ -69,9 +73,14 @@
7074 <AdditionalDependencies>
7175 </AdditionalDependencies>
7276 </Link>
 77+ <PostBuildEvent>
 78+ <Command>$(OutDir)$(TargetName)$(TargetExt) makeheader $(SolutionDir)common</Command>
 79+ </PostBuildEvent>
 80+ <PostBuildEvent>
 81+ <Message>Build headers</Message>
 82+ </PostBuildEvent>
7383 </ItemDefinitionGroup>
7484 <ItemGroup>
75 - <ClInclude Include="common.h" />
7685 <ClInclude Include="resource.h" />
7786 </ItemGroup>
7887 <ItemGroup>
@@ -79,10 +88,6 @@
8089 </ItemGroup>
8190 <ItemGroup>
8291 <ClCompile Include="buildtool.cpp" />
83 - <ClCompile Include="precomp.cpp">
84 - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
85 - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
86 - </ClCompile>
8792 </ItemGroup>
8893 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
8994 <ImportGroup Label="ExtensionTargets">
Index: buildtool/buildtool.vcxproj.filters
@@ -18,9 +18,6 @@
1919 <ClCompile Include="buildtool.cpp">
2020 <Filter>Source Files</Filter>
2121 </ClCompile>
22 - <ClCompile Include="precomp.cpp">
23 - <Filter>Source Files</Filter>
24 - </ClCompile>
2522 </ItemGroup>
2623 <ItemGroup>
2724 <ResourceCompile Include="buildtool.rc">
@@ -28,9 +25,6 @@
2926 </ResourceCompile>
3027 </ItemGroup>
3128 <ItemGroup>
32 - <ClInclude Include="common.h">
33 - <Filter>Header Files</Filter>
34 - </ClInclude>
3529 <ClInclude Include="resource.h">
3630 <Filter>Header Files</Filter>
3731 </ClInclude>
Index: common/common.vcxproj
@@ -111,10 +111,11 @@
112112 <None Include="dxglicon.svg" />
113113 <None Include="dxglsm.ico" />
114114 <None Include="star.ico" />
115 - <None Include="version.nsh" />
 115+ <None Include="version.nsh.in" />
116116 </ItemGroup>
117117 <ItemGroup>
118 - <ClInclude Include="version.h" />
 118+ <ClInclude Include="releasever.h" />
 119+ <ClInclude Include="version.h.in" />
119120 </ItemGroup>
120121 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
121122 <ImportGroup Label="ExtensionTargets">
Index: common/common.vcxproj.filters
@@ -27,13 +27,16 @@
2828 <None Include="dxglicon.svg">
2929 <Filter>Resource Files</Filter>
3030 </None>
31 - <None Include="version.nsh">
 31+ <None Include="version.nsh.in">
3232 <Filter>Header Files</Filter>
3333 </None>
3434 </ItemGroup>
3535 <ItemGroup>
36 - <ClInclude Include="version.h">
 36+ <ClInclude Include="releasever.h">
3737 <Filter>Header Files</Filter>
3838 </ClInclude>
 39+ <ClInclude Include="version.h.in">
 40+ <Filter>Header Files</Filter>
 41+ </ClInclude>
3942 </ItemGroup>
4043 </Project>
\ No newline at end of file
Index: common/releasever.h
@@ -0,0 +1,16 @@
 2+#pragma once
 3+#ifndef __VERSION_H
 4+#define __VERSION_H
 5+
 6+#define DXGLMAJORVER 0
 7+#define DXGLMINORVER 3
 8+#define DXGLPOINTVER 0
 9+
 10+#define STR2(x) #x
 11+#define STR(x) STR2(x)
 12+
 13+#define DXGLSTRVER STR(DXGLMAJORVER) "." STR(DXGLMINORVER) "." STR(DXGLPOINTVER)
 14+
 15+
 16+
 17+#endif //__VERSION_H
Index: common/version.h.in
@@ -0,0 +1,15 @@
 2+#pragma once
 3+#ifndef __VERSION_H
 4+#define __VERSION_H
 5+
 6+#define DXGLMAJOR $MAJOR
 7+#define DXGLMINOR $MINOR
 8+#define DXGLPOINT $POINT
 9+#define DXGLBUILD $REVISION
 10+
 11+#define DXGLVERNUMBER DXGLMAJOR,DXGLMINOR,DXGLPOINT,DXGLBUILD
 12+#define DXGLVERQWORD (((unsigned __int64)DXGLMAJOR<<48)+((unsigned __int64)DXGLMINOR<<32)+((unsigned __int64)DXGLPOINT<<16)+(unsigned __int64)DXGLBUILD)
 13+#define DXGLVERSTRING $VERSTRING
 14+
 15+
 16+#endif //__VERSION_H
Index: common/version.nsh.in
@@ -0,0 +1,3 @@
 2+!define PRODUCT_VERSION $PRODUCTVERSTRING
 3+!define PRODUCT_REVISION $PRODUCTREVISION
 4+;!define DEBUG
\ No newline at end of file
Index: dxgl.sln
@@ -8,6 +8,9 @@
99 EndProjectSection
1010 EndProject
1111 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common\common.vcxproj", "{87D591EB-B598-431B-9B3B-D0FF771AB473}"
 12+ ProjectSection(ProjectDependencies) = postProject
 13+ {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0} = {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0}
 14+ EndProjectSection
1215 EndProject
1316 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dxglcfg", "dxglcfg\dxglcfg.vcxproj", "{DF380DA1-90DE-4174-9A1F-EEC16C5B5879}"
1417 ProjectSection(ProjectDependencies) = postProject
@@ -23,6 +26,9 @@
2427 EndProjectSection
2528 EndProject
2629 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Help", "Help\Help.vcxproj", "{8041FD11-3A2E-4EE9-A3FF-A9755803B7FB}"
 30+ ProjectSection(ProjectDependencies) = postProject
 31+ {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0} = {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0}
 32+ EndProjectSection
2733 EndProject
2834 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buildtool", "buildtool\buildtool.vcxproj", "{34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0}"
2935 EndProject