Skip to content

Commit f52f88e

Browse files
committed
Fix AD5X IFS support detection and respect -j for MSBuild
1 parent a77ab34 commit f52f88e

File tree

9 files changed

+63
-14
lines changed

9 files changed

+63
-14
lines changed

build_release_vs.bat

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
@REM OrcaSlicer build script for Windows with VS auto-detect
22
@echo off
3+
setlocal ENABLEDELAYEDEXPANSION
34
set WP=%CD%
45
set _START_TIME=%TIME%
56

67
@REM Check for Ninja Multi-Config option (-x)
78
set USE_NINJA=0
9+
set JOBS=
10+
set NEXT_IS_JOBS=0
811
for %%a in (%*) do (
912
if "%%a"=="-x" set USE_NINJA=1
13+
if "!NEXT_IS_JOBS!"=="1" (
14+
set JOBS=%%a
15+
set NEXT_IS_JOBS=0
16+
) else (
17+
if "%%a"=="-j" set NEXT_IS_JOBS=1
18+
)
19+
)
20+
21+
set BUILD_PARALLEL_NINJA=
22+
set BUILD_PARALLEL_MSBUILD=
23+
if defined JOBS (
24+
set BUILD_PARALLEL_NINJA=--parallel %JOBS%
25+
set BUILD_PARALLEL_MSBUILD=-m:%JOBS%
26+
set CMAKE_BUILD_PARALLEL_LEVEL=%JOBS%
27+
set ORCA_MSBUILD_PARALLEL=/m:%JOBS%
28+
) else (
29+
set BUILD_PARALLEL_MSBUILD=-m
30+
set ORCA_MSBUILD_PARALLEL=/m
1031
)
1132

1233
if "%USE_NINJA%"=="1" (
@@ -96,6 +117,7 @@ if "%debug%"=="ON" (
96117
)
97118
)
98119
echo build type set to %build_type%
120+
if defined JOBS echo parallel jobs set to %JOBS%
99121

100122
setlocal DISABLEDELAYEDEXPANSION
101123
cd deps
@@ -114,10 +136,10 @@ REM Set minimum CMake policy to avoid <3.5 errors
114136
set CMAKE_POLICY_VERSION_MINIMUM=3.5
115137
if "%USE_NINJA%"=="1" (
116138
cmake ../ -G %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=%build_type%
117-
cmake --build . --config %build_type% --target deps
139+
cmake --build . --config %build_type% --target deps %BUILD_PARALLEL_NINJA%
118140
) else (
119141
cmake ../ -G %CMAKE_GENERATOR% -A x64 -DCMAKE_BUILD_TYPE=%build_type%
120-
cmake --build . --config %build_type% --target deps -- -m
142+
cmake --build . --config %build_type% --target deps -- %BUILD_PARALLEL_MSBUILD%
121143
)
122144
@echo off
123145

@@ -133,10 +155,10 @@ echo on
133155
set CMAKE_POLICY_VERSION_MINIMUM=3.5
134156
if "%USE_NINJA%"=="1" (
135157
cmake .. -G %CMAKE_GENERATOR% -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type%
136-
cmake --build . --config %build_type% --target ALL_BUILD
158+
cmake --build . --config %build_type% --target ALL_BUILD %BUILD_PARALLEL_NINJA%
137159
) else (
138160
cmake .. -G %CMAKE_GENERATOR% -A x64 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type%
139-
cmake --build . --config %build_type% --target ALL_BUILD -- -m
161+
cmake --build . --config %build_type% --target ALL_BUILD -- %BUILD_PARALLEL_MSBUILD%
140162
)
141163
@echo off
142164
cd ..

deps/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ function(orcaslicer_add_cmake_project projectname)
170170
set(_build_j "-j${NPROC}")
171171
if (MSVC)
172172
set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}")
173-
set(_build_j "/m")
173+
if (DEFINED ENV{ORCA_MSBUILD_PARALLEL} AND NOT "$ENV{ORCA_MSBUILD_PARALLEL}" STREQUAL "")
174+
set(_build_j "$ENV{ORCA_MSBUILD_PARALLEL}")
175+
else ()
176+
set(_build_j "/m")
177+
endif ()
174178
endif ()
175179

176180
if (NOT IS_CROSS_COMPILE OR NOT APPLE)

deps/OpenVDB/OpenVDB.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ orcaslicer_add_cmake_project(OpenVDB
3131
if (MSVC)
3232
if (${DEP_DEBUG})
3333
ExternalProject_Get_Property(dep_OpenVDB BINARY_DIR)
34+
if (DEFINED ENV{ORCA_MSBUILD_PARALLEL} AND NOT "$ENV{ORCA_MSBUILD_PARALLEL}" STREQUAL "")
35+
set(_msbuild_parallel "$ENV{ORCA_MSBUILD_PARALLEL}")
36+
else ()
37+
set(_msbuild_parallel "/m")
38+
endif ()
3439
ExternalProject_Add_Step(dep_OpenVDB build_debug
3540
DEPENDEES build
3641
DEPENDERS install
3742
COMMAND ${CMAKE_COMMAND} ../dep_OpenVDB -DOPENVDB_BUILD_VDB_PRINT=OFF
38-
COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
43+
COMMAND msbuild ${_msbuild_parallel} /P:Configuration=Debug INSTALL.vcxproj
3944
WORKING_DIRECTORY "${BINARY_DIR}"
4045
)
4146
endif ()
42-
endif ()
47+
endif ()

deps/deps-windows.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ endif ()
4949
macro(add_debug_dep _dep)
5050
if (${DEP_DEBUG})
5151
ExternalProject_Get_Property(${_dep} BINARY_DIR)
52+
if (DEFINED ENV{ORCA_MSBUILD_PARALLEL} AND NOT "$ENV{ORCA_MSBUILD_PARALLEL}" STREQUAL "")
53+
set(_msbuild_parallel "$ENV{ORCA_MSBUILD_PARALLEL}")
54+
else ()
55+
set(_msbuild_parallel "/m")
56+
endif ()
5257
ExternalProject_Add_Step(${_dep} build_debug
5358
DEPENDEES build
5459
DEPENDERS install
55-
COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
60+
COMMAND msbuild ${_msbuild_parallel} /P:Configuration=Debug INSTALL.vcxproj
5661
WORKING_DIRECTORY "${BINARY_DIR}"
5762
)
5863
endif ()

src/slic3r/GUI/Plater.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15796,10 +15796,11 @@ void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn, bool us
1579615796
}
1579715797

1579815798
std::vector<FlashforgeMaterialSlot> slots;
15799+
bool supports_material_station = false;
1579915800
{
1580015801
wxBusyCursor wait;
1580115802
wxString msg;
15802-
if (!flashforge_host->fetch_material_slots(slots, msg)) {
15803+
if (!flashforge_host->fetch_material_slots(slots, &supports_material_station, msg)) {
1580315804
show_error(this, msg.empty() ? _L("Unable to log in to the Flashforge printer.") : msg, false);
1580415805
return;
1580515806
}
@@ -15843,6 +15844,7 @@ void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn, bool us
1584315844
storage_paths, storage_names,
1584415845
config->get_bool("open_device_tab_post_upload"),
1584515846
flashforge_host,
15847+
supports_material_station,
1584615848
std::move(slots),
1584715849
project_filaments);
1584815850
} else {

src/slic3r/GUI/PrintHostDialogs.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ FlashforgePrintHostSendDialog::FlashforgePrintHostSendDialog(const fs::path&
626626
const wxArrayString& storage_names,
627627
bool switch_to_device_tab,
628628
const Slic3r::Flashforge* host,
629+
bool supports_material_station,
629630
std::vector<Slic3r::FlashforgeMaterialSlot> slots,
630631
const std::vector<FilamentInfo>& project_filaments)
631632
: PrintHostSendDialog(path, post_actions, groups, storage_paths, storage_names, switch_to_device_tab)
@@ -634,7 +635,7 @@ FlashforgePrintHostSendDialog::FlashforgePrintHostSendDialog(const fs::path&
634635
, m_project_filaments(project_filaments)
635636
{
636637
m_slots_loaded = !m_slots.empty();
637-
m_supports_material_station = m_slots_loaded;
638+
m_supports_material_station = supports_material_station;
638639
}
639640

640641
void FlashforgePrintHostSendDialog::init()
@@ -871,12 +872,14 @@ void FlashforgePrintHostSendDialog::load_slots()
871872
}
872873

873874
wxString msg;
874-
if (!m_host->fetch_material_slots(m_slots, msg)) {
875+
bool supports_material_station = m_supports_material_station;
876+
if (!m_host->fetch_material_slots(m_slots, &supports_material_station, msg)) {
877+
m_supports_material_station = supports_material_station;
875878
m_status_text->SetLabel(msg.empty() ? _L("Unable to read IFS slots from printer.") : msg);
876879
return;
877880
}
878881

879-
m_supports_material_station = !m_slots.empty();
882+
m_supports_material_station = supports_material_station;
880883
m_slots_loaded = m_supports_material_station;
881884
m_use_material_station = m_supports_material_station;
882885

src/slic3r/GUI/PrintHostDialogs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class FlashforgePrintHostSendDialog : public PrintHostSendDialog
197197
const wxArrayString& storage_names,
198198
bool switch_to_device_tab,
199199
const Slic3r::Flashforge* host,
200+
bool supports_material_station,
200201
std::vector<Slic3r::FlashforgeMaterialSlot> slots,
201202
const std::vector<FilamentInfo>& project_filaments);
202203

src/slic3r/Utils/Flashforge.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,16 @@ Flashforge::Flashforge(DynamicPrintConfig* config)
122122
: m_host()
123123
, m_serial_number()
124124
, m_check_code()
125+
, m_supports_material_station(false)
125126
, m_console_port("8899")
126127
, m_gcFlavor(gcfMarlinLegacy)
127128
, m_bufferSize(4096) // 4K buffer size
128129
{
129130
m_host = safe_config_string(config, "print_host");
130131
m_serial_number = safe_config_string(config, "flashforge_serial_number");
131132
m_check_code = safe_config_string(config, "printhost_apikey");
133+
const auto printer_model = safe_config_string(config, "printer_model");
134+
m_supports_material_station = boost::icontains(printer_model, "AD5X");
132135

133136
if (config != nullptr) {
134137
if (const auto* gcode_flavor = config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor"); gcode_flavor != nullptr)
@@ -409,7 +412,7 @@ bool Flashforge::test_local_api(wxString& msg) const
409412
return request_local_api_json("detail", json{{"serialNumber", m_serial_number}, {"checkCode", m_check_code}}.dump(), body, msg);
410413
}
411414

412-
bool Flashforge::fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots, wxString& msg) const
415+
bool Flashforge::fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots, bool* supports_material_station, wxString& msg) const
413416
{
414417
slots.clear();
415418

@@ -433,6 +436,9 @@ bool Flashforge::fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots
433436
detail.contains("MatlStationInfo") ? detail["MatlStationInfo"] : json();
434437
const auto& slot_infos = station.contains("slotInfos") ? station["slotInfos"] : json::array();
435438

439+
if (supports_material_station != nullptr)
440+
*supports_material_station = m_supports_material_station;
441+
436442
for (const auto& slot : slot_infos) {
437443
FlashforgeMaterialSlot info;
438444
info.slot_id = slot.value("slotId", static_cast<int>(slots.size()) + 1);

src/slic3r/Utils/Flashforge.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ class Flashforge : public PrintHost
4444
bool can_test() const override { return true; }
4545
PrintHostPostUploadActions get_post_upload_actions() const override { return PrintHostPostUploadAction::StartPrint; }
4646
std::string get_host() const override { return m_host; }
47-
bool fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots, wxString& msg) const;
47+
bool fetch_material_slots(std::vector<FlashforgeMaterialSlot>& slots, bool* supports_material_station, wxString& msg) const;
4848
static bool discover_printers(std::vector<FlashforgeDiscoveredPrinter>& printers, wxString& msg, int timeout_ms = 10000, int idle_timeout_ms = 1500, int max_retries = 3);
4949

5050
private:
5151
std::string m_host;
5252
std::string m_serial_number;
5353
std::string m_check_code;
54+
bool m_supports_material_station {false};
5455
std::string m_console_port;
5556
const int m_bufferSize;
5657
GCodeFlavor m_gcFlavor;

0 commit comments

Comments
 (0)