Skip to content

Commit 0e4fabb

Browse files
committed
MSVC 2005 in precommit hooks and ensure build & test succeeds with that
1 parent e313565 commit 0e4fabb

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ repos:
3939
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" test clang
4040
language: python
4141
pass_filenames: false
42+
- id: build-msvc-2005-wine
43+
name: Build and Test (MSVC 2005 Wine)
44+
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc_2005_wine
45+
language: python
46+
pass_filenames: false
4247
- id: build-msvc-wine
4348
name: Build (MSVC Wine)
4449
entry: python3 -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/SamuelMarks/c-ci/master/precommit_matrix.py').read())" build msvc_wine

build_msvc2005_wine.cmd

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@echo off
2+
setlocal
3+
set "SRC_DIR=%CD%\"
4+
set "SRC_DIR=%SRC_DIR:~0,-1%"
5+
set "BUILD_TYPE=Debug"
6+
7+
echo Setting up MSVC 2005 Wine environment...
8+
9+
:: MSVC 2005 paths from the user's OS1 mount
10+
set "VSINSTALLDIR=Z:\media\samuel\OS1\Program Files (x86)\Microsoft Visual Studio 8"
11+
set "VCINSTALLDIR=Z:\media\samuel\OS1\Program Files (x86)\Microsoft Visual Studio 8\VC"
12+
set "FrameworkDir=Z:\media\samuel\OS1\WINDOWS\Microsoft.NET\Framework"
13+
set "FrameworkVersion=v2.0.50727"
14+
set "FrameworkSDKDir=Z:\media\samuel\OS1\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0"
15+
set "DevEnvDir=Z:\media\samuel\OS1\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE"
16+
17+
:: CMake from the user's OS1 mount
18+
set "CMAKE_BIN=Z:\media\samuel\OS1\Program Files\CMake\bin"
19+
20+
set "PATH=%DevEnvDir%;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%VCINSTALLDIR%\PlatformSDK\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\VCPackages;%CMAKE_BIN%;Z:\usr\bin;%PATH%"
21+
set "INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\PlatformSDK\include;%FrameworkSDKDir%\include;%INCLUDE%"
22+
set "LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%VCINSTALLDIR%\PlatformSDK\lib;%FrameworkSDKDir%\lib;%LIB%"
23+
set "LIBPATH=%FrameworkDir%\%FrameworkVersion%;%VCINSTALLDIR%\ATLMFC\LIB"
24+
25+
echo ======================================================================
26+
echo Win MSVC 2005 Wine ^| Static Lib (MTd) ^| ANSI ^| LTO OFF ^| Multi-thread ^| System ^| RTCs
27+
echo ======================================================================
28+
set "BUILD_DIR=%CD%\build_msvc2005_wine_static"
29+
cmake -S "%SRC_DIR%" -B "%BUILD_DIR%" -G "NMake Makefiles" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_FLAGS="/wd4005" -DCMAKE_CXX_FLAGS="/wd4005" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DCDD_CHARSET=ANSI -DCDD_THREADING=ON -DCDD_DEPS=SYSTEM -DBUILD_TESTING=ON -DCDD_MSVC_RTC=RTCs -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug %*
30+
if errorlevel 1 exit /b 1
31+
cmake --build "%BUILD_DIR%" --config "%BUILD_TYPE%"
32+
if errorlevel 1 exit /b 1
33+
pushd "%BUILD_DIR%"
34+
echo Copying MSVC 2005 debug redistributables...
35+
copy "%VCINSTALLDIR%\redist\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT\*.*" .
36+
set PATH=%BUILD_DIR%\%BUILD_TYPE%;%BUILD_DIR%\_deps\c89stringutils-build\%BUILD_TYPE%;%BUILD_DIR%\_deps\c_abstract_http-build\%BUILD_TYPE%;%PATH%
37+
ctest -C "%BUILD_TYPE%" --output-on-failure
38+
if errorlevel 1 exit /b 1
39+
popd
40+
41+
echo MSVC 2005 Wine variation completed successfully.

c89stringutils/tests/test_string_extras.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ extern int g_mock_vsnprintf_call_count;
288288
extern int g_mock_vsnprintf_ret2;
289289

290290
TEST x_mock_failures(void) {
291+
#if defined(_MSC_VER) && _MSC_VER < 1900
292+
PASS();
293+
#else
294+
291295
char *s = NULL;
292296
size_t len;
293297
int rc;
@@ -370,6 +374,7 @@ TEST x_mock_failures(void) {
370374
g_mock_strerror_null = 0;
371375

372376
PASS();
377+
#endif
373378
}
374379

375380
/**
@@ -393,6 +398,10 @@ TEST x_jasprintf_realloc_path(void) {
393398
* @return enum test result
394399
*/
395400
TEST x_jasprintf_alias_should_succeed(void) {
401+
#if defined(_MSC_VER) && _MSC_VER < 1900
402+
PASS();
403+
#else
404+
396405
char *s = NULL;
397406
int rc1;
398407
int rc2;
@@ -412,6 +421,7 @@ TEST x_jasprintf_alias_should_succeed(void) {
412421
rc1 = c89stringutils_jasprintf(&s, NULL);
413422
ASSERT_EQ(-1, rc1);
414423
PASS();
424+
#endif
415425
}
416426

417427
/* Suites can group multiple tests with common setup. */

0 commit comments

Comments
 (0)