From f54d2e5c70676b20d71f9c5e540adfcf06636f85 Mon Sep 17 00:00:00 2001 From: Christian Grasser Date: Thu, 2 Mar 2017 19:32:26 +0100 Subject: [PATCH] - added changes from PR#115 to a single new commit/PR - added win32 x64 build - added initial appveyor config - some win32 x64 compiler warning fixes --- CMakeLists.txt | 13 ++++++++ UTCP/src/UTDataSource.cpp | 2 +- UTCP/src/uh_ctrl.cpp | 4 +-- UTCP/src/ut_clnt.cpp | 2 +- appveyor.yml | 66 +++++++++++++++++++++++++++++++++++++++ build_3rdparty.py | 37 ++++++++++++++++++++-- src/StdInc.h | 2 +- 7 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 appveyor.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 195faef..6c45598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,17 @@ if (MINGW) set (CMAKE_MODULE_LINKER_FLAGS "-s -static" ) +else (MINGW) + set (defs + -DUNICODE -D_UNICODE -D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES -D_CRT_SECURE_NO_WARNINGS -D_WIN32 -DWIN32 + -D_WIN32_WINNT=0x0501 -DWIN32_LEAN_AND_MEAN -DNOCOMM -DLIBSSH_STATIC + ) + + set (CMAKE_CXX_FLAGS + "/EHsc /MP /W4" + ) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") endif (MINGW) set (project_rc_files @@ -122,6 +133,8 @@ if (MINGW) SET(CMAKE_SHARED_LIBRARY_PREFIX "") target_link_libraries (NppFTP comctl32 shlwapi ssh ssl crypto z ws2_32) +else (MINGW) + target_link_libraries (NppFTP comctl32 shlwapi ssh libeay32 ssleay32 zlib ws2_32) endif (MINGW) # build a CPack driven zip package diff --git a/UTCP/src/UTDataSource.cpp b/UTCP/src/UTDataSource.cpp index 2b9e07d..7c045e3 100644 --- a/UTCP/src/UTDataSource.cpp +++ b/UTCP/src/UTDataSource.cpp @@ -77,7 +77,7 @@ long CUT_DataSource::Find(LPCSTR szStrToFind, size_t nStartOffset, BOOL bCaseSen while( (nBytesRead = Read(szBuffer, FIND_BUFFER_SIZE - 1)) > nStrLength ) { // Terminate buffer with NULL - szBuffer[nBytesRead] = NULL; + szBuffer[nBytesRead] = '\0'; // Convert to upper case if case insensitive search if(!bCaseSensitive) diff --git a/UTCP/src/uh_ctrl.cpp b/UTCP/src/uh_ctrl.cpp index 050fab2..6ceec72 100644 --- a/UTCP/src/uh_ctrl.cpp +++ b/UTCP/src/uh_ctrl.cpp @@ -131,7 +131,7 @@ int CUH_Control::CreateHistoryWindow(HWND parent,DWORD style,RECT &rect){ return UH_ERROR; #ifdef WIN32 - HINSTANCE hInstance = (HINSTANCE)(ULONG_PTR)GetWindowLong(parent,GWLP_HINSTANCE); + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(parent,GWLP_HINSTANCE); #else HINSTANCE hInstance = (HINSTANCE)GetWindowWord(parent,GWW_HINSTANCE); #endif @@ -258,7 +258,7 @@ LRESULT CALLBACK CUH_Control::WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARA } //get the pointer to the calling class - CUH_Control *_this = (CUH_Control*)(ULONG_PTR)GetWindowLong(hwnd,0); + CUH_Control *_this = (CUH_Control*)GetWindowLongPtr(hwnd,0); //call the functions that match in incoming message if(_this != NULL){ diff --git a/UTCP/src/ut_clnt.cpp b/UTCP/src/ut_clnt.cpp index e2a98a2..cd94a83 100644 --- a/UTCP/src/ut_clnt.cpp +++ b/UTCP/src/ut_clnt.cpp @@ -2217,7 +2217,7 @@ LRESULT CALLBACK CUT_WSClient::WndProc(HWND hwnd, UINT message, WPARAM wParam, L } // Get the pointer to the calling class - CUT_WSClient *_this = (CUT_WSClient*)(ULONG_PTR)GetWindowLong(hwnd,0); + CUT_WSClient *_this = (CUT_WSClient*)GetWindowLongPtr(hwnd,0); // Call the functions that match in incoming message if (_this == NULL) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..e22835a --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,66 @@ +version: 0.26.8.{build} +image: Visual Studio 2015 + + +environment: + matrix: + - PlatformToolset: v140_xp + #- PlatformToolset: v120_xp + +platform: + - x64 + - Win32 + +configuration: + - Release + #- Debug + +install: + - if "%platform%"=="x64" set archi=amd64 + - if "%platform%"=="Win32" set archi=x86 + - if "%PlatformToolset%"=="v140_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi% + - if "%PlatformToolset%"=="v120_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %archi% + +build: + verbosity: minimal + +before_build: +- ps: | + Write-Output "Configuration: $env:CONFIGURATION" + Write-Output "Platform: $env:PLATFORM" + $generator = switch ($env:PLATFORMTOOLSET) + { + "v140_xp" {"Visual Studio 14 2015"} + "v120_xp" {"Visual Studio 12 2013"} + } + if ($env:PLATFORM -eq "x64") + { + $generator = "$generator Win64" + } + +build_script: + - cd "%APPVEYOR_BUILD_FOLDER%" + # Python 3 needed + - set PATH=C:\Python34-x64;C:\Python34-x64\Scripts;%PATH% + #done within cmake - if "%platform%"=="X64" python build_3rdparty.py x64 msvc_x64 + #done within cmake - if "%platform%"=="Win32" C:\Python34-x64\python build_3rdparty.py + - mkdir _build + - cd _build + + - ps: | + cmake -G "$generator" -T "$env:PLATFORMTOOLSET" .. + if ($LastExitCode -ne 0) { + throw "Exec: $ErrorMessage" + } + & cmake --build . --config $env:CONFIGURATION + if ($LastExitCode -ne 0) { + throw "Exec: $ErrorMessage" + } + +after_build: + - cd "%APPVEYOR_BUILD_FOLDER%" + - ps: >- + + if ($env:CONFIGURATION -eq "Release") { + Push-AppveyorArtifact "_build\Release\NppFTP.dll" -FileName "NppFTP.dll" + } diff --git a/build_3rdparty.py b/build_3rdparty.py index 0e8396f..6027312 100755 --- a/build_3rdparty.py +++ b/build_3rdparty.py @@ -18,10 +18,18 @@ 'msvc': { 'result': ['include/openssl/ssl.h', 'lib/libeay32.lib', 'lib/ssleay32.lib'], 'commands': [ - 'perl Configure --openssldir=%(dest)s no-shared no-asm VC-WIN32', + 'perl Configure --openssldir=%(dest)s no-shared no-asm VC-WIN32', 'ms\\do_ms.bat', 'nmake /f ms\\nt.mak install' ] + }, + 'msvc_x64': { + 'result': ['include/openssl/ssl.h', 'lib/libeay32.lib', 'lib/ssleay32.lib'], + 'commands': [ + 'perl Configure --openssldir=%(dest)s no-shared no-asm VC-WIN64A', + 'ms\\do_win64a.bat', + 'nmake /f ms\\nt.mak install' + ] } } }, @@ -48,6 +56,16 @@ 'copy /Y zconf.h %(dest)s\\include >nul', 'copy /Y zlib.lib %(dest)s\\lib >nul' ] + }, + 'msvc_x64': { + 'result': ['include/zlib.h', 'include/zconf.h', 'lib/zlib.lib'], + 'replace': [('win32/Makefile.msc', '-MD', '-MT')], + 'commands': [ + 'nmake /f win32/Makefile.msc zlib.lib', + 'copy /Y zlib.h %(dest)s\\include >nul', + 'copy /Y zconf.h %(dest)s\\include >nul', + 'copy /Y zlib.lib %(dest)s\\lib >nul' + ] } } }, @@ -80,6 +98,18 @@ 'del %(dest)s\\lib\\ssh.lib >nul', 'move %(dest)s\\lib\\static\\ssh.lib %(dest)s\\lib >nul' ] + }, + 'msvc_x64': { + 'result': ['include/libssh/libssh.h', 'lib/ssh.lib'], + 'commands': [ + 'cmake -G "NMake Makefiles" -DWITH_STATIC_LIB=ON -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /D NDEBUG" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /D NDEBUG" \ + -DOPENSSL_INCLUDE_DIRS=%(dest)s\\include -DOPENSSL_CRYPTO_LIBRARY=%(dest)s\\lib\\libeay32.lib \ + -DCMAKE_INSTALL_PREFIX=%(dest)s -DCMAKE_PREFIX_PATH=%(dest)s %(src)s', + 'nmake install', + 'del %(dest)s\\lib\\ssh.lib >nul', + 'move %(dest)s\\lib\\static\\ssh.lib %(dest)s\\lib >nul' + ] } } } @@ -162,7 +192,10 @@ def main(outdir, prefix): mkdir_p(dest, 'include') mkdir_p(dest, 'lib') - target = platform.system() == 'Windows' and 'msvc' or 'mingw-w64' + if(prefix == 'msvc_x64'): + target = 'msvc_x64' + else: + target = platform.system() == 'Windows' and 'msvc' or 'mingw-w64' for library in sorted(DEPENDENT_LIBS, key=lambda x: DEPENDENT_LIBS[x]['order']): if target not in DEPENDENT_LIBS[library]['target']: print('%s: skipping (not available)' % library) diff --git a/src/StdInc.h b/src/StdInc.h index eed0654..520448e 100644 --- a/src/StdInc.h +++ b/src/StdInc.h @@ -21,7 +21,7 @@ #define _WIN32_WINNT 0x0501 #include #include -#include +#include #include #include #include