[Spice-commits] 9 commits - appveyor.yml CMakeLists.txt common/vdlog.cpp common/version.rc Makefile.am test-png

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 6 10:47:17 UTC 2019


 CMakeLists.txt    |  182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.am       |    7 +-
 appveyor.yml      |   49 ++++++++++++++
 common/vdlog.cpp  |    4 -
 common/version.rc |    2 
 test-png          |   22 +++++-
 6 files changed, 259 insertions(+), 7 deletions(-)

New commits:
commit 981b5f0dd1c32d4098f973a7119ace35e12bfc67
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Nov 30 09:47:53 2019 +0000

    build: Do not generate CMake config.h in source directory
    
    Allows to build out-of-tree and have a clean working directory.
    Autoconf used to work with out-of-tree and "config.h" in the
    build directory as a "common" directory in the build directory
    was created, so including "../config.h" in version.rc and having
    "-I $(top_builddir)/common" used to work.
    CMake does not create "common" under the build directory so the
    "../config.h" inclusion fails.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7debd27..d5504fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,7 +42,7 @@ endif()
 config_write("#define RC_PRODUCTVERSION ${RC_PRODUCTVERSION}\n")
 config_write("#define RC_PRODUCTVERSION_STR \"${RC_PRODUCTVERSION}\"\n")
 
-configure_file(${CMAKE_BINARY_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/config.h)
+configure_file(${CMAKE_BINARY_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
 
 
 if(MSVC)
@@ -76,7 +76,7 @@ else(MSVC)
     set(COMMSUPPW_LIBRARY)
 endif(MSVC)
 
-include_directories(common . spice-protocol ${PNG_INCLUDE_DIR})
+include_directories(common ${CMAKE_BINARY_DIR} spice-protocol ${PNG_INCLUDE_DIR})
 add_definitions(-DUNICODE -D_UNICODE -DOLDMSVCRT -DWINVER=0x0601)
 
 add_executable(vdagent WIN32
diff --git a/Makefile.am b/Makefile.am
index 24d2446..b87c072 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -51,7 +51,7 @@ vdagent_SOURCES =			\
 	$(NULL)
 
 vdagent_rc.$(OBJEXT): vdagent/vdagent.rc
-	$(AM_V_GEN)$(WINDRES) -I $(top_builddir)/common -i $< -o $@
+	$(AM_V_GEN)$(WINDRES) -I $(top_builddir) -i $< -o $@
 
 MAINTAINERCLEANFILES += vdagent_rc.$(OBJEXT)
 
@@ -66,7 +66,7 @@ vdservice_SOURCES =			\
 	$(NULL)
 
 vdservice_rc.$(OBJEXT): vdservice/vdservice.rc
-	$(AM_V_GEN)$(WINDRES) -I $(top_builddir)/common -i $< -o $@
+	$(AM_V_GEN)$(WINDRES) -I $(top_builddir) -i $< -o $@
 
 MAINTAINERCLEANFILES += vdservice_rc.$(OBJEXT)
 
diff --git a/common/version.rc b/common/version.rc
index 2603dce..9981157 100644
--- a/common/version.rc
+++ b/common/version.rc
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // English (U.S.) resources
 
-#include "../config.h"
+#include "config.h"
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
 #ifdef _WIN32
commit d59123bdeecb84963290771bbc84e78a1154e122
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 28 16:59:50 2019 +0000

    ci: Add testing to CMake
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 295eda3..7debd27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,9 +126,57 @@ target_link_libraries(vdservice
     wtsapi32
 )
 
+enable_testing()
+add_custom_target(check COMMAND ctest -C $<CONFIG>)
+
+if(CMAKE_CROSSCOMPILING)
+    set(CMAKE_CROSSCOMPILING_EMULATOR wine)
+endif()
+
+add_executable(imagetest EXCLUDE_FROM_ALL
+    common/vdcommon.cpp
+    common/vdcommon.h
+    common/vdlog.cpp
+    common/vdlog.h
+    vdagent/imagetest.cpp
+    vdagent/image.cpp
+    vdagent/image.h
+    vdagent/imagepng.cpp
+    vdagent/imagepng.h
+)
+target_link_libraries(imagetest
+    ${PNG_LIBRARY}
+    ${ZLIB_LIBRARY}
+    wtsapi32
+)
+add_test(NAME test-png COMMAND bash "${CMAKE_SOURCE_DIR}/test-png")
+
+add_executable(test-log EXCLUDE_FROM_ALL
+    common/vdcommon.cpp
+    common/vdcommon.h
+    common/vdlog.cpp
+    common/vdlog.h
+    common/test-log.cpp
+)
+add_test(NAME test-log COMMAND test-log)
+
+add_executable(test-shell EXCLUDE_FROM_ALL
+    vdagent/test-shell.cpp
+)
+target_link_libraries(test-shell
+    uuid
+    ole32
+    oleaut32
+    ${COMMSUPPW_LIBRARY}
+)
+add_test(NAME test-shell COMMAND test-shell)
+
+add_dependencies(check test-log test-shell imagetest)
+
 if(MSVC)
     # select static CRT without debugging (/MT option)
     if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15")
-        set_property(TARGET vdagent vdservice PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
+        set_property(TARGET vdagent vdservice imagetest
+            PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
     endif()
 endif()
diff --git a/appveyor.yml b/appveyor.yml
index b6462f6..db1329e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -9,25 +9,36 @@ install:
 - git submodule update --init --recursive
 - mkdir build32
 - mkdir build64
+
+- choco install --timeout 600 -y imagemagick.tool
+
 - cd %VCPKG_ROOT%
 - git pull
 - .\bootstrap-vcpkg.bat
 - vcpkg install libpng:x64-windows-static libpng:x86-windows-static
 
 build_script:
+- set CTEST_OUTPUT_ON_FAILURE=1
+
 - cd %APPVEYOR_BUILD_FOLDER%\build64
 - cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A x64 -DVCPKG_TARGET_TRIPLET=x64-windows-static ..
 - cmake --build . --config Release
+- cmake --build . --config Release --target check
 
 - cd %APPVEYOR_BUILD_FOLDER%\build32
 - cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A Win32 -DVCPKG_TARGET_TRIPLET=x86-windows-static ..
 - cmake --build . --config Release
+- cmake --build . --config Release --target check
 
 after_build:
 - cd %APPVEYOR_BUILD_FOLDER%\build64
+- del Release\test*
+- del Release\imagetest*
 - 7z a vdagent-win-x64.zip Release\*
 
 - cd %APPVEYOR_BUILD_FOLDER%\build32
+- del Release\test*
+- del Release\imagetest*
 - 7z a vdagent-win-x86.zip Release\*
 
 artifacts:
diff --git a/test-png b/test-png
index ee9d86e..b0fe1d2 100755
--- a/test-png
+++ b/test-png
@@ -17,6 +17,24 @@ verbose() {
     fi
 }
 
+# under Windows we don't need to run test under Wine
+WINE=wine
+if [ "x`uname -s`" != xLinux ]; then
+    WINE=
+fi
+
+# this fixes search under Windows which often detect convert utility
+# under system directory, look for the one in the same directory as
+# mogrify
+CONVERT="$(command -v mogrify)"
+CONVERT="${CONVERT//mogrify/convert}"
+
+# MSVC build put executables under <Configuration> directory
+IMAGETEST=imagetest.exe
+if [ -e ./Release/imagetest.exe ]; then
+    IMAGETEST=./Release/imagetest.exe
+fi
+
 compare_images() {
     DIFF=$(compare -metric AE $1 $2 - 2>&1 > /dev/null || true)
     if [ "$DIFF" != "0" ]; then
@@ -26,8 +44,8 @@ compare_images() {
 
 do_test() {
     echo "Running image $IMAGE with '$*'..."
-    convert $IMAGE "$@" $IN
-    wine imagetest.exe $IN $OUT_BMP $OUT
+    $CONVERT $IMAGE "$@" $IN
+    $WINE $IMAGETEST $IN $OUT_BMP $OUT
     verbose ls -lh $IN
     verbose identify $IN
     verbose identify $OUT_BMP
commit 3b5f0929c20d90a980ae7d972881da538b7550c5
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 28 10:53:58 2019 +0000

    build: Generate config.h from CMake
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af75a5b..295eda3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,46 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15")
 endif()
 project(vdagent-win)
 
+# configure
+file(WRITE "${CMAKE_BINARY_DIR}/config.h.in" "/* Automatic generated by CMake */\n\n")
+
+macro(config_write str)
+    file(APPEND "${CMAKE_BINARY_DIR}/config.h.in" "${str}")
+endmacro()
+
+string(TIMESTAMP BUILD_YEAR "%Y")
+config_write("#define BUILD_YEAR \"${BUILD_YEAR}\"\n")
+
+if(EXISTS "${CMAKE_SOURCE_DIR}/.tarball-version")
+    file(STRINGS "${CMAKE_SOURCE_DIR}/.tarball-version" VER)
+    list(GET VER 0 VER)
+    set(VER "v${VER}")
+else()
+    find_package(Git)
+    if(GIT_FOUND)
+        execute_process(
+            COMMAND ${GIT_EXECUTABLE} describe --abbrev=4 --match=v* HEAD
+            WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+            OUTPUT_VARIABLE VER
+            ERROR_QUIET
+            OUTPUT_STRIP_TRAILING_WHITESPACE
+        )
+    else()
+        message(FATAL_ERROR "GIT not found")
+    endif()
+endif()
+
+if("${VER}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+    set(RC_PRODUCTVERSION "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, ${CMAKE_MATCH_3}, 0")
+else()
+    message(FATAL_ERROR "wrong VERSION format ${VER}")
+endif()
+config_write("#define RC_PRODUCTVERSION ${RC_PRODUCTVERSION}\n")
+config_write("#define RC_PRODUCTVERSION_STR \"${RC_PRODUCTVERSION}\"\n")
+
+configure_file(${CMAKE_BINARY_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/config.h)
+
+
 if(MSVC)
     if(${CMAKE_VERSION} VERSION_LESS "3.15")
         # compile MSVCRT into executable (link it statically)
commit 266b67e2a71be2932c655c70ac27bbbee8175382
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Nov 27 14:58:12 2019 +0000

    ci: Integrate with AppVeyor
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..b6462f6
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,38 @@
+configuration: Release
+
+cache: c:\Tools\vcpkg\installed\
+
+environment:
+  VCPKG_ROOT: c:\Tools\vcpkg
+
+install:
+- git submodule update --init --recursive
+- mkdir build32
+- mkdir build64
+- cd %VCPKG_ROOT%
+- git pull
+- .\bootstrap-vcpkg.bat
+- vcpkg install libpng:x64-windows-static libpng:x86-windows-static
+
+build_script:
+- cd %APPVEYOR_BUILD_FOLDER%\build64
+- cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A x64 -DVCPKG_TARGET_TRIPLET=x64-windows-static ..
+- cmake --build . --config Release
+
+- cd %APPVEYOR_BUILD_FOLDER%\build32
+- cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A Win32 -DVCPKG_TARGET_TRIPLET=x86-windows-static ..
+- cmake --build . --config Release
+
+after_build:
+- cd %APPVEYOR_BUILD_FOLDER%\build64
+- 7z a vdagent-win-x64.zip Release\*
+
+- cd %APPVEYOR_BUILD_FOLDER%\build32
+- 7z a vdagent-win-x86.zip Release\*
+
+artifacts:
+- path: build64/vdagent-win-x64.zip
+  name: VdAgentWin-x64
+
+- path: build32/vdagent-win-x86.zip
+  name: VdAgentWin-x86
commit 9a36133b85de65ad329250238b4820cb87d36eaf
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 28 09:48:52 2019 +0000

    build: Make sure to use multi-thread library for MSVC
    
    We want to have self-contained executables so link to the static
    version of Microsoft CRT, not the DLL ones.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c6ca921..af75a5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,22 @@
 cmake_minimum_required(VERSION 3.0)
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15")
+    # this is for MSVC_RUNTIME_LIBRARY property below
+    cmake_policy(SET CMP0091 NEW)
+endif()
 project(vdagent-win)
 
 if(MSVC)
+    if(${CMAKE_VERSION} VERSION_LESS "3.15")
+        # compile MSVCRT into executable (link it statically)
+        foreach(flag_var
+            CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+            CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+            if(${flag_var} MATCHES "/MD")
+                string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+            endif(${flag_var} MATCHES "/MD")
+        endforeach(flag_var)
+    endif()
+
     # generate PDB files
     # see https://stackoverflow.com/questions/28178978/how-to-generate-pdb-files-for-release-build-with-cmake-flags/31264946
     set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
@@ -70,3 +85,10 @@ add_executable(vdservice
 target_link_libraries(vdservice
     wtsapi32
 )
+
+if(MSVC)
+    # select static CRT without debugging (/MT option)
+    if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15")
+        set_property(TARGET vdagent vdservice PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
+    endif()
+endif()
commit 437ebd11eb29c630a765bde81df4ce2c46e2348d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Nov 27 16:03:35 2019 +0000

    build: Generate PDB files for Release configuration
    
    This will make debugging and error reporting easier.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e239179..c6ca921 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.0)
 project(vdagent-win)
 
 if(MSVC)
+    # generate PDB files
+    # see https://stackoverflow.com/questions/28178978/how-to-generate-pdb-files-for-release-build-with-cmake-flags/31264946
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+    set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF" CACHE STRING "" FORCE)
+
     # find using vcpkg packages
     find_package(libpng CONFIG REQUIRED)
     find_path(PNG_INCLUDE_DIR NAMES png.h)
commit 218d89e6dbb264367948b5d100dc1094aa50a7ed
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Nov 4 12:55:13 2019 +0000

    build: Allows to easily compile using vcpkg and Visual Studio
    
    Add support for MSVC to CMake files.
    This settings assume you are using vcpkg to build libpng.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c110d72..e239179 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,20 @@
 cmake_minimum_required(VERSION 3.0)
 project(vdagent-win)
 
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -s")
+if(MSVC)
+    # find using vcpkg packages
+    find_package(libpng CONFIG REQUIRED)
+    find_path(PNG_INCLUDE_DIR NAMES png.h)
 
-find_package(PNG REQUIRED)
+    set(PNG_LIBRARY png_static)
+    set(ZLIB_LIBRARY)
+    set(COMMSUPPW_LIBRARY comsuppw)
+else(MSVC)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -s")
+
+    find_package(PNG REQUIRED)
+    set(COMMSUPPW_LIBRARY)
+endif(MSVC)
 
 include_directories(common . spice-protocol ${PNG_INCLUDE_DIR})
 add_definitions(-DUNICODE -D_UNICODE -DOLDMSVCRT -DWINVER=0x0601)
@@ -39,6 +50,7 @@ target_link_libraries(vdagent
     uuid
     ole32
     oleaut32
+    ${COMMSUPPW_LIBRARY}
 )
 
 add_executable(vdservice
commit 3995a8747654cfb6d31fde78f3c4f07857842fec
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon May 28 09:21:35 2018 +0100

    build: Base CMake support
    
    Although for other projects we started moving to Meson instead of
    Autoconf add support for CMake for Windows agent.
    Windows has more support for CMake than for Meson, there are
    many tools (like Visual Studio, NuGet and vcpkg) and libraries
    (like libz and libpng that we use here) that support CMake instead
    of Meson.
    This will also make easier to add automatic builds using Microsoft
    tools.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c110d72
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,55 @@
+cmake_minimum_required(VERSION 3.0)
+project(vdagent-win)
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -s")
+
+find_package(PNG REQUIRED)
+
+include_directories(common . spice-protocol ${PNG_INCLUDE_DIR})
+add_definitions(-DUNICODE -D_UNICODE -DOLDMSVCRT -DWINVER=0x0601)
+
+add_executable(vdagent WIN32
+    common/vdcommon.cpp
+    common/vdcommon.h
+    common/vdlog.cpp
+    common/vdlog.h
+    vdagent/display_configuration.cpp
+    vdagent/display_configuration.h
+    vdagent/desktop_layout.cpp
+    vdagent/desktop_layout.h
+    vdagent/display_setting.cpp
+    vdagent/display_setting.h
+    vdagent/file_xfer.cpp
+    vdagent/file_xfer.h
+    vdagent/vdagent.cpp
+    vdagent/as_user.cpp
+    vdagent/as_user.h
+    vdagent/image.cpp
+    vdagent/image.h
+    vdagent/imagepng.cpp
+    vdagent/imagepng.h
+    vdagent/shell.cpp
+    vdagent/shell.h
+    vdagent/vdagent.rc
+)
+target_link_libraries(vdagent
+    ${PNG_LIBRARY}
+    ${ZLIB_LIBRARY}
+    wtsapi32
+    uuid
+    ole32
+    oleaut32
+)
+
+add_executable(vdservice
+    common/stdint.h
+    common/vdcommon.cpp
+    common/vdcommon.h
+    common/vdlog.cpp
+    common/vdlog.h
+    vdservice/vdservice.cpp
+    vdservice/vdservice.rc
+)
+target_link_libraries(vdservice
+    wtsapi32
+)
diff --git a/Makefile.am b/Makefile.am
index 77c86b6..24d2446 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -143,7 +143,8 @@ EXTRA_DIST +=			\
 	vdagent/vdagent.vcproj	\
 	vdservice/resource.h	\
 	vdservice/vdservice.rc	\
-	vdservice/vdservice.vcproj
+	vdservice/vdservice.vcproj \
+	CMakeLists.txt
 
 # see git-version-gen
 dist-hook:
commit 7aa46954fd3b76b8ed8e72a10d4fa00db152dfd5
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Nov 26 13:10:12 2019 +0000

    vdlog: Fix compatibility with MSVC
    
    _wstat64 documentation states that we should include sys/types.h
    and sys/stat.h.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index a484a07..f3b8619 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -21,6 +21,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <share.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <vector>
 
 #define LOG_ROLL_SIZE (1024 * 1024)
@@ -46,7 +48,7 @@ VDLog* VDLog::get(TCHAR* path)
     if (_log || !path) {
         return _log;
     }
-    __stat64 buf;
+    struct _stat64 buf;
     if (_wstat64(path, &buf) == 0 && buf.st_size > LOG_ROLL_SIZE) {
         TCHAR roll_path[MAX_PATH];
         swprintf_s(roll_path, MAX_PATH, L"%s.1", path);


More information about the Spice-commits mailing list