diff --git a/cad/PrusaSlicer/Makefile b/cad/PrusaSlicer/Makefile index 14b3929e38ca..8b94985334b7 100644 --- a/cad/PrusaSlicer/Makefile +++ b/cad/PrusaSlicer/Makefile @@ -1,40 +1,40 @@ PORTNAME= PrusaSlicer DISTVERSIONPREFIX=version_ -DISTVERSION= 2.3.3 -PORTREVISION= 9 +DISTVERSION= 2.5.0 CATEGORIES= cad MAINTAINER= teodorsigaev@gmail.com COMMENT= Slicing application for 3D printers WWW= https://www.prusa3d.com/prusaslicer/ LICENSE= AGPLv3 LICENSE_FILE= ${WRKSRC}/LICENSE +BUILD_DEPENDS= cereal>=1.3.0.10:devel/cereal \ + cgal>=5.0.2:math/cgal \ + opencascade>=7.7.0:cad/opencascade LIB_DEPENDS= libtbb.so:devel/onetbb \ libboost_log.so:devel/boost-libs \ libImath.so:math/Imath \ libnlopt.so:math/nlopt \ libcurl.so:ftp/curl \ libexpat.so:textproc/expat2 \ libopenvdb.so:misc/openvdb \ libgmp.so:math/gmp \ libmpfr.so:math/mpfr \ libdbus-1.so:devel/dbus \ libpng.so:graphics/png -BUILD_DEPENDS= cereal>=1.3.0.10:devel/cereal \ - cgal>=5.0.2:math/cgal USES= cmake cpe desktop-file-utils eigen:3 gettext gl iconv pkgconfig CPE_VENDOR= prusa3d CMAKE_ARGS+= -DwxWidgets_CONFIG_EXECUTABLE="${WX_CONFIG}" \ -DSLIC3R_GTK=3 \ -DSLIC3R_FHS=1 USE_GITHUB= yes GH_ACCOUNT= prusa3d -USE_WX= 3.2 USE_GL= gl glu glew +USE_WX= 3.2 PORTDATA= * .include diff --git a/cad/PrusaSlicer/distinfo b/cad/PrusaSlicer/distinfo index f25d7ad594d1..f6e560972d6b 100644 --- a/cad/PrusaSlicer/distinfo +++ b/cad/PrusaSlicer/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1628978092 -SHA256 (prusa3d-PrusaSlicer-version_2.3.3_GH0.tar.gz) = deda209505f740ac3d6f59cb2a960f4df908269ee09bd30cd4edb9fc472d29ac -SIZE (prusa3d-PrusaSlicer-version_2.3.3_GH0.tar.gz) = 40659538 +TIMESTAMP = 1668348926 +SHA256 (prusa3d-PrusaSlicer-version_2.5.0_GH0.tar.gz) = dbbf3e10c812d1dc7bae4bd6879e60f864d763b2738b099dd34b9636d0e5eb6a +SIZE (prusa3d-PrusaSlicer-version_2.5.0_GH0.tar.gz) = 48591956 diff --git a/cad/PrusaSlicer/files/patch-CMakeLists.txt b/cad/PrusaSlicer/files/patch-CMakeLists.txt index ad640b3d895b..ef5fab78c7e5 100644 --- a/cad/PrusaSlicer/files/patch-CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-CMakeLists.txt @@ -1,30 +1,40 @@ ---- CMakeLists.txt.orig 2021-04-16 11:41:00 UTC +--- CMakeLists.txt.orig 2022-09-06 07:09:19 UTC +++ CMakeLists.txt -@@ -3,6 +3,7 @@ project(PrusaSlicer) - +@@ -4,6 +4,7 @@ project(PrusaSlicer) include("version.inc") include(GNUInstallDirs) + include(CMakeDependentOption) +add_compile_options(-DNDEBUG) set(SLIC3R_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") file(TO_NATIVE_PATH "${SLIC3R_RESOURCES_DIR}" SLIC3R_RESOURCES_DIR_WIN) -@@ -166,7 +167,7 @@ if (APPLE) +@@ -197,7 +198,7 @@ if (APPLE) endif () endif () -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") find_package(PkgConfig REQUIRED) if (CMAKE_VERSION VERSION_LESS "3.1") -@@ -525,8 +526,8 @@ elseif (SLIC3R_FHS) - # CMAKE_INSTALL_FULL_DATAROOTDIR: read-only architecture-independent data root (share) - set(SLIC3R_FHS_RESOURCES "${CMAKE_INSTALL_FULL_DATAROOTDIR}/PrusaSlicer") - install(DIRECTORY "${SLIC3R_RESOURCES_DIR}/" DESTINATION "${SLIC3R_FHS_RESOURCES}") -- install(FILES src/platform/unix/PrusaSlicer.desktop DESTINATION ${SLIC3R_FHS_RESOURCES}/applications) -- install(FILES src/platform/unix/PrusaGcodeviewer.desktop DESTINATION ${SLIC3R_FHS_RESOURCES}/applications) -+ install(FILES src/platform/unix/PrusaSlicer.desktop DESTINATION share/applications) -+ install(FILES src/platform/unix/PrusaGcodeviewer.desktop DESTINATION share/applications) +@@ -597,8 +598,8 @@ elseif (SLIC3R_FHS) + install(DIRECTORY ${SLIC3R_RESOURCES_DIR}/ DESTINATION ${SLIC3R_FHS_RESOURCES} + PATTERN "*/udev" EXCLUDE + ) +- install(FILES src/platform/unix/PrusaSlicer.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications) +- install(FILES src/platform/unix/PrusaGcodeviewer.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications) ++ install(FILES src/platform/unix/PrusaSlicer.desktop DESTINATION share/applications) ++ install(FILES src/platform/unix/PrusaGcodeviewer.desktop DESTINATION share/applications) + foreach(SIZE 32 128 192) + install(FILES ${SLIC3R_RESOURCES_DIR}/icons/PrusaSlicer_${SIZE}px.png + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}x${SIZE}/apps RENAME PrusaSlicer.png +@@ -607,7 +608,8 @@ elseif (SLIC3R_FHS) + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}x${SIZE}/apps RENAME PrusaSlicer-gcodeviewer.png + ) + endforeach() +- install(DIRECTORY ${SLIC3R_RESOURCES_DIR}/udev/ DESTINATION lib/udev/rules.d) ++ #FreeBSD doesn't have a udev ++ #install(DIRECTORY ${SLIC3R_RESOURCES_DIR}/udev/ DESTINATION lib/udev/rules.d) else () install(FILES src/platform/unix/PrusaSlicer.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications) install(FILES src/platform/unix/PrusaGcodeviewer.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/resources/applications) diff --git a/cad/PrusaSlicer/files/patch-cmake_modules_FindOpenVDB.cmake b/cad/PrusaSlicer/files/patch-cmake_modules_FindOpenVDB.cmake index 34a84f656874..3a99d042e938 100644 --- a/cad/PrusaSlicer/files/patch-cmake_modules_FindOpenVDB.cmake +++ b/cad/PrusaSlicer/files/patch-cmake_modules_FindOpenVDB.cmake @@ -1,83 +1,84 @@ ---- cmake/modules/FindOpenVDB.cmake.orig 2021-01-11 13:01:51 UTC +--- cmake/modules/FindOpenVDB.cmake.orig 2022-09-06 07:09:19 UTC +++ cmake/modules/FindOpenVDB.cmake -@@ -326,24 +326,24 @@ macro(just_fail msg) +@@ -347,24 +347,24 @@ macro(just_fail msg) return() endmacro() --find_package(IlmBase QUIET COMPONENTS Half) +-find_package(IlmBase QUIET) -if(NOT IlmBase_FOUND) - pkg_check_modules(IlmBase QUIET IlmBase) +find_package(Imath QUIET COMPONENTS Half) +if(NOT Imath_FOUND) + pkg_check_modules(Imath QUIET Imath) endif() -if (IlmBase_FOUND AND NOT TARGET IlmBase::Half) - message(STATUS "Falling back to IlmBase found by pkg-config...") +if (Imath_FOUND AND NOT TARGET Imath::Half) + message(STATUS "Falling back to Imath found by pkg-config...") - find_library(IlmHalf_LIBRARY NAMES Half) - if(IlmHalf_LIBRARY-NOTFOUND OR NOT IlmBase_INCLUDE_DIRS) - just_fail("IlmBase::Half can not be found!") + find_library(Imath_LIBRARY NAMES Imath) + if(Imath_LIBRARY-NOTFOUND OR NOT Imath_INCLUDE_DIRS) + just_fail("Imath::Half can not be found!") endif() - +- - add_library(IlmBase::Half UNKNOWN IMPORTED) - set_target_properties(IlmBase::Half PROPERTIES - IMPORTED_LOCATION "${IlmHalf_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${IlmBase_INCLUDE_DIRS}") -elseif(NOT IlmBase_FOUND) - just_fail("IlmBase::Half can not be found!") ++ + add_library(Imath::Half UNKNOWN IMPORTED) + set_target_properties(Imath::Half PROPERTIES -+ IMPORTED_LOCATION "${Imath_LIBRARY}" -+ INTERFACE_INCLUDE_DIRECTORIES "${Imath_INCLUDE_DIRS}") ++ IMPORTED_LOCATION "${Imath_LIBRARY}" ++ INTERFACE_INCLUDE_DIRECTORIES "${Imath_INCLUDE_DIRS}") +elseif(NOT Imath_FOUND) + just_fail("Imath::Half can not be found!") endif() find_package(TBB ${_quiet} ${_required} COMPONENTS tbb) find_package(ZLIB ${_quiet} ${_required}) -@@ -430,7 +430,7 @@ if(OpenVDB_USES_LOG4CPLUS) +@@ -451,7 +451,7 @@ if(OpenVDB_USES_LOG4CPLUS) endif() if(OpenVDB_USES_ILM) - find_package(IlmBase ${_quiet} ${_required}) + find_package(Imath ${_quiet} ${_required}) endif() if(OpenVDB_USES_EXR) -@@ -442,7 +442,7 @@ if(UNIX) +@@ -463,7 +463,7 @@ if(UNIX) endif() # Set deps. Note that the order here is important. If we're building against -# Houdini 17.5 we must include OpenEXR and IlmBase deps first to ensure the +# Houdini 17.5 we must include OpenEXR and Imath deps first to ensure the # users chosen namespaced headers are correctly prioritized. Otherwise other # include paths from shared installs (including houdini) may pull in the wrong # headers -@@ -450,7 +450,7 @@ endif() +@@ -471,7 +471,7 @@ endif() set(_OPENVDB_VISIBLE_DEPENDENCIES Boost::iostreams Boost::system - IlmBase::Half + Imath::Half ) set(_OPENVDB_DEFINITIONS) -@@ -460,10 +460,10 @@ endif() +@@ -481,10 +481,10 @@ endif() if(OpenVDB_USES_EXR) list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES - IlmBase::IlmThread - IlmBase::Iex - IlmBase::Imath - OpenEXR::IlmImf + OpenEXR::IlmThread + OpenEXR::Iex + Imath::Imath + OpenEXR::OpenEXR ) list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_TOOLS_RAYTRACER_USE_EXR") endif() diff --git a/cad/PrusaSlicer/files/patch-cmake_modules_FindTBB.cmake b/cad/PrusaSlicer/files/patch-cmake_modules_FindTBB.cmake deleted file mode 100644 index 4faa74ef3698..000000000000 --- a/cad/PrusaSlicer/files/patch-cmake_modules_FindTBB.cmake +++ /dev/null @@ -1,738 +0,0 @@ ---- cmake/modules/FindTBB.cmake.orig 2021-07-16 10:14:03 UTC -+++ cmake/modules/FindTBB.cmake -@@ -1,332 +1,456 @@ --# The MIT License (MIT) -+# - Find ThreadingBuildingBlocks include dirs and libraries -+# Use this module by invoking find_package with the form: -+# find_package(TBB -+# [REQUIRED] # Fail with error if TBB is not found -+# ) # -+# Once done, this will define - # --# Copyright (c) 2015 Justus Calvin --# --# Permission is hereby granted, free of charge, to any person obtaining a copy --# of this software and associated documentation files (the "Software"), to deal --# in the Software without restriction, including without limitation the rights --# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --# copies of the Software, and to permit persons to whom the Software is --# furnished to do so, subject to the following conditions: --# --# The above copyright notice and this permission notice shall be included in all --# copies or substantial portions of the Software. --# --# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --# SOFTWARE. -- -+# TBB_FOUND - system has TBB -+# TBB_INCLUDE_DIRS - the TBB include directories -+# TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or -+# malloc proxy -+# TBB::tbb - imported target for the TBB library - # --# FindTBB --# ------- -+# TBB_VERSION_MAJOR - Major Product Version Number -+# TBB_VERSION_MINOR - Minor Product Version Number -+# TBB_INTERFACE_VERSION - Engineering Focused Version Number -+# TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version -+# still supported. This uses the engineering -+# focused interface version numbers. - # --# Find TBB include directories and libraries. -+# TBB_MALLOC_FOUND - system has TBB malloc library -+# TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories -+# TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined -+# TBB::malloc - imported target for the TBB malloc library - # --# Usage: -+# TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library -+# TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories -+# TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined -+# TBB::malloc_proxy - imported target for the TBB malloc proxy library - # --# find_package(TBB [major[.minor]] [EXACT] --# [QUIET] [REQUIRED] --# [[COMPONENTS] [components...]] --# [OPTIONAL_COMPONENTS components...]) - # --# where the allowed components are tbbmalloc and tbb_preview. Users may modify --# the behavior of this module with the following variables: -+# This module reads hints about search locations from variables: -+# ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds -+# ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation -+# ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb -+# libraries. Should be specified with ENV TBB_ROOT -+# and optionally... -+# ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build - # --# * TBB_ROOT_DIR - The base directory the of TBB installation. --# * TBB_INCLUDE_DIR - The directory that contains the TBB headers files. --# * TBB_LIBRARY - The directory that contains the TBB library files. --# * TBB__LIBRARY - The path of the TBB the corresponding TBB library. --# These libraries, if specified, override the --# corresponding library search results, where --# may be tbb, tbb_debug, tbbmalloc, tbbmalloc_debug, --# tbb_preview, or tbb_preview_debug. --# * TBB_USE_DEBUG_BUILD - The debug version of tbb libraries, if present, will --# be used instead of the release version. --# * TBB_STATIC - Static linking of libraries with a _static suffix. --# For example, on Windows a tbb_static.lib will be searched for --# instead of tbb.lib. - # --# Users may modify the behavior of this module with the following environment --# variables: -+# Modified by Robert Maynard from the original OGRE source - # --# * TBB_INSTALL_DIR --# * TBBROOT --# * LIBRARY_PATH -+#------------------------------------------------------------------- -+# This file is part of the CMake build system for OGRE -+# (Object-oriented Graphics Rendering Engine) -+# For the latest info, see http://www.ogre3d.org/ - # --# This module will set the following variables: -+# The contents of this file are placed in the public domain. Feel -+# free to make use of it in any way you like. -+#------------------------------------------------------------------- - # --# * TBB_FOUND - Set to false, or undefined, if we haven’t found, or --# don’t want to use TBB. --# * TBB__FOUND - If False, optional part of TBB sytem is --# not available. --# * TBB_VERSION - The full version string --# * TBB_VERSION_MAJOR - The major version --# * TBB_VERSION_MINOR - The minor version --# * TBB_INTERFACE_VERSION - The interface version number defined in --# tbb/tbb_stddef.h. --# * TBB__LIBRARY_RELEASE - The path of the TBB release version of --# , where may be tbb, tbb_debug, --# tbbmalloc, tbbmalloc_debug, tbb_preview, or --# tbb_preview_debug. --# * TBB__LIBRARY_DEGUG - The path of the TBB release version of --# , where may be tbb, tbb_debug, --# tbbmalloc, tbbmalloc_debug, tbb_preview, or --# tbb_preview_debug. -+#============================================================================= -+# Copyright 2010-2012 Kitware, Inc. -+# Copyright 2012 Rolf Eike Beer - # --# The following varibles should be used to build and link with TBB: -+# Distributed under the OSI-approved BSD License (the "License"); -+# see accompanying file Copyright.txt for details. - # --# * TBB_INCLUDE_DIRS - The include directory for TBB. --# * TBB_LIBRARIES - The libraries to link against to use TBB. --# * TBB_LIBRARIES_RELEASE - The release libraries to link against to use TBB. --# * TBB_LIBRARIES_DEBUG - The debug libraries to link against to use TBB. --# * TBB_DEFINITIONS - Definitions to use when compiling code that uses --# TBB. --# * TBB_DEFINITIONS_RELEASE - Definitions to use when compiling release code that --# uses TBB. --# * TBB_DEFINITIONS_DEBUG - Definitions to use when compiling debug code that --# uses TBB. -+# This software is distributed WITHOUT ANY WARRANTY; without even the -+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -+# See the License for more information. -+#============================================================================= -+# (To distribute this file outside of CMake, substitute the full -+# License text for the above reference.) -+ -+ -+#============================================================================= -+# FindTBB helper functions and macros - # --# This module will also create the "tbb" target that may be used when building --# executables and libraries. - --unset(TBB_FOUND CACHE) --unset(TBB_INCLUDE_DIRS CACHE) --unset(TBB_LIBRARIES) --unset(TBB_LIBRARIES_DEBUG) --unset(TBB_LIBRARIES_RELEASE) -+# Use TBBConfig.cmake if possible. - --include(FindPackageHandleStandardArgs) -+set(_tbb_find_quiet) -+if (TBB_FIND_QUIETLY) -+ set(_tbb_find_quiet QUIET) -+endif () -+set(_tbb_find_components) -+set(_tbb_find_optional_components) -+foreach (_tbb_find_component IN LISTS TBB_FIND_COMPONENTS) -+ if (TBB_FIND_REQUIRED_${_tbb_find_component}) -+ list(APPEND _tbb_find_components "${_tbb_find_component}") -+ else () -+ list(APPEND _tbb_find_optional_components "${_tbb_find_component}") -+ endif () -+endforeach () -+unset(_tbb_find_component) -+find_package(TBB CONFIG ${_tbb_find_quiet} -+ COMPONENTS ${_tbb_find_components} -+ OPTIONAL_COMPONENTS ${_tbb_find_optional_components}) -+unset(_tbb_find_quiet) -+unset(_tbb_find_components) -+unset(_tbb_find_optional_components) -+if (TBB_FOUND) -+ return () -+endif () - --find_package(Threads QUIET REQUIRED) -+#==================================================== -+# Fix the library path in case it is a linker script -+#==================================================== -+function(tbb_extract_real_library library real_library) -+ if(NOT UNIX OR NOT EXISTS ${library}) -+ set(${real_library} "${library}" PARENT_SCOPE) -+ return() -+ endif() - --if(NOT TBB_FOUND) -+ #Read in the first 4 bytes and see if they are the ELF magic number -+ set(_elf_magic "7f454c46") -+ file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX) -+ if(_hex_data STREQUAL _elf_magic) -+ #we have opened a elf binary so this is what -+ #we should link to -+ set(${real_library} "${library}" PARENT_SCOPE) -+ return() -+ endif() - -- ################################## -- # Check the build type -- ################################## -- -- if(NOT DEFINED TBB_USE_DEBUG_BUILD) -- if(CMAKE_BUILD_TYPE MATCHES "(Debug|DEBUG|debug)") -- set(TBB_BUILD_TYPE DEBUG) -- else() -- set(TBB_BUILD_TYPE RELEASE) -- endif() -- elseif(TBB_USE_DEBUG_BUILD) -- set(TBB_BUILD_TYPE DEBUG) -+ file(READ ${library} _data OFFSET 0 LIMIT 1024) -+ if("${_data}" MATCHES "INPUT \\(([^(]+)\\)") -+ #extract out the .so name from REGEX MATCH command -+ set(_proper_so_name "${CMAKE_MATCH_1}") -+ -+ #construct path to the real .so which is presumed to be in the same directory -+ #as the input file -+ get_filename_component(_so_dir "${library}" DIRECTORY) -+ set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE) - else() -- set(TBB_BUILD_TYPE RELEASE) -+ #unable to determine what this library is so just hope everything works -+ #and pass it unmodified. -+ set(${real_library} "${library}" PARENT_SCOPE) - endif() -- -- ################################## -- # Set the TBB search directories -- ################################## -- -- # Define search paths based on user input and environment variables -- set(TBB_SEARCH_DIR ${TBB_ROOT_DIR} $ENV{TBB_INSTALL_DIR} $ENV{TBBROOT}) -- -- # Define the search directories based on the current platform -- if(CMAKE_SYSTEM_NAME STREQUAL "Windows") -- set(TBB_DEFAULT_SEARCH_DIR "C:/Program Files/Intel/TBB" -- "C:/Program Files (x86)/Intel/TBB") -+endfunction() - -- # Set the target architecture -- if(CMAKE_SIZEOF_VOID_P EQUAL 8) -- set(TBB_ARCHITECTURE "intel64") -- else() -- set(TBB_ARCHITECTURE "ia32") -- endif() -+#=============================================== -+# Do the final processing for the package find. -+#=============================================== -+macro(findpkg_finish PREFIX TARGET_NAME) -+ if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY) -+ set(${PREFIX}_FOUND TRUE) -+ set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR}) -+ set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY}) -+ else () -+ if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY) -+ message(FATAL_ERROR "Required library ${PREFIX} not found.") -+ endif () -+ endif () - -- # Set the TBB search library path search suffix based on the version of VC -- if(WINDOWS_STORE) -- set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11_ui") -- elseif(MSVC14) -- set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc14") -- elseif(MSVC12) -- set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc12") -- elseif(MSVC11) -- set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11") -- elseif(MSVC10) -- set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc10") -- endif() -+ if (NOT TARGET "TBB::${TARGET_NAME}") -+ if (${PREFIX}_LIBRARY_RELEASE) -+ tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release) -+ endif () -+ if (${PREFIX}_LIBRARY_DEBUG) -+ tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug) -+ endif () -+ add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED) -+ set_target_properties(TBB::${TARGET_NAME} PROPERTIES -+ INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}") -+ if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE) -+ set_target_properties(TBB::${TARGET_NAME} PROPERTIES -+ IMPORTED_LOCATION "${real_release}" -+ IMPORTED_LOCATION_DEBUG "${real_debug}" -+ IMPORTED_LOCATION_RELEASE "${real_release}") -+ elseif (${PREFIX}_LIBRARY_RELEASE) -+ set_target_properties(TBB::${TARGET_NAME} PROPERTIES -+ IMPORTED_LOCATION "${real_release}") -+ elseif (${PREFIX}_LIBRARY_DEBUG) -+ set_target_properties(TBB::${TARGET_NAME} PROPERTIES -+ IMPORTED_LOCATION "${real_debug}") -+ endif () -+ endif () - -- # Add the library path search suffix for the VC independent version of TBB -- list(APPEND TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc_mt") -+ #mark the following variables as internal variables -+ mark_as_advanced(${PREFIX}_INCLUDE_DIR -+ ${PREFIX}_LIBRARY -+ ${PREFIX}_LIBRARY_DEBUG -+ ${PREFIX}_LIBRARY_RELEASE) -+endmacro() - -- elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") -- # OS X -- set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb") -- -- # TODO: Check to see which C++ library is being used by the compiler. -- if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 13.0) -- # The default C++ library on OS X 10.9 and later is libc++ -- set(TBB_LIB_PATH_SUFFIX "lib/libc++" "lib") -- else() -- set(TBB_LIB_PATH_SUFFIX "lib") -- endif() -- elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") -- # Linux -- set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb") -- -- # TODO: Check compiler version to see the suffix should be /gcc4.1 or -- # /gcc4.1. For now, assume that the compiler is more recent than -- # gcc 4.4.x or later. -- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") -- set(TBB_LIB_PATH_SUFFIX "lib/intel64/gcc4.4") -- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") -- set(TBB_LIB_PATH_SUFFIX "lib/ia32/gcc4.4") -- endif() -- endif() -- -- ################################## -- # Find the TBB include dir -- ################################## -- -- find_path(TBB_INCLUDE_DIRS tbb/tbb.h -- HINTS ${TBB_INCLUDE_DIR} ${TBB_SEARCH_DIR} -- PATHS ${TBB_DEFAULT_SEARCH_DIR} -- PATH_SUFFIXES include) -+#=============================================== -+# Generate debug names from given release names -+#=============================================== -+macro(get_debug_names PREFIX) -+ foreach(i ${${PREFIX}}) -+ set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i}) -+ endforeach() -+endmacro() - -- ################################## -- # Set version strings -- ################################## -+#=============================================== -+# See if we have env vars to help us find tbb -+#=============================================== -+macro(getenv_path VAR) -+ set(ENV_${VAR} $ENV{${VAR}}) -+ # replace won't work if var is blank -+ if (ENV_${VAR}) -+ string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} ) -+ endif () -+endmacro() - -- if(TBB_INCLUDE_DIRS) -- file(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _tbb_version_file) -- string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" -- TBB_VERSION_MAJOR "${_tbb_version_file}") -- string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" -- TBB_VERSION_MINOR "${_tbb_version_file}") -- string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" -- TBB_INTERFACE_VERSION "${_tbb_version_file}") -- set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}") -- endif() -+#=============================================== -+# Couple a set of release AND debug libraries -+#=============================================== -+macro(make_library_set PREFIX) -+ if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG) -+ set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG}) -+ elseif (${PREFIX}_RELEASE) -+ set(${PREFIX} ${${PREFIX}_RELEASE}) -+ elseif (${PREFIX}_DEBUG) -+ set(${PREFIX} ${${PREFIX}_DEBUG}) -+ endif () -+endmacro() - -- ################################## -- # Find TBB components -- ################################## - -- if(TBB_VERSION VERSION_LESS 4.3) -- set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc tbb) -- else() -- set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb) -- endif() -+#============================================================================= -+# Now to actually find TBB -+# - -- if(TBB_STATIC) -- set(TBB_STATIC_SUFFIX "_static") -- endif() -+# Get path, convert backslashes as ${ENV_${var}} -+getenv_path(TBB_ROOT) - -- # Find each component -- foreach(_comp ${TBB_SEARCH_COMPOMPONENTS}) -- if(";${TBB_FIND_COMPONENTS};tbb;" MATCHES ";${_comp};") -+# initialize search paths -+set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT}) -+set(TBB_INC_SEARCH_PATH "") -+set(TBB_LIB_SEARCH_PATH "") - -- unset(TBB_${_comp}_LIBRARY_DEBUG CACHE) -- unset(TBB_${_comp}_LIBRARY_RELEASE CACHE) - -- # Search for the libraries -- find_library(TBB_${_comp}_LIBRARY_RELEASE ${_comp}${TBB_STATIC_SUFFIX} -- HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR} -- PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH -- PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX}) -+# If user built from sources -+set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX}) -+if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT) -+ getenv_path(TBB_BUILD_DIR) -+ if (NOT ENV_TBB_BUILD_DIR) -+ set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build) -+ endif () - -- find_library(TBB_${_comp}_LIBRARY_DEBUG ${_comp}${TBB_STATIC_SUFFIX}_debug -- HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR} -- PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH -- PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX}) -+ # include directory under ${ENV_TBB_ROOT}/include -+ list(APPEND TBB_LIB_SEARCH_PATH -+ ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release -+ ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug) -+endif () - -- if(TBB_${_comp}_LIBRARY_DEBUG) -- list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}") -- endif() -- if(TBB_${_comp}_LIBRARY_RELEASE) -- list(APPEND TBB_LIBRARIES_RELEASE "${TBB_${_comp}_LIBRARY_RELEASE}") -- endif() -- if(TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE} AND NOT TBB_${_comp}_LIBRARY) -- set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}") -- endif() - -- if(TBB_${_comp}_LIBRARY AND EXISTS "${TBB_${_comp}_LIBRARY}") -- set(TBB_${_comp}_FOUND TRUE) -- else() -- set(TBB_${_comp}_FOUND FALSE) -- endif() -+# For Windows, let's assume that the user might be using the precompiled -+# TBB packages from the main website. These use a rather awkward directory -+# structure (at least for automatically finding the right files) depending -+# on platform and compiler, but we'll do our best to accommodate it. -+# Not adding the same effort for the precompiled linux builds, though. Those -+# have different versions for CC compiler versions and linux kernels which -+# will never adequately match the user's setup, so there is no feasible way -+# to detect the "best" version to use. The user will have to manually -+# select the right files. (Chances are the distributions are shipping their -+# custom version of tbb, anyway, so the problem is probably nonexistent.) -+if (WIN32 AND MSVC) -+ set(COMPILER_PREFIX "vc7.1") -+ if (MSVC_VERSION EQUAL 1400) -+ set(COMPILER_PREFIX "vc8") -+ elseif(MSVC_VERSION EQUAL 1500) -+ set(COMPILER_PREFIX "vc9") -+ elseif(MSVC_VERSION EQUAL 1600) -+ set(COMPILER_PREFIX "vc10") -+ elseif(MSVC_VERSION EQUAL 1700) -+ set(COMPILER_PREFIX "vc11") -+ elseif(MSVC_VERSION EQUAL 1800) -+ set(COMPILER_PREFIX "vc12") -+ elseif(MSVC_VERSION GREATER_EQUAL 1900) -+ set(COMPILER_PREFIX "vc14") -+ endif () - -- # Mark internal variables as advanced -- mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE) -- mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG) -- mark_as_advanced(TBB_${_comp}_LIBRARY) -+ # for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path -+ foreach (dir IN LISTS TBB_PREFIX_PATH) -+ if (CMAKE_CL_64) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX}) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX}) -+ else () -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX}) -+ endif () -+ endforeach () -+endif () - -- endif() -- endforeach() -+# For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9) -+# and above and AppleClang -+if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND -+ NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0) -+ set (USE_LIBCXX OFF) -+ cmake_policy(GET CMP0025 POLICY_VAR) - -- ################################## -- # Set compile flags and libraries -- ################################## -+ if (POLICY_VAR STREQUAL "NEW") -+ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") -+ set (USE_LIBCXX ON) -+ endif () -+ else () -+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") -+ set (USE_LIBCXX ON) -+ endif () -+ endif () - -- set(TBB_DEFINITIONS_RELEASE "") -- set(TBB_DEFINITIONS_DEBUG "TBB_USE_DEBUG=1") -- -- if(TBB_LIBRARIES_${TBB_BUILD_TYPE}) -- set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}") -+ if (USE_LIBCXX) -+ foreach (dir IN LISTS TBB_PREFIX_PATH) -+ list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib) -+ endforeach () -+ endif () -+endif () -+ -+# check compiler ABI -+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -+ set(COMPILER_PREFIX) -+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) -+ list(APPEND COMPILER_PREFIX "gcc4.8") - endif() -- -- if(NOT MSVC AND NOT TBB_LIBRARIES) -- set(TBB_LIBRARIES ${TBB_LIBRARIES_RELEASE}) -+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) -+ list(APPEND COMPILER_PREFIX "gcc4.7") - endif() -+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) -+ list(APPEND COMPILER_PREFIX "gcc4.4") -+ endif() -+ list(APPEND COMPILER_PREFIX "gcc4.1") -+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") -+ set(COMPILER_PREFIX) -+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess -+ list(APPEND COMPILER_PREFIX "gcc4.8") -+ endif() -+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) -+ list(APPEND COMPILER_PREFIX "gcc4.7") -+ endif() -+ list(APPEND COMPILER_PREFIX "gcc4.4") -+else() # Assume compatibility with 4.4 for other compilers -+ list(APPEND COMPILER_PREFIX "gcc4.4") -+endif () - -- set(TBB_DEFINITIONS "") -- if (MSVC AND TBB_STATIC) -- set(TBB_DEFINITIONS __TBB_NO_IMPLICIT_LINKAGE) -- endif () -+# if platform architecture is explicitly specified -+set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM}) -+if (TBB_ARCH_PLATFORM) -+ foreach (dir IN LISTS TBB_PREFIX_PATH) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM}) -+ endforeach () -+endif () - -- unset (TBB_STATIC_SUFFIX) -+foreach (dir IN LISTS TBB_PREFIX_PATH) -+ foreach (prefix IN LISTS COMPILER_PREFIX) -+ if (CMAKE_SIZEOF_VOID_P EQUAL 8) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix}) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib) -+ else () -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix}) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib) -+ endif () -+ endforeach() -+endforeach () - -- find_package_handle_standard_args(TBB -- REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES -- FAIL_MESSAGE "TBB library cannot be found. Consider set TBBROOT environment variable." -- HANDLE_COMPONENTS -- VERSION_VAR TBB_VERSION) -+# add general search paths -+foreach (dir IN LISTS TBB_PREFIX_PATH) -+ list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb -+ ${dir}/Libs) -+ list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include -+ ${dir}/include/tbb) -+endforeach () - -- ################################## -- # Create targets -- ################################## -+set(TBB_LIBRARY_NAMES tbb) -+get_debug_names(TBB_LIBRARY_NAMES) - -- if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND) -- add_library(TBB::tbb UNKNOWN IMPORTED) -- set_target_properties(TBB::tbb PROPERTIES -- INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS}" -- INTERFACE_LINK_LIBRARIES "Threads::Threads;${CMAKE_DL_LIBS}" -- INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS} -- IMPORTED_LOCATION ${TBB_LIBRARIES}) -- if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG) -- set_target_properties(TBB::tbb PROPERTIES -- INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS};$<$,$>:${TBB_DEFINITIONS_DEBUG}>;$<$:${TBB_DEFINITIONS_RELEASE}>" -- IMPORTED_LOCATION_DEBUG ${TBB_LIBRARIES_DEBUG} -- IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_RELEASE} -- IMPORTED_LOCATION_RELEASE ${TBB_LIBRARIES_RELEASE} -- IMPORTED_LOCATION_MINSIZEREL ${TBB_LIBRARIES_RELEASE} -- ) -- endif() -- endif() - -- mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES) -+find_path(TBB_INCLUDE_DIR -+ NAMES tbb/tbb.h -+ PATHS ${TBB_INC_SEARCH_PATH}) - -- unset(TBB_ARCHITECTURE) -- unset(TBB_BUILD_TYPE) -- unset(TBB_LIB_PATH_SUFFIX) -- unset(TBB_DEFAULT_SEARCH_DIR) -+find_library(TBB_LIBRARY_RELEASE -+ NAMES ${TBB_LIBRARY_NAMES} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+find_library(TBB_LIBRARY_DEBUG -+ NAMES ${TBB_LIBRARY_NAMES_DEBUG} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+make_library_set(TBB_LIBRARY) - -- if(TBB_DEBUG) -- message(STATUS " TBB_FOUND = ${TBB_FOUND}") -- message(STATUS " TBB_INCLUDE_DIRS = ${TBB_INCLUDE_DIRS}") -- message(STATUS " TBB_DEFINITIONS = ${TBB_DEFINITIONS}") -- message(STATUS " TBB_LIBRARIES = ${TBB_LIBRARIES}") -- message(STATUS " TBB_DEFINITIONS_DEBUG = ${TBB_DEFINITIONS_DEBUG}") -- message(STATUS " TBB_LIBRARIES_DEBUG = ${TBB_LIBRARIES_DEBUG}") -- message(STATUS " TBB_DEFINITIONS_RELEASE = ${TBB_DEFINITIONS_RELEASE}") -- message(STATUS " TBB_LIBRARIES_RELEASE = ${TBB_LIBRARIES_RELEASE}") -+findpkg_finish(TBB tbb) -+ -+#if we haven't found TBB no point on going any further -+if (NOT TBB_FOUND) -+ return() -+endif () -+ -+#============================================================================= -+# Look for TBB's malloc package -+set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc) -+get_debug_names(TBB_MALLOC_LIBRARY_NAMES) -+ -+find_path(TBB_MALLOC_INCLUDE_DIR -+ NAMES tbb/tbb.h -+ PATHS ${TBB_INC_SEARCH_PATH}) -+ -+find_library(TBB_MALLOC_LIBRARY_RELEASE -+ NAMES ${TBB_MALLOC_LIBRARY_NAMES} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+find_library(TBB_MALLOC_LIBRARY_DEBUG -+ NAMES ${TBB_MALLOC_LIBRARY_NAMES_DEBUG} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+make_library_set(TBB_MALLOC_LIBRARY) -+ -+findpkg_finish(TBB_MALLOC tbbmalloc) -+ -+#============================================================================= -+# Look for TBB's malloc proxy package -+set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy) -+get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES) -+ -+find_path(TBB_MALLOC_PROXY_INCLUDE_DIR -+ NAMES tbb/tbbmalloc_proxy.h -+ PATHS ${TBB_INC_SEARCH_PATH}) -+ -+find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE -+ NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG -+ NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DEBUG} -+ PATHS ${TBB_LIB_SEARCH_PATH}) -+make_library_set(TBB_MALLOC_PROXY_LIBRARY) -+ -+findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy) -+ -+ -+#============================================================================= -+#parse all the version numbers from tbb -+if(NOT TBB_VERSION) -+ if (EXISTS "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h") -+ file(STRINGS -+ "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h" -+ TBB_VERSION_CONTENTS -+ REGEX "VERSION") -+ else() -+ #only read the start of the file -+ file(STRINGS -+ "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" -+ TBB_VERSION_CONTENTS -+ REGEX "VERSION") - endif() -+ -+ string(REGEX REPLACE -+ ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" -+ TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}") -+ -+ string(REGEX REPLACE -+ ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" -+ TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}") -+ -+ string(REGEX REPLACE -+ ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" -+ TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") -+ -+ string(REGEX REPLACE -+ ".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1" -+ TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") - - endif() diff --git a/cad/PrusaSlicer/files/patch-src_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_CMakeLists.txt index 011a5f500bd0..5072871d7f95 100644 --- a/cad/PrusaSlicer/files/patch-src_CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-src_CMakeLists.txt @@ -1,11 +1,11 @@ ---- src/CMakeLists.txt.orig 2021-02-16 20:42:55 UTC +--- src/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC +++ src/CMakeLists.txt -@@ -111,7 +111,7 @@ if (NOT WIN32 AND NOT APPLE) +@@ -127,7 +127,7 @@ if (NOT WIN32 AND NOT APPLE) set_target_properties(PrusaSlicer PROPERTIES OUTPUT_NAME "prusa-slicer") endif () -target_link_libraries(PrusaSlicer libslic3r cereal) +target_link_libraries(PrusaSlicer libslic3r) + if (APPLE) # add_compile_options(-stdlib=libc++) - # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) diff --git a/cad/PrusaSlicer/files/patch-src_avrdude_libavrdude.h b/cad/PrusaSlicer/files/patch-src_avrdude_libavrdude.h index 83ef84662202..ed7c44e0e5bc 100644 --- a/cad/PrusaSlicer/files/patch-src_avrdude_libavrdude.h +++ b/cad/PrusaSlicer/files/patch-src_avrdude_libavrdude.h @@ -1,11 +1,11 @@ ---- src/avrdude/libavrdude.h.orig 2020-03-21 10:55:51 UTC +--- src/avrdude/libavrdude.h.orig 2022-09-06 07:09:19 UTC +++ src/avrdude/libavrdude.h @@ -950,6 +950,8 @@ int read_config_builtin(); // Header file for alloca() #if defined(WIN32NATIVE) # include +#elif defined __FreeBSD__ +# include #else # include #endif diff --git a/cad/PrusaSlicer/files/patch-src_avrdude_main.c b/cad/PrusaSlicer/files/patch-src_avrdude_main.c index 19381b05b4a7..57f18516cc78 100644 --- a/cad/PrusaSlicer/files/patch-src_avrdude_main.c +++ b/cad/PrusaSlicer/files/patch-src_avrdude_main.c @@ -1,11 +1,11 @@ ---- src/avrdude/main.c.orig 2021-08-13 03:29:34 UTC +--- src/avrdude/main.c.orig 2022-09-06 07:09:19 UTC +++ src/avrdude/main.c @@ -806,7 +806,7 @@ int avrdude_main(int argc, char * argv []) avrdude_message(MSG_NOTICE, "\n%s: Version %s, compiled on %s at %s\n" "%sCopyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/\n" "%sCopyright (c) 2007-2014 Joerg Wunsch\n\n", - progname, version, __DATE__, __TIME__, progbuf, progbuf); + progname, version, "REDACTED", "REDACTED", progbuf, progbuf); // avrdude_message(MSG_NOTICE, "%sSystem wide configuration file is \"%s\"\n", // progbuf, sys_config); diff --git a/cad/PrusaSlicer/files/patch-src_hidapi_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_hidapi_CMakeLists.txt index c346d6a7490a..282d616f9efa 100644 --- a/cad/PrusaSlicer/files/patch-src_hidapi_CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-src_hidapi_CMakeLists.txt @@ -1,20 +1,20 @@ ---- src/hidapi/CMakeLists.txt.orig 2020-03-21 10:55:51 UTC +--- src/hidapi/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC +++ src/hidapi/CMakeLists.txt @@ -1,8 +1,9 @@ - if (WIN32) set(HIDAPI_IMPL win/hid.c) elseif (APPLE) set(HIDAPI_IMPL mac/hid.c) +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(HIDAPI_IMPL libusb/hid.c) else () # Assume Linux or Unix other than Mac OS set(HIDAPI_IMPL linux/hid.c) @@ -16,4 +17,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") # Don't link the udev library, as there are two versions out there (libudev.so.0, libudev.so.1), so they are linked explicitely. # target_link_libraries(hidapi udev) target_link_libraries(hidapi dl) +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + target_link_libraries(hidapi usb iconv) endif() diff --git a/cad/PrusaSlicer/files/patch-src_hidapi_libusb_hid.c b/cad/PrusaSlicer/files/patch-src_hidapi_libusb_hid.c index 6880b20f860f..5cc678a4b344 100644 --- a/cad/PrusaSlicer/files/patch-src_hidapi_libusb_hid.c +++ b/cad/PrusaSlicer/files/patch-src_hidapi_libusb_hid.c @@ -1,1517 +1,1517 @@ ---- src/hidapi/libusb/hid.c.orig 2020-03-31 19:30:48 UTC +--- src/hidapi/libusb/hid.c.orig 2022-11-13 14:36:46 UTC +++ src/hidapi/libusb/hid.c @@ -0,0 +1,1514 @@ +/******************************************************* + HIDAPI - Multi-Platform library for + communication with HID devices. + + Alan Ott + Signal 11 Software + + 8/22/2009 + Linux Version - 6/2/2010 + Libusb Version - 8/13/2010 + FreeBSD Version - 11/1/2011 + + Copyright 2009, All Rights Reserved. + + At the discretion of the user of this library, + this software may be licensed under the terms of the + GNU General Public License v3, a BSD-Style license, or the + original HIDAPI license as outlined in the LICENSE.txt, + LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt + files located at the root of the source distribution. + These files may also be found in the public source + code repository located at: + http://github.com/signal11/hidapi . +********************************************************/ + +#define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */ + +/* C */ +#include +#include +#include +#include +#include +#include + +/* Unix */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* GNU / LibUSB */ +#include +#ifndef __ANDROID__ +#include +#endif + +#include "hidapi.h" + +#ifdef __ANDROID__ + +/* Barrier implementation because Android/Bionic don't have pthread_barrier. + This implementation came from Brent Priddy and was posted on + StackOverflow. It is used with his permission. */ +typedef int pthread_barrierattr_t; +typedef struct pthread_barrier { + pthread_mutex_t mutex; + pthread_cond_t cond; + int count; + int trip_count; +} pthread_barrier_t; + +static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) +{ + if(count == 0) { + errno = EINVAL; + return -1; + } + + if(pthread_mutex_init(&barrier->mutex, 0) < 0) { + return -1; + } + if(pthread_cond_init(&barrier->cond, 0) < 0) { + pthread_mutex_destroy(&barrier->mutex); + return -1; + } + barrier->trip_count = count; + barrier->count = 0; + + return 0; +} + +static int pthread_barrier_destroy(pthread_barrier_t *barrier) +{ + pthread_cond_destroy(&barrier->cond); + pthread_mutex_destroy(&barrier->mutex); + return 0; +} + +static int pthread_barrier_wait(pthread_barrier_t *barrier) +{ + pthread_mutex_lock(&barrier->mutex); + ++(barrier->count); + if(barrier->count >= barrier->trip_count) + { + barrier->count = 0; + pthread_cond_broadcast(&barrier->cond); + pthread_mutex_unlock(&barrier->mutex); + return 1; + } + else + { + pthread_cond_wait(&barrier->cond, &(barrier->mutex)); + pthread_mutex_unlock(&barrier->mutex); + return 0; + } +} + +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DEBUG_PRINTF +#define LOG(...) fprintf(stderr, __VA_ARGS__) +#else +#define LOG(...) do {} while (0) +#endif + +#ifndef __FreeBSD__ +#define DETACH_KERNEL_DRIVER +#endif + +/* Uncomment to enable the retrieval of Usage and Usage Page in +hid_enumerate(). Warning, on platforms different from FreeBSD +this is very invasive as it requires the detach +and re-attach of the kernel driver. See comments inside hid_enumerate(). +libusb HIDAPI programs are encouraged to use the interface number +instead to differentiate between interfaces on a composite HID device. */ +/*#define INVASIVE_GET_USAGE*/ + +/* Linked List of input reports received from the device. */ +struct input_report { + uint8_t *data; + size_t len; + struct input_report *next; +}; + + +struct hid_device_ { + /* Handle to the actual device. */ + libusb_device_handle *device_handle; + + /* Endpoint information */ + int input_endpoint; + int output_endpoint; + int input_ep_max_packet_size; + + /* The interface number of the HID */ + int interface; + + /* Indexes of Strings */ + int manufacturer_index; + int product_index; + int serial_index; + + /* Whether blocking reads are used */ + int blocking; /* boolean */ + + /* Read thread objects */ + pthread_t thread; + pthread_mutex_t mutex; /* Protects input_reports */ + pthread_cond_t condition; + pthread_barrier_t barrier; /* Ensures correct startup sequence */ + int shutdown_thread; + int cancelled; + struct libusb_transfer *transfer; + + /* List of received input reports. */ + struct input_report *input_reports; +}; + +static libusb_context *usb_context = NULL; + +uint16_t get_usb_code_for_current_locale(void); +static int return_data(hid_device *dev, unsigned char *data, size_t length); + +static hid_device *new_hid_device(void) +{ + hid_device *dev = calloc(1, sizeof(hid_device)); + dev->blocking = 1; + + pthread_mutex_init(&dev->mutex, NULL); + pthread_cond_init(&dev->condition, NULL); + pthread_barrier_init(&dev->barrier, NULL, 2); + + return dev; +} + +static void free_hid_device(hid_device *dev) +{ + /* Clean up the thread objects */ + pthread_barrier_destroy(&dev->barrier); + pthread_cond_destroy(&dev->condition); + pthread_mutex_destroy(&dev->mutex); + + /* Free the device itself */ + free(dev); +} + +#if 0 +/*TODO: Implement this funciton on hidapi/libusb.. */ +static void register_error(hid_device *dev, const char *op) +{ + +} +#endif + +#ifdef INVASIVE_GET_USAGE +/* Get bytes from a HID Report Descriptor. + Only call with a num_bytes of 0, 1, 2, or 4. */ +static uint32_t get_bytes(uint8_t *rpt, size_t len, size_t num_bytes, size_t cur) +{ + /* Return if there aren't enough bytes. */ + if (cur + num_bytes >= len) + return 0; + + if (num_bytes == 0) + return 0; + else if (num_bytes == 1) { + return rpt[cur+1]; + } + else if (num_bytes == 2) { + return (rpt[cur+2] * 256 + rpt[cur+1]); + } + else if (num_bytes == 4) { + return (rpt[cur+4] * 0x01000000 + + rpt[cur+3] * 0x00010000 + + rpt[cur+2] * 0x00000100 + + rpt[cur+1] * 0x00000001); + } + else + return 0; +} + +/* Retrieves the device's Usage Page and Usage from the report + descriptor. The algorithm is simple, as it just returns the first + Usage and Usage Page that it finds in the descriptor. + The return value is 0 on success and -1 on failure. */ +static int get_usage(uint8_t *report_descriptor, size_t size, + unsigned short *usage_page, unsigned short *usage) +{ + unsigned int i = 0; + int size_code; + int data_len, key_size; + int usage_found = 0, usage_page_found = 0; + + while (i < size) { + int key = report_descriptor[i]; + int key_cmd = key & 0xfc; + + //printf("key: %02hhx\n", key); + + if ((key & 0xf0) == 0xf0) { + /* This is a Long Item. The next byte contains the + length of the data section (value) for this key. + See the HID specification, version 1.11, section + 6.2.2.3, titled "Long Items." */ + if (i+1 < size) + data_len = report_descriptor[i+1]; + else + data_len = 0; /* malformed report */ + key_size = 3; + } + else { + /* This is a Short Item. The bottom two bits of the + key contain the size code for the data section + (value) for this key. Refer to the HID + specification, version 1.11, section 6.2.2.2, + titled "Short Items." */ + size_code = key & 0x3; + switch (size_code) { + case 0: + case 1: + case 2: + data_len = size_code; + break; + case 3: + data_len = 4; + break; + default: + /* Can't ever happen since size_code is & 0x3 */ + data_len = 0; + break; + }; + key_size = 1; + } + + if (key_cmd == 0x4) { + *usage_page = get_bytes(report_descriptor, size, data_len, i); + usage_page_found = 1; + //printf("Usage Page: %x\n", (uint32_t)*usage_page); + } + if (key_cmd == 0x8) { + *usage = get_bytes(report_descriptor, size, data_len, i); + usage_found = 1; + //printf("Usage: %x\n", (uint32_t)*usage); + } + + if (usage_page_found && usage_found) + return 0; /* success */ + + /* Skip over this key and it's associated data */ + i += data_len + key_size; + } + + return -1; /* failure */ +} +#endif /* INVASIVE_GET_USAGE */ + +#if defined(__FreeBSD__) && __FreeBSD__ < 10 +/* The libusb version included in FreeBSD < 10 doesn't have this function. In + mainline libusb, it's inlined in libusb.h. This function will bear a striking + resemblance to that one, because there's about one way to code it. + + Note that the data parameter is Unicode in UTF-16LE encoding. + Return value is the number of bytes in data, or LIBUSB_ERROR_*. + */ +static inline int libusb_get_string_descriptor(libusb_device_handle *dev, + uint8_t descriptor_index, uint16_t lang_id, + unsigned char *data, int length) +{ + return libusb_control_transfer(dev, + LIBUSB_ENDPOINT_IN | 0x0, /* Endpoint 0 IN */ + LIBUSB_REQUEST_GET_DESCRIPTOR, + (LIBUSB_DT_STRING << 8) | descriptor_index, + lang_id, data, (uint16_t) length, 1000); +} + +#endif + + +/* Get the first language the device says it reports. This comes from + USB string #0. */ +static uint16_t get_first_language(libusb_device_handle *dev) +{ + uint16_t buf[32]; + int len; + + /* Get the string from libusb. */ + len = libusb_get_string_descriptor(dev, + 0x0, /* String ID */ + 0x0, /* Language */ + (unsigned char*)buf, + sizeof(buf)); + if (len < 4) + return 0x0; + + return buf[1]; /* First two bytes are len and descriptor type. */ +} + +static int is_language_supported(libusb_device_handle *dev, uint16_t lang) +{ + uint16_t buf[32]; + int len; + int i; + + /* Get the string from libusb. */ + len = libusb_get_string_descriptor(dev, + 0x0, /* String ID */ + 0x0, /* Language */ + (unsigned char*)buf, + sizeof(buf)); + if (len < 4) + return 0x0; + + + len /= 2; /* language IDs are two-bytes each. */ + /* Start at index 1 because there are two bytes of protocol data. */ + for (i = 1; i < len; i++) { + if (buf[i] == lang) + return 1; + } + + return 0; +} + + +/* This function returns a newly allocated wide string containing the USB + device string numbered by the index. The returned string must be freed + by using free(). */ +static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx) +{ + char buf[512]; + int len; + wchar_t *str = NULL; + +#ifndef __ANDROID__ /* we don't use iconv on Android */ + wchar_t wbuf[256]; + /* iconv variables */ + iconv_t ic; + size_t inbytes; + size_t outbytes; + size_t res; +#ifdef __FreeBSD__ + const char *inptr; +#else + char *inptr; +#endif + char *outptr; +#endif + + /* Determine which language to use. */ + uint16_t lang; + lang = get_usb_code_for_current_locale(); + if (!is_language_supported(dev, lang)) + lang = get_first_language(dev); + + /* Get the string from libusb. */ + len = libusb_get_string_descriptor(dev, + idx, + lang, + (unsigned char*)buf, + sizeof(buf)); + if (len < 0) + return NULL; + +#ifdef __ANDROID__ + + /* Bionic does not have iconv support nor wcsdup() function, so it + has to be done manually. The following code will only work for + code points that can be represented as a single UTF-16 character, + and will incorrectly convert any code points which require more + than one UTF-16 character. + + Skip over the first character (2-bytes). */ + len -= 2; + str = malloc((len / 2 + 1) * sizeof(wchar_t)); + int i; + for (i = 0; i < len / 2; i++) { + str[i] = buf[i * 2 + 2] | (buf[i * 2 + 3] << 8); + } + str[len / 2] = 0x00000000; + +#else + + /* buf does not need to be explicitly NULL-terminated because + it is only passed into iconv() which does not need it. */ + + /* Initialize iconv. */ + ic = iconv_open("WCHAR_T", "UTF-16LE"); + if (ic == (iconv_t)-1) { + LOG("iconv_open() failed\n"); + return NULL; + } + + /* Convert to native wchar_t (UTF-32 on glibc/BSD systems). + Skip the first character (2-bytes). */ + inptr = buf+2; + inbytes = len-2; + outptr = (char*) wbuf; + outbytes = sizeof(wbuf); + res = iconv(ic, &inptr, &inbytes, &outptr, &outbytes); + if (res == (size_t)-1) { + LOG("iconv() failed\n"); + goto err; + } + + /* Write the terminating NULL. */ + wbuf[sizeof(wbuf)/sizeof(wbuf[0])-1] = 0x00000000; + if (outbytes >= sizeof(wbuf[0])) + *((wchar_t*)outptr) = 0x00000000; + + /* Allocate and copy the string. */ + str = wcsdup(wbuf); + +err: + iconv_close(ic); + +#endif + + return str; +} + +static char *make_path(libusb_device *dev, int interface_number) +{ + char str[64]; + snprintf(str, sizeof(str), "%04x:%04x:%02x", + libusb_get_bus_number(dev), + libusb_get_device_address(dev), + interface_number); + str[sizeof(str)-1] = '\0'; + + return strdup(str); +} + + +int HID_API_EXPORT hid_init(void) +{ + if (!usb_context) { + const char *locale; + + /* Init Libusb */ + if (libusb_init(&usb_context)) + return -1; + + /* Set the locale if it's not set. */ + locale = setlocale(LC_CTYPE, NULL); + if (!locale) + setlocale(LC_CTYPE, ""); + } + + return 0; +} + +int HID_API_EXPORT hid_exit(void) +{ + if (usb_context) { + libusb_exit(usb_context); + usb_context = NULL; + } + + return 0; +} + +struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) +{ + libusb_device **devs; + libusb_device *dev; + libusb_device_handle *handle; + ssize_t num_devs; + int i = 0; + + struct hid_device_info *root = NULL; /* return object */ + struct hid_device_info *cur_dev = NULL; + + if(hid_init() < 0) + return NULL; + + num_devs = libusb_get_device_list(usb_context, &devs); + if (num_devs < 0) + return NULL; + while ((dev = devs[i++]) != NULL) { + struct libusb_device_descriptor desc; + struct libusb_config_descriptor *conf_desc = NULL; + int j, k; + int interface_num = 0; + + int res = libusb_get_device_descriptor(dev, &desc); + unsigned short dev_vid = desc.idVendor; + unsigned short dev_pid = desc.idProduct; + + res = libusb_get_active_config_descriptor(dev, &conf_desc); + if (res < 0) + libusb_get_config_descriptor(dev, 0, &conf_desc); + if (conf_desc) { + for (j = 0; j < conf_desc->bNumInterfaces; j++) { + const struct libusb_interface *intf = &conf_desc->interface[j]; + for (k = 0; k < intf->num_altsetting; k++) { + const struct libusb_interface_descriptor *intf_desc; + intf_desc = &intf->altsetting[k]; + if (intf_desc->bInterfaceClass == LIBUSB_CLASS_HID) { + interface_num = intf_desc->bInterfaceNumber; + + /* Check the VID/PID against the arguments */ + if ((vendor_id == 0x0 || vendor_id == dev_vid) && + (product_id == 0x0 || product_id == dev_pid)) { + struct hid_device_info *tmp; + + /* VID/PID match. Create the record. */ + tmp = calloc(1, sizeof(struct hid_device_info)); + if (cur_dev) { + cur_dev->next = tmp; + } + else { + root = tmp; + } + cur_dev = tmp; + + /* Fill out the record */ + cur_dev->next = NULL; + cur_dev->path = make_path(dev, interface_num); + + res = libusb_open(dev, &handle); + + if (res >= 0) { + /* Serial Number */ + if (desc.iSerialNumber > 0) + cur_dev->serial_number = + get_usb_string(handle, desc.iSerialNumber); + + /* Manufacturer and Product strings */ + if (desc.iManufacturer > 0) + cur_dev->manufacturer_string = + get_usb_string(handle, desc.iManufacturer); + if (desc.iProduct > 0) + cur_dev->product_string = + get_usb_string(handle, desc.iProduct); + +#ifdef INVASIVE_GET_USAGE +{ + /* + This section is removed because it is too + invasive on the system. Getting a Usage Page + and Usage requires parsing the HID Report + descriptor. Getting a HID Report descriptor + involves claiming the interface. Claiming the + interface involves detaching the kernel driver. + Detaching the kernel driver is hard on the system + because it will unclaim interfaces (if another + app has them claimed) and the re-attachment of + the driver will sometimes change /dev entry names. + It is for these reasons that this section is + #if 0. For composite devices, use the interface + field in the hid_device_info struct to distinguish + between interfaces. */ + unsigned char data[256]; +#ifdef DETACH_KERNEL_DRIVER + int detached = 0; + /* Usage Page and Usage */ + res = libusb_kernel_driver_active(handle, interface_num); + if (res == 1) { + res = libusb_detach_kernel_driver(handle, interface_num); + if (res < 0) + LOG("Couldn't detach kernel driver, even though a kernel driver was attached."); + else + detached = 1; + } +#endif + res = libusb_claim_interface(handle, interface_num); + if (res >= 0) { + /* Get the HID Report Descriptor. */ + res = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_RECIPIENT_INTERFACE, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_REPORT << 8)|interface_num, 0, data, sizeof(data), 5000); + if (res >= 0) { + unsigned short page=0, usage=0; + /* Parse the usage and usage page + out of the report descriptor. */ + get_usage(data, res, &page, &usage); + cur_dev->usage_page = page; + cur_dev->usage = usage; + } + else + LOG("libusb_control_transfer() for getting the HID report failed with %d\n", res); + + /* Release the interface */ + res = libusb_release_interface(handle, interface_num); + if (res < 0) + LOG("Can't release the interface.\n"); + } + else + LOG("Can't claim interface %d\n", res); +#ifdef DETACH_KERNEL_DRIVER + /* Re-attach kernel driver if necessary. */ + if (detached) { + res = libusb_attach_kernel_driver(handle, interface_num); + if (res < 0) + LOG("Couldn't re-attach kernel driver.\n"); + } +#endif +} +#endif /* INVASIVE_GET_USAGE */ + + libusb_close(handle); + } + /* VID/PID */ + cur_dev->vendor_id = dev_vid; + cur_dev->product_id = dev_pid; + + /* Release Number */ + cur_dev->release_number = desc.bcdDevice; + + /* Interface Number */ + cur_dev->interface_number = interface_num; + } + } + } /* altsettings */ + } /* interfaces */ + libusb_free_config_descriptor(conf_desc); + } + } + + libusb_free_device_list(devs, 1); + + return root; +} + +void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) +{ + struct hid_device_info *d = devs; + while (d) { + struct hid_device_info *next = d->next; + free(d->path); + free(d->serial_number); + free(d->manufacturer_string); + free(d->product_string); + free(d); + d = next; + } +} + +hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) +{ + struct hid_device_info *devs, *cur_dev; + const char *path_to_open = NULL; + hid_device *handle = NULL; + + devs = hid_enumerate(vendor_id, product_id); + cur_dev = devs; + while (cur_dev) { + if (cur_dev->vendor_id == vendor_id && + cur_dev->product_id == product_id) { + if (serial_number) { + if (cur_dev->serial_number && + wcscmp(serial_number, cur_dev->serial_number) == 0) { + path_to_open = cur_dev->path; + break; + } + } + else { + path_to_open = cur_dev->path; + break; + } + } + cur_dev = cur_dev->next; + } + + if (path_to_open) { + /* Open the device */ + handle = hid_open_path(path_to_open); + } + + hid_free_enumeration(devs); + + return handle; +} + +static void read_callback(struct libusb_transfer *transfer) +{ + hid_device *dev = transfer->user_data; + int res; + + if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { + + struct input_report *rpt = malloc(sizeof(*rpt)); + rpt->data = malloc(transfer->actual_length); + memcpy(rpt->data, transfer->buffer, transfer->actual_length); + rpt->len = transfer->actual_length; + rpt->next = NULL; + + pthread_mutex_lock(&dev->mutex); + + /* Attach the new report object to the end of the list. */ + if (dev->input_reports == NULL) { + /* The list is empty. Put it at the root. */ + dev->input_reports = rpt; + pthread_cond_signal(&dev->condition); + } + else { + /* Find the end of the list and attach. */ + struct input_report *cur = dev->input_reports; + int num_queued = 0; + while (cur->next != NULL) { + cur = cur->next; + num_queued++; + } + cur->next = rpt; + + /* Pop one off if we've reached 30 in the queue. This + way we don't grow forever if the user never reads + anything from the device. */ + if (num_queued > 30) { + return_data(dev, NULL, 0); + } + } + pthread_mutex_unlock(&dev->mutex); + } + else if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { + dev->shutdown_thread = 1; + dev->cancelled = 1; + return; + } + else if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { + dev->shutdown_thread = 1; + dev->cancelled = 1; + return; + } + else if (transfer->status == LIBUSB_TRANSFER_TIMED_OUT) { + //LOG("Timeout (normal)\n"); + } + else { + LOG("Unknown transfer code: %d\n", transfer->status); + } + + /* Re-submit the transfer object. */ + res = libusb_submit_transfer(transfer); + if (res != 0) { + LOG("Unable to submit URB. libusb error code: %d\n", res); + dev->shutdown_thread = 1; + dev->cancelled = 1; + } +} + + +static void *read_thread(void *param) +{ + hid_device *dev = param; + unsigned char *buf; + const size_t length = dev->input_ep_max_packet_size; + + /* Set up the transfer object. */ + buf = malloc(length); + dev->transfer = libusb_alloc_transfer(0); + libusb_fill_interrupt_transfer(dev->transfer, + dev->device_handle, + dev->input_endpoint, + buf, + length, + read_callback, + dev, + 5000/*timeout*/); + + /* Make the first submission. Further submissions are made + from inside read_callback() */ + libusb_submit_transfer(dev->transfer); + + /* Notify the main thread that the read thread is up and running. */ + pthread_barrier_wait(&dev->barrier); + + /* Handle all the events. */ + while (!dev->shutdown_thread) { + int res; + res = libusb_handle_events(usb_context); + if (res < 0) { + /* There was an error. */ + LOG("read_thread(): libusb reports error # %d\n", res); + + /* Break out of this loop only on fatal error.*/ + if (res != LIBUSB_ERROR_BUSY && + res != LIBUSB_ERROR_TIMEOUT && + res != LIBUSB_ERROR_OVERFLOW && + res != LIBUSB_ERROR_INTERRUPTED) { + break; + } + } + } + + /* Cancel any transfer that may be pending. This call will fail + if no transfers are pending, but that's OK. */ + libusb_cancel_transfer(dev->transfer); + + while (!dev->cancelled) + libusb_handle_events_completed(usb_context, &dev->cancelled); + + /* Now that the read thread is stopping, Wake any threads which are + waiting on data (in hid_read_timeout()). Do this under a mutex to + make sure that a thread which is about to go to sleep waiting on + the condition actually will go to sleep before the condition is + signaled. */ + pthread_mutex_lock(&dev->mutex); + pthread_cond_broadcast(&dev->condition); + pthread_mutex_unlock(&dev->mutex); + + /* The dev->transfer->buffer and dev->transfer objects are cleaned up + in hid_close(). They are not cleaned up here because this thread + could end either due to a disconnect or due to a user + call to hid_close(). In both cases the objects can be safely + cleaned up after the call to pthread_join() (in hid_close()), but + since hid_close() calls libusb_cancel_transfer(), on these objects, + they can not be cleaned up here. */ + + return NULL; +} + + +hid_device * HID_API_EXPORT hid_open_path(const char *path) +{ + hid_device *dev = NULL; + + libusb_device **devs; + libusb_device *usb_dev; + int res; + int d = 0; + int good_open = 0; + + if(hid_init() < 0) + return NULL; + + dev = new_hid_device(); + + libusb_get_device_list(usb_context, &devs); + while ((usb_dev = devs[d++]) != NULL) { + struct libusb_device_descriptor desc; + struct libusb_config_descriptor *conf_desc = NULL; + int i,j,k; + libusb_get_device_descriptor(usb_dev, &desc); + + if (libusb_get_active_config_descriptor(usb_dev, &conf_desc) < 0) + continue; + for (j = 0; j < conf_desc->bNumInterfaces; j++) { + const struct libusb_interface *intf = &conf_desc->interface[j]; + for (k = 0; k < intf->num_altsetting; k++) { + const struct libusb_interface_descriptor *intf_desc; + intf_desc = &intf->altsetting[k]; + if (intf_desc->bInterfaceClass == LIBUSB_CLASS_HID) { + char *dev_path = make_path(usb_dev, intf_desc->bInterfaceNumber); + if (!strcmp(dev_path, path)) { + /* Matched Paths. Open this device */ + + /* OPEN HERE */ + res = libusb_open(usb_dev, &dev->device_handle); + if (res < 0) { + LOG("can't open device\n"); + free(dev_path); + break; + } + good_open = 1; +#ifdef DETACH_KERNEL_DRIVER + /* Detach the kernel driver, but only if the + device is managed by the kernel */ + if (libusb_kernel_driver_active(dev->device_handle, intf_desc->bInterfaceNumber) == 1) { + res = libusb_detach_kernel_driver(dev->device_handle, intf_desc->bInterfaceNumber); + if (res < 0) { + libusb_close(dev->device_handle); + LOG("Unable to detach Kernel Driver\n"); + free(dev_path); + good_open = 0; + break; + } + } +#endif + res = libusb_claim_interface(dev->device_handle, intf_desc->bInterfaceNumber); + if (res < 0) { + LOG("can't claim interface %d: %d\n", intf_desc->bInterfaceNumber, res); + free(dev_path); + libusb_close(dev->device_handle); + good_open = 0; + break; + } + + /* Store off the string descriptor indexes */ + dev->manufacturer_index = desc.iManufacturer; + dev->product_index = desc.iProduct; + dev->serial_index = desc.iSerialNumber; + + /* Store off the interface number */ + dev->interface = intf_desc->bInterfaceNumber; + + /* Find the INPUT and OUTPUT endpoints. An + OUTPUT endpoint is not required. */ + for (i = 0; i < intf_desc->bNumEndpoints; i++) { + const struct libusb_endpoint_descriptor *ep + = &intf_desc->endpoint[i]; + + /* Determine the type and direction of this + endpoint. */ + int is_interrupt = + (ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + == LIBUSB_TRANSFER_TYPE_INTERRUPT; + int is_output = + (ep->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + == LIBUSB_ENDPOINT_OUT; + int is_input = + (ep->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + == LIBUSB_ENDPOINT_IN; + + /* Decide whether to use it for input or output. */ + if (dev->input_endpoint == 0 && + is_interrupt && is_input) { + /* Use this endpoint for INPUT */ + dev->input_endpoint = ep->bEndpointAddress; + dev->input_ep_max_packet_size = ep->wMaxPacketSize; + } + if (dev->output_endpoint == 0 && + is_interrupt && is_output) { + /* Use this endpoint for OUTPUT */ + dev->output_endpoint = ep->bEndpointAddress; + } + } + + pthread_create(&dev->thread, NULL, read_thread, dev); + + /* Wait here for the read thread to be initialized. */ + pthread_barrier_wait(&dev->barrier); + + } + free(dev_path); + } + } + } + libusb_free_config_descriptor(conf_desc); + + } + + libusb_free_device_list(devs, 1); + + /* If we have a good handle, return it. */ + if (good_open) { + return dev; + } + else { + /* Unable to open any devices. */ + free_hid_device(dev); + return NULL; + } +} + + +int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) +{ + int res; + int report_number = data[0]; + int skipped_report_id = 0; + + if (report_number == 0x0) { + data++; + length--; + skipped_report_id = 1; + } + + + if (dev->output_endpoint <= 0) { + /* No interrupt out endpoint. Use the Control Endpoint */ + res = libusb_control_transfer(dev->device_handle, + LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_OUT, + 0x09/*HID Set_Report*/, + (2/*HID output*/ << 8) | report_number, + dev->interface, + (unsigned char *)data, length, + 1000/*timeout millis*/); + + if (res < 0) + return -1; + + if (skipped_report_id) + length++; + + return length; + } + else { + /* Use the interrupt out endpoint */ + int actual_length; + res = libusb_interrupt_transfer(dev->device_handle, + dev->output_endpoint, + (unsigned char*)data, + length, + &actual_length, 1000); + + if (res < 0) + return -1; + + if (skipped_report_id) + actual_length++; + + return actual_length; + } +} + +/* Helper function, to simplify hid_read(). + This should be called with dev->mutex locked. */ +static int return_data(hid_device *dev, unsigned char *data, size_t length) +{ + /* Copy the data out of the linked list item (rpt) into the + return buffer (data), and delete the liked list item. */ + struct input_report *rpt = dev->input_reports; + size_t len = (length < rpt->len)? length: rpt->len; + if (len > 0) + memcpy(data, rpt->data, len); + dev->input_reports = rpt->next; + free(rpt->data); + free(rpt); + return len; +} + +static void cleanup_mutex(void *param) +{ + hid_device *dev = param; + pthread_mutex_unlock(&dev->mutex); +} + + +int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) +{ + int bytes_read = -1; + +#if 0 + int transferred; + int res = libusb_interrupt_transfer(dev->device_handle, dev->input_endpoint, data, length, &transferred, 5000); + LOG("transferred: %d\n", transferred); + return transferred; +#endif + + pthread_mutex_lock(&dev->mutex); + pthread_cleanup_push(&cleanup_mutex, dev); + + /* There's an input report queued up. Return it. */ + if (dev->input_reports) { + /* Return the first one */ + bytes_read = return_data(dev, data, length); + goto ret; + } + + if (dev->shutdown_thread) { + /* This means the device has been disconnected. + An error code of -1 should be returned. */ + bytes_read = -1; + goto ret; + } + + if (milliseconds == -1) { + /* Blocking */ + while (!dev->input_reports && !dev->shutdown_thread) { + pthread_cond_wait(&dev->condition, &dev->mutex); + } + if (dev->input_reports) { + bytes_read = return_data(dev, data, length); + } + } + else if (milliseconds > 0) { + /* Non-blocking, but called with timeout. */ + int res; + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += milliseconds / 1000; + ts.tv_nsec += (milliseconds % 1000) * 1000000; + if (ts.tv_nsec >= 1000000000L) { + ts.tv_sec++; + ts.tv_nsec -= 1000000000L; + } + + while (!dev->input_reports && !dev->shutdown_thread) { + res = pthread_cond_timedwait(&dev->condition, &dev->mutex, &ts); + if (res == 0) { + if (dev->input_reports) { + bytes_read = return_data(dev, data, length); + break; + } + + /* If we're here, there was a spurious wake up + or the read thread was shutdown. Run the + loop again (ie: don't break). */ + } + else if (res == ETIMEDOUT) { + /* Timed out. */ + bytes_read = 0; + break; + } + else { + /* Error. */ + bytes_read = -1; + break; + } + } + } + else { + /* Purely non-blocking */ + bytes_read = 0; + } + +ret: + pthread_mutex_unlock(&dev->mutex); + pthread_cleanup_pop(0); + + return bytes_read; +} + +int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) +{ + return hid_read_timeout(dev, data, length, dev->blocking ? -1 : 0); +} + +int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) +{ + dev->blocking = !nonblock; + + return 0; +} + + +int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) +{ + int res = -1; + int skipped_report_id = 0; + int report_number = data[0]; + + if (report_number == 0x0) { + data++; + length--; + skipped_report_id = 1; + } + + res = libusb_control_transfer(dev->device_handle, + LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_OUT, + 0x09/*HID set_report*/, + (3/*HID feature*/ << 8) | report_number, + dev->interface, + (unsigned char *)data, length, + 1000/*timeout millis*/); + + if (res < 0) + return -1; + + /* Account for the report ID */ + if (skipped_report_id) + length++; + + return length; +} + +int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) +{ + int res = -1; + int skipped_report_id = 0; + int report_number = data[0]; + + if (report_number == 0x0) { + /* Offset the return buffer by 1, so that the report ID + will remain in byte 0. */ + data++; + length--; + skipped_report_id = 1; + } + res = libusb_control_transfer(dev->device_handle, + LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_IN, + 0x01/*HID get_report*/, + (3/*HID feature*/ << 8) | report_number, + dev->interface, + (unsigned char *)data, length, + 1000/*timeout millis*/); + + if (res < 0) + return -1; + + if (skipped_report_id) + res++; + + return res; +} + + +void HID_API_EXPORT hid_close(hid_device *dev) +{ + if (!dev) + return; + + /* Cause read_thread() to stop. */ + dev->shutdown_thread = 1; + libusb_cancel_transfer(dev->transfer); + + /* Wait for read_thread() to end. */ + pthread_join(dev->thread, NULL); + + /* Clean up the Transfer objects allocated in read_thread(). */ + free(dev->transfer->buffer); + libusb_free_transfer(dev->transfer); + + /* release the interface */ + libusb_release_interface(dev->device_handle, dev->interface); + + /* Close the handle */ + libusb_close(dev->device_handle); + + /* Clear out the queue of received reports. */ + pthread_mutex_lock(&dev->mutex); + while (dev->input_reports) { + return_data(dev, NULL, 0); + } + pthread_mutex_unlock(&dev->mutex); + + free_hid_device(dev); +} + + +int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) +{ + return hid_get_indexed_string(dev, dev->manufacturer_index, string, maxlen); +} + +int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) +{ + return hid_get_indexed_string(dev, dev->product_index, string, maxlen); +} + +int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) +{ + return hid_get_indexed_string(dev, dev->serial_index, string, maxlen); +} + +int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) +{ + wchar_t *str; + + str = get_usb_string(dev->device_handle, string_index); + if (str) { + wcsncpy(string, str, maxlen); + string[maxlen-1] = L'\0'; + free(str); + return 0; + } + else + return -1; +} + + +HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) +{ + return NULL; +} + + +struct lang_map_entry { + const char *name; + const char *string_code; + uint16_t usb_code; +}; + +#define LANG(name,code,usb_code) { name, code, usb_code } +static struct lang_map_entry lang_map[] = { + LANG("Afrikaans", "af", 0x0436), + LANG("Albanian", "sq", 0x041C), + LANG("Arabic - United Arab Emirates", "ar_ae", 0x3801), + LANG("Arabic - Bahrain", "ar_bh", 0x3C01), + LANG("Arabic - Algeria", "ar_dz", 0x1401), + LANG("Arabic - Egypt", "ar_eg", 0x0C01), + LANG("Arabic - Iraq", "ar_iq", 0x0801), + LANG("Arabic - Jordan", "ar_jo", 0x2C01), + LANG("Arabic - Kuwait", "ar_kw", 0x3401), + LANG("Arabic - Lebanon", "ar_lb", 0x3001), + LANG("Arabic - Libya", "ar_ly", 0x1001), + LANG("Arabic - Morocco", "ar_ma", 0x1801), + LANG("Arabic - Oman", "ar_om", 0x2001), + LANG("Arabic - Qatar", "ar_qa", 0x4001), + LANG("Arabic - Saudi Arabia", "ar_sa", 0x0401), + LANG("Arabic - Syria", "ar_sy", 0x2801), + LANG("Arabic - Tunisia", "ar_tn", 0x1C01), + LANG("Arabic - Yemen", "ar_ye", 0x2401), + LANG("Armenian", "hy", 0x042B), + LANG("Azeri - Latin", "az_az", 0x042C), + LANG("Azeri - Cyrillic", "az_az", 0x082C), + LANG("Basque", "eu", 0x042D), + LANG("Belarusian", "be", 0x0423), + LANG("Bulgarian", "bg", 0x0402), + LANG("Catalan", "ca", 0x0403), + LANG("Chinese - China", "zh_cn", 0x0804), + LANG("Chinese - Hong Kong SAR", "zh_hk", 0x0C04), + LANG("Chinese - Macau SAR", "zh_mo", 0x1404), + LANG("Chinese - Singapore", "zh_sg", 0x1004), + LANG("Chinese - Taiwan", "zh_tw", 0x0404), + LANG("Croatian", "hr", 0x041A), + LANG("Czech", "cs", 0x0405), + LANG("Danish", "da", 0x0406), + LANG("Dutch - Netherlands", "nl_nl", 0x0413), + LANG("Dutch - Belgium", "nl_be", 0x0813), + LANG("English - Australia", "en_au", 0x0C09), + LANG("English - Belize", "en_bz", 0x2809), + LANG("English - Canada", "en_ca", 0x1009), + LANG("English - Caribbean", "en_cb", 0x2409), + LANG("English - Ireland", "en_ie", 0x1809), + LANG("English - Jamaica", "en_jm", 0x2009), + LANG("English - New Zealand", "en_nz", 0x1409), + LANG("English - Phillippines", "en_ph", 0x3409), + LANG("English - Southern Africa", "en_za", 0x1C09), + LANG("English - Trinidad", "en_tt", 0x2C09), + LANG("English - Great Britain", "en_gb", 0x0809), + LANG("English - United States", "en_us", 0x0409), + LANG("Estonian", "et", 0x0425), + LANG("Farsi", "fa", 0x0429), + LANG("Finnish", "fi", 0x040B), + LANG("Faroese", "fo", 0x0438), + LANG("French - France", "fr_fr", 0x040C), + LANG("French - Belgium", "fr_be", 0x080C), + LANG("French - Canada", "fr_ca", 0x0C0C), + LANG("French - Luxembourg", "fr_lu", 0x140C), + LANG("French - Switzerland", "fr_ch", 0x100C), + LANG("Gaelic - Ireland", "gd_ie", 0x083C), + LANG("Gaelic - Scotland", "gd", 0x043C), + LANG("German - Germany", "de_de", 0x0407), + LANG("German - Austria", "de_at", 0x0C07), + LANG("German - Liechtenstein", "de_li", 0x1407), + LANG("German - Luxembourg", "de_lu", 0x1007), + LANG("German - Switzerland", "de_ch", 0x0807), + LANG("Greek", "el", 0x0408), + LANG("Hebrew", "he", 0x040D), + LANG("Hindi", "hi", 0x0439), + LANG("Hungarian", "hu", 0x040E), + LANG("Icelandic", "is", 0x040F), + LANG("Indonesian", "id", 0x0421), + LANG("Italian - Italy", "it_it", 0x0410), + LANG("Italian - Switzerland", "it_ch", 0x0810), + LANG("Japanese", "ja", 0x0411), + LANG("Korean", "ko", 0x0412), + LANG("Latvian", "lv", 0x0426), + LANG("Lithuanian", "lt", 0x0427), + LANG("F.Y.R.O. Macedonia", "mk", 0x042F), + LANG("Malay - Malaysia", "ms_my", 0x043E), + LANG("Malay – Brunei", "ms_bn", 0x083E), + LANG("Maltese", "mt", 0x043A), + LANG("Marathi", "mr", 0x044E), + LANG("Norwegian - Bokml", "no_no", 0x0414), + LANG("Norwegian - Nynorsk", "no_no", 0x0814), + LANG("Polish", "pl", 0x0415), + LANG("Portuguese - Portugal", "pt_pt", 0x0816), + LANG("Portuguese - Brazil", "pt_br", 0x0416), + LANG("Raeto-Romance", "rm", 0x0417), + LANG("Romanian - Romania", "ro", 0x0418), + LANG("Romanian - Republic of Moldova", "ro_mo", 0x0818), + LANG("Russian", "ru", 0x0419), + LANG("Russian - Republic of Moldova", "ru_mo", 0x0819), + LANG("Sanskrit", "sa", 0x044F), + LANG("Serbian - Cyrillic", "sr_sp", 0x0C1A), + LANG("Serbian - Latin", "sr_sp", 0x081A), + LANG("Setsuana", "tn", 0x0432), + LANG("Slovenian", "sl", 0x0424), + LANG("Slovak", "sk", 0x041B), + LANG("Sorbian", "sb", 0x042E), + LANG("Spanish - Spain (Traditional)", "es_es", 0x040A), + LANG("Spanish - Argentina", "es_ar", 0x2C0A), + LANG("Spanish - Bolivia", "es_bo", 0x400A), + LANG("Spanish - Chile", "es_cl", 0x340A), + LANG("Spanish - Colombia", "es_co", 0x240A), + LANG("Spanish - Costa Rica", "es_cr", 0x140A), + LANG("Spanish - Dominican Republic", "es_do", 0x1C0A), + LANG("Spanish - Ecuador", "es_ec", 0x300A), + LANG("Spanish - Guatemala", "es_gt", 0x100A), + LANG("Spanish - Honduras", "es_hn", 0x480A), + LANG("Spanish - Mexico", "es_mx", 0x080A), + LANG("Spanish - Nicaragua", "es_ni", 0x4C0A), + LANG("Spanish - Panama", "es_pa", 0x180A), + LANG("Spanish - Peru", "es_pe", 0x280A), + LANG("Spanish - Puerto Rico", "es_pr", 0x500A), + LANG("Spanish - Paraguay", "es_py", 0x3C0A), + LANG("Spanish - El Salvador", "es_sv", 0x440A), + LANG("Spanish - Uruguay", "es_uy", 0x380A), + LANG("Spanish - Venezuela", "es_ve", 0x200A), + LANG("Southern Sotho", "st", 0x0430), + LANG("Swahili", "sw", 0x0441), + LANG("Swedish - Sweden", "sv_se", 0x041D), + LANG("Swedish - Finland", "sv_fi", 0x081D), + LANG("Tamil", "ta", 0x0449), + LANG("Tatar", "tt", 0X0444), + LANG("Thai", "th", 0x041E), + LANG("Turkish", "tr", 0x041F), + LANG("Tsonga", "ts", 0x0431), + LANG("Ukrainian", "uk", 0x0422), + LANG("Urdu", "ur", 0x0420), + LANG("Uzbek - Cyrillic", "uz_uz", 0x0843), + LANG("Uzbek – Latin", "uz_uz", 0x0443), + LANG("Vietnamese", "vi", 0x042A), + LANG("Xhosa", "xh", 0x0434), + LANG("Yiddish", "yi", 0x043D), + LANG("Zulu", "zu", 0x0435), + LANG(NULL, NULL, 0x0), +}; + +uint16_t get_usb_code_for_current_locale(void) +{ + char *locale; + char search_string[64]; + char *ptr; + struct lang_map_entry *lang; + + /* Get the current locale. */ + locale = setlocale(0, NULL); + if (!locale) + return 0x0; + + /* Make a copy of the current locale string. */ + strncpy(search_string, locale, sizeof(search_string)); + search_string[sizeof(search_string)-1] = '\0'; + + /* Chop off the encoding part, and make it lower case. */ + ptr = search_string; + while (*ptr) { + *ptr = tolower(*ptr); + if (*ptr == '.') { + *ptr = '\0'; + break; + } + ptr++; + } + + /* Find the entry which matches the string code of our locale. */ + lang = lang_map; + while (lang->string_code) { + if (!strcmp(lang->string_code, search_string)) { + return lang->usb_code; + } + lang++; + } + + /* There was no match. Find with just the language only. */ + /* Chop off the variant. Chop it off at the '_'. */ + ptr = search_string; + while (*ptr) { + *ptr = tolower(*ptr); + if (*ptr == '_') { + *ptr = '\0'; + break; + } + ptr++; + } + +#if 0 /* TODO: Do we need this? */ + /* Find the entry which matches the string code of our language. */ + lang = lang_map; + while (lang->string_code) { + if (!strcmp(lang->string_code, search_string)) { + return lang->usb_code; + } + lang++; + } +#endif + + /* Found nothing. */ + return 0x0; +} + +#ifdef __cplusplus +} +#endif diff --git a/cad/PrusaSlicer/files/patch-src_hints_HintsToPot.cpp b/cad/PrusaSlicer/files/patch-src_hints_HintsToPot.cpp new file mode 100644 index 000000000000..26f89c4506e5 --- /dev/null +++ b/cad/PrusaSlicer/files/patch-src_hints_HintsToPot.cpp @@ -0,0 +1,10 @@ +--- src/hints/HintsToPot.cpp.orig 2022-11-13 19:31:07 UTC ++++ src/hints/HintsToPot.cpp +@@ -2,6 +2,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_libslic3r_CMakeLists.txt index 0ad79d2f8993..e7e49767c5d5 100644 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-src_libslic3r_CMakeLists.txt @@ -1,10 +1,10 @@ ---- src/libslic3r/CMakeLists.txt.orig 2021-07-16 10:14:03 UTC +--- src/libslic3r/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC +++ src/libslic3r/CMakeLists.txt -@@ -300,7 +300,6 @@ target_include_directories(libslic3r PUBLIC ${EXPAT_IN +@@ -395,7 +395,6 @@ find_package(JPEG REQUIRED) target_link_libraries(libslic3r libnest2d admesh - cereal libigl miniz boost_libs diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.cpp index c584b09b4bef..ac651976424c 100644 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.cpp +++ b/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.cpp @@ -1,13 +1,13 @@ ---- src/libslic3r/Platform.cpp.orig 2021-04-20 12:16:52 UTC +--- src/libslic3r/Platform.cpp.orig 2022-09-06 07:09:19 UTC +++ src/libslic3r/Platform.cpp -@@ -49,6 +49,10 @@ void detect_platform() +@@ -86,6 +86,10 @@ void detect_platform() BOOST_LOG_TRIVIAL(info) << "Platform: OpenBSD"; s_platform = Platform::BSDUnix; s_platform_flavor = PlatformFlavor::OpenBSD; +#elif defined(__FreeBSD__) + BOOST_LOG_TRIVIAL(info) << "Platform: FreeBSD"; + s_platform = Platform::BSDUnix; + s_platform_flavor = PlatformFlavor::FreeBSD; #else // This should not happen. BOOST_LOG_TRIVIAL(info) << "Platform: Unknown"; diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.hpp b/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.hpp index 17da981d267a..15036b0e7a2b 100644 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.hpp +++ b/cad/PrusaSlicer/files/patch-src_libslic3r_Platform.hpp @@ -1,10 +1,10 @@ ---- src/libslic3r/Platform.hpp.orig 2021-04-20 12:26:01 UTC +--- src/libslic3r/Platform.hpp.orig 2022-09-06 07:09:19 UTC +++ src/libslic3r/Platform.hpp -@@ -28,6 +28,7 @@ enum class PlatformFlavor - WSL2, - // For Platform::BSDUnix - OpenBSD, -+ FreeBSD, - }; - - // To be called on program start-up. +@@ -25,6 +25,7 @@ enum class PlatformFlavor + WSL, // Microsoft's Windows on Linux (Linux kernel simulated on NTFS kernel) + WSL2, // Microsoft's Windows on Linux, version 2 (virtual machine) + OpenBSD, // For Platform::BSDUnix ++ FreeBSD, // For Platform::BSDUnix + GenericOSX, // For Platform::OSX + OSXOnX86, // For Apple's on Intel X86 CPU + OSXOnArm, // For Apple's on Arm CPU diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_Print.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_Print.cpp deleted file mode 100644 index 497cce5467a7..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_Print.cpp +++ /dev/null @@ -1,29 +0,0 @@ ---- src/libslic3r/Print.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/Print.cpp -@@ -36,7 +36,7 @@ template class PrintState; - - void Print::clear() - { -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - // The following call should stop background processing if it is running. - this->invalidate_all_steps(); - for (PrintObject *object : m_objects) -@@ -262,7 +262,7 @@ bool Print::is_step_done(PrintObjectStep step) const - { - if (m_objects.empty()) - return false; -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - for (const PrintObject *object : m_objects) - if (! object->is_step_done_unguarded(step)) - return false; -@@ -617,7 +617,7 @@ Print::ApplyStatus Print::apply(const Model &model, Dy - update_apply_status(false); - - // Grab the lock for the Print / PrintObject milestones. -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - - // The following call may stop the background processing. - if (! print_diff.empty()) diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.cpp deleted file mode 100644 index 7f903f9adaa4..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.cpp +++ /dev/null @@ -1,11 +0,0 @@ ---- src/libslic3r/PrintBase.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/PrintBase.cpp -@@ -97,7 +97,7 @@ void PrintBase::status_update_warnings(ObjectID object - printf("%s warning: %s\n", (object_id == this->id()) ? "print" : "print object", message.c_str()); - } - --tbb::mutex& PrintObjectBase::state_mutex(PrintBase *print) -+std::mutex& PrintObjectBase::state_mutex(PrintBase *print) - { - return print->state_mutex(); - } diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.hpp b/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.hpp deleted file mode 100644 index 0db7f4672dfd..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintBase.hpp +++ /dev/null @@ -1,118 +0,0 @@ ---- src/libslic3r/PrintBase.hpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/PrintBase.hpp -@@ -6,13 +6,9 @@ - #include - #include - #include -+#include -+#include - --// tbb/mutex.h includes Windows, which in turn defines min/max macros. Convince Windows.h to not define these min/max macros. --#ifndef NOMINMAX -- #define NOMINMAX --#endif --#include "tbb/mutex.h" -- - #include "ObjectID.hpp" - #include "Model.hpp" - #include "PlaceholderParser.hpp" -@@ -84,23 +80,23 @@ class PrintState : public PrintStateBase - public: - PrintState() {} - -- StateWithTimeStamp state_with_timestamp(StepType step, tbb::mutex &mtx) const { -- tbb::mutex::scoped_lock lock(mtx); -+ StateWithTimeStamp state_with_timestamp(StepType step, std::mutex &mtx) const { -+ std::scoped_lock lock(mtx); - StateWithTimeStamp state = m_state[step]; - return state; - } - -- StateWithWarnings state_with_warnings(StepType step, tbb::mutex &mtx) const { -- tbb::mutex::scoped_lock lock(mtx); -+ StateWithWarnings state_with_warnings(StepType step, std::mutex &mtx) const { -+ std::scoped_lock lock(mtx); - StateWithWarnings state = m_state[step]; - return state; - } - -- bool is_started(StepType step, tbb::mutex &mtx) const { -+ bool is_started(StepType step, std::mutex &mtx) const { - return this->state_with_timestamp(step, mtx).state == STARTED; - } - -- bool is_done(StepType step, tbb::mutex &mtx) const { -+ bool is_done(StepType step, std::mutex &mtx) const { - return this->state_with_timestamp(step, mtx).state == DONE; - } - -@@ -121,8 +117,8 @@ class PrintState : public PrintStateBase - // This is necessary to block until the Print::apply() updates its state, which may - // influence the processing step being entered. - template -- bool set_started(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) { -- tbb::mutex::scoped_lock lock(mtx); -+ bool set_started(StepType step, std::mutex &mtx, ThrowIfCanceled throw_if_canceled) { -+ std::scoped_lock lock(mtx); - // If canceled, throw before changing the step state. - throw_if_canceled(); - #ifndef NDEBUG -@@ -154,8 +150,8 @@ class PrintState : public PrintStateBase - // Timestamp when this stepentered the DONE state. - // bool indicates whether the UI has to update the slicing warnings of this step or not. - template -- std::pair set_done(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) { -- tbb::mutex::scoped_lock lock(mtx); -+ std::pair set_done(StepType step, std::mutex &mtx, ThrowIfCanceled throw_if_canceled) { -+ std::scoped_lock lock(mtx); - // If canceled, throw before changing the step state. - throw_if_canceled(); - assert(m_state[step].state == STARTED); -@@ -266,9 +262,9 @@ class PrintState : public PrintStateBase - // Return value: - // Current milestone (StepType). - // bool indicates whether the UI has to be updated or not. -- std::pair active_step_add_warning(PrintStateBase::WarningLevel warning_level, const std::string &message, int message_id, tbb::mutex &mtx) -+ std::pair active_step_add_warning(PrintStateBase::WarningLevel warning_level, const std::string &message, int message_id, std::mutex &mtx) - { -- tbb::mutex::scoped_lock lock(mtx); -+ std::scoped_lock lock(mtx); - assert(m_step_active != -1); - StateWithWarnings &state = m_state[m_step_active]; - assert(state.state == STARTED); -@@ -314,7 +310,7 @@ class PrintObjectBase : public ObjectBase (protected) - PrintObjectBase(ModelObject *model_object) : m_model_object(model_object) {} - virtual ~PrintObjectBase() {} - // Declared here to allow access from PrintBase through friendship. -- static tbb::mutex& state_mutex(PrintBase *print); -+ static std::mutex& state_mutex(PrintBase *print); - static std::function cancel_callback(PrintBase *print); - // Notify UI about a new warning of a milestone "step" on this PrintObjectBase. - // The UI will be notified by calling a status callback registered on print. -@@ -461,7 +457,7 @@ class PrintBase : public ObjectBase (protected) - friend class PrintObjectBase; - friend class BackgroundSlicingProcess; - -- tbb::mutex& state_mutex() const { return m_state_mutex; } -+ std::mutex& state_mutex() const { return m_state_mutex; } - std::function cancel_callback() { return m_cancel_callback; } - void call_cancel_callback() { m_cancel_callback(); } - // Notify UI about a new warning of a milestone "step" on this PrintBase. -@@ -486,7 +482,7 @@ class PrintBase : public ObjectBase (protected) - status_callback_type m_status_callback; - - private: -- tbb::atomic m_cancel_status; -+ std::atomic m_cancel_status; - - // Callback to be evoked to stop the background processing before a state is updated. - cancel_callback_type m_cancel_callback = [](){}; -@@ -494,7 +490,7 @@ class PrintBase : public ObjectBase (protected) - // Mutex used for synchronization of the worker thread with the UI thread: - // The mutex will be used to guard the worker thread against entering a stage - // while the data influencing the stage is modified. -- mutable tbb::mutex m_state_mutex; -+ mutable std::mutex m_state_mutex; - }; - - template diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintObject.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_PrintObject.cpp deleted file mode 100644 index 3239fa337a41..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_PrintObject.cpp +++ /dev/null @@ -1,10 +0,0 @@ ---- src/libslic3r/PrintObject.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/PrintObject.cpp -@@ -19,7 +19,6 @@ - #include - - #include --#include - - #include - diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_SLAPrint.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_SLAPrint.cpp deleted file mode 100644 index 0b9990bc2b1e..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_SLAPrint.cpp +++ /dev/null @@ -1,47 +0,0 @@ ---- src/libslic3r/SLAPrint.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/SLAPrint.cpp -@@ -19,8 +19,6 @@ - #include - #endif - --//#include //#include "tbb/mutex.h" -- - #include "I18N.hpp" - - //! macro used to mark string used at localization, -@@ -118,7 +116,7 @@ bool validate_pad(const TriangleMesh &pad, const sla:: - - void SLAPrint::clear() - { -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - // The following call should stop background processing if it is running. - this->invalidate_all_steps(); - for (SLAPrintObject *object : m_objects) -@@ -212,7 +210,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &mod - update_apply_status(false); - - // Grab the lock for the Print / PrintObject milestones. -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - - // The following call may stop the background processing. - bool invalidate_all_model_objects = false; -@@ -514,7 +512,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &mod - void SLAPrint::set_task(const TaskParams ¶ms) - { - // Grab the lock for the Print / PrintObject milestones. -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - - int n_object_steps = int(params.to_object_step) + 1; - if (n_object_steps == 0) -@@ -884,7 +882,7 @@ bool SLAPrint::is_step_done(SLAPrintObjectStep step) c - { - if (m_objects.empty()) - return false; -- tbb::mutex::scoped_lock lock(this->state_mutex()); -+ std::scoped_lock lock(this->state_mutex()); - for (const SLAPrintObject *object : m_objects) - if (! object->is_step_done_unguarded(step)) - return false; diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_Concurrency.hpp b/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_Concurrency.hpp deleted file mode 100644 index 673e157e0775..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_Concurrency.hpp +++ /dev/null @@ -1,20 +0,0 @@ ---- src/libslic3r/SLA/Concurrency.hpp.orig 2021-08-14 22:14:14 UTC -+++ src/libslic3r/SLA/Concurrency.hpp -@@ -2,7 +2,7 @@ - #define SLA_CONCURRENCY_H - - #include --#include -+#include - #include - #include - -@@ -23,7 +23,7 @@ template struct _ccr {}; - template<> struct _ccr - { - using SpinningMutex = tbb::spin_mutex; -- using BlockingMutex = tbb::mutex; -+ using BlockingMutex = std::mutex; - - template - static IteratorOnly loop_(const tbb::blocked_range &range, Fn &&fn) diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_SupportTree.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_SupportTree.cpp deleted file mode 100644 index 128667eac2d0..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_SLA_SupportTree.cpp +++ /dev/null @@ -1,12 +0,0 @@ ---- src/libslic3r/SLA/SupportTree.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/SLA/SupportTree.cpp -@@ -16,9 +16,6 @@ - #include - #include - #include --#include --#include --#include - #include - - //! macro used to mark string used at localization, diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_SupportMaterial.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_SupportMaterial.cpp deleted file mode 100644 index 569e440ec707..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_SupportMaterial.cpp +++ /dev/null @@ -1,10 +0,0 @@ ---- src/libslic3r/SupportMaterial.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/SupportMaterial.cpp -@@ -12,7 +12,6 @@ - #include - - #include --#include - #include - #include - diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp deleted file mode 100644 index 32ff24bbfd77..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_Thread.cpp +++ /dev/null @@ -1,41 +0,0 @@ ---- src/libslic3r/Thread.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/Thread.cpp -@@ -9,10 +9,10 @@ - #include - #include - #include -+#include -+#include - #include --#include - #include --#include - - #include "Thread.hpp" - -@@ -206,13 +206,13 @@ void name_tbb_thread_pool_threads() - nthreads = 1; - #endif - -- if (nthreads != nthreads_hw) -- new tbb::task_scheduler_init(int(nthreads)); -+ if (nthreads != nthreads_hw) -+ tbb::global_control(tbb::global_control::max_allowed_parallelism, nthreads); - - std::atomic nthreads_running(0); - std::condition_variable cv; - std::mutex cv_m; -- auto master_thread_id = tbb::this_tbb_thread::get_id(); -+ auto master_thread_id = std::this_thread::get_id(); - tbb::parallel_for( - tbb::blocked_range(0, nthreads, 1), - [&nthreads_running, nthreads, &master_thread_id, &cv, &cv_m](const tbb::blocked_range &range) { -@@ -226,7 +226,7 @@ void name_tbb_thread_pool_threads() - std::unique_lock lk(cv_m); - cv.wait(lk, [&nthreads_running, nthreads]{return nthreads_running == nthreads;}); - } -- auto thread_id = tbb::this_tbb_thread::get_id(); -+ auto thread_id = std::this_thread::get_id(); - if (thread_id == master_thread_id) { - // The calling thread runs the 0'th task. - assert(range.begin() == 0); diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_pchheader.hpp b/cad/PrusaSlicer/files/patch-src_libslic3r_pchheader.hpp deleted file mode 100644 index 11b6b726c0c4..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_pchheader.hpp +++ /dev/null @@ -1,15 +0,0 @@ ---- src/libslic3r/pchheader.hpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/pchheader.hpp -@@ -93,12 +93,9 @@ - #include - #include - --#include - #include - #include --#include - #include --#include - - #include - #include diff --git a/cad/PrusaSlicer/files/patch-src_libslic3r_utils.cpp b/cad/PrusaSlicer/files/patch-src_libslic3r_utils.cpp deleted file mode 100644 index 4eb0a65020b3..000000000000 --- a/cad/PrusaSlicer/files/patch-src_libslic3r_utils.cpp +++ /dev/null @@ -1,22 +0,0 @@ ---- src/libslic3r/utils.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/libslic3r/utils.cpp -@@ -43,7 +43,7 @@ - #include - #include - --#include -+#include - - #if defined(__linux__) || defined(__GNUC__ ) - #include -@@ -118,9 +118,7 @@ void trace(unsigned int level, const char *message) - void disable_multi_threading() - { - // Disable parallelization so the Shiny profiler works -- static tbb::task_scheduler_init *tbb_init = nullptr; -- if (tbb_init == nullptr) -- tbb_init = new tbb::task_scheduler_init(1); -+ tbb::global_control(tbb::global_control::max_allowed_parallelism, 1); - } - - static std::string g_var_dir; diff --git a/cad/PrusaSlicer/files/patch-src_occt__wrapper_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_occt__wrapper_CMakeLists.txt new file mode 100644 index 000000000000..49e2c3fa9851 --- /dev/null +++ b/cad/PrusaSlicer/files/patch-src_occt__wrapper_CMakeLists.txt @@ -0,0 +1,22 @@ +--- src/occt_wrapper/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC ++++ src/occt_wrapper/CMakeLists.txt +@@ -19,9 +19,11 @@ include(GenerateExportHeader) + + generate_export_header(OCCTWrapper) + +-find_package(OpenCASCADE 7.6.2 REQUIRED) ++list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib/cmake) ++find_package(OpenCASCADE REQUIRED) + + set(OCCT_LIBS ++ -L${CMAKE_INSTALL_PREFIX}/lib + TKXDESTEP + TKSTEP + TKSTEP209 +@@ -56,5 +58,5 @@ target_link_libraries(OCCTWrapper ${OCCT_LIBS}) + + include(GNUInstallDirs) + +-install(TARGETS OCCTWrapper DESTINATION "${CMAKE_INSTALL_BINDIR}") ++install(TARGETS OCCTWrapper DESTINATION "${CMAKE_INSTALL_LIBDIR}") + diff --git a/cad/PrusaSlicer/files/patch-src_qhull_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_qhull_CMakeLists.txt index ce0b95dc9110..ff839fb90855 100644 --- a/cad/PrusaSlicer/files/patch-src_qhull_CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-src_qhull_CMakeLists.txt @@ -1,29 +1,29 @@ ---- src/qhull/CMakeLists.txt.orig 2021-11-19 21:23:46.166100000 -0500 -+++ src/qhull/CMakeLists.txt 2021-11-19 21:27:12.170235000 -0500 -@@ -14,19 +14,8 @@ +--- src/qhull/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC ++++ src/qhull/CMakeLists.txt +@@ -14,19 +14,8 @@ find_package(Qhull 7.2 QUIET) add_library(qhull INTERFACE) -if(Qhull_FOUND) +#force use of bundled qhull#else(Qhull_FOUND) -message(STATUS "Using qhull from system.") -if(SLIC3R_STATIC) - slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhullstatic_r" RelWithDebInfo Release) - target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r) -else() - slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhull_r" RelWithDebInfo Release) - target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhull_r) -endif() - -else(Qhull_FOUND) - project(qhull) cmake_minimum_required(VERSION 2.6) -@@ -144,4 +133,4 @@ +@@ -144,4 +133,4 @@ endif(UNIX) target_include_directories(${qhull_STATIC} BEFORE PUBLIC ${LIBDIR}/qhull/src) target_link_libraries(qhull INTERFACE ${qhull_STATIC}) -endif() +#force use of bundled qhull##endif() diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_CMakeLists.txt b/cad/PrusaSlicer/files/patch-src_slic3r_CMakeLists.txt index 22efe2367d62..3c7becc43169 100644 --- a/cad/PrusaSlicer/files/patch-src_slic3r_CMakeLists.txt +++ b/cad/PrusaSlicer/files/patch-src_slic3r_CMakeLists.txt @@ -1,14 +1,16 @@ ---- src/slic3r/CMakeLists.txt.orig 2021-01-11 13:01:51 UTC +--- src/slic3r/CMakeLists.txt.orig 2022-09-06 07:09:19 UTC +++ src/slic3r/CMakeLists.txt -@@ -232,9 +232,9 @@ add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES} +@@ -260,11 +260,11 @@ add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES} encoding_check(libslic3r_gui) --target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi libcurl ${wxWidgets_LIBRARIES}) +-target_link_libraries(libslic3r_gui libslic3r avrdude cereal imgui GLEW::GLEW OpenGL::GL hidapi libcurl ${wxWidgets_LIBRARIES}) +target_link_libraries(libslic3r_gui libslic3r avrdude imgui GLEW::GLEW OpenGL::GL OpenGL::GLU hidapi libcurl ${wxWidgets_LIBRARIES}) --if (CMAKE_SYSTEM_NAME STREQUAL "Linux") -+if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + if (MSVC) + target_link_libraries(libslic3r_gui Setupapi.lib) +-elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") ++elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") target_link_libraries(libslic3r_gui ${DBUS_LIBRARIES}) - endif() - + elseif (APPLE) + target_link_libraries(libslic3r_gui ${DISKARBITRATION_LIBRARY}) diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp deleted file mode 100644 index f56446391229..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp +++ /dev/null @@ -1,29 +0,0 @@ ---- src/slic3r/GUI/BackgroundSlicingProcess.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/BackgroundSlicingProcess.cpp -@@ -465,7 +465,7 @@ void BackgroundSlicingProcess::schedule_export(const s - return; - - // Guard against entering the export step before changing the export path. -- tbb::mutex::scoped_lock lock(m_print->state_mutex()); -+ std::scoped_lock lock(m_print->state_mutex()); - this->invalidate_step(bspsGCodeFinalize); - m_export_path = path; - m_export_path_on_removable_media = export_path_on_removable_media; -@@ -478,7 +478,7 @@ void BackgroundSlicingProcess::schedule_upload(Slic3r: - return; - - // Guard against entering the export step before changing the export path. -- tbb::mutex::scoped_lock lock(m_print->state_mutex()); -+ std::scoped_lock lock(m_print->state_mutex()); - this->invalidate_step(bspsGCodeFinalize); - m_export_path.clear(); - m_upload_job = std::move(upload_job); -@@ -491,7 +491,7 @@ void BackgroundSlicingProcess::reset_export() - m_export_path.clear(); - m_export_path_on_removable_media = false; - // invalidate_step expects the mutex to be locked. -- tbb::mutex::scoped_lock lock(m_print->state_mutex()); -+ std::scoped_lock lock(m_print->state_mutex()); - this->invalidate_step(bspsGCodeFinalize); - } - } diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp deleted file mode 100644 index e35befaa435a..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp +++ /dev/null @@ -1,11 +0,0 @@ ---- src/slic3r/GUI/BackgroundSlicingProcess.hpp.orig 2021-08-14 22:52:55 UTC -+++ src/slic3r/GUI/BackgroundSlicingProcess.hpp -@@ -213,7 +213,7 @@ class BackgroundSlicingProcess (private) - State m_state = STATE_INITIAL; - - PrintState m_step_state; -- mutable tbb::mutex m_step_state_mutex; -+ mutable std::mutex m_step_state_mutex; - bool set_step_started(BackgroundSlicingProcessStep step); - void set_step_done(BackgroundSlicingProcessStep step); - bool is_step_done(BackgroundSlicingProcessStep step) const; diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp new file mode 100644 index 000000000000..16c1ad89dcd4 --- /dev/null +++ b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_GUI__App.cpp @@ -0,0 +1,19 @@ +--- src/slic3r/GUI/GUI_App.cpp.orig 2022-09-06 07:09:19 UTC ++++ src/slic3r/GUI/GUI_App.cpp +@@ -2072,7 +2072,7 @@ bool GUI_App::load_language(wxString language, bool in + BOOST_LOG_TRIVIAL(trace) << boost::format("System language detected (user locales and such): %1%") % m_language_info_system->CanonicalName.ToUTF8().data(); + } + } +- { ++ if (0) { + // Allocating a temporary locale will switch the default wxTranslations to its internal wxTranslations instance. + wxLocale temp_locale; + // Set the current translation's language to default, otherwise GetBestTranslation() may not work (see the wxWidgets source code). +@@ -2096,6 +2096,7 @@ bool GUI_App::load_language(wxString language, bool in + } + #endif + } ++ m_language_info_best = nullptr; + } + + const wxLanguageInfo *language_info = language.empty() ? nullptr : wxLocale::FindLanguageInfo(language); diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.cpp index c5505225059a..d104cb945f3d 100644 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.cpp +++ b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.cpp @@ -1,20 +1,20 @@ ---- src/slic3r/GUI/InstanceCheck.cpp.orig 2021-01-11 13:01:51 UTC +--- src/slic3r/GUI/InstanceCheck.cpp.orig 2022-09-06 07:09:19 UTC +++ src/slic3r/GUI/InstanceCheck.cpp @@ -23,7 +23,7 @@ #include #endif //WIN32 -#if __linux__ +#if defined(__linux__) || defined (__FreeBSD__) #include /* Pull in all of D-Bus headers. */ #endif //__linux__ -@@ -169,7 +169,7 @@ namespace instance_check_internal +@@ -222,7 +222,7 @@ namespace instance_check_internal return false; } -#elif defined(__linux__) +#elif defined(__linux__) || defined (__FreeBSD__) static bool send_message(const std::string &message_text, const std::string &version) { diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.hpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.hpp deleted file mode 100644 index 0c32c309a1d8..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_InstanceCheck.hpp +++ /dev/null @@ -1,11 +0,0 @@ ---- src/slic3r/GUI/InstanceCheck.hpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/InstanceCheck.hpp -@@ -13,7 +13,7 @@ - - #if __linux__ - #include --#include -+#include - #include - #endif // __linux__ - diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.cpp deleted file mode 100644 index f1122392e483..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.cpp +++ /dev/null @@ -1,154 +0,0 @@ ---- src/slic3r/GUI/Mouse3DController.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/Mouse3DController.cpp -@@ -66,7 +66,7 @@ void update_maximum(std::atomic& maximum_value, T c - - void Mouse3DController::State::append_translation(const Vec3d& translation, size_t input_queue_max_size) - { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - while (m_input_queue.size() >= input_queue_max_size) - m_input_queue.pop_front(); - m_input_queue.emplace_back(QueueItem::translation(translation)); -@@ -77,7 +77,7 @@ void Mouse3DController::State::append_translation(cons - - void Mouse3DController::State::append_rotation(const Vec3f& rotation, size_t input_queue_max_size) - { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - while (m_input_queue.size() >= input_queue_max_size) - m_input_queue.pop_front(); - m_input_queue.emplace_back(QueueItem::rotation(rotation.cast())); -@@ -92,7 +92,7 @@ void Mouse3DController::State::append_rotation(const V - - void Mouse3DController::State::append_button(unsigned int id, size_t /* input_queue_max_size */) - { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - m_input_queue.emplace_back(QueueItem::buttons(id)); - #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT - update_maximum(input_queue_max_size_achieved, m_input_queue.size()); -@@ -277,7 +277,7 @@ void Mouse3DController::device_attached(const std::str - #if ENABLE_CTRL_M_ON_WINDOWS - m_device_str = format_device_string(vid, pid); - if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params = m_params_ui = it_params->second; - } - else -@@ -295,7 +295,7 @@ void Mouse3DController::device_detached(const std::str - int pid = 0; - if (sscanf(device.c_str(), "\\\\?\\HID#VID_%x&PID_%x&", &vid, &pid) == 2) { - if (std::find(_3DCONNEXION_VENDORS.begin(), _3DCONNEXION_VENDORS.end(), vid) != _3DCONNEXION_VENDORS.end()) { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params_by_device[format_device_string(vid, pid)] = m_params_ui; - } - } -@@ -307,12 +307,12 @@ void Mouse3DController::device_detached(const std::str - // Filter out mouse scroll events produced by the 3DConnexion driver. - bool Mouse3DController::State::process_mouse_wheel() - { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -- if (m_mouse_wheel_counter == 0) -- // No 3DConnexion rotation has been captured since the last mouse scroll event. -+ std::scoped_lock lock(m_input_queue_mutex); -+ if (m_mouse_wheel_counter == 0) -+ // No 3DConnexion rotation has been captured since the last mouse scroll event. - return false; - if (std::find_if(m_input_queue.begin(), m_input_queue.end(), [](const QueueItem &item){ return item.is_rotation(); }) != m_input_queue.end()) { -- // There is a rotation stored in the queue. Suppress one mouse scroll event. -+ // There is a rotation stored in the queue. Suppress one mouse scroll event. - -- m_mouse_wheel_counter; - return true; - } -@@ -329,7 +329,7 @@ bool Mouse3DController::State::apply(const Mouse3DCont - std::deque input_queue; - { - // Atomically move m_input_queue to input_queue. -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - input_queue = std::move(m_input_queue); - m_input_queue.clear(); - } -@@ -418,7 +418,7 @@ bool Mouse3DController::apply(Camera& camera) - #if ENABLE_CTRL_M_ON_WINDOWS - #ifdef _WIN32 - { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - if (m_params_ui_changed) { - m_params = m_params_ui; - m_params_ui_changed = false; -@@ -447,7 +447,7 @@ void Mouse3DController::render_settings_dialog(GLCanva - Params params_copy; - bool params_changed = false; - { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - params_copy = m_params_ui; - } - -@@ -565,7 +565,7 @@ void Mouse3DController::render_settings_dialog(GLCanva - - if (params_changed) { - // Synchronize front end parameters to back end. -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - auto pthis = const_cast(this); - #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT - if (params_copy.input_queue_max_size != params_copy.input_queue_max_size) -@@ -586,7 +586,7 @@ void Mouse3DController::connected(std::string device_n - m_device_str = device_name; - // Copy the parameters for m_device_str into the current parameters. - if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params = m_params_ui = it_params->second; - } - m_connected = true; -@@ -597,7 +597,7 @@ void Mouse3DController::disconnected() - // Copy the current parameters for m_device_str into the parameter database. - assert(m_connected == ! m_device_str.empty()); - if (m_connected) { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params_by_device[m_device_str] = m_params_ui; - m_device_str.clear(); - m_connected = false; -@@ -621,7 +621,7 @@ bool Mouse3DController::handle_input(const DataPacketA - { - // Synchronize parameters between the UI thread and the background thread. - //FIXME is this necessary on OSX? Are these notifications triggered from the main thread or from a worker thread? -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - if (m_params_ui_changed) { - m_params = m_params_ui; - m_params_ui_changed = false; -@@ -733,7 +733,7 @@ void Mouse3DController::run() - - for (;;) { - { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - if (m_stop) - break; - if (m_params_ui_changed) { -@@ -998,7 +998,7 @@ bool Mouse3DController::connect_device() - #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT - // Copy the parameters for m_device_str into the current parameters. - if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params = m_params_ui = it_params->second; - } - } -@@ -1023,7 +1023,7 @@ void Mouse3DController::disconnect_device() - BOOST_LOG_TRIVIAL(info) << "Disconnected device: " << m_device_str; - // Copy the current parameters for m_device_str into the parameter database. - { -- tbb::mutex::scoped_lock lock(m_params_ui_mutex); -+ std::scoped_lock lock(m_params_ui_mutex); - m_params_by_device[m_device_str] = m_params_ui; - } - m_device_str.clear(); diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.hpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.hpp deleted file mode 100644 index 47600dece5a7..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_Mouse3DController.hpp +++ /dev/null @@ -1,49 +0,0 @@ ---- src/slic3r/GUI/Mouse3DController.hpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/Mouse3DController.hpp -@@ -10,12 +10,12 @@ - - #include - #include -+#include - #include - #include - #include - #include - --#include - - namespace Slic3r { - -@@ -85,7 +85,7 @@ class Mouse3DController - // m_input_queue is accessed by the background thread and by the UI thread. Access to m_input_queue - // is guarded with m_input_queue_mutex. - std::deque m_input_queue; -- mutable tbb::mutex m_input_queue_mutex; -+ mutable std::mutex m_input_queue_mutex; - - #ifdef WIN32 - // When the 3Dconnexion driver is running the system gets, by default, mouse wheel events when rotations around the X axis are detected. -@@ -112,12 +112,12 @@ class Mouse3DController - - #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT - Vec3d get_first_vector_of_type(unsigned int type) const { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - auto it = std::find_if(m_input_queue.begin(), m_input_queue.end(), [type](const QueueItem& item) { return item.type_or_buttons == type; }); - return (it == m_input_queue.end()) ? Vec3d::Zero() : it->vector; - } - size_t input_queue_size_current() const { -- tbb::mutex::scoped_lock lock(m_input_queue_mutex); -+ std::scoped_lock lock(m_input_queue_mutex); - return m_input_queue.size(); - } - std::atomic input_queue_max_size_achieved; -@@ -133,7 +133,7 @@ class Mouse3DController - // UI thread will read / write this copy. - Params m_params_ui; - bool m_params_ui_changed { false }; -- mutable tbb::mutex m_params_ui_mutex; -+ mutable std::mutex m_params_ui_mutex; - - // This is a database of parametes of all 3DConnexion devices ever connected. - // This database is loaded from AppConfig on application start and it is stored to AppConfig on application exit. diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_OpenGLManager.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_OpenGLManager.cpp index fb6931a7fe86..305014e9f2fe 100644 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_OpenGLManager.cpp +++ b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_OpenGLManager.cpp @@ -1,12 +1,12 @@ ---- src/slic3r/GUI/OpenGLManager.cpp.orig 2021-04-16 11:41:00 UTC +--- src/slic3r/GUI/OpenGLManager.cpp.orig 2022-09-06 07:09:19 UTC +++ src/slic3r/GUI/OpenGLManager.cpp -@@ -239,7 +239,8 @@ bool OpenGLManager::init_gl() +@@ -236,7 +236,8 @@ bool OpenGLManager::init_gl() if (!m_gl_initialized) { if (glewInit() != GLEW_OK) { BOOST_LOG_TRIVIAL(error) << "Unable to init glew library"; - return false; + /* Ugly fix for https://github.com/prusa3d/PrusaSlicer/issues/6396 */ + //return false; } m_gl_initialized = true; if (GLEW_EXT_texture_compression_s3tc) diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.cpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.cpp deleted file mode 100644 index 1f810f561423..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.cpp +++ /dev/null @@ -1,104 +0,0 @@ ---- src/slic3r/GUI/RemovableDriveManager.cpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/RemovableDriveManager.cpp -@@ -84,7 +84,7 @@ void RemovableDriveManager::eject_drive() - this->update(); - #endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS - BOOST_LOG_TRIVIAL(info) << "Ejecting started"; -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - auto it_drive_data = this->find_last_save_path_drive_data(); - if (it_drive_data != m_current_drives.end()) { - // get handle to device -@@ -130,7 +130,7 @@ std::string RemovableDriveManager::get_removable_drive - this->update(); - #endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS - -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - if (m_current_drives.empty()) - return std::string(); - std::size_t found = path.find_last_of("\\"); -@@ -146,7 +146,7 @@ std::string RemovableDriveManager::get_removable_drive - - std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path) - { -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - std::size_t found = path.find_last_of("\\"); - std::string new_path = path.substr(0, found); - int letter = PathGetDriveNumberW(boost::nowide::widen(new_path).c_str()); -@@ -285,7 +285,7 @@ void RemovableDriveManager::eject_drive() - - DriveData drive_data; - { -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - auto it_drive_data = this->find_last_save_path_drive_data(); - if (it_drive_data == m_current_drives.end()) - return; -@@ -341,7 +341,7 @@ void RemovableDriveManager::eject_drive() - if (success) { - // Remove the drive_data from m_current drives, searching by value, not by pointer, as m_current_drives may get modified during - // asynchronous execution on m_eject_thread. -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - auto it = std::find(m_current_drives.begin(), m_current_drives.end(), drive_data); - if (it != m_current_drives.end()) - m_current_drives.erase(it); -@@ -361,7 +361,7 @@ std::string RemovableDriveManager::get_removable_drive - std::size_t found = path.find_last_of("/"); - std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path; - -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - for (const DriveData &data : m_current_drives) - if (search_for_drives_internal::compare_filesystem_id(new_path, data.path)) - return path; -@@ -377,7 +377,7 @@ std::string RemovableDriveManager::get_removable_drive - new_path = new_path.substr(0, found); - - // check if same filesystem -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - for (const DriveData &drive_data : m_current_drives) - if (search_for_drives_internal::compare_filesystem_id(new_path, drive_data.path)) - return drive_data.path; -@@ -452,7 +452,7 @@ RemovableDriveManager::RemovableDrivesStatus Removable - - RemovableDriveManager::RemovableDrivesStatus out; - { -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - out.has_eject = - // Cannot control eject on Chromium. - platform_flavor() != PlatformFlavor::LinuxOnChromium && -@@ -468,17 +468,17 @@ RemovableDriveManager::RemovableDrivesStatus Removable - // Update is called from thread_proc() and from most of the public methods on demand. - void RemovableDriveManager::update() - { -- tbb::mutex::scoped_lock inside_update_lock; -+ std::unique_lock inside_update_lock(m_inside_update_mutex, std::defer_lock); - #ifdef _WIN32 - // All wake up calls up to now are now consumed when the drive enumeration starts. - m_wakeup = false; - #endif // _WIN32 -- if (inside_update_lock.try_acquire(m_inside_update_mutex)) { -+ if (inside_update_lock.try_lock()) { - // Got the lock without waiting. That means, the update was not running. - // Run the update. - std::vector current_drives = this->search_for_removable_drives(); - // Post update events. -- tbb::mutex::scoped_lock lock(m_drives_mutex); -+ std::scoped_lock lock(m_drives_mutex); - std::sort(current_drives.begin(), current_drives.end()); - if (current_drives != m_current_drives) { - assert(m_callback_evt_handler); -@@ -489,7 +489,7 @@ void RemovableDriveManager::update() - } else { - // Acquiring the m_iniside_update lock failed, therefore another update is running. - // Just block until the other instance of update() finishes. -- inside_update_lock.acquire(m_inside_update_mutex); -+ inside_update_lock.lock(); - } - } - diff --git a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.hpp b/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.hpp deleted file mode 100644 index a09b359b6dbf..000000000000 --- a/cad/PrusaSlicer/files/patch-src_slic3r_GUI_RemovableDriveManager.hpp +++ /dev/null @@ -1,23 +0,0 @@ ---- src/slic3r/GUI/RemovableDriveManager.hpp.orig 2021-07-16 10:14:03 UTC -+++ src/slic3r/GUI/RemovableDriveManager.hpp -@@ -5,7 +5,7 @@ - #include - - #include --#include -+#include - #include - - // Custom wxWidget events -@@ -111,9 +111,9 @@ class RemovableDriveManager (private) - // m_current_drives is guarded by m_drives_mutex - // sorted ascending by path - std::vector m_current_drives; -- mutable tbb::mutex m_drives_mutex; -+ mutable std::mutex m_drives_mutex; - // Locking the update() function to avoid that the function is executed multiple times. -- mutable tbb::mutex m_inside_update_mutex; -+ mutable std::mutex m_inside_update_mutex; - - // Returns drive path (same as path in DriveData) if exists otherwise empty string. - std::string get_removable_drive_from_path(const std::string& path); diff --git a/cad/PrusaSlicer/files/patch-tests_fff_print_test_data.cpp b/cad/PrusaSlicer/files/patch-tests_fff__print_test__data.cpp similarity index 62% rename from cad/PrusaSlicer/files/patch-tests_fff_print_test_data.cpp rename to cad/PrusaSlicer/files/patch-tests_fff__print_test__data.cpp index ee3f0c0fccd4..5cbe25832291 100644 --- a/cad/PrusaSlicer/files/patch-tests_fff_print_test_data.cpp +++ b/cad/PrusaSlicer/files/patch-tests_fff__print_test__data.cpp @@ -1,28 +1,19 @@ -commit 926ae0471800abd1e5335e251a5934570eb8f6ff -Author: Vojtech Bubnik -Date: 2022-04-25 11:32:03 +0200 - - Follow-up to 408e56f0390f20aaf793e0aa0c70c4d9544401d4 - Fixing compilation of tests on latest GCC/boost - -diff --git tests/fff_print/test_data.cpp tests/fff_print/test_data.cpp -index 32e31c264..f7077007d 100644 ---- tests/fff_print/test_data.cpp +--- tests/fff_print/test_data.cpp.orig 2022-09-06 07:09:19 UTC +++ tests/fff_print/test_data.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -286,7 +287,7 @@ std::string gcode(Print & print) print.set_status_silent(); print.process(); print.export_gcode(temp.string(), nullptr, nullptr); - std::ifstream t(temp.string()); + boost::nowide::ifstream t(temp.string()); std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); boost::nowide::remove(temp.string().c_str()); return str; diff --git a/cad/PrusaSlicer/pkg-plist b/cad/PrusaSlicer/pkg-plist index a4bdeba7ca6f..6af5ef084a6e 100644 --- a/cad/PrusaSlicer/pkg-plist +++ b/cad/PrusaSlicer/pkg-plist @@ -1,4 +1,11 @@ bin/prusa-gcodeviewer bin/prusa-slicer +lib/OCCTWrapper.so share/applications/PrusaGcodeviewer.desktop share/applications/PrusaSlicer.desktop +share/icons/hicolor/128x128/apps/PrusaSlicer-gcodeviewer.png +share/icons/hicolor/128x128/apps/PrusaSlicer.png +share/icons/hicolor/192x192/apps/PrusaSlicer-gcodeviewer.png +share/icons/hicolor/192x192/apps/PrusaSlicer.png +share/icons/hicolor/32x32/apps/PrusaSlicer-gcodeviewer.png +share/icons/hicolor/32x32/apps/PrusaSlicer.png