Worked around some quirky Linux file system issues. Namely

the Chromebooks share their file system to Linux using the 9p file
system, which does not support setting file ownership. Newly PrusaSlicer
will detect platform and it will not panick if copy_file() cannot set
file ownership after copying. It just logs the incident, and on
chromebooks the loglevel for that incident is "Info", not "Error".

Adjusted the full screen mode to contain menu bar.
Moved Platform.cpp/hpp to libslic3r
This commit is contained in:
Vojtech Bubnik 2021-03-15 16:19:22 +01:00
parent 84a333e4ed
commit 01406fd521
12 changed files with 168 additions and 30 deletions

View file

@ -1,78 +0,0 @@
#include "Platform.hpp"
// For starting another PrusaSlicer instance on OSX.
// Fails to compile on Windows on the build server.
#include <wx/stdpaths.h>
#include <boost/log/trivial.hpp>
namespace Slic3r {
namespace GUI {
static auto s_platform = Platform::Uninitialized;
static auto s_platform_flavor = PlatformFlavor::Uninitialized;
void detect_platform()
{
#if defined(_WIN32)
BOOST_LOG_TRIVIAL(info) << "Platform: Windows";
s_platform = Platform::Windows;
s_platform_flavor = PlatformFlavor::Generic;
#elif defined(__APPLE__)
BOOST_LOG_TRIVIAL(info) << "Platform: OSX";
s_platform = Platform::OSX;
s_platform_flavor = PlatformFlavor::Generic;
#elif defined(__linux__)
BOOST_LOG_TRIVIAL(info) << "Platform: Linux";
s_platform = Platform::Linux;
s_platform_flavor = PlatformFlavor::GenericLinux;
// Test for Chromium.
{
FILE *f = ::fopen("/proc/version", "rt");
if (f) {
char buf[4096];
// Read the 1st line.
if (::fgets(buf, 4096, f)) {
if (strstr(buf, "Chromium OS") != nullptr) {
s_platform_flavor = PlatformFlavor::LinuxOnChromium;
BOOST_LOG_TRIVIAL(info) << "Platform flavor: LinuxOnChromium";
} else if (strstr(buf, "microsoft") != nullptr || strstr(buf, "Microsoft") != nullptr) {
if (boost::filesystem::exists("/run/WSL") && getenv("WSL_INTEROP") != nullptr) {
BOOST_LOG_TRIVIAL(info) << "Platform flavor: WSL2";
s_platform_flavor = PlatformFlavor::WSL2;
} else {
BOOST_LOG_TRIVIAL(info) << "Platform flavor: WSL";
s_platform_flavor = PlatformFlavor::WSL;
}
}
}
::fclose(f);
}
}
#elif defined(__OpenBSD__)
BOOST_LOG_TRIVIAL(info) << "Platform: OpenBSD";
s_platform = Platform::BSDUnix;
s_platform_flavor = PlatformFlavor::OpenBSD;
#else
// This should not happen.
BOOST_LOG_TRIVIAL(info) << "Platform: Unknown";
static_assert(false, "Unknown platform detected");
s_platform = Platform::Unknown;
s_platform_flavor = PlatformFlavor::Unknown;
#endif
}
Platform platform()
{
return s_platform;
}
PlatformFlavor platform_flavor()
{
return s_platform_flavor;
}
} // namespace GUI
} // namespace Slic3r

View file

@ -1,44 +0,0 @@
#ifndef SLIC3R_GUI_Utils_Platform_HPP
#define SLIC3R_GUI_Utils_Platform_HPP
namespace Slic3r {
namespace GUI {
enum class Platform
{
Uninitialized,
Unknown,
Windows,
OSX,
Linux,
BSDUnix,
};
enum class PlatformFlavor
{
Uninitialized,
Unknown,
// For Windows and OSX, until we need to be more specific.
Generic,
// For Platform::Linux
GenericLinux,
LinuxOnChromium,
// Microsoft's Windows on Linux (Linux kernel simulated on NTFS kernel)
WSL,
// Microsoft's Windows on Linux, version 2 (virtual machine)
WSL2,
// For Platform::BSDUnix
OpenBSD,
};
// To be called on program start-up.
void detect_platform();
Platform platform();
PlatformFlavor platform_flavor();
} // namespace GUI
} // namespace Slic3r
#endif // SLIC3R_GUI_Utils_Platform_HPP