From d788ada4e97ce5b36fc397a94da453814342ec43 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 3 Apr 2019 02:16:30 -0700 Subject: [PATCH] [vtk] Fix flakiness by relying on vcpkg-provided dependencies [libharu] Add patches required for vtk [vcpkg-build-cmake] Add retry logic for mt.exe failures --- ports/libharu/CONTROL | 2 +- ports/libharu/add-boolean-typedef.patch | 12 ++++ ports/libharu/portfile.cmake | 15 ++++- ports/vtk/CONTROL | 8 +-- ports/vtk/fix-pugixml-link.patch | 14 +++++ ports/vtk/portfile.cmake | 73 +++++++------------------ scripts/cmake/vcpkg_build_cmake.cmake | 29 +++++++++- 7 files changed, 89 insertions(+), 64 deletions(-) create mode 100644 ports/libharu/add-boolean-typedef.patch create mode 100644 ports/vtk/fix-pugixml-link.patch diff --git a/ports/libharu/CONTROL b/ports/libharu/CONTROL index c4f48ab3d8..72778aa6bd 100644 --- a/ports/libharu/CONTROL +++ b/ports/libharu/CONTROL @@ -1,4 +1,4 @@ Source: libharu -Version: 2017-08-15-d84867ebf9f-5 +Version: 2017-08-15-d84867ebf9f-6 Description: libharu - free PDF library Build-Depends: zlib, libpng diff --git a/ports/libharu/add-boolean-typedef.patch b/ports/libharu/add-boolean-typedef.patch new file mode 100644 index 0000000000..7768ed301b --- /dev/null +++ b/ports/libharu/add-boolean-typedef.patch @@ -0,0 +1,12 @@ +diff --git a/include/hpdf.h b/include/hpdf.h +index 1cf0dd9..cce9b59 100644 +--- a/include/hpdf.h ++++ b/include/hpdf.h +@@ -54,6 +54,7 @@ + #include "hpdf_types.h" + + typedef void *HPDF_HANDLE; ++typedef HPDF_HANDLE HPDF_Boolean; + typedef HPDF_HANDLE HPDF_Doc; + typedef HPDF_HANDLE HPDF_Page; + typedef HPDF_HANDLE HPDF_Pages; diff --git a/ports/libharu/portfile.cmake b/ports/libharu/portfile.cmake index 42f85c2b49..7855dedc74 100644 --- a/ports/libharu/portfile.cmake +++ b/ports/libharu/portfile.cmake @@ -1,11 +1,22 @@ include(vcpkg_common_functions) + +vcpkg_download_distfile(SHADING_PR + URLS "https://github.com/libharu/libharu/pull/157.diff" + FILENAME "libharu-shading-pr-157.patch" + SHA512 f2ddb22b54b4eccc79400b6a4b2d245a221898f75456a5a559523eab7a523a87dfc5dfd0ec5fb17a771697e03c7ea6ed4c6095eff73e0a4302cd6eb24584c957 +) + vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO libharu/libharu REF d84867ebf9f3de6afd661d2cdaff102457fbc371 SHA512 789579dd52c1056ae90a4ce5360c26ba92cadae5341a3901c4159afe624129a1f628fa6412952a398e048b0e5040c93f7ed5b4e4bc620a22d897098298fe2a99 HEAD_REF master - PATCHES fix-build-fail.patch + PATCHES + fix-build-fail.patch + add-boolean-typedef.patch + # This patch adds shading support which is required for VTK. If desired, this could be moved into an on-by-default feature. + ${SHADING_PR} ) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" LIBHPDF_STATIC) @@ -21,7 +32,7 @@ vcpkg_configure_cmake( vcpkg_install_cmake() -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libhpdfs.lib ${CURRENT_PACKAGES_DIR}/lib/libhpdf.lib) file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libhpdfsd.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libhpdfd.lib) endif() diff --git a/ports/vtk/CONTROL b/ports/vtk/CONTROL index 0d489e677a..c575868245 100644 --- a/ports/vtk/CONTROL +++ b/ports/vtk/CONTROL @@ -1,7 +1,7 @@ Source: vtk Version: 8.2.0-2 Description: Software system for 3D computer graphics, image processing, and visualization -Build-Depends: zlib, libpng, tiff, libxml2, jsoncpp, glew, freetype, expat, hdf5, libjpeg-turbo, proj4, lz4, libtheora, atlmfc (windows) +Build-Depends: zlib, libpng, tiff, libxml2, jsoncpp, glew, freetype, expat, hdf5, libjpeg-turbo, proj4, lz4, libtheora, atlmfc (windows), eigen3, double-conversion, pugixml, libharu, sqlite3 Feature: openvr Description: OpenVR functionality for VTK @@ -9,7 +9,7 @@ Build-Depends: sdl2, openvr Feature: qt Description: Qt functionality for VTK -Build-Depends: qt5 +Build-Depends: qt5, netcdf-c Feature: mpi Description: MPI functionality for VTK @@ -18,7 +18,3 @@ Build-Depends: msmpi, hdf5[parallel] Feature: python Description: Python functionality for VTK Build-Depends: python3 - -Feature: libharu -Description: PDF libharu functionality for VTK -Build-Depends: libharu diff --git a/ports/vtk/fix-pugixml-link.patch b/ports/vtk/fix-pugixml-link.patch new file mode 100644 index 0000000000..8708506b6e --- /dev/null +++ b/ports/vtk/fix-pugixml-link.patch @@ -0,0 +1,14 @@ +diff --git a/IO/CityGML/CMakeLists.txt b/IO/CityGML/CMakeLists.txt +index ce979ba..322e2de 100644 +--- a/IO/CityGML/CMakeLists.txt ++++ b/IO/CityGML/CMakeLists.txt +@@ -4,8 +4,5 @@ vtk_module_library(vtkIOCityGML ${Module_SRCS}) + # pugixml does not set _INCLUDE_DIRS or _LIBRARIES + if(VTK_USE_SYSTEM_PUGIXML AND NOT pugixml_INCLUDE_DIRS) + find_package(pugixml REQUIRED) +- get_target_property(pugixml_INCLUDE_DIRS pugixml INTERFACE_INCLUDE_DIRECTORIES) +- get_target_property(pugixml_LIBRARIES pugixml LOCATION) +- include_directories(${pugixml_INCLUDE_DIRS}) +- vtk_module_link_libraries(vtkIOCityGML LINK_PRIVATE ${pugixml_LIBRARIES}) ++ vtk_module_link_libraries(vtkIOCityGML LINK_PRIVATE pugixml) + endif() diff --git a/ports/vtk/portfile.cmake b/ports/vtk/portfile.cmake index baff2cb06c..deed58eb93 100644 --- a/ports/vtk/portfile.cmake +++ b/ports/vtk/portfile.cmake @@ -16,9 +16,9 @@ else() endif() if ("mpi" IN_LIST FEATURES) - set(VTK_WITH_MPI ON ) + set(VTK_Group_MPI ON) else() - set(VTK_WITH_MPI OFF ) + set(VTK_Group_MPI OFF) endif() if ("python" IN_LIST FEATURES) @@ -28,15 +28,9 @@ else() endif() if("openvr" IN_LIST FEATURES) - set(VTK_WITH_OPENVR ON) + set(Module_vtkRenderingOpenVR ON) else() - set(VTK_WITH_OPENVR OFF) -endif() - -if("libharu" IN_LIST FEATURES) - set(VTK_WITH_LIBHARU ON) -else() - set(VTK_WITH_LIBHARU OFF) + set(Module_vtkRenderingOpenVR OFF) endif() set(VTK_WITH_ALL_MODULES OFF) # IMPORTANT: if ON make sure `qt5`, `mpi`, `python3`, `ffmpeg`, `gdal`, `fontconfig`, @@ -46,14 +40,16 @@ set(VTK_WITH_ALL_MODULES OFF) # IMPORTANT: if ON make sure `qt5` # Clone & patch vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH - REPO "Kitware/VTK" + REPO Kitware/VTK REF "v${VTK_LONG_VERSION}" SHA512 fd1d9c2872baa6eca7f8105b0057b56ec554e9d5eaf25985302e7fc032bdce72255d79e3f5f16ca50504151bda49cb3a148272ba32e0f410b4bdb70959b8f3f4 HEAD_REF "master" PATCHES fix-find-lz4.patch fix_ogg_linkage.patch + fix-pugixml-link.patch ) + # Remove the FindGLEW.cmake and FindPythonLibs.cmake that are distributed with VTK, # since they do not detect the debug libraries correctly. # The default files distributed with CMake (>= 3.9) should be superior by all means. @@ -73,12 +69,6 @@ if(VTK_WITH_QT) ) endif() -if(VTK_WITH_MPI) - list(APPEND ADDITIONAL_OPTIONS - -DVTK_Group_MPI=ON - ) -endif() - if(VTK_WITH_PYTHON) list(APPEND ADDITIONAL_OPTIONS -DVTK_WRAP_PYTHON=ON @@ -86,18 +76,6 @@ if(VTK_WITH_PYTHON) ) endif() -if(VTK_WITH_OPENVR) - list(APPEND ADDITIONAL_OPTIONS - -DModule_vtkRenderingOpenVR=ON - ) -endif() - -if(VTK_WITH_LIBHARU) - list(APPEND ADDITIONAL_OPTIONS - -DVTK_USE_SYSTEM_LIBHARU=ON - ) -endif() - if(VTK_WITH_ALL_MODULES) list(APPEND ADDITIONAL_OPTIONS -DVTK_BUILD_ALL_MODULES=ON @@ -123,44 +101,31 @@ endif() # ============================================================================= # Configure & Install -if(${VCPKG_LIBRARY_LINKAGE} MATCHES "static") - set(HDF5_USE_STATIC_LIBRARIES ON) -endif() vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS - -DHDF5_USE_STATIC_LIBRARIES=${HDF5_USE_STATIC_LIBRARIES} - -DHAVE_SNPRINTF=ON - -DVTK_Group_Imaging=ON - -DVTK_Group_Views=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF - -DVTK_USE_SYSTEM_EXPAT=ON - -DVTK_USE_SYSTEM_FREETYPE=ON - # -DVTK_USE_SYSTEM_GL2PS=ON - -DVTK_USE_SYSTEM_JPEG=ON - -DVTK_USE_SYSTEM_GLEW=ON - -DVTK_USE_SYSTEM_HDF5=ON - -DVTK_USE_SYSTEM_JSONCPP=ON - -DVTK_USE_SYSTEM_LIBPROJ=ON - -DVTK_USE_SYSTEM_LIBXML2=ON - -DVTK_USE_SYSTEM_LZ4=ON - # -DVTK_USE_SYSTEM_NETCDF=ON - # -DVTK_USE_SYSTEM_NETCDFCPP=ON - -DVTK_USE_SYSTEM_OGG=ON - -DVTK_USE_SYSTEM_THEORA=ON - -DVTK_USE_SYSTEM_PNG=ON - -DVTK_USE_SYSTEM_TIFF=ON - -DVTK_USE_SYSTEM_ZLIB=ON -DVTK_INSTALL_INCLUDE_DIR=include -DVTK_INSTALL_DATA_DIR=share/vtk/data -DVTK_INSTALL_DOC_DIR=share/vtk/doc -DVTK_INSTALL_PACKAGE_DIR=share/vtk -DVTK_INSTALL_RUNTIME_DIR=bin -DVTK_FORBID_DOWNLOADS=ON + + # We set all libraries to "system" and explicitly list the ones that should use embedded copies + -DVTK_USE_SYSTEM_LIBRARIES=ON + -DVTK_USE_SYSTEM_GL2PS=OFF + + # Select modules / groups to install + -DVTK_Group_Imaging=ON + -DVTK_Group_Views=ON -DModule_vtkGUISupportMFC=${Module_vtkGUISupportMFC} + -DModule_vtkRenderingOpenVR=${Module_vtkRenderingOpenVR} + -DVTK_Group_MPI=${VTK_Group_MPI} + ${ADDITIONAL_OPTIONS} ) @@ -286,7 +251,7 @@ if(VTK_WITH_ALL_MODULES) file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/XdmfConfig.cmake) endif() -if(VCPKG_LIBRARY_LINKAGE STREQUAL static) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) endif() diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 2f0da07f96..e86632c7e3 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -162,6 +162,33 @@ function(vcpkg_build_cmake) endif() endwhile() endif() + elseif(out_contents MATCHES "mt : general error c101008d: ") + # Antivirus workaround - occasionally files are locked and cause mt.exe to fail + set(ITERATION 0) + while (ITERATION LESS 3 AND out_contents MATCHES "mt : general error c101008d: ") + MATH(EXPR ITERATION "${ITERATION}+1") + message(STATUS "Restarting Build ${TARGET_TRIPLET}-${SHORT_BUILDTYPE} because of mt.exe file locking issue. Iteration: ${ITERATION}") + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} + OUTPUT_FILE "${LOGPREFIX}-out-${ITERATION}.log" + ERROR_FILE "${LOGPREFIX}-err-${ITERATION}.log" + RESULT_VARIABLE error_code + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}) + + if(error_code) + file(READ "${LOGPREFIX}-out-${ITERATION}.log" out_contents) + file(READ "${LOGPREFIX}-err-${ITERATION}.log" err_contents) + + if(out_contents) + list(APPEND LOGS "${LOGPREFIX}-out-${ITERATION}.log") + endif() + if(err_contents) + list(APPEND LOGS "${LOGPREFIX}-err-${ITERATION}.log") + endif() + else() + break() + endif() + endwhile() endif() if(error_code) @@ -170,7 +197,7 @@ function(vcpkg_build_cmake) file(TO_NATIVE_PATH "${LOG}" NATIVE_LOG) list(APPEND STRINGIFIED_LOGS " ${NATIVE_LOG}\n") endforeach() - set(_eb_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}) + set(_eb_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}) set(_eb_WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}) message(FATAL_ERROR " Command failed: ${_eb_COMMAND}\n"