diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index e5997c2e707..9c308de2164 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -58,4 +58,21 @@ jobs: os: ${{ matrix.os }} arch: ${{ matrix.arch }} build-deps-only: ${{ inputs.build-deps-only || false }} - secrets: inherit \ No newline at end of file + secrets: inherit + flatpak: + name: "Flatpak" + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:gnome-45 + options: --privileged + steps: + # maybe i'm too dumb and fucked up to do CI. OH WELL :D -ppd + - name: "Remove unneeded stuff to free disk space" + run: + sudo rm -rf /usr/share/dotnet /opt/ghc "/usr/local/share/boost" "$AGENT_TOOLSDIRECTORY" + - uses: actions/checkout@v4 + - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 + with: + bundle: orcaslicer.flatpak + manifest-path: flatpak/io.github.softfever.OrcaSlicer.yml + cache-key: flatpak-builder-${{ github.sha }} diff --git a/.gitignore b/.gitignore index 4ec8a2075e4..df5239095e7 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ src/OrcaSlicer-doc/ **/filament_full/ /deps/DL_CACHE/ /deps/DL_CACHE -resources/profiles/user/default \ No newline at end of file +**/.flatpak-builder/ +resources/profiles/user/default diff --git a/CMakeLists.txt b/CMakeLists.txt index d0cec2845e9..8854ab903de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,9 +271,18 @@ if (NOT MSVC AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMP # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 # We will turn the warning of for GCC for now: if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # GCC generates loads of -Wunknown-pragmas when compiling igl. The fix is not easy due to a bug in gcc, see + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66943 or + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 + # We will turn the warning of for GCC for now: add_compile_options(-Wno-unknown-pragmas) endif() + # Bit of a hack for flatpak building: compress the debug info with zstd to save space in CI + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13.0) + add_compile_options(-gz=zstd) + endif() + endif() if (SLIC3R_ASAN) @@ -382,9 +391,7 @@ endif() # set(Boost_COMPILER "-mgw81") # boost::process was introduced first in version 1.64.0, # boost::beast::detail::base64 was introduced first in version 1.66.0 -set(MINIMUM_BOOST_VERSION "1.66.0") -set(_boost_components "system;filesystem;thread;log;locale;regex;chrono;atomic;date_time;iostreams;program_options") -find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS ${_boost_components}) +find_package(Boost 1.66 REQUIRED COMPONENTS system filesystem thread log locale regex chrono atomic date_time iostreams program_options) add_library(boost_libs INTERFACE) add_library(boost_headeronly INTERFACE) @@ -410,28 +417,8 @@ function(slic3r_remap_configs targets from_Cfg to_Cfg) endif() endfunction() -if(TARGET Boost::system) - message(STATUS "Boost::boost exists") - target_link_libraries(boost_headeronly INTERFACE Boost::boost) - - # Only from cmake 3.12 - # list(TRANSFORM _boost_components PREPEND Boost:: OUTPUT_VARIABLE _boost_targets) - set(_boost_targets "") - foreach(comp ${_boost_components}) - list(APPEND _boost_targets "Boost::${comp}") - endforeach() - - target_link_libraries(boost_libs INTERFACE - boost_headeronly # includes the custom compile definitions as well - ${_boost_targets} - ) - slic3r_remap_configs("${_boost_targets}" RelWithDebInfo Release) -else() - target_include_directories(boost_headeronly INTERFACE ${Boost_INCLUDE_DIRS}) - target_link_libraries(boost_libs INTERFACE boost_headeronly ${Boost_LIBRARIES}) -endif() - - +target_include_directories(boost_headeronly INTERFACE ${Boost_INCLUDE_DIRS}) +target_link_libraries(boost_libs INTERFACE boost_headeronly ${Boost_LIBRARIES}) # Find and configure intel-tbb if(SLIC3R_STATIC) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index a21cc1bb5cc..4bd3470d441 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -42,6 +42,10 @@ endif () set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") set(DEP_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../DL_CACHE CACHE PATH "Path for downloaded source packages.") +set(FLATPAK FALSE CACHE BOOL "Toggles various build settings for flatpak, like /usr/local in DESTDIR or not building wxwidgets") +if (NOT FLATPAK) + set(DESTDIR "${DESTDIR}/usr/local/") +endif() get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -120,13 +124,13 @@ if (NOT IS_CROSS_COMPILE OR NOT APPLE) ExternalProject_Add( dep_${projectname} EXCLUDE_FROM_ALL ON - INSTALL_DIR ${DESTDIR}/usr/local + INSTALL_DIR ${DESTDIR} DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/${projectname} ${_gen} CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR}/usr/local + -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR} -DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/../cmake/modules - -DCMAKE_PREFIX_PATH:STRING=${DESTDIR}/usr/local + -DCMAKE_PREFIX_PATH:STRING=${DESTDIR} -DCMAKE_DEBUG_POSTFIX:STRING=d -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} @@ -140,16 +144,26 @@ if (NOT IS_CROSS_COMPILE OR NOT APPLE) BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j} INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release ) -else() +elseif(FLATPAK) + # the only reason this is here is because of the HACK at the bottom for ci + # + # note for future devs: shared libs may actually create a size reduction + # but orcaslicer_deps tends to get really funny regarding linking after that (notably boost) + # so, as much as I would like to use that, it's not happening ExternalProject_Add( dep_${projectname} EXCLUDE_FROM_ALL ON - INSTALL_DIR ${DESTDIR}/usr/local + INSTALL_DIR ${DESTDIR} DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/${projectname} ${_gen} CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR}/usr/local - -DCMAKE_PREFIX_PATH:STRING=${DESTDIR}/usr/local + -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR} + -DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/../cmake/modules + -DCMAKE_PREFIX_PATH:STRING=${DESTDIR} + -DCMAKE_DEBUG_POSTFIX:STRING=d + -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} + -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE} -DBUILD_SHARED_LIBS:BOOL=OFF ${_cmake_osx_arch} "${_configs_line}" @@ -158,6 +172,29 @@ else() ${P_ARGS_UNPARSED_ARGUMENTS} BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j} INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release + # HACK: save space after each compile job, because CI + # reasoning: cmake changes directory after this command, so just keep only the folders + # so that it can navigate out + COMMAND find "${CMAKE_BINARY_DIR}/dep_${projectname}-prefix/" -type f -delete + ) +else() + ExternalProject_Add( + dep_${projectname} + EXCLUDE_FROM_ALL ON + INSTALL_DIR ${DESTDIR} + DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/${projectname} + ${_gen} + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR} + -DCMAKE_PREFIX_PATH:STRING=${DESTDIR} + -DBUILD_SHARED_LIBS:BOOL=OFF + ${_cmake_osx_arch} + "${_configs_line}" + ${DEP_CMAKE_OPTS} + ${P_ARGS_CMAKE_ARGS} + ${P_ARGS_UNPARSED_ARGUMENTS} + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j} + INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release ) endif() @@ -203,6 +240,20 @@ else() include("deps-linux.cmake") endif() +if(FLATPAK) + # flatpak bundles some deps with the layer, so attempt to find them first + # also, yes, this reduces CI by not needing to vendor certain deps + find_package(ZLIB) + find_package(PNG) + find_package(EXPAT) + find_package(CURL) + find_package(JPEG) + find_package(TIFF) + find_package(Freetype) + find_package(OpenSSL 1.1...<3.2) + find_package(CURL) +endif() + set(ZLIB_PKG "") if (NOT ZLIB_FOUND) include(ZLIB/ZLIB.cmake) @@ -214,6 +265,7 @@ if (NOT PNG_FOUND) set(PNG_PKG dep_PNG) endif () set(EXPAT_PKG "") +find_package(EXPAT) if (NOT EXPAT_FOUND) include(EXPAT/EXPAT.cmake) set(EXPAT_PKG dep_EXPAT) @@ -226,6 +278,7 @@ include(Boost/Boost.cmake) include(Cereal/Cereal.cmake) include(Qhull/Qhull.cmake) include(GLEW/GLEW.cmake) + include(GLFW/GLFW.cmake) include(OpenCSG/OpenCSG.cmake) @@ -241,34 +294,69 @@ include(CGAL/CGAL.cmake) include(NLopt/NLopt.cmake) -include(OpenSSL/OpenSSL.cmake) +# I *think* 1.1 is used for *just* md5 hashing? +# 3.1 has everything in the right place, but the md5 funcs used are deprecated +# a grep across the repo shows it is used for other things +# TODO: update openssl and everything that uses +set(OPENSSL_PKG "") +if(NOT OPENSSL_FOUND) + include(OpenSSL/OpenSSL.cmake) + set(OPENSSL_PKG dep_OpenSSL) +endif() + +# we don't want to load a "wrong" openssl when loading curl +# so, just don't even bother +# ...i think this is how it works? change if wrong set(CURL_PKG "") -if (NOT CURL_FOUND) +if (NOT OPENSSL_FOUND OR NOT CURL_FOUND) include(CURL/CURL.cmake) set(CURL_PKG dep_CURL) endif () -include(JPEG/JPEG.cmake) -include(TIFF/TIFF.cmake) -include(wxWidgets/wxWidgets.cmake) +set(JPEG_PKG "") +if (NOT JPEG_FOUND) + include(JPEG/JPEG.cmake) + set(JPEG_PKG dep_JPEG) +endif() + +set(TIFF_PKG "") +if (NOT TIFF_FOUND) + include(TIFF/TIFF.cmake) + set(TIFF_PKG "dep_TIFF") +endif() + +# flatpak builds wxwidgets separately +set(WXWIDGETS_PKG "") +if (NOT FLATPAK) + include(wxWidgets/wxWidgets.cmake) + set(WXWIDGETS_PKG "dep_wxWidgets") +endif() + +set(FREETYPE_PKG "") +if(NOT FREETYPE_FOUND) + include(FREETYPE/FREETYPE.cmake) + set(FREETYPE_PKG "dep_FREETYPE") +endif() + include(OCCT/OCCT.cmake) include(OpenCV/OpenCV.cmake) -include(FREETYPE/FREETYPE.cmake) set(_dep_list dep_Boost dep_TBB + ${OPENSSL_PKG} ${CURL_PKG} - dep_wxWidgets + ${WXWIDGETS_PKG} dep_Cereal dep_NLopt dep_OpenVDB dep_OpenCSG dep_OpenCV dep_CGAL - dep_OpenSSL dep_GLFW + dep_OCCT + ${FREETYPE_PKG} ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} @@ -283,9 +371,6 @@ else() #list(APPEND _dep_list "dep_libigl") endif() -list(APPEND _dep_list "dep_OCCT") -list(APPEND _dep_list "dep_FREETYPE") - add_custom_target(deps ALL DEPENDS ${_dep_list}) # Note: I'm not using any of the LOG_xxx options in ExternalProject_Add() commands diff --git a/deps/CURL/CURL.cmake b/deps/CURL/CURL.cmake index 9846c7c9c6f..a5ae1b9d00c 100644 --- a/deps/CURL/CURL.cmake +++ b/deps/CURL/CURL.cmake @@ -72,9 +72,10 @@ orcaslicer_add_cmake_project(CURL ${_curl_platform_flags} ) -# if (APPLE OR (CMAKE_SYSTEM_NAME STREQUAL "Linux")) - add_dependencies(dep_CURL dep_OpenSSL) -# endif () +if(NOT OPENSSL_FOUND) + # (openssl may or may not be built) + add_dependencies(dep_CURL ${OPENSSL_PKG}) +endif() if (MSVC) add_debug_dep(dep_CURL) diff --git a/deps/GMP/GMP.cmake b/deps/GMP/GMP.cmake index 8629f834fae..4f79a657316 100644 --- a/deps/GMP/GMP.cmake +++ b/deps/GMP/GMP.cmake @@ -1,17 +1,16 @@ set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/gmp) -set(_dstdir ${DESTDIR}/usr/local) if (MSVC) - set(_output ${_dstdir}/include/gmp.h - ${_dstdir}/lib/libgmp-10.lib - ${_dstdir}/bin/libgmp-10.dll) + set(_output ${DESTDIR}/include/gmp.h + ${DESTDIR}/lib/libgmp-10.lib + ${DESTDIR}/bin/libgmp-10.dll) add_custom_command( OUTPUT ${_output} - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/gmp.h ${_dstdir}/include/ - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${_dstdir}/lib/ - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${_dstdir}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/gmp.h ${DESTDIR}/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.lib ${DESTDIR}/lib/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libgmp-10.dll ${DESTDIR}/bin/ ) add_custom_target(dep_GMP SOURCES ${_output}) @@ -61,8 +60,8 @@ else () URL_HASH SHA256=eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/GMP BUILD_IN_SOURCE ON - CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --enable-shared=no --enable-cxx=yes --enable-static=yes "--prefix=${DESTDIR}/usr/local" ${_gmp_build_tgt} + CONFIGURE_COMMAND env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --enable-shared=no --enable-cxx=yes --enable-static=yes "--prefix=${DESTDIR}" ${_gmp_build_tgt} BUILD_COMMAND make -j INSTALL_COMMAND make install ) -endif () \ No newline at end of file +endif () diff --git a/deps/MPFR/MPFR.cmake b/deps/MPFR/MPFR.cmake index 30ceca90b39..1161a1ca6e9 100644 --- a/deps/MPFR/MPFR.cmake +++ b/deps/MPFR/MPFR.cmake @@ -1,18 +1,17 @@ set(_srcdir ${CMAKE_CURRENT_LIST_DIR}/mpfr) -set(_dstdir ${DESTDIR}/usr/local) if (MSVC) - set(_output ${_dstdir}/include/mpfr.h - ${_dstdir}/include/mpf2mpfr.h - ${_dstdir}/lib/libmpfr-4.lib - ${_dstdir}/bin/libmpfr-4.dll) + set(_output ${DESTDIR}/include/mpfr.h + ${DESTDIR}/include/mpf2mpfr.h + ${DESTDIR}/lib/libmpfr-4.lib + ${DESTDIR}/bin/libmpfr-4.dll) add_custom_command( OUTPUT ${_output} - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/mpfr.h ${_dstdir}/include/ - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/mpf2mpfr.h ${_dstdir}/include/ - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libmpfr-4.lib ${_dstdir}/lib/ - COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libmpfr-4.dll ${_dstdir}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/mpfr.h ${DESTDIR}/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/include/mpf2mpfr.h ${DESTDIR}/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libmpfr-4.lib ${DESTDIR}/lib/ + COMMAND ${CMAKE_COMMAND} -E copy ${_srcdir}/lib/win${DEPS_BITS}/libmpfr-4.dll ${DESTDIR}/bin/ ) add_custom_target(dep_MPFR SOURCES ${_output}) @@ -31,7 +30,7 @@ else () DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/MPFR BUILD_IN_SOURCE ON CONFIGURE_COMMAND autoreconf -f -i && - env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --prefix=${DESTDIR}/usr/local --enable-shared=no --enable-static=yes --with-gmp=${DESTDIR}/usr/local ${_gmp_build_tgt} + env "CFLAGS=${_gmp_ccflags}" "CXXFLAGS=${_gmp_ccflags}" ./configure ${_cross_compile_arg} --prefix=${DESTDIR} --enable-shared=no --enable-static=yes --with-gmp=${DESTDIR} ${_gmp_build_tgt} BUILD_COMMAND make -j INSTALL_COMMAND make install DEPENDS dep_GMP diff --git a/deps/OCCT/OCCT.cmake b/deps/OCCT/OCCT.cmake index 541412b1cab..651e40ec83c 100644 --- a/deps/OCCT/OCCT.cmake +++ b/deps/OCCT/OCCT.cmake @@ -14,7 +14,7 @@ orcaslicer_add_cmake_project(OCCT #PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-OCCT-fix.patch PATCH_COMMAND git apply --directory ${BINARY_DIR_REL}/dep_OCCT-prefix/src/dep_OCCT --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-OCCT-fix.patch #DEPENDS dep_Boost - #DEPENDS dep_FREETYPE + DEPENDS ${FREETYPE_PKG} CMAKE_ARGS -DBUILD_LIBRARY_TYPE=${library_build_type} -DUSE_TK=OFF @@ -31,4 +31,4 @@ orcaslicer_add_cmake_project(OCCT -DBUILD_MODULE_Visualization=OFF ) -add_dependencies(dep_OCCT dep_FREETYPE) +# add_dependencies(dep_OCCT ${FREETYPE_PKG}) diff --git a/deps/OpenEXR/OpenEXR.cmake b/deps/OpenEXR/OpenEXR.cmake index 6aea12b1f27..dd754d3a383 100644 --- a/deps/OpenEXR/OpenEXR.cmake +++ b/deps/OpenEXR/OpenEXR.cmake @@ -15,11 +15,11 @@ if (APPLE AND IS_CROSS_COMPILE) EXCLUDE_FROM_ALL ON URL https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.5.zip URL_HASH SHA256=0307a3d7e1fa1e77e9d84d7e9a8694583fbbbfd50bdc6884e2c96b8ef6b902de - INSTALL_DIR ${DESTDIR}/usr/local + INSTALL_DIR ${DESTDIR} DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenEXR ${_openxr_list_sep} CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR}/usr/local + -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_TESTING=OFF @@ -54,4 +54,4 @@ endif() if (MSVC) add_debug_dep(dep_OpenEXR) -endif () \ No newline at end of file +endif () diff --git a/deps/OpenSSL/OpenSSL.cmake b/deps/OpenSSL/OpenSSL.cmake index 0adbaab43e6..45f82ec5890 100644 --- a/deps/OpenSSL/OpenSSL.cmake +++ b/deps/OpenSSL/OpenSSL.cmake @@ -46,8 +46,8 @@ ExternalProject_Add(dep_OpenSSL # URL_HASH SHA256=8c776993154652d0bb393f506d850b811517c8bd8d24b1008aef57fbe55d3f31 DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/OpenSSL CONFIGURE_COMMAND ${_conf_cmd} ${_cross_arch} - "--openssldir=${DESTDIR}/usr/local" - "--prefix=${DESTDIR}/usr/local" + "--openssldir=${DESTDIR}" + "--prefix=${DESTDIR}" ${_cross_comp_prefix_line} no-shared no-asm @@ -61,6 +61,6 @@ ExternalProject_Add(dep_OpenSSL ExternalProject_Add_Step(dep_OpenSSL install_cmake_files DEPENDEES install - COMMAND ${CMAKE_COMMAND} -E copy_directory openssl "${DESTDIR}/usr/local/${CMAKE_INSTALL_LIBDIR}/cmake/openssl" + COMMAND ${CMAKE_COMMAND} -E copy_directory openssl "${DESTDIR}${CMAKE_INSTALL_LIBDIR}/cmake/openssl" WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" ) diff --git a/deps/TBB/GNU.cmake b/deps/TBB/GNU.cmake new file mode 100644 index 00000000000..a0ba4e5df7c --- /dev/null +++ b/deps/TBB/GNU.cmake @@ -0,0 +1,79 @@ +# Copyright (c) 2020-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (MINGW) + set(TBB_LINK_DEF_FILE_FLAG "") + set(TBB_DEF_FILE_PREFIX "") +elseif (APPLE) + set(TBB_LINK_DEF_FILE_FLAG -Wl,-exported_symbols_list,) + set(TBB_DEF_FILE_PREFIX mac${TBB_ARCH}) + + # For correct ucontext.h structures layout + set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -D_XOPEN_SOURCE) +else() + set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=) + set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH}) +endif() + +# Add -Wno-error=stringop-overflow to fix GCC 12+ build as suggested on https://github.com/oneapi-src/oneTBB/issues/843#issuecomment-1152646035 +set(TBB_WARNING_LEVEL -Wall -Wextra $<$:-Werror> -Wfatal-errors -Wno-error=stringop-overflow) +set(TBB_TEST_WARNING_FLAGS -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor) + +# Depfile options (e.g. -MD) are inserted automatically in some cases. +# Don't add -MMD to avoid conflicts in such cases. +if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER) + set(TBB_MMD_FLAG -MMD) +endif() + +# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors +if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)") + set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$>,$>>:-mwaitpkg>) +endif() + +if (NOT MINGW) + set(TBB_COMMON_LINK_LIBS dl) +endif() + +# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled. +if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag) + tbb_remove_compile_flag(-Werror) +endif() + +if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel) + # gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime + set(TBB_DSE_FLAG $<$>:-flifetime-dse=1>) +endif() + +# Workaround for heavy tests and too many symbols in debug (rellocation truncated to fit: R_MIPS_CALL16) +if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips") + set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} -DTBB_TEST_LOW_WORKLOAD $<$:-mxgot>) +endif() + +if (MINGW) + list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__) +endif() + +# For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used. +if (NOT TBB_SANITIZE MATCHES "thread") + set(TBB_IPO_COMPILE_FLAGS $<$>:-flto>) + set(TBB_IPO_LINK_FLAGS $<$>:-flto>) +endif() + +# Disable lto flag +set(TBB_IPO_COMPILE_FLAGS "") +set(TBB_IPO_LINK_FLAGS "") + +# TBB malloc settings +set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions) +set(TBB_OPENMP_FLAG -fopenmp) diff --git a/deps/TBB/TBB.cmake b/deps/TBB/TBB.cmake index 6bf28ca2ec6..13d40c05738 100644 --- a/deps/TBB/TBB.cmake +++ b/deps/TBB/TBB.cmake @@ -1,8 +1,14 @@ +if (FLATPAK) + set(_patch_command ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/GNU.cmake ./cmake/compilers/GNU.cmake) +else() + set(_patch_command "") +endif() + orcaslicer_add_cmake_project( TBB URL "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.5.0.zip" URL_HASH SHA256=83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47 - #PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-TBB-GCC13.patch + PATCH_COMMAND ${_patch_command} CMAKE_ARGS -DTBB_BUILD_SHARED=OFF -DTBB_BUILD_TESTS=OFF diff --git a/deps/wxWidgets/wxWidgets.cmake b/deps/wxWidgets/wxWidgets.cmake index b7f852d2443..1097e6cfc0f 100644 --- a/deps/wxWidgets/wxWidgets.cmake +++ b/deps/wxWidgets/wxWidgets.cmake @@ -17,11 +17,16 @@ else () set(_wx_edge "-DwxUSE_WEBVIEW_EDGE=OFF") endif () +# Note: The flatpak build builds wxwidgets separately due to CI size constraints. +# ANY CHANGES MADE IN HERE MUST ALSO BE REFLECTED IN `flatpak/io.github.SoftFever.OrcaSlicer.yml`. +# ** THIS INCLUDES BUILD ARGS. ** +# ...if you can find a way around this size limitation, be my guest. + orcaslicer_add_cmake_project( wxWidgets GIT_REPOSITORY "https://github.com/SoftFever/Orca-deps-wxWidgets" GIT_SHALLOW ON - DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} dep_TIFF dep_JPEG + DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} ${TIFF_PKG} ${JPEG_PKG} CMAKE_ARGS -DwxBUILD_PRECOMP=ON ${_wx_toolkit} @@ -34,6 +39,7 @@ orcaslicer_add_cmake_project( -DwxUSE_UNICODE=ON ${_wx_private_font} -DwxUSE_OPENGL=ON + -DwxUSE_WEBREQUEST=ON -DwxUSE_WEBVIEW=ON ${_wx_edge} -DwxUSE_WEBVIEW_IE=OFF @@ -47,9 +53,10 @@ orcaslicer_add_cmake_project( -DwxUSE_ZLIB=sys -DwxUSE_LIBJPEG=sys -DwxUSE_LIBTIFF=sys + -DwxUSE_NANOSVG=OFF -DwxUSE_EXPAT=sys ) if (MSVC) add_debug_dep(dep_wxWidgets) -endif () \ No newline at end of file +endif () diff --git a/flatpak/.gitignore b/flatpak/.gitignore new file mode 100644 index 00000000000..49269ac6b0d --- /dev/null +++ b/flatpak/.gitignore @@ -0,0 +1,2 @@ +builddir +.flatpak-builder diff --git a/flatpak/README.md b/flatpak/README.md new file mode 100644 index 00000000000..4445f1e869f --- /dev/null +++ b/flatpak/README.md @@ -0,0 +1,3 @@ +# OrcaSlicer + +This is basically a copy of [com.bambulab.BambuStudio](https://github.com/flathub/com.bambulab.BambuStudio). As such, same rules apply here as does over there. diff --git a/flatpak/entrypoint b/flatpak/entrypoint new file mode 100644 index 00000000000..958d1cd1300 --- /dev/null +++ b/flatpak/entrypoint @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +# Work-around https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/754 +grep -q org.freedesktop.Platform.GL.nvidia /.flatpak-info && export WEBKIT_DISABLE_DMABUF_RENDERER=1 + +# Work-around https://github.com/bambulab/BambuStudio/issues/3440 +export LC_ALL=C.UTF-8 + +if [ $BAMBU_STUDIO_DARK_THEME == true ]; then + export GTK_THEME='Adwaita:dark' + # echo "Message: $(date +%T): INFO: using dark theme variant" +fi + +exec /app/bin/orca-slicer "$@" & +$(/app/bin/set-dark-theme-variant.py) & diff --git a/flatpak/images/1.png b/flatpak/images/1.png new file mode 100644 index 00000000000..bf69169a022 Binary files /dev/null and b/flatpak/images/1.png differ diff --git a/flatpak/images/2.png b/flatpak/images/2.png new file mode 100644 index 00000000000..510b7564fb6 Binary files /dev/null and b/flatpak/images/2.png differ diff --git a/flatpak/io.github.softfever.OrcaSlicer.metainfo.xml b/flatpak/io.github.softfever.OrcaSlicer.metainfo.xml new file mode 100755 index 00000000000..1b2a60d7431 --- /dev/null +++ b/flatpak/io.github.softfever.OrcaSlicer.metainfo.xml @@ -0,0 +1,48 @@ + + + io.github.softfever.OrcaSlicer + io.github.softfever.OrcaSlicer.desktop + + io.github.softfever.OrcaSlicer.desktop + + OrcaSlicer + + Get even more perfect prints! + SoftFever + https://github.com/SoftFever/OrcaSlicer + https://github.com/SoftFever/OrcaSlicer/wiki + https://github.com/SoftFever/OrcaSlicer/issues/ + https://ko-fi.com/SoftFever + 0BSD + AGPL-3.0-only + + + 768 + + + keyboard + pointing + + + + https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/1.png + A model ready to be sliced on a buildplate. + + + https://raw.githubusercontent.com/powpingdone/com.github.softfever.orcaslicer/master/images/2.png + + A calibration test ready to be printed out. + + + +

A 3D printer slicer forked from Bambu Studio, PrusaSlicer, and SuperSlicer with many more printer profiles, helpful calibration prints, and many more features to get your 3D printer printing perfectly!

+
+ + #009688 + + + https://github.com/SoftFever/OrcaSlicer/commit/951fc8e98a0d5ca0ccb254315646ce7889a44836 + + +
diff --git a/flatpak/io.github.softfever.OrcaSlicer.yml b/flatpak/io.github.softfever.OrcaSlicer.yml new file mode 100755 index 00000000000..f5a148cda0c --- /dev/null +++ b/flatpak/io.github.softfever.OrcaSlicer.yml @@ -0,0 +1,344 @@ +app-id: io.github.softfever.OrcaSlicer +runtime: org.gnome.Platform +runtime-version: "45" +sdk: org.gnome.Sdk +command: entrypoint +separate-locales: true +rename-icon: OrcaSlicer +finish-args: + - --share=ipc + - --socket=x11 + - --share=network + - --device=all + - --filesystem=home + - --filesystem=xdg-run/gvfs + - --filesystem=/run/media + - --filesystem=/media + # Allow OrcaSlicer to talk to other instances + - --talk-name=io.github.softfever.OrcaSlicer.InstanceCheck.* + - --system-talk-name=org.freedesktop.UDisks2 + # set dark theme + - --env=BAMBU_STUDIO_DARK_THEME=false + +modules: + + # JPEG codec for the liveview + - name: gst-plugins-good + buildsystem: meson + config-opts: + - -Dauto_features=disabled + - -Djpeg=enabled + - -Ddoc=disabled + - -Dexamples=disabled + - -Dtests=disabled + sources: + - type: archive + url: https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-1.22.8.tar.xz + sha256: e305b9f07f52743ca481da0a4e0c76c35efd60adaf1b0694eb3bb021e2137e39 + + # xprop, xlib is needed to manipulate the X11 window and set _GTK_THEME_VARIANT dark on X11 + # and paint the window dark when PRUSA_SLICER_DARK_THEME is true + # see: entrypoint & set-dark-theme-variant.py (originated from spotify client flatpak) + - name: xprop + sources: + - type: archive + url: http://mirrors.ircam.fr/pub/x.org/individual/app/xprop-1.2.5.tar.gz + sha256: b7bf6b6be6cf23e7966a153fc84d5901c14f01ee952fbd9d930aa48e2385d670 + - name: python-setuptools_scm + buildsystem: simple + build-commands: + - pip3 install --no-deps --no-build-isolation --verbose --prefix=${FLATPAK_DEST} . + sources: + - type: archive + url: https://files.pythonhosted.org/packages/57/38/930b1241372a9f266a7df2b184fb9d4f497c2cef2e016b014f82f541fe7c/setuptools_scm-6.0.1.tar.gz + sha256: d1925a69cb07e9b29416a275b9fadb009a23c148ace905b2fb220649a6c18e92 + - name: python-xlib + buildsystem: simple + build-commands: + - pip3 install --no-deps --no-build-isolation --verbose --prefix=${FLATPAK_DEST} . + sources: + - type: archive + url: https://files.pythonhosted.org/packages/86/f5/8c0653e5bb54e0cbdfe27bf32d41f27bc4e12faa8742778c17f2a71be2c0/python-xlib-0.33.tar.gz + sha256: 55af7906a2c75ce6cb280a584776080602444f75815a7aff4d287bb2d7018b32 + + # For libOSMesa + - name: mesa + buildsystem: meson + config-opts: + - -Dosmesa=classic + - -Ddri-drivers=[] + - -Dgallium-drivers=[] + - -Dvulkan-drivers=[] + - -Dplatforms=[] + build-options: + arch: + aarch64: + config-opts: + - -Dlibunwind=disabled + cleanup: + - /share/drirc.d + - /include + - "*.a" + sources: + - type: archive + url: https://archive.mesa3d.org/mesa-20.2.6.tar.xz + sha256: f12ca3c6c622f11cd79ad66b4220f04514fa96f795062fe92a37339ab19885db + + - name: glu + config-opts: + - --disable-static + sources: + - type: archive + url: https://ftp.osuosl.org/pub/blfs/conglomeration/glu/glu-9.0.2.tar.xz + sha256: 6e7280ff585c6a1d9dfcdf2fca489251634b3377bfc33c29e4002466a38d02d4 + cleanup: + - /include + - /lib/*.a + - /lib/*.la + - /lib/pkgconfig + + - name: kde-extra-cmake-modules + buildsystem: cmake-ninja + sources: + - type: git + url: https://github.com/KDE/extra-cmake-modules + tag: v5.249.0 + cleanup: + - / + + - name: orca_wxwidgets + buildsystem: simple + build-commands: + - | + mkdir builddir && cd builddir + cmake ../ -GNinja \ + -DwxBUILD_PRECOMP=ON \ + -DwxBUILD_TOOLKIT=gtk3 \ + -DwxBUILD_DEBUG_LEVEL=0 \ + -DwxBUILD_SAMPLES=OFF \ + -DwxBUILD_SHARED=ON \ + -DwxUSE_MEDIACTRL=ON \ + -DwxUSE_DETECT_SM=OFF \ + -DwxUSE_UNICODE=ON \ + -DwxUSE_PRIVATE_FONTS=ON \ + -DwxUSE_OPENGL=ON \ + -DwxUSE_WEBREQUEST=ON \ + -DwxUSE_WEBVIEW=ON \ + -DwxUSE_WEBVIEW_EDGE=OFF \ + -DwxUSE_WEBVIEW_IE=OFF \ + -DwxUSE_REGEX=builtin \ + -DwxUSE_LIBSDL=OFF \ + -DwxUSE_XTEST=OFF \ + -DwxUSE_STC=OFF \ + -DwxUSE_AUI=ON \ + -DwxUSE_LIBPNG=sys \ + -DwxUSE_ZLIB=sys \ + -DwxUSE_LIBJPEG=sys \ + -DwxUSE_LIBTIFF=sys \ + -DwxUSE_EXPAT=sys \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DCMAKE_INSTALL_PREFIX:STRING=/app \ + -DCMAKE_PREFIX_PATH=/app \ + -DCMAKE_BUILD_TYPE=Release + cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS + sources: + - type: git + url: https://github.com/SoftFever/Orca-deps-wxWidgets + branch: master + path: ../ + cleanup: + - "*.la" + - "*.a" + - "*.cmake" + - /include + - /app/bin/* + + - name: orca_deps + buildsystem: simple + build-commands: + # start build + - | + mkdir deps/build && cd deps/build + cmake ../ \ + -DDEP_WX_GTK3=ON \ + -DDEP_DOWNLOAD_DIR=/run/build/orca_deps/external-packages \ + -DCMAKE_PREFIX_PATH=/app \ + -DDESTDIR=/app \ + -DCMAKE_INSTALL_LIBDIR=/app/lib \ + -DFLATPAK=ON \ + -DCMAKE_INSTALL_PREFIX=/app + cmake --build . + rm -r /run/build/orca_deps/external-packages + + cleanup: + - /app/include + - "*.a" + - "*.la" + - /app/lib/cmake + + sources: + # - + # Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* . + # -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest. + # + # NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/ + # - + + # OrcaSlicer Source Archive + - type: dir + path: ../ + + # Blosc + - type: file + url: https://github.com/tamasmeszaros/c-blosc/archive/refs/heads/v1.17.0_tm.zip + dest: external-packages/Blosc + sha256: dcb48bf43a672fa3de6a4b1de2c4c238709dad5893d1e097b8374ad84b1fc3b3 + + # Cereal + - type: file + url: https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.0.zip + dest: external-packages/Cereal + sha256: 71642cb54658e98c8f07a0f0d08bf9766f1c3771496936f6014169d3726d9657 + + # CGAL + - type: file + url: https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip + dest: external-packages/CGAL + sha256: d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0 + + # GMP + - type: file + url: https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2 + dest: external-packages/GMP + sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c + + # MPFR + - type: file + url: https://www.mpfr.org/mpfr-current/mpfr-4.2.1.tar.bz2 + dest: external-packages/MPFR + sha256: b9df93635b20e4089c29623b19420c4ac848a1b29df1cfd59f26cab0d2666aa0 + + # NLopt + - type: file + url: https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz + dest: external-packages/NLopt + sha256: c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae + + # OCCT + - type: file + url: https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip + dest: external-packages/OCCT + sha256: 28334f0e98f1b1629799783e9b4d21e05349d89e695809d7e6dfa45ea43e1dbc + + # OpenCSG + - type: file + url: https://github.com/floriankirsch/OpenCSG/archive/refs/tags/opencsg-1-4-2-release.zip + dest: external-packages/OpenCSG + sha256: 51afe0db79af8386e2027d56d685177135581e0ee82ade9d7f2caff8deab5ec5 + + # OpenCV + - type: file + url: https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz + dest: external-packages/OpenCV + sha256: 1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277 + + # OpenEXR + - type: file + url: https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.5.zip + dest: external-packages/OpenEXR + sha256: 0307a3d7e1fa1e77e9d84d7e9a8694583fbbbfd50bdc6884e2c96b8ef6b902de + + # OpenVDB + - type: file + url: https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip + dest: external-packages/OpenVDB + sha256: f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81 + + # Qhull + - type: file + url: https://github.com/qhull/qhull/archive/v8.0.1.zip + dest: external-packages/Qhull + sha256: 5287f5edd6a0372588f5d6640799086a4033d89d19711023ef8229dd9301d69b + + # TBB + - type: file + url: https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.5.0.zip + dest: external-packages/TBB + sha256: 83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47 + + # Boost + - type: file + url: https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz + dest: external-packages/Boost + sha256: 4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95 + + # GLFW + - type: file + url: https://github.com/glfw/glfw/archive/refs/tags/3.3.7.zip + dest: external-packages/GLFW + sha256: e02d956935e5b9fb4abf90e2c2e07c9a0526d7eacae8ee5353484c69a2a76cd0 + + - name: OrcaSlicer + buildsystem: simple + build-commands: + - | + mkdir -p build && cd build + CXXFLAGS=-std=gnu++20 cmake ../ \ + -DSLIC3R_PCH=OFF \ + -DSLIC3R_FHS=ON \ + -DSLIC3R_GTK=3 \ + -DSLIC3R_STATIC=ON \ + -DSLIC3R_BUILD_TESTS=OFF \ + -DSLIC3R_DESKTOP_INTEGRATION=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DFLATPAK=ON \ + -DBBL_RELEASE_TO_PUBLIC=1 \ + -DCMAKE_PREFIX_PATH=/app \ + -DCMAKE_INSTALL_PREFIX=/app + CXXFLAGS=-std=gnu++20 cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS + + cleanup: + - /include + + post-install: + + - | # Desktop Integration files + install -Dm644 -t /app/share/icons/hicolor/scalable/apps/ resources/images/OrcaSlicer.svg + install -Dm644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml + mv /app/share/applications/OrcaSlicer.desktop /app/share/applications/${FLATPAK_ID}.desktop + desktop-file-edit --set-key=Exec --set-value="entrypoint %U" /app/share/applications/${FLATPAK_ID}.desktop + install -Dm755 set-dark-theme-variant.py /app/bin + install -Dm755 entrypoint /app/bin + install -Dm755 umount /app/bin + + sources: + # - + # Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* . + # -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest. + # + # NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/ + # - + + # OrcaSlicer Source Archive + - type: dir + path: ../ + + # AppData metainfo for Gnome Software & Co. + - type: file + path: io.github.softfever.OrcaSlicer.metainfo.xml + + # script to set dark theme variant + - type: file + path: set-dark-theme-variant.py + + # start-up script + # README: workaround for the following issues, also enables dark theme variant: + # SEE: https://github.com/flathub/com.bambulab.BambuStudio/issues/27 + # SEE: https://github.com/flathub/com.bambulab.BambuStudio/issues/3 + # SEE: https://github.com/prusa3d/PrusaSlicer/issues/2365 + - type: file + path: entrypoint + + # umount wrapper used to redirect umount calls to udisk2 + - type: file + path: umount diff --git a/flatpak/set-dark-theme-variant.py b/flatpak/set-dark-theme-variant.py new file mode 100644 index 00000000000..78bbf5d690a --- /dev/null +++ b/flatpak/set-dark-theme-variant.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 + +import Xlib +import Xlib.display +import time +import subprocess +import os +import sys + + +disp = Xlib.display.Display() +root = disp.screen().root + +NET_CLIENT_LIST = disp.intern_atom('_NET_CLIENT_LIST') + + +def set_theme_variant_by_window_id(id, variant): + # Use subprocess to call + # xprop and set the variant from id. + try: + s = subprocess.call(['xprop', '-f', '_GTK_THEME_VARIANT', '8u', '-set', '_GTK_THEME_VARIANT', variant, '-id', str(id)], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + if s == 0: + return True + return False + except Exception as ex: + return False + + +def set_theme_variant_from_win_id_collection(win_id_collection, variant): + # Loop though all of the collected + # window ids and set theme variant + for win_id in win_id_collection: + set_theme_variant_by_window_id(win_id, variant) + + +def collection_win_id_from_wm_class_name(win_class_name): + + collect = [] + + # Loop though all of the windows + # and collect id's those that match + # win_class: prusa-slicer + for win_id in root.get_full_property(NET_CLIENT_LIST, Xlib.X.AnyPropertyType).value: + try: + win = disp.create_resource_object('window', win_id) + if not win.get_wm_transient_for(): + win_class = win.get_wm_class() + if win_id and win_class_name in win_class: + collect.append( + win_id) if win_id not in collect else collect + except Xlib.error.BadWindow: + pass + + return collect + + +if __name__ == '__main__': + + if os.environ.get('PRUSA_SLICER_DARK_THEME', 'false') != 'true': + sys.exit(0) + + # Listen for X Property Change events. + root.change_attributes(event_mask=Xlib.X.PropertyChangeMask) + # the class name of the slicer window + win_class_name = 'prusa-slicer' + # the variant to set + variant = 'dark' + + start = time.time() + + while True: + # collect all of the window ids + collect = collection_win_id_from_wm_class_name(win_class_name) + # give PrusaSlicer window 2 secs to + # collect the wanted window ids + # set the theme variant and exit + if time.time() - start <= 2: + # disp.next_event() blocks if no events are + # queued. In combination with while True + # it creates a very simple event loop. + disp.next_event() + set_theme_variant_from_win_id_collection(collect, variant) + else: + break diff --git a/flatpak/umount b/flatpak/umount new file mode 100755 index 00000000000..5cbf32e6b8a --- /dev/null +++ b/flatpak/umount @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +if [ $# -eq 0 ]; then + echo "No arguments supplied" + exit 1 +fi + +DEVICE=$(basename $(findmnt -oSOURCE -n "$@") ) + +exec /usr/bin/gdbus call -y -d org.freedesktop.UDisks2 -o /org/freedesktop/UDisks2/block_devices/$DEVICE -m org.freedesktop.UDisks2.Filesystem.Unmount "{'b': <'false'>}" 1> /dev/null + diff --git a/src/libslic3r/ParameterUtils.cpp b/src/libslic3r/ParameterUtils.cpp index 4e5fed7e6b2..adde84d5cd2 100644 --- a/src/libslic3r/ParameterUtils.cpp +++ b/src/libslic3r/ParameterUtils.cpp @@ -1,4 +1,5 @@ #include "ParameterUtils.hpp" +#include namespace Slic3r { diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index d2242c9fff0..e254e3c067f 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -622,7 +622,6 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES}) encoding_check(libslic3r_gui) target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui imguizmo minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto) -#target_link_libraries(libslic3r_gui libslic3r cereal imgui minilzo GLEW::GLEW OpenGL::GL hidapi libcurl OpenSSL::SSL OpenSSL::Crypto ${wxWidgets_LIBRARIES} glfw) if (MSVC) target_link_libraries(libslic3r_gui Setupapi.lib) @@ -666,9 +665,18 @@ endif () # link these libraries. if (UNIX AND NOT APPLE) find_package(GTK${SLIC3R_GTK} REQUIRED) + if (FLATPAK) + # I don't know why this is needed, but for whatever reason slic3r isn't + # linking to X11 and webkit2gtk. force it. + find_package(X11 REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(webkit2gtk REQUIRED webkit2gtk-4.1) + target_link_libraries (libslic3r_gui ${X11_LIBRARIES} ${webkit2gtk_LIBRARIES}) + endif() target_include_directories(libslic3r_gui PRIVATE ${GTK${SLIC3R_GTK}_INCLUDE_DIRS}) target_link_libraries(libslic3r_gui ${GTK${SLIC3R_GTK}_LIBRARIES} fontconfig) + # We add GStreamer for bambu:/// support. pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0) pkg_check_modules(GST_BASE REQUIRED gstreamer-base-1.0) @@ -677,4 +685,4 @@ if (UNIX AND NOT APPLE) endif () # Add a definition so that we can tell we are compiling slic3r. -target_compile_definitions(libslic3r_gui PRIVATE SLIC3R_CURRENTLY_COMPILING_GUI_MODULE) \ No newline at end of file +target_compile_definitions(libslic3r_gui PRIVATE SLIC3R_CURRENTLY_COMPILING_GUI_MODULE) diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 8cf36eb54fb..79e09ba5058 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index 1b8fcc3050c..fd444f46982 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -14,6 +14,7 @@ #include "libslic3r/ObjectID.hpp" +#include #include //BBS: GUI refactor: to support top layout diff --git a/src/slic3r/GUI/HttpServer.hpp b/src/slic3r/GUI/HttpServer.hpp index 1f23fd9d306..5c1547f0137 100644 --- a/src/slic3r/GUI/HttpServer.hpp +++ b/src/slic3r/GUI/HttpServer.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #define LOCALHOST_PORT 13618 diff --git a/src/slic3r/GUI/Jobs/OAuthJob.cpp b/src/slic3r/GUI/Jobs/OAuthJob.cpp index 0a38fa6e601..fa79c2c999e 100644 --- a/src/slic3r/GUI/Jobs/OAuthJob.cpp +++ b/src/slic3r/GUI/Jobs/OAuthJob.cpp @@ -4,7 +4,8 @@ #include "ThreadSafeQueue.hpp" #include "slic3r/GUI/I18N.hpp" #include "nlohmann/json.hpp" - +#include +#include namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/OAuthJob.hpp b/src/slic3r/GUI/Jobs/OAuthJob.hpp index dd64e966be1..7b58c53b2e2 100644 --- a/src/slic3r/GUI/Jobs/OAuthJob.hpp +++ b/src/slic3r/GUI/Jobs/OAuthJob.hpp @@ -3,6 +3,9 @@ #include "Job.hpp" #include "slic3r/GUI/HttpServer.hpp" +#include +#include +#include namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/PrinterWebView.hpp b/src/slic3r/GUI/PrinterWebView.hpp index 5b1908c9ee5..070bd4ea978 100644 --- a/src/slic3r/GUI/PrinterWebView.hpp +++ b/src/slic3r/GUI/PrinterWebView.hpp @@ -6,7 +6,7 @@ #include "wx/cmdline.h" #include "wx/notifmsg.h" #include "wx/settings.h" -#include "wx/webview.h" +#include #include #if wxUSE_WEBVIEW_EDGE diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index b96b9051fca..feeace8fecb 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -6,7 +6,7 @@ #include "wx/cmdline.h" #include "wx/notifmsg.h" #include "wx/settings.h" -#include "wx/webview.h" +#include #if wxUSE_WEBVIEW_EDGE #include "wx/msw/webview_edge.h" diff --git a/src/slic3r/Utils/SimplyPrint.cpp b/src/slic3r/Utils/SimplyPrint.cpp index 9c5603c7d76..2fc72fb9efd 100644 --- a/src/slic3r/Utils/SimplyPrint.cpp +++ b/src/slic3r/Utils/SimplyPrint.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include "nlohmann/json.hpp" #include "libslic3r/Utils.hpp" diff --git a/src/slic3r/Utils/SimplyPrint.hpp b/src/slic3r/Utils/SimplyPrint.hpp index b2c06a04e6d..2b56764d7c1 100644 --- a/src/slic3r/Utils/SimplyPrint.hpp +++ b/src/slic3r/Utils/SimplyPrint.hpp @@ -42,4 +42,4 @@ class SimplyPrint : public PrintHost }; } // namespace Slic3r -#endif \ No newline at end of file +#endif