WIP: Restoring of the command line only builds (no GUI support).

This commit is contained in:
bubnikv 2019-04-12 12:16:44 +02:00
parent 8094cd22da
commit 349e30a39c
3 changed files with 42 additions and 13 deletions

View File

@ -49,6 +49,10 @@ foreach (_cache_var ${_cache_vars})
endif () endif ()
endforeach() endforeach()
if (SLIC3R_GUI)
add_definitions(-DSLIC3R_GUI)
endif ()
if (MSVC) if (MSVC)
if (SLIC3R_MSVC_COMPILE_PARALLEL) if (SLIC3R_MSVC_COMPILE_PARALLEL)
add_compile_options(/MP) add_compile_options(/MP)

View File

@ -6,10 +6,12 @@
#define NOMINMAX #define NOMINMAX
#include <Windows.h> #include <Windows.h>
#include <wchar.h> #include <wchar.h>
#ifdef SLIC3R_GUI
// Let the NVIDIA and AMD know we want to use their graphics card // Let the NVIDIA and AMD know we want to use their graphics card
// on a dual graphics card system. // on a dual graphics card system.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif /* SLIC3R_GUI */
#endif /* WIN32 */ #endif /* WIN32 */
#include <cstdio> #include <cstdio>
@ -448,7 +450,7 @@ int CLI::run(int argc, char **argv)
} }
if (start_gui) { if (start_gui) {
#if 1 #ifdef SLIC3R_GUI
// #ifdef USE_WX // #ifdef USE_WX
GUI::GUI_App *gui = new GUI::GUI_App(); GUI::GUI_App *gui = new GUI::GUI_App();
// gui->autosave = m_config.opt_string("autosave"); // gui->autosave = m_config.opt_string("autosave");
@ -477,12 +479,12 @@ int CLI::run(int argc, char **argv)
gui->mainframe->load_config(m_extra_config); gui->mainframe->load_config(m_extra_config);
}); });
return wxEntry(argc, argv); return wxEntry(argc, argv);
#else #else /* SLIC3R_GUI */
// No GUI support. Just print out a help. // No GUI support. Just print out a help.
this->print_help(false); this->print_help(false);
// If started without a parameter, consider it to be OK, otherwise report an error code (no action etc). // If started without a parameter, consider it to be OK, otherwise report an error code (no action etc).
return (argc == 0) ? 0 : 1; return (argc == 0) ? 0 : 1;
#endif #endif /* SLIC3R_GUI */
} }
return 0; return 0;
@ -563,7 +565,13 @@ bool CLI::setup(int argc, char **argv)
void CLI::print_help(bool include_print_options, PrinterTechnology printer_technology) const void CLI::print_help(bool include_print_options, PrinterTechnology printer_technology) const
{ {
boost::nowide::cout boost::nowide::cout
<< "Slic3r Prusa Edition " << SLIC3R_BUILD << std::endl << "Slic3r Prusa Edition " << SLIC3R_BUILD
#ifdef SLIC3R_GUI
<< " (with GUI support)"
#else /* SLIC3R_GUI */
<< " (without GUI support)"
#endif /* SLIC3R_GUI */
<< std::endl
<< "https://github.com/prusa3d/Slic3r" << std::endl << std::endl << "https://github.com/prusa3d/Slic3r" << std::endl << std::endl
<< "Usage: slic3r [ ACTIONS ] [ TRANSFORM ] [ OPTIONS ] [ file.stl ... ]" << std::endl << "Usage: slic3r [ ACTIONS ] [ TRANSFORM ] [ OPTIONS ] [ file.stl ... ]" << std::endl
<< std::endl << std::endl

View File

@ -6,14 +6,20 @@
#include <Windows.h> #include <Windows.h>
#include <shellapi.h> #include <shellapi.h>
#include <wchar.h> #include <wchar.h>
// Let the NVIDIA and AMD know we want to use their graphics card
// on a dual graphics card system. #ifdef SLIC3R_GUI
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; // Let the NVIDIA and AMD know we want to use their graphics card
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; // on a dual graphics card system.
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif /* SLIC3R_GUI */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <GL/GL.h>
#ifdef SLIC3R_GUI
#include <GL/GL.h>
#endif /* SLIC3R_GUI */
#include <string> #include <string>
#include <vector> #include <vector>
@ -23,6 +29,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#include <stdio.h> #include <stdio.h>
#ifdef SLIC3R_GUI
class OpenGLVersionCheck class OpenGLVersionCheck
{ {
public: public:
@ -188,6 +195,7 @@ protected:
}; };
bool OpenGLVersionCheck::message_pump_exit = false; bool OpenGLVersionCheck::message_pump_exit = false;
#endif /* SLIC3R_GUI */
extern "C" { extern "C" {
typedef int (__stdcall *Slic3rMainFunc)(int argc, wchar_t **argv); typedef int (__stdcall *Slic3rMainFunc)(int argc, wchar_t **argv);
@ -206,17 +214,23 @@ int wmain(int argc, wchar_t **argv)
std::vector<wchar_t*> argv_extended; std::vector<wchar_t*> argv_extended;
argv_extended.emplace_back(argv[0]); argv_extended.emplace_back(argv[0]);
#ifdef SLIC3R_GUI
// Here one may push some additional parameters based on the wrapper type. // Here one may push some additional parameters based on the wrapper type.
bool force_mesa = false; bool force_mesa = false;
#endif /* SLIC3R_GUI */
for (int i = 1; i < argc; ++ i) { for (int i = 1; i < argc; ++ i) {
#ifdef SLIC3R_GUI
if (wcscmp(argv[i], L"--sw-renderer") == 0) if (wcscmp(argv[i], L"--sw-renderer") == 0)
force_mesa = true; force_mesa = true;
else if (wcscmp(argv[i], L"--no-sw-renderer") == 0) else if (wcscmp(argv[i], L"--no-sw-renderer") == 0)
force_mesa = false; force_mesa = false;
#endif /* SLIC3R_GUI */
argv_extended.emplace_back(argv[i]); argv_extended.emplace_back(argv[i]);
} }
argv_extended.emplace_back(nullptr); argv_extended.emplace_back(nullptr);
#ifdef SLIC3R_GUI
OpenGLVersionCheck opengl_version_check; OpenGLVersionCheck opengl_version_check;
bool load_mesa = bool load_mesa =
// Forced from the command line. // Forced from the command line.
@ -226,6 +240,7 @@ int wmain(int argc, wchar_t **argv)
::GetSystemMetrics(SM_REMOTESESSION) || ::GetSystemMetrics(SM_REMOTESESSION) ||
// Try to load the default OpenGL driver and test its context version. // Try to load the default OpenGL driver and test its context version.
! opengl_version_check.load_opengl_dll() || ! opengl_version_check.is_version_greater_or_equal_to(2, 0); ! opengl_version_check.load_opengl_dll() || ! opengl_version_check.is_version_greater_or_equal_to(2, 0);
#endif /* SLIC3R_GUI */
wchar_t path_to_exe[MAX_PATH + 1] = { 0 }; wchar_t path_to_exe[MAX_PATH + 1] = { 0 };
::GetModuleFileNameW(nullptr, path_to_exe, MAX_PATH); ::GetModuleFileNameW(nullptr, path_to_exe, MAX_PATH);
@ -236,6 +251,7 @@ int wmain(int argc, wchar_t **argv)
_wsplitpath(path_to_exe, drive, dir, fname, ext); _wsplitpath(path_to_exe, drive, dir, fname, ext);
_wmakepath(path_to_exe, drive, dir, nullptr, nullptr); _wmakepath(path_to_exe, drive, dir, nullptr, nullptr);
#ifdef SLIC3R_GUI
// https://wiki.qt.io/Cross_compiling_Mesa_for_Windows // https://wiki.qt.io/Cross_compiling_Mesa_for_Windows
// http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/ // http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/
if (load_mesa) { if (load_mesa) {
@ -260,6 +276,7 @@ int wmain(int argc, wchar_t **argv)
printf("slic3r.dll was not loaded\n"); printf("slic3r.dll was not loaded\n");
return -1; return -1;
} }
#endif /* SLIC3R_GUI */
// resolve function address here // resolve function address here
slic3r_main = (Slic3rMainFunc)GetProcAddress(hInstance_Slic3r, slic3r_main = (Slic3rMainFunc)GetProcAddress(hInstance_Slic3r,