Browse Source

VS2010 build: config.h cleanup and offload. Added git versioning.

nfactor-troky
unknown 11 years ago
parent
commit
fc51d1696b
  1. 195
      winbuild/dist/include/config.h
  2. 0
      winbuild/dist/include/gitversion.h
  3. 140
      winbuild/dist/include/winbuild.h
  4. 25
      winbuild/sgminer.vcxproj
  5. 3
      winbuild/sgminer.vcxproj.filters

195
winbuild/dist/include/config.h vendored

@ -11,18 +11,22 @@
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define HAVE_LIBCURL 1
#define CURL_HAS_KEEPALIVE 1
#define HAVE_CURSES 1
#define USE_SCRYPT 1
#define HAVE_OPENCL 1
#define HAVE_ADL 1
#define WIN32 1 #define WIN32 1
#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN
#define WANT_X8664_SSE4
#define STDC_HEADERS 1 #define STDC_HEADERS 1
#define EXECV_2ND_ARG_TYPE char* const* #define EXECV_2ND_ARG_TYPE char* const*
#define GNULIB_TEST_MEMCHR 1
#define GNULIB_TEST_MEMMEM 1
#define GNULIB_TEST_SIGACTION 1
#define GNULIB_TEST_SIGPROCMASK 1
#define HAVE_LIBCURL 1
#define CURL_HAS_KEEPALIVE 1
#define HAVE_CURSES 1
#define HAVE_ALLOCA 1 #define HAVE_ALLOCA 1
#define HAVE_ATTRIBUTE_COLD 1 #define HAVE_ATTRIBUTE_COLD 1
@ -53,20 +57,6 @@
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
#define HAVE_WCHAR_T 1 #define HAVE_WCHAR_T 1
#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdbool.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
#define WANT_X8664_SSE4
#define USE_SCRYPT
#define HAVE_OPENCL
#define HAVE_ADL
#define PRIi64 "I64d" #define PRIi64 "I64d"
#define PRIi32 "I32d" #define PRIi32 "I32d"
#define PRIu32 "I32u" #define PRIu32 "I32u"
@ -76,166 +66,33 @@
#define R_OK 0 #define R_OK 0
#define snprintf _snprintf // Libraries to include
#define strdup _strdup #pragma comment(lib, "winmm.lib")
#pragma comment(lib, "wsock32.lib")
#include <io.h> #pragma comment(lib, "pthreadVC2.lib")
#include <process.h> #pragma comment(lib, "OpenCL.lib")
#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) #ifdef HAVE_LIBCURL
#define CURL_STATICLIB 1
//#define USE_AVX2 1 #pragma comment(lib, "libcurl_a.lib")
#define inline __inline
#include <stdint.h>
#include <ctype.h>
#include <stdio.h>
typedef intptr_t ssize_t;
struct timezone2
{
__int32 tz_minuteswest; /* minutes W of Greenwich */
__int32 tz_dsttime; /* type of dst correction */
};
#include <time.h>
#include <WinSock2.h>
const __int64 DELTA_EPOCH_IN_MICROSECS= 11644473600000000;
/* IN UNIX the use of the timezone struct is obsolete;
I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm
But if you want to use this structure to know about GMT(UTC) diffrence from your local time
it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag
indicates whether daylight is now in use
*/
inline int gettimeofday(struct timeval *tv/*in*/, struct timezone2 *tz/*in*/)
{
FILETIME ft;
__int64 tmpres = 0;
TIME_ZONE_INFORMATION tz_winapi;
int rez=0;
ZeroMemory(&ft,sizeof(ft));
ZeroMemory(&tz_winapi,sizeof(tz_winapi));
GetSystemTimeAsFileTime(&ft);
tmpres = ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (__int32)(tmpres*0.000001);
tv->tv_usec =(tmpres%1000000);
if( tz )
{
//_tzset(),don't work properly, so we use GetTimeZoneInformation
rez=GetTimeZoneInformation(&tz_winapi);
tz->tz_dsttime=(rez==2)?true:false;
tz->tz_minuteswest = tz_winapi.Bias + ((rez==2)?tz_winapi.DaylightBias:0);
}
return 0;
}
inline int strcasecmp(const char *s1, const char *s2)
{
unsigned char c1,c2;
do {
c1 = *s1++;
c2 = *s2++;
c1 = (unsigned char) tolower( (unsigned char) c1);
c2 = (unsigned char) tolower( (unsigned char) c2);
}
while((c1 == c2) && (c1 != '\0'));
return (int) c1-c2;
}
inline int strncasecmp(const char *s1, const char *s2, size_t n)
{
if (n == 0)
return 0;
while (n-- != 0 && tolower(*s1) == tolower(*s2))
{
if (n == 0 || *s1 == '\0' || *s2 == '\0')
break;
s1++;
s2++;
}
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
}
#include <math.h>
inline long double roundl(long double r)
{
return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5);
}
#if (_MSC_VER < 1800)
#define round (int)roundl
inline long long int lround(double r)
{
return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5);
}
#endif #endif
inline void* memmem (void* buf, size_t buflen, void* pat, size_t patlen) #ifdef HAVE_CURSES
{ #pragma comment(lib, "pdcurses.lib")
void* end = (char *) buf+buflen-patlen; #endif
while (buf=memchr (buf, ((char *) pat) [0], buflen))
{
if (buf> end)
return 0;
if (memcmp (buf, pat, patlen) == 0)
return buf;
buf = (char *) buf+1;
}
return 0;
}
#define usleep(x) Sleep((x)/1000)
#define sleep(x) Sleep((x)*1000)
#endif #endif
#define VERSION "v4.1.0" #define VERSION "v4.1.0"
#define PACKAGE_NAME "sgminer" #define PACKAGE_NAME "sgminer"
#define PACKAGE_TARNAME "sgminer" #define PACKAGE_TARNAME "sgminer"
#define PACKAGE_VERSION "4.1.0" #define PACKAGE_VERSION "4.1.0"
#define PACKAGE_STRING "sgminer 4.1.0" #define PACKAGE_STRING "sgminer 4.1.0"
#define PACKAGE "sgminer" #define PACKAGE "sgminer"
#define SGMINER_PREFIX ""
#if defined (WIN32)
#define __func__ __FUNCTION__
#define __attribute__(x)
#endif
// Libraries to include
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "pthreadVC2.lib")
#pragma comment(lib, "OpenCL.lib")
#ifdef HAVE_LIBCURL #define SGMINER_PREFIX ""
#define CURL_STATICLIB 1
#pragma comment(lib, "libcurl_a.lib")
#endif
#ifdef HAVE_CURSES #include "gitversion.h"
#pragma comment(lib, "pdcurses.lib") #include "winbuild.h"
#endif
#endif #endif

0
winbuild/dist/include/gitversion.h vendored

140
winbuild/dist/include/winbuild.h vendored

@ -0,0 +1,140 @@
#ifndef __WINBUILD_H__
#define __WINBUILD_H__
#endif
#if defined(_MSC_VER)
#include <stdint.h>
#include <ctype.h>
#include <stdio.h>
#include <windows.h>
#include <stdbool.h>
#include <mmsystem.h>
#include <io.h>
#include <process.h>
#include <math.h>
#include <time.h>
#include <WinSock2.h>
typedef intptr_t ssize_t;
#define snprintf _snprintf
#define strdup _strdup
#define inline __inline
struct timezone2
{
__int32 tz_minuteswest; /* minutes W of Greenwich */
__int32 tz_dsttime; /* type of dst correction */
};
const __int64 DELTA_EPOCH_IN_MICROSECS= 11644473600000000;
/* IN UNIX the use of the timezone struct is obsolete;
I don't know why you use it. See http://linux.about.com/od/commands/l/blcmdl2_gettime.htm
But if you want to use this structure to know about GMT(UTC) diffrence from your local time
it will be next: tz_minuteswest is the real diffrence in minutes from GMT(UTC) and a tz_dsttime is a flag
indicates whether daylight is now in use
*/
inline int gettimeofday(struct timeval *tv/*in*/, struct timezone2 *tz/*in*/)
{
FILETIME ft;
__int64 tmpres = 0;
TIME_ZONE_INFORMATION tz_winapi;
int rez=0;
ZeroMemory(&ft,sizeof(ft));
ZeroMemory(&tz_winapi,sizeof(tz_winapi));
GetSystemTimeAsFileTime(&ft);
tmpres = ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch*/
tmpres /= 10; /*convert into microseconds*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (__int32)(tmpres*0.000001);
tv->tv_usec =(tmpres%1000000);
if( tz )
{
//_tzset(),don't work properly, so we use GetTimeZoneInformation
rez=GetTimeZoneInformation(&tz_winapi);
tz->tz_dsttime=(rez==2)?true:false;
tz->tz_minuteswest = tz_winapi.Bias + ((rez==2)?tz_winapi.DaylightBias:0);
}
return 0;
}
inline int strcasecmp(const char *s1, const char *s2)
{
unsigned char c1,c2;
do {
c1 = *s1++;
c2 = *s2++;
c1 = (unsigned char) tolower( (unsigned char) c1);
c2 = (unsigned char) tolower( (unsigned char) c2);
}
while((c1 == c2) && (c1 != '\0'));
return (int) c1-c2;
}
inline int strncasecmp(const char *s1, const char *s2, size_t n)
{
if (n == 0)
return 0;
while (n-- != 0 && tolower(*s1) == tolower(*s2))
{
if (n == 0 || *s1 == '\0' || *s2 == '\0')
break;
s1++;
s2++;
}
return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
}
inline long double roundl(long double r)
{
return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5);
}
#if (_MSC_VER < 1800)
#define round (int)roundl
inline long long int lround(double r)
{
return (r>0.0) ? floor(r+0.5f) : ceil(r-0.5);
}
#endif
inline void* memmem (void* buf, size_t buflen, void* pat, size_t patlen)
{
void* end = (char *) buf+buflen-patlen;
while (buf=memchr (buf, ((char *) pat) [0], buflen))
{
if (buf> end)
return 0;
if (memcmp (buf, pat, patlen) == 0)
return buf;
buf = (char *) buf+1;
}
return 0;
}
#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list))
#define usleep(x) Sleep((x)/1000)
#define sleep(x) Sleep((x)*1000)
#define __func__ __FUNCTION__
#define __attribute__(x)
#endif

25
winbuild/sgminer.vcxproj

@ -110,7 +110,11 @@
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Command>del /f "$(OutDir)*.exe" <Command>del /f "$(OutDir)*.exe"
del /f "$(OutDir)*.dll"</Command> del /f "$(OutDir)*.dll"
type nul &gt; "$(ProjectDir)dist\include\gitversion.h"
FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" &gt; "$(ProjectDir)dist\include\gitversion.h"
exit 0</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -141,7 +145,11 @@ del /f "$(OutDir)*.dll"</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Command>del /f "$(OutDir)*.exe" <Command>del /f "$(OutDir)*.exe"
del /f "$(OutDir)*.dll"</Command> del /f "$(OutDir)*.dll"
type nul &gt; "$(ProjectDir)dist\include\gitversion.h"
FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" &gt; "$(ProjectDir)dist\include\gitversion.h"
exit 0</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -175,7 +183,11 @@ del /f "$(OutDir)*.dll"</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Command>del /f "$(OutDir)*.exe" <Command>del /f "$(OutDir)*.exe"
del /f "$(OutDir)*.dll"</Command> del /f "$(OutDir)*.dll"
type nul &gt; "$(ProjectDir)dist\include\gitversion.h"
FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" &gt; "$(ProjectDir)dist\include\gitversion.h"
exit 0</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -212,7 +224,11 @@ del /f "$(OutDir)*.dll"</Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Command>del /f "$(OutDir)*.exe" <Command>del /f "$(OutDir)*.exe"
del /f "$(OutDir)*.dll"</Command> del /f "$(OutDir)*.dll"
type nul &gt; "$(ProjectDir)dist\include\gitversion.h"
FOR /F "tokens=*" %%i IN ('call git describe --abbrev=4 --dirty') DO echo #define GIT_VERSION "%%i" &gt; "$(ProjectDir)dist\include\gitversion.h"
exit 0</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
@ -267,6 +283,7 @@ del /f "$(OutDir)*.dll"</Command>
<ClInclude Include="..\util.h" /> <ClInclude Include="..\util.h" />
<ClInclude Include="..\warn-on-use.h" /> <ClInclude Include="..\warn-on-use.h" />
<ClInclude Include="dist\include\config.h" /> <ClInclude Include="dist\include\config.h" />
<ClInclude Include="dist\include\winbuild.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.txt" /> <None Include="README.txt" />

3
winbuild/sgminer.vcxproj.filters

@ -160,6 +160,9 @@
<ClInclude Include="..\compat\jansson-2.5\src\utf.h"> <ClInclude Include="..\compat\jansson-2.5\src\utf.h">
<Filter>Libraries\jansson</Filter> <Filter>Libraries\jansson</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="dist\include\winbuild.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="README.txt" /> <None Include="README.txt" />

Loading…
Cancel
Save