Windows stuff for visual studio now offical works with exception to colorized output to cmd (which actually should work). As well as the testsuite which lacks implementations of task_popen/task_pclose.

This commit is contained in:
Dale Weiler 2012-12-21 06:13:16 -05:00
parent 43cf6e7cba
commit 88fee02228
6 changed files with 99 additions and 119 deletions

View file

@ -77,7 +77,7 @@ enum {
MAGENTA,
CYAN,
GRAY,
WHITE
WHITE = GRAY
};
enum {
@ -90,9 +90,9 @@ enum {
WMAGENTA = WBLUE | WRED,
WYELLOW = WGREEN | WRED,
WWHITE = WBLUE | WGREEN | WRED
}
};
static const ansi2win[] = {
static const int ansi2win[] = {
WBLACK,
WRED,
WGREEN,
@ -103,7 +103,7 @@ static const ansi2win[] = {
WWHITE
};
static void win_fputs(char *str, FILE *h) {
static int win_fputs(const char *str, FILE *h) {
/* state for translate */
int acolor;
int wcolor;
@ -115,7 +115,7 @@ static void win_fputs(char *str, FILE *h) {
int intense = -1;
int colors[] = {-1, -1 };
int colorpos = 1;
int length = 0;
CONSOLE_SCREEN_BUFFER_INFO cinfo;
GetConsoleScreenBufferInfo (
(GMQCC_IS_STDOUT(h)) ?
@ -125,9 +125,9 @@ static void win_fputs(char *str, FILE *h) {
icolor = cinfo.wAttributes;
while (*str) {
if (*str == '\e')
state = '\e';
else if (state == '\e' && *str == '[')
if (*str == '\x1B')
state = '\x1B';
else if (state == '\x1B' && *str == '[')
state = '[';
else if (state == '[') {
if (*str != 'm') {
@ -148,7 +148,7 @@ static void win_fputs(char *str, FILE *h) {
intense = WBLACK;
wcolor = icolor;
}
else if (BLACK < acolor && acolor <= WHITE)
else if (BLACK <= acolor && acolor <= WHITE)
wcolor = ansi2win[acolor - 30];
else if (acolor == 90) {
/* special gray really white man */
@ -157,7 +157,7 @@ static void win_fputs(char *str, FILE *h) {
}
SetConsoleTextAttribute (
(h == stdout) ?
(GMQCC_IS_STDOUT(h)) ?
GetStdHandle(STD_OUTPUT_HANDLE) :
GetStdHandle(STD_ERROR_HANDLE),
@ -168,7 +168,9 @@ static void win_fputs(char *str, FILE *h) {
}
} else {
fputc(*str, h);
length ++;
}
str++;
}
/* restore */
SetConsoleTextAttribute(
@ -177,6 +179,7 @@ static void win_fputs(char *str, FILE *h) {
GetStdHandle(STD_ERROR_HANDLE),
icolor
);
return length;
}
#endif
@ -212,16 +215,10 @@ static int con_write(FILE *handle, const char *fmt, va_list va) {
ln = vfprintf(handle, fmt, va);
#else
{
char *data = NULL;
ln = _vscprintf(fmt, va);
data = malloc(ln + 1);
data[ln] = 0;
vsprintf(data, fmt, va);
if (GMQCC_IS_DEFINE(handle))
win_fputs(data, handle);
else
ln = fputs(data, handle);
free(data);
char data[4096];
memset(data, 0, sizeof(data));
vsnprintf(data, sizeof(data), fmt, va);
ln = (GMQCC_IS_DEFINE(handle)) ? win_fputs(data, handle) : fputs(data, handle);
}
#endif
return ln;

44
gmqcc.h
View file

@ -77,6 +77,8 @@
# endif /* !__STDC_VERSION__ */
#endif /* !__cplusplus */
/*
* Of some functions which are generated we want to make sure
* that the result isn't ignored. To find such function calls,
@ -271,14 +273,42 @@ size_t util_strtononcmd (const char *, char *, size_t);
uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
uint32_t util_crc32(uint32_t crc, const char *data, size_t len);
#ifdef NOTRACK
# define mem_a(x) malloc (x)
# define mem_d(x) free (x)
# define mem_r(x, n) realloc(x, n)
/*
* If we're compiling as C++ code we need to fix some subtle issues regarding casts between mem_a/mem_d
* since C++ doesn't allow implicit conversions between void*
*/
#ifdef __cplusplus
/*
* void * will be implicitally converted to gmqcc_voidptr using gmqcc_voidptr(void*). This is what
* essentially allows us to allow implicit conversion to whatever pointer type we're trying to assign
* to because it acks as a default assignment constructor.
*/
class gmqcc_voidptr {
void *m_pointer;
public:
gmqcc_voidptr(void *pointer) :
m_pointer(pointer)
{ };
template <typename T>
GMQCC_INLINE operator T *() {
return m_pointer;
}
};
# define GMQCC_IMPLICIT_POINTER(X) (gmqcc_voidptr(X))
#else
# define mem_a(x) util_memory_a((x), __LINE__, __FILE__)
# define mem_d(x) util_memory_d((x), __LINE__, __FILE__)
# define mem_r(x, n) util_memory_r((x), (n), __LINE__, __FILE__)
# define GMQCC_IMPLICIT_POINTER(X) (X)
#endif
#ifdef NOTRACK
# define mem_a(x) GMQCC_IMPLICIT_POINTER(malloc (x))
# define mem_d(x) free ((void*)x)
# define mem_r(x, n) realloc((void*)x, n)
#else
# define mem_a(x) GMQCC_IMPLICIT_POINTER(util_memory_a((x), __LINE__, __FILE__))
# define mem_d(x) util_memory_d((void*)(x), __LINE__, __FILE__)
# define mem_r(x, n) util_memory_r((void*)(x), (n), __LINE__, __FILE__)
#endif
/*

View file

@ -9,20 +9,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite.vcxp
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.ActiveCfg = Debug|Win32
{8DC505A6-6047-4683-BA81-BC4B7A839352}.Debug|Win32.Build.0 = Debug|Win32
{8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.ActiveCfg = Release|Win32
{8DC505A6-6047-4683-BA81-BC4B7A839352}.Release|Win32.Build.0 = Release|Win32
{0F0B0779-1A2F-43E9-B833-18C443F7229E}.Debug|Win32.ActiveCfg = Debug|Win32
{0F0B0779-1A2F-43E9-B833-18C443F7229E}.Debug|Win32.Build.0 = Debug|Win32
{0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.ActiveCfg = Release|Win32
{0F0B0779-1A2F-43E9-B833-18C443F7229E}.Release|Win32.Build.0 = Release|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Debug|Win32.ActiveCfg = Debug|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Debug|Win32.Build.0 = Debug|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.ActiveCfg = Release|Win32
{3F8F0021-66B8-43ED-906C-1CFE204E5673}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection

View file

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@ -13,13 +9,9 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{0F0B0779-1A2F-43E9-B833-18C443F7229E}</ProjectGuid>
<RootNamespace>gmqcc</RootNamespace>
<TrackFileAccess>false</TrackFileAccess>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
@ -29,23 +21,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@ -54,22 +36,35 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ProgramDatabaseFile>
</ProgramDatabaseFile>
</Link>
<PostBuildEvent>
<Command>Del /Q "$(IntDir)\*.tlog"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\ast.c" />
<ClCompile Include="..\code.c" />
<ClCompile Include="..\conout.c" />
<ClCompile Include="..\ast.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
</ClCompile>
<ClCompile Include="..\code.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
</ClCompile>
<ClCompile Include="..\conout.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_gmqcc.o</ObjectFileName>
</ClCompile>
<ClCompile Include="..\ftepp.c" />
<ClCompile Include="..\ir.c" />
<ClCompile Include="..\lexer.c" />
<ClCompile Include="..\main.c" />
<ClCompile Include="..\opts.c" />
<ClCompile Include="..\parser.c" />
<ClCompile Include="..\util.c" />
<ClCompile Include="..\util.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_gmqcc.o</ObjectFileName>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ast.h" />

View file

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@ -13,15 +9,9 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{8DC505A6-6047-4683-BA81-BC4B7A839352}</ProjectGuid>
<RootNamespace>qcvm</RootNamespace>
<TrackFileAccess>false</TrackFileAccess>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
@ -31,29 +21,10 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<PreprocessorDefinitions>QCVM_EXECUTOR=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@ -72,11 +43,20 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>Del /Q "$(IntDir)\*.tlog"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\conout.c" />
<ClCompile Include="..\exec.c" />
<ClCompile Include="..\util.c" />
<ClCompile Include="..\conout.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_qcvm.o</ObjectFileName>
</ClCompile>
<ClCompile Include="..\exec.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)</ObjectFileName>
</ClCompile>
<ClCompile Include="..\util.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_qcvm.o</ObjectFileName>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\gmqcc.h" />

View file

@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@ -13,13 +9,9 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{3F8F0021-66B8-43ED-906C-1CFE204E5673}</ProjectGuid>
<RootNamespace>testsuite</RootNamespace>
<TrackFileAccess>false</TrackFileAccess>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
@ -29,23 +21,9 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@ -58,11 +36,18 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>Del /Q "$(IntDir)\*.tlog"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\conout.c" />
<ClCompile Include="..\conout.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)conout_testsuite.o</ObjectFileName>
</ClCompile>
<ClCompile Include="..\test.c" />
<ClCompile Include="..\util.c" />
<ClCompile Include="..\util.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)util_testsuite.o</ObjectFileName>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\gmqcc.h" />