Skip to content

Commit

Permalink
Flatpak build (#4175)
Browse files Browse the repository at this point in the history
* Initial commit for the builder

* fix wx, use hack to install into /app

* add some workarounds for /usr/local

* fix up rest of paths

* attempt to fix wxwebview undef

* figure out why wxwidgets isnt getting its patches applied

* do "proper" patching of wxwidgets

* Flip the flag

* actually append the /usr/local

* restrict package finding to flatpak only

* Update the destdir stuff for mpfr, gmp

* Transfer over all the _destdir, again

* update patch command for all other plats

* initial ci check

* what even happened

* clear ci image

* I doubt this will do anything

* do cleanup after running each step

* remove build objects for flatpak ci

* compress debug info

* Fix MacOS build

* Try saving space after building deps

* No debug info for now

* Do debug info, use thin static archives

* use BSD flag, not --thin

* try building with lto

* Use release, no debug info

* remove lto

* Revert the last 5 commits

* It might require write perms

* Revert "It might require write perms"

This reverts commit 44cec58.

* Import fixes for merge

* remove some patch stuff

* the worst hack!

* remove uneeded patches

* Initial commit for the builder

* note to self, go back to regular wx

* attempt to fix wxwebview undef

* do "proper" patching of wxwidgets

* update patch command for all other plats

* what even happened

* -ldep_name-NOTFOUND is still here

* concat patches

* Build wx with flatpak

* more wx shenatigans

* fix a missing import

* build wx with proper flags

* fix imports and libs

* trigger ci

* try fixing mac and windows ci

* remove duplicate definition of freetype

* curl may not have openssl for a dep

* has openssl been found?

* force building

* build images on apple

* cleanup for review

* cleanup cmake files

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
  • Loading branch information
powpingdone and SoftFever committed May 25, 2024
1 parent b1bd30f commit 17fec83
Show file tree
Hide file tree
Showing 33 changed files with 790 additions and 84 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,21 @@ jobs:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
build-deps-only: ${{ inputs.build-deps-only || false }}
secrets: inherit
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 }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ src/OrcaSlicer-doc/
**/filament_full/
/deps/DL_CACHE/
/deps/DL_CACHE
resources/profiles/user/default
**/.flatpak-builder/
resources/profiles/user/default
37 changes: 12 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
121 changes: 103 additions & 18 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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}
Expand All @@ -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}"
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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 <openssl/md5.h>
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}
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions deps/CURL/CURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 8 additions & 9 deletions deps/GMP/GMP.cmake
Original file line number Diff line number Diff line change
@@ -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})
Expand Down Expand Up @@ -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 ()
endif ()
19 changes: 9 additions & 10 deletions deps/MPFR/MPFR.cmake
Original file line number Diff line number Diff line change
@@ -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})
Expand All @@ -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
Expand Down

0 comments on commit 17fec83

Please sign in to comment.