Fix Linux build & some warnings (#6438)

* Fix linux deps debug build

* Use the same DL_CACHE for release build when building debug version of deps on Linux.
This prevents downloading the same source packages twice, and avoid downloading again after deleting the build dir.

* Fix debug build

* Fix warnings "loop variable creates a copy from type" and "loop variable binds to a temporary constructed from type"
This commit is contained in:
Noisyfox 2024-08-18 11:33:00 +08:00 committed by GitHub
parent 0d886a133f
commit f136f04cfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 45 additions and 38 deletions

View file

@ -127,8 +127,11 @@ then
if [[ -n "${BUILD_DEBUG}" ]] if [[ -n "${BUILD_DEBUG}" ]]
then then
# have to build deps with debug & release or the cmake won't find everything it needs # have to build deps with debug & release or the cmake won't find everything it needs
if [ ! -d "deps/build/release" ]
then
mkdir deps/build/release mkdir deps/build/release
cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="../destdir" ${BUILD_ARGS} fi
cmake -S deps -B deps/build/release -G Ninja -DDESTDIR="${PWD}/deps/build/destdir" -DDEP_DOWNLOAD_DIR="${PWD}/deps/DL_CACHE" ${BUILD_ARGS}
cmake --build deps/build/release cmake --build deps/build/release
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug" BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
fi fi

View file

@ -23,7 +23,7 @@ Clipper2Lib::Paths64 Slic3rPoints_to_Paths64(const std::vector<T>& in)
{ {
Clipper2Lib::Paths64 out; Clipper2Lib::Paths64 out;
out.reserve(in.size()); out.reserve(in.size());
for (const T item: in) { for (const T& item: in) {
Clipper2Lib::Path64 path; Clipper2Lib::Path64 path;
path.reserve(item.size()); path.reserve(item.size());
for (const Slic3r::Point& point : item.points) for (const Slic3r::Point& point : item.points)

View file

@ -334,8 +334,8 @@ bool Emboss::divide_segments_for_close_point(ExPolygons &expolygons, double dist
const Points &poly_pts = poly.points; const Points &poly_pts = poly.points;
const Point &line_a = poly_pts[id.point_index]; const Point &line_a = poly_pts[id.point_index];
const Point &line_b = (!ids.is_last_point(id)) ? poly_pts[id.point_index + 1] : poly_pts.front(); const Point &line_b = (!ids.is_last_point(id)) ? poly_pts[id.point_index + 1] : poly_pts.front();
assert(line_a == lines[index].a.cast<int>()); assert(line_a == lines[index].a.cast<coord_t>());
assert(line_b == lines[index].b.cast<int>()); assert(line_b == lines[index].b.cast<coord_t>());
if (p == line_a || p == line_b) continue; if (p == line_a || p == line_b) continue;
divs.emplace_back(p, index); divs.emplace_back(p, index);

View file

@ -4622,7 +4622,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
its.vertices.assign(sub_object->geometry.vertices.begin(), sub_object->geometry.vertices.end()); its.vertices.assign(sub_object->geometry.vertices.begin(), sub_object->geometry.vertices.end());
// BBS // BBS
for (const std::string prop_str : sub_object->geometry.face_properties) { for (const std::string& prop_str : sub_object->geometry.face_properties) {
FaceProperty face_prop; FaceProperty face_prop;
face_prop.from_string(prop_str); face_prop.from_string(prop_str);
its.properties.push_back(face_prop); its.properties.push_back(face_prop);

View file

@ -3538,7 +3538,7 @@ void check_model_ids_validity(const Model &model)
for (const ModelInstance *model_instance : model_object->instances) for (const ModelInstance *model_instance : model_object->instances)
check(model_instance->id()); check(model_instance->id());
} }
for (const auto mm : model.materials) { for (const auto& mm : model.materials) {
check(mm.second->id()); check(mm.second->id());
check(mm.second->config.id()); check(mm.second->config.id());
} }

View file

@ -340,7 +340,7 @@ void Preset::normalize(DynamicPrintConfig &config)
static_cast<ConfigOptionVectorBase*>(opt)->resize(n, defaults.option(key)); static_cast<ConfigOptionVectorBase*>(opt)->resize(n, defaults.option(key));
} }
// The following keys are mandatory for the UI, but they are not part of FullPrintConfig, therefore they are handled separately. // The following keys are mandatory for the UI, but they are not part of FullPrintConfig, therefore they are handled separately.
for (const std::string &key : { "filament_settings_id" }) { for (const std::string key : { "filament_settings_id" }) {
auto *opt = config.option(key, false); auto *opt = config.option(key, false);
assert(opt == nullptr || opt->type() == coStrings); assert(opt == nullptr || opt->type() == coStrings);
if (opt != nullptr && opt->type() == coStrings) if (opt != nullptr && opt->type() == coStrings)

View file

@ -2925,7 +2925,7 @@ DynamicConfig PrintStatistics::config() const
DynamicConfig PrintStatistics::placeholders() DynamicConfig PrintStatistics::placeholders()
{ {
DynamicConfig config; DynamicConfig config;
for (const std::string &key : { for (const std::string key : {
"print_time", "normal_print_time", "silent_print_time", "print_time", "normal_print_time", "silent_print_time",
"used_filament", "extruded_volume", "total_cost", "total_weight", "used_filament", "extruded_volume", "total_cost", "total_weight",
"initial_tool", "total_toolchanges", "total_wipe_tower_cost", "total_wipe_tower_filament"}) "initial_tool", "total_toolchanges", "total_wipe_tower_cost", "total_wipe_tower_filament"})

View file

@ -5329,11 +5329,11 @@ void PrintConfigDef::init_extruder_option_keys()
"retraction_length", "retraction_length",
"retraction_minimum_travel", "retraction_minimum_travel",
"retraction_speed", "retraction_speed",
"travel_slope",
"wipe", "wipe",
"wipe_distance", "wipe_distance",
"z_hop", "z_hop",
"z_hop_types", "z_hop_types"
"travel_slope"
}; };
assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end())); assert(std::is_sorted(m_extruder_retract_keys.begin(), m_extruder_retract_keys.end()));
} }

View file

@ -29,7 +29,7 @@ template<typename T> inline void reorder_by_shortest_traverse(std::vector<T> &po
{ {
Points start_point; Points start_point;
start_point.reserve(polylines_out.size()); start_point.reserve(polylines_out.size());
for (const T contour : polylines_out) start_point.push_back(contour.points.front()); for (const T& contour : polylines_out) start_point.push_back(contour.points.front());
std::vector<Points::size_type> order = chain_points(start_point); std::vector<Points::size_type> order = chain_points(start_point);

View file

@ -482,7 +482,7 @@ static bool move_inside_expolys(const ExPolygons& polygons, Point& from, double
// because we compare with vsize2_with_unscale here (no division by zero), we also need to compare by vsize2_with_unscale inside the loop // because we compare with vsize2_with_unscale here (no division by zero), we also need to compare by vsize2_with_unscale inside the loop
// to avoid integer rounding edge cases // to avoid integer rounding edge cases
bool projected_p_beyond_prev_segment = dot_with_unscale(p1 - p0, from - p0) >= vsize2_with_unscale(p1 - p0); bool projected_p_beyond_prev_segment = dot_with_unscale(p1 - p0, from - p0) >= vsize2_with_unscale(p1 - p0);
for(const Point p2 : poly.contour.points) for(const Point& p2 : poly.contour.points)
{ {
// X = A + Normal(B-A) * (((B-A) dot_with_unscale (P-A)) / VSize(B-A)); // X = A + Normal(B-A) * (((B-A) dot_with_unscale (P-A)) / VSize(B-A));
// = A + (B-A) * ((B-A) dot_with_unscale (P-A)) / VSize2(B-A); // = A + (B-A) * ((B-A) dot_with_unscale (P-A)) / VSize2(B-A);
@ -1437,11 +1437,11 @@ void TreeSupport::generate_toolpaths()
if (m_object->support_layer_count() > m_raft_layers) { if (m_object->support_layer_count() > m_raft_layers) {
const SupportLayer *ts_layer = m_object->get_support_layer(m_raft_layers); const SupportLayer *ts_layer = m_object->get_support_layer(m_raft_layers);
for (const ExPolygon expoly : ts_layer->floor_areas) for (const ExPolygon& expoly : ts_layer->floor_areas)
raft_areas.push_back(expoly); raft_areas.push_back(expoly);
for (const ExPolygon expoly : ts_layer->roof_areas) for (const ExPolygon& expoly : ts_layer->roof_areas)
raft_areas.push_back(expoly); raft_areas.push_back(expoly);
for (const ExPolygon expoly : ts_layer->base_areas) for (const ExPolygon& expoly : ts_layer->base_areas)
raft_areas.push_back(expoly); raft_areas.push_back(expoly);
} }
@ -3628,7 +3628,7 @@ const ExPolygons& TreeSupportData::get_avoidance(coordf_t radius, size_t layer_n
Polygons TreeSupportData::get_contours(size_t layer_nr) const Polygons TreeSupportData::get_contours(size_t layer_nr) const
{ {
Polygons contours; Polygons contours;
for (const ExPolygon expoly : m_layer_outlines[layer_nr]) { for (const ExPolygon& expoly : m_layer_outlines[layer_nr]) {
contours.push_back(expoly.contour); contours.push_back(expoly.contour);
} }
@ -3638,7 +3638,7 @@ Polygons TreeSupportData::get_contours(size_t layer_nr) const
Polygons TreeSupportData::get_contours_with_holes(size_t layer_nr) const Polygons TreeSupportData::get_contours_with_holes(size_t layer_nr) const
{ {
Polygons contours; Polygons contours;
for (const ExPolygon expoly : m_layer_outlines[layer_nr]) { for (const ExPolygon& expoly : m_layer_outlines[layer_nr]) {
for(int i=0;i<expoly.num_contours();i++) for(int i=0;i<expoly.num_contours();i++)
contours.push_back(expoly.contour_or_hole(i)); contours.push_back(expoly.contour_or_hole(i));
} }

View file

@ -19,7 +19,11 @@ if(Qhull_FOUND)
message(STATUS "Using qhull from system.") message(STATUS "Using qhull from system.")
if(SLIC3R_STATIC) if(SLIC3R_STATIC)
slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhullstatic_r" RelWithDebInfo Release) slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhullstatic_r" RelWithDebInfo Release)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
target_link_libraries(qhull INTERFACE Qhull::qhullcpp_d Qhull::qhullstatic_rd)
else()
target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r) target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhullstatic_r)
endif()
else() else()
slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhull_r" RelWithDebInfo Release) slic3r_remap_configs("Qhull::qhullcpp;Qhull::qhull_r" RelWithDebInfo Release)
target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhull_r) target_link_libraries(qhull INTERFACE Qhull::qhullcpp Qhull::qhull_r)

View file

@ -277,7 +277,7 @@ static wxArrayString get_exist_vendor_choices(VendorMap& vendors)
vendors[users_models.name] = users_models; vendors[users_models.name] = users_models;
} }
for (const pair<std::string, VendorProfile> &vendor : vendors) { for (const auto& vendor : vendors) {
if (vendor.second.models.empty() || vendor.second.id.empty()) continue; if (vendor.second.models.empty() || vendor.second.id.empty()) continue;
choices.Add(vendor.first); choices.Add(vendor.first);
} }
@ -658,11 +658,11 @@ void CreateFilamentPresetDialog::on_dpi_changed(const wxRect &suggested_rect) {
bool CreateFilamentPresetDialog::is_check_box_selected() bool CreateFilamentPresetDialog::is_check_box_selected()
{ {
for (const std::pair<::CheckBox *, std::pair<std::string, Preset *>> &checkbox_preset : m_filament_preset) { for (const auto& checkbox_preset : m_filament_preset) {
if (checkbox_preset.first->GetValue()) { return true; } if (checkbox_preset.first->GetValue()) { return true; }
} }
for (const std::pair<::CheckBox *, std::pair<std::string, Preset *>> &checkbox_preset : m_machint_filament_preset) { for (const auto& checkbox_preset : m_machint_filament_preset) {
if (checkbox_preset.first->GetValue()) { return true; } if (checkbox_preset.first->GetValue()) { return true; }
} }
@ -693,7 +693,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_vendor_item()
horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
wxArrayString choices; wxArrayString choices;
for (const wxString &vendor : filament_vendors) { for (const wxString vendor : filament_vendors) {
choices.push_back(vendor); choices.push_back(vendor);
} }
choices.Sort(); choices.Sort();
@ -775,7 +775,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_type_item()
horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); horizontal_sizer->Add(optionSizer, 0, wxEXPAND | wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
wxArrayString filament_type; wxArrayString filament_type;
for (const wxString &filament : m_system_filament_types_set) { for (const wxString filament : m_system_filament_types_set) {
filament_type.Add(filament); filament_type.Add(filament);
} }
filament_type.Sort(); filament_type.Sort();
@ -1050,7 +1050,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_button_item()
if (curr_create_type == m_create_type.base_filament) { if (curr_create_type == m_create_type.base_filament) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament create type filament "; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament create type filament ";
for (const std::pair<::CheckBox *, std::pair<std::string, Preset *>> &checkbox_preset : m_filament_preset) { for (const auto& checkbox_preset : m_filament_preset) {
if (checkbox_preset.first->GetValue()) { if (checkbox_preset.first->GetValue()) {
std::string compatible_printer_name = checkbox_preset.second.first; std::string compatible_printer_name = checkbox_preset.second.first;
std::vector<std::string> failures; std::vector<std::string> failures;
@ -1077,7 +1077,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_button_item()
} }
} else if (curr_create_type == m_create_type.base_filament_preset) { } else if (curr_create_type == m_create_type.base_filament_preset) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament presets create type filament preset"; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":clone filament presets create type filament preset";
for (const std::pair<::CheckBox *, std::pair<std::string, Preset *>> &checkbox_preset : m_machint_filament_preset) { for (const auto& checkbox_preset : m_machint_filament_preset) {
if (checkbox_preset.first->GetValue()) { if (checkbox_preset.first->GetValue()) {
std::string compatible_printer_name = checkbox_preset.second.first; std::string compatible_printer_name = checkbox_preset.second.first;
std::vector<std::string> failures; std::vector<std::string> failures;
@ -1155,7 +1155,7 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices()
} }
int suffix = 0; int suffix = 0;
for (const pair<std::string, std::vector<Preset *>> &preset : m_filament_choice_map) { for (const auto& preset : m_filament_choice_map) {
if (preset.second.empty()) continue; if (preset.second.empty()) continue;
std::set<wxString> preset_name_set; std::set<wxString> preset_name_set;
for (Preset* filament_preset : preset.second) { for (Preset* filament_preset : preset.second) {
@ -1752,7 +1752,7 @@ wxBoxSizer *CreatePrinterPresetDialog::create_nozzle_diameter_item(wxWindow *par
wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer *comboBoxSizer = new wxBoxSizer(wxVERTICAL);
m_nozzle_diameter = new ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, OPTION_SIZE, 0, nullptr, wxCB_READONLY); m_nozzle_diameter = new ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, OPTION_SIZE, 0, nullptr, wxCB_READONLY);
wxArrayString nozzle_diameters; wxArrayString nozzle_diameters;
for (const std::string nozzle : nozzle_diameter_vec) { for (const std::string& nozzle : nozzle_diameter_vec) {
nozzle_diameters.Add(nozzle + " mm"); nozzle_diameters.Add(nozzle + " mm");
} }
m_nozzle_diameter->Set(nozzle_diameters); m_nozzle_diameter->Set(nozzle_diameters);
@ -3899,7 +3899,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_
BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful: " << filament_preset->name; BOOST_LOG_TRIVIAL(info) << "Filament preset json add successful: " << filament_preset->name;
} }
for (const std::pair<std::string, json>& vendor_name_to_json : vendor_structure) { for (const auto& vendor_name_to_json : vendor_structure) {
json j; json j;
std::string printer_vendor = vendor_name_to_json.first; std::string printer_vendor = vendor_name_to_json.first;
j["vendor"] = printer_vendor; j["vendor"] = printer_vendor;

View file

@ -9466,21 +9466,21 @@ void Plater::_calib_pa_pattern(const Calib_Params& params)
print_config.set_key_value( "travel_jerk", new ConfigOptionFloat(jerk)); print_config.set_key_value( "travel_jerk", new ConfigOptionFloat(jerk));
} }
for (const auto opt : SuggestedConfigCalibPAPattern().float_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().float_pairs) {
print_config.set_key_value( print_config.set_key_value(
opt.first, opt.first,
new ConfigOptionFloat(opt.second) new ConfigOptionFloat(opt.second)
); );
} }
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
print_config.set_key_value( print_config.set_key_value(
opt.first, opt.first,
new ConfigOptionFloatOrPercent(nozzle_diameter * opt.second / 100, false) new ConfigOptionFloatOrPercent(nozzle_diameter * opt.second / 100, false)
); );
} }
for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().int_pairs) {
print_config.set_key_value( print_config.set_key_value(
opt.first, opt.first,
new ConfigOptionInt(opt.second) new ConfigOptionInt(opt.second)

View file

@ -866,7 +866,7 @@ void SearchDialog::msw_rescale()
SearchListModel::SearchListModel(wxWindow *parent) : wxDataViewVirtualListModel(0) SearchListModel::SearchListModel(wxWindow *parent) : wxDataViewVirtualListModel(0)
{ {
int icon_id = 0; int icon_id = 0;
for (const std::string &icon : {"cog", "printer", "printer", "spool", "blank_16"}) m_icon[icon_id++] = ScalableBitmap(parent, icon); for (const std::string icon : {"cog", "printer", "printer", "spool", "blank_16"}) m_icon[icon_id++] = ScalableBitmap(parent, icon);
} }
void SearchListModel::Clear() void SearchListModel::Clear()

View file

@ -4846,7 +4846,7 @@ wxBoxSizer *ScoreDialog::get_photo_btn_sizer() {
it = m_selected_image_list.erase(it); it = m_selected_image_list.erase(it);
} }
m_image_url_paths.clear(); m_image_url_paths.clear();
for (const std::pair<wxStaticBitmap *, ImageMsg> &bitmap : m_image) { for (const auto& bitmap : m_image) {
if (bitmap.second.is_uploaded) { if (bitmap.second.is_uploaded) {
if (!bitmap.second.img_url_paths.empty()) { if (!bitmap.second.img_url_paths.empty()) {
m_image_url_paths.push_back(bitmap.second.img_url_paths); m_image_url_paths.push_back(bitmap.second.img_url_paths);

View file

@ -858,7 +858,7 @@ bool GuideFrame::apply_config(AppConfig *app_config, PresetBundle *preset_bundle
const std::map<std::string, std::set<std::string>>& model_maps = config->second; const std::map<std::string, std::set<std::string>>& model_maps = config->second;
//for (const auto& vendor_profile : preset_bundle->vendors) { //for (const auto& vendor_profile : preset_bundle->vendors) {
for (const auto model_it: model_maps) { for (const auto& model_it: model_maps) {
if (model_it.second.size() > 0) { if (model_it.second.size() > 0) {
variant = *model_it.second.begin(); variant = *model_it.second.begin();
const auto config_old = old_enabled_vendors.find(bundle_name); const auto config_old = old_enabled_vendors.find(bundle_name);

View file

@ -618,7 +618,7 @@ void CalibUtils::calib_pa_pattern(const CalibInfo &calib_info, Model& model)
float nozzle_diameter = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0); float nozzle_diameter = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
for (const auto opt : SuggestedConfigCalibPAPattern().float_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().float_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionFloat(opt.second)); print_config.set_key_value(opt.first, new ConfigOptionFloat(opt.second));
} }
@ -627,11 +627,11 @@ void CalibUtils::calib_pa_pattern(const CalibInfo &calib_info, Model& model)
full_config, print_config.get_abs_value("line_width"), full_config, print_config.get_abs_value("line_width"),
print_config.get_abs_value("layer_height"), 0))); print_config.get_abs_value("layer_height"), 0)));
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100)); print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
} }
for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) { for (const auto& opt : SuggestedConfigCalibPAPattern().int_pairs) {
print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second)); print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second));
} }