Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Upgrade dependencies and code to work on new macOS SDK #3968

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if (APPLE)
if (CMAKE_MACOSX_BUNDLE)
set(CMAKE_INSTALL_RPATH @executable_path/../Frameworks)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.3" CACHE STRING "Minimum OS X deployment version" FORCE)
endif ()

# Proposal for C++ unit tests and sandboxes
Expand Down Expand Up @@ -338,6 +338,9 @@ if(SLIC3R_STATIC)
set(Boost_USE_STATIC_LIBS ON)
# Use boost libraries linked statically to the C++ runtime.
# set(Boost_USE_STATIC_RUNTIME ON)

# Enable deprecated timer header (XXX replace header)
add_definitions(-DBOOST_TIMER_ENABLE_DEPRECATED)
endif()
#set(Boost_DEBUG ON)
# set(Boost_COMPILER "-mgw81")
Expand Down Expand Up @@ -493,6 +496,9 @@ find_package(GLEW REQUIRED)

find_package(glfw3 REQUIRED)

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIR})

# Find the Cereal serialization library
find_package(cereal REQUIRED)

Expand Down
7 changes: 3 additions & 4 deletions deps/Boost/Boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ list(APPEND _patch_command COMMAND git init && ${PATCH_CMD} ${CMAKE_CURRENT_LIST

ExternalProject_Add(
dep_Boost
#URL "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.zip"
URL "https://github.com/bambulab/boost/releases/download/1.78.0/boost_1_78_0.zip"
URL_HASH SHA256=f22143b5528e081123c3c5ed437e92f648fe69748e95fa6e2bd41484e2986cc3
URL "https://boostorg.jfrog.io/artifactory/main/release/1.85.0/source/boost_1_85_0.zip"
URL_HASH SHA256=e712fe7eb1b9ec37ac25102525412fb4d74e638996443944025791f48f29408a
DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/Boost
CONFIGURE_COMMAND "${_bootstrap_cmd}"
PATCH_COMMAND ${_patch_command}
# PATCH_COMMAND ${_patch_command}
BUILD_COMMAND "${_build_cmd}"
BUILD_IN_SOURCE ON
INSTALL_COMMAND "${_install_cmd}"
Expand Down
4 changes: 2 additions & 2 deletions deps/CGAL/CGAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ bambustudio_add_cmake_project(
# GIT_REPOSITORY https://github.com/CGAL/cgal.git
# GIT_TAG caacd806dc55c61cc68adaad99f2240f00493b29 # releases/CGAL-5.3
# For whatever reason, this keeps downloading forever (repeats downloads if finished)
URL https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip
URL_HASH SHA256=d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0
URL https://github.com/CGAL/cgal/archive/refs/tags/v5.6.1.zip
URL_HASH SHA256=a968cc77b9a2c6cbe5b1680ceee8d8cd8c5369aedb9daced9e5c90b4442dc574
DEPENDS dep_Boost dep_GMP dep_MPFR
)

Expand Down
27 changes: 0 additions & 27 deletions deps/OCCT/0001-OCCT-fix.patch
Original file line number Diff line number Diff line change
Expand Up @@ -168,30 +168,3 @@ index d98acc0f..28eb8eb4 100644
endforeach()

if (BUILD_SAMPLES_QT)
diff --git a/src/Font/Font_FTFont.cxx b/src/Font/Font_FTFont.cxx
index 5ae9899f..0a17372b 100644
--- a/src/Font/Font_FTFont.cxx
+++ b/src/Font/Font_FTFont.cxx
@@ -103,9 +103,11 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
{
throw Standard_ProgramError ("Font_FTFont, Light and Normal hinting styles are mutually exclusive");
}
+#ifdef HAVE_FREETYPE
setLoadFlag (FT_LOAD_TARGET_LIGHT, (theParams.FontHinting & Font_Hinting_Light) != 0);
setLoadFlag (FT_LOAD_NO_HINTING, (theParams.FontHinting & Font_Hinting_Normal) == 0
&& (theParams.FontHinting & Font_Hinting_Light) == 0);
+#endif

// manage native / autohinting
if ((theParams.FontHinting & Font_Hinting_ForceAutohint) != 0
@@ -113,8 +115,10 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
{
throw Standard_ProgramError ("Font_FTFont, ForceAutohint and NoAutohint are mutually exclusive");
}
+#ifdef HAVE_FREETYPE
setLoadFlag (FT_LOAD_FORCE_AUTOHINT, (theParams.FontHinting & Font_Hinting_ForceAutohint) != 0);
setLoadFlag (FT_LOAD_NO_AUTOHINT, (theParams.FontHinting & Font_Hinting_NoAutohint) != 0);
+#endif

if (!myFTLib->IsValid())
{
8 changes: 2 additions & 6 deletions deps/OCCT/OCCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ else()
endif()

bambustudio_add_cmake_project(OCCT
URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip
URL_HASH SHA256=28334f0e98f1b1629799783e9b4d21e05349d89e695809d7e6dfa45ea43e1dbc
#PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-OCCT-fix.patch
URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_8_1.zip
URL_HASH SHA256=05e1fc2d8d14acecb3c2fcfd962255f1eb35b384d5b5619d516eef329131f3db
PATCH_COMMAND git apply --directory deps/build/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
CMAKE_ARGS
-DBUILD_LIBRARY_TYPE=${library_build_type}
-DUSE_TK=OFF
-DUSE_TBB=OFF
#-DUSE_FREETYPE=OFF
-DUSE_FFMPEG=OFF
-DUSE_VTK=OFF
-DBUILD_MODULE_ApplicationFramework=OFF
Expand Down
4 changes: 2 additions & 2 deletions deps/OpenCV/OpenCV.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ else ()
endif ()

bambustudio_add_cmake_project(OpenCV
URL https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz
URL_HASH SHA256=1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
URL https://github.com/opencv/opencv/archive/refs/tags/4.9.0.tar.gz
URL_HASH SHA256=ddf76f9dffd322c7c3cb1f721d0887f62d747b82059342213138dc190f28bc6c
CMAKE_ARGS
-DBUILD_SHARED_LIBS=0
-DBUILD_PERE_TESTS=OFF
Expand Down
48 changes: 35 additions & 13 deletions src/libslic3r/Format/bbs_3mf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/nowide/fstream.hpp>
#include <boost/nowide/cstdio.hpp>
Expand Down Expand Up @@ -1237,12 +1236,19 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
m_backup_path = filename.substr(0, filename.size() - 5);
model.set_backup_path(m_backup_path);
try {
if (boost::filesystem::exists(model.get_backup_path() + "/origin.txt"))
boost::filesystem::load_string_file(model.get_backup_path() + "/origin.txt", m_origin_file);
std::string filepath = model.get_backup_path() + "/origin.txt";
if (boost::filesystem::exists(filepath)) {
boost::filesystem::ifstream originfile(filepath);
m_origin_file.assign(
(std::istreambuf_iterator<char>(originfile)),
(std::istreambuf_iterator<char>())
);
originfile.close();
}
} catch (...) {}
boost::filesystem::save_string_file(
model.get_backup_path() + "/lock.txt",
boost::lexical_cast<std::string>(get_current_pid()));
boost::filesystem::ofstream lockfile(model.get_backup_path() + "/lock.txt");
lockfile << boost::lexical_cast<std::string>(get_current_pid());
lockfile.close();
}
else {
m_backup_path = model.get_backup_path();
Expand All @@ -1253,7 +1259,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
file_version = *m_bambuslicer_generator_version;
// save for restore
if (result && m_load_aux && !m_load_restore) {
boost::filesystem::save_string_file(model.get_backup_path() + "/origin.txt", filename);
boost::filesystem::ofstream originfile(model.get_backup_path() + "/origin.txt");
originfile << filename;
originfile.close();
}
if (m_load_restore && !result) // not clear failed backup data for later analyze
model.set_backup_path("detach");
Expand Down Expand Up @@ -5355,6 +5363,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
boost::system::error_code ec;
std::string filename = std::string(store_params.path);
boost::filesystem::remove(filename + ".tmp", ec);
boost::filesystem::ofstream outputfile;

bool result = _save_model_to_file(filename + ".tmp", *store_params.model, store_params.plate_data_list, store_params.project_presets, store_params.config,
store_params.thumbnail_data, store_params.top_thumbnail_data, store_params.pick_thumbnail_data, store_params.proFn,
Expand All @@ -5367,7 +5376,9 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
return false;
}
if (!(store_params.strategy & SaveStrategy::Silence))
boost::filesystem::save_string_file(store_params.model->get_backup_path() + "/origin.txt", filename);
outputfile.open(store_params.model->get_backup_path() + "/origin.txt");
outputfile << filename;
outputfile.close();
}
return result;
}
Expand Down Expand Up @@ -8164,9 +8175,14 @@ bool has_restore_data(std::string & path, std::string& origin)
origin = "<lock>";
return false;
}
if (boost::filesystem::exists(path + "/lock.txt")) {
std::string pid;
boost::filesystem::load_string_file(path + "/lock.txt", pid);
const std::string lockfile_path = path + "/lock.txt";
if (boost::filesystem::exists(lockfile_path)) {
boost::filesystem::ifstream lockfile(lockfile_path);
std::string pid(
(std::istreambuf_iterator<char>(lockfile)),
(std::istreambuf_iterator<char>())
);
lockfile.close();
try {
if (get_process_name(boost::lexical_cast<int>(pid)) ==
get_process_name(0)) {
Expand All @@ -8182,8 +8198,14 @@ bool has_restore_data(std::string & path, std::string& origin)
if (!boost::filesystem::exists(file3mf))
return false;
try {
if (boost::filesystem::exists(path + "/origin.txt"))
boost::filesystem::load_string_file(path + "/origin.txt", origin);
if (boost::filesystem::exists(path + "/origin.txt")) {
boost::filesystem::ifstream originfile(path + "/origin.txt");
origin.assign(
(std::istreambuf_iterator<char>(originfile)),
(std::istreambuf_iterator<char>())
);
originfile.close();
}
}
catch (...) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/MeshBoolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ indexed_triangle_set cgal_to_indexed_triangle_set(const _Mesh &cgalmesh)
const auto &vertices = cgalmesh.vertices();
int vsize = int(vertices.size());

for (auto &vi : vertices) {
for (const auto &vi : vertices) {
auto &v = cgalmesh.point(vi); // Don't ask...
its.vertices.emplace_back(to_vec3f(v));
}

for (auto &face : faces) {
for (const auto &face : faces) {
auto vtc = cgalmesh.vertices_around_face(cgalmesh.halfedge(face));

int i = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/string_file.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/log/trivial.hpp>
#include <boost/nowide/iostream.hpp>
Expand Down Expand Up @@ -906,8 +905,9 @@ std::string Model::get_backup_path()
BOOST_LOG_TRIVIAL(info) << "create /Metadata in " << temp_path;
boost::filesystem::create_directories(backup_path + "/Metadata");
BOOST_LOG_TRIVIAL(info) << "create /lock.txt in " << temp_path;
boost::filesystem::save_string_file(backup_path + "/lock.txt",
boost::lexical_cast<std::string>(get_current_pid()));
boost::filesystem::ofstream lockfile(backup_path + "/lock.txt");
lockfile << boost::lexical_cast<std::string>(get_current_pid());
lockfile.close();
}
} catch (std::exception &ex) {
BOOST_LOG_TRIVIAL(error) << "Failed to create backup path" << temp_path << ": " << ex.what();
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ std::string PrintBase::output_filename(const std::string &format, const std::str
cfg.opt_string("input_filename_base") + default_ext :
this->placeholder_parser().process(format, 0, &cfg);
if (filename.extension().empty())
filename = boost::filesystem::change_extension(filename, default_ext);
filename.replace_extension(default_ext);
return filename.string();
} catch (std::runtime_error &err) {
throw Slic3r::PlaceholderParserError(L("Failed processing of the filename_format template.") + "\n" + err.what());
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ CopyFileResult copy_file_inner(const std::string& from, const std::string& to, s
// That may happen when copying on some exotic file system, for example Linux on Chrome.
copy_file_linux(source, target, ec);
#else // __linux__
boost::filesystem::copy_file(source, target, boost::filesystem::copy_option::overwrite_if_exists, ec);
boost::filesystem::copy_file(source, target, boost::filesystem::copy_options::overwrite_existing, ec);
#endif // __linux__
if (ec) {
error_message = ec.message();
Expand Down
12 changes: 6 additions & 6 deletions src/slic3r/GUI/Auxiliary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
}

auto existing = false;
auto dir = m_file_path.branch_path();
auto dir = m_file_path.parent_path();
auto new_fullname = new_file_name + m_file_path.extension().string();


Expand Down Expand Up @@ -462,8 +462,8 @@ void AuFile::on_set_cover()
wxGetApp().plater()->model().model_info->cover_file = path.string();
//wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString();

auto full_path = m_file_path.branch_path();
auto full_root_path = full_path.branch_path();
auto full_path = m_file_path.parent_path();
auto full_root_path = full_path.parent_path();
auto full_root_path_str = encode_path(full_root_path.string().c_str());
auto dir = wxString::Format("%s/.thumbnails", full_root_path_str);

Expand Down Expand Up @@ -507,8 +507,8 @@ void AuFile::on_set_delete()
auto is_fine = fs::remove(bfs_path);

if (m_cover) {
auto full_path = m_file_path.branch_path();
auto full_root_path = full_path.branch_path();
auto full_path = m_file_path.parent_path();
auto full_root_path = full_path.parent_path();
auto full_root_path_str = encode_path(full_root_path.string().c_str());
auto dir = wxString::Format("%s/.thumbnails", full_root_path_str);
fs::path dir_path(dir.c_str());
Expand Down Expand Up @@ -949,7 +949,7 @@ void AuxiliaryPanel::on_import_file(wxCommandEvent &event)


boost::system::error_code ec;
if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_option::overwrite_if_exists, ec)) continue;
if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_options::overwrite_existing, ec)) continue;
Slic3r::put_other_changes();

// add in file list
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/AuxiliaryDataViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ wxDataViewItemArray AuxiliaryModel::ImportFile(AuxiliaryModelNode* sel, wxArrayS
dir_path += "\\" + src_bfs_path.filename().generic_wstring();

boost::system::error_code ec;
if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_option::overwrite_if_exists, ec))
if (!fs::copy_file(src_bfs_path, fs::path(dir_path.ToStdWstring()), fs::copy_options::overwrite_existing, ec))
continue;

// Update model data
Expand Down
Loading