Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #68 from ali-ince/1.7-windows-builds
Browse files Browse the repository at this point in the history
Update build configuration for MINGW and MSVC builds
  • Loading branch information
ali-ince authored Jan 29, 2019
2 parents 67f59c6 + e816235 commit d4a484e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 21 deletions.
14 changes: 14 additions & 0 deletions CMakeCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${OS_ID}-${OS_VERSION_ID}")
endif ()

if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(CMAKE_BITNESS "64")
elseif (CMAKE_SIZEOF_VOID_P STREQUAL "4")
set(CMAKE_BITNESS "32")
endif ()

if (MSVC)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win${CMAKE_BITNESS}-msvc")
else ()
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win${CMAKE_BITNESS}-mingw")
endif ()
endif ()

if (UNIX)
if (OS_ID_LIKE MATCHES "debian")
list(APPEND CPACK_GENERATOR "DEB")
Expand Down
29 changes: 24 additions & 5 deletions make.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ If "%~3" == "" (
)
)

Set "CMAKE_BUILD=%~2"
If "%~4" == "" (
Goto :Usage
) Else If Not "%~4" == "package" (
If Not "%~4" == "install" (
Goto :Usage
)
)

If "%~1" == "MSVC" (
Set "BUILDTYPE=msvc"
Set "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"

If "%~3" == "x86" (
Expand All @@ -35,22 +42,34 @@ If "%~1" == "MSVC" (
)

If "%~1" == "MINGW" (
Set "BUILDTYPE=mingw"
Set "CMAKE_GENERATOR=MinGW Makefiles"
)

If "%~2" == "Debug" (
Set "BUILDCONFIG=debug"
Set "CMAKE_BUILD=Debug"
)

If "%~2" == "Release" (
Set "BUILDCONFIG=release"
Set "CMAKE_BUILD=RelWithDebInfo"
)

Set TARGET=%~4
Set SEABOLTDIR=%~dp0
Set BUILDDIR=%SEABOLTDIR%\build
Set BUILDDIR=%SEABOLTDIR%\build-%BUILDTYPE%-%BUILDCONFIG%
Mkdir %BUILDDIR%
Pushd %BUILDDIR%

cmake.exe -G "%CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=%CMAKE_BUILD% -DCMAKE_INSTALL_PREFIX=dist .. || Goto :Failure
cmake.exe --build . --target install --config %CMAKE_BUILD% || Goto :Failure
cmake.exe -G "%CMAKE_GENERATOR%" -DCMAKE_CONFIGURATION_TYPES=%CMAKE_BUILD% -DCMAKE_BUILD_TYPE=%CMAKE_BUILD% -DCMAKE_INSTALL_PREFIX=dist .. || Goto :Failure
cmake.exe --build . --target %TARGET% --config %CMAKE_BUILD% || Goto :Failure

Popd
Exit /b 0

:Usage
@Echo "Usage: %~n0 (MSVC|MINGW) (Debug|Release) (x86|x64)"
@Echo "Usage: %~n0 (MSVC|MINGW) (Debug|Release) (x86|x64) (install|package)"
Goto :Failure

:Failure
Expand Down
2 changes: 1 addition & 1 deletion make_debug.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Echo Off

Call %~dp0\make.cmd %~1 Debug x64 || Goto :Failure
Call %~dp0\make.cmd %~1 Debug x64 install || Goto :Failure
Exit /b 0

:Failure
Expand Down
2 changes: 1 addition & 1 deletion make_release.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Echo Off

Call %~dp0\make.cmd %~1 Release x64 || Goto :Failure
Call %~dp0\make.cmd %~1 Release x64 install || Goto :Failure
Exit /b 0

:Failure
Expand Down
14 changes: 9 additions & 5 deletions run_tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$ErrorActionPreference="Stop"
$ErrorActionPreference="Stop"
$BaseDir=$PSScriptRoot
$Password="password"
$Port=7699
Expand Down Expand Up @@ -49,7 +49,7 @@ Function Cleanup($Target)
{
try
{
Get-ChildItem -Path $Target -Recurse | Remove-Item -Force -Recurse -ErrorAction Stop
Get-ChildItem -Path $Target -ErrorAction Ignore | Remove-Item -Force -Recurse -ErrorAction Stop
}
catch
{
Expand Down Expand Up @@ -138,7 +138,11 @@ Function StopServer($Server)

Function RunTests($Version)
{
$ServerBase = "$BaseDir\build\server"
$CompilationBase = "$Basedir\build-$( $env:SEABOLT_TOOLCHAIN )-debug"
$SeaboltCli = Get-ChildItem -Path $CompilationBase\bin -Filter seabolt-cli.exe -Recurse
$SeaboltTest = Get-ChildItem -Path $CompilationBase\bin -Filter seabolt-test.exe -Recurse

$ServerBase = "$CompilationBase\server"
Cleanup $ServerBase

Write-Host "Testing against Neo4j $Version"
Expand All @@ -150,7 +154,7 @@ Function RunTests($Version)
Write-Host "-- Checking server"
$env:BOLT_PASSWORD=$Password
$env:BOLT_PORT=$Port
& $BaseDir\build\bin\Debug\seabolt-cli.exe debug "UNWIND range(1, 10000) AS n RETURN n"
& $SeaboltCli.FullName debug "UNWIND range(1, 10000) AS n RETURN n"
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Expand All @@ -160,7 +164,7 @@ Function RunTests($Version)
}

Write-Host "-- Running tests"
& $BaseDir\build\bin\Debug\seabolt-test.exe $TestArgs
& $SeaboltTest.FullName $TestArgs
if ( $LASTEXITCODE -ne 0 )
{
throw @{
Expand Down
14 changes: 6 additions & 8 deletions src/seabolt/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ foreach (target ${SEABOLT_SHARED} ${SEABOLT_STATIC})
target_link_libraries(${target}
PUBLIC
ws2_32)

target_compile_definitions(${target}
PRIVATE
_WIN32_WINNT=0x0601)
endif ()

if (WITH_TLS_SUPPORT AND WITH_TLS_OPENSSL)
Expand Down Expand Up @@ -188,7 +192,7 @@ endforeach ()

if (WITH_TLS_SUPPORT AND WITH_TLS_OPENSSL)
target_link_libraries(${SEABOLT_SHARED}
PUBLIC
PRIVATE
${OPENSSL_SHARED_LIBRARIES})

target_link_libraries(${SEABOLT_STATIC}
Expand All @@ -200,19 +204,13 @@ if (WITH_TLS_SUPPORT AND WITH_TLS_OPENSSL)
pkg_check_modules(OPENSSLDEPS openssl)

target_link_libraries(${SEABOLT_SHARED}
PUBLIC
PRIVATE
${OPENSSLDEPS_LIBRARIES})

target_link_libraries(${SEABOLT_STATIC}
PUBLIC
${OPENSSLDEPS_STATIC_LIBRARIES})
endif ()

if (MSVC)
target_link_libraries(${SEABOLT_STATIC}
PUBLIC
legacy_stdio_definitions)
endif ()
endif ()

if (CMAKE_C_COMPILER_ID MATCHES AppleClang)
Expand Down
8 changes: 7 additions & 1 deletion src/seabolt/src/bolt/string-builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ void StringBuilder_append_f(struct StringBuilder* builder, const char* format, .
va_start(args, format);
written = vsnprintf(message_fmt, size, format, args);
va_end(args);
if (written<size) {
if (written!=-1 && written<size) {
break;
}

// For some old implementations, vsnprintf returns -1 if the target buffer size is less than
// the generated string.
if (written==-1) {
written = size*10;
}

message_fmt = (char*) realloc(message_fmt, written+1);
size = written+1;
}
Expand Down

0 comments on commit d4a484e

Please sign in to comment.