2023-04-16 15:28:55 -07:00
|
|
|
|
/* Copyright (C) 2023 Wildfire Games.
|
2023-07-27 13:54:46 -07:00
|
|
|
|
* This file is part of 0 A.D.
|
2010-11-20 11:46:49 -08:00
|
|
|
|
*
|
2023-07-27 13:54:46 -07:00
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2010-11-20 11:46:49 -08:00
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
2023-07-27 13:54:46 -07:00
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2010-11-20 11:46:49 -08:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-07-27 13:54:46 -07:00
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-20 11:46:49 -08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
2011-02-16 12:40:15 -08:00
|
|
|
|
#include "lib/svn_revision.h"
|
2013-11-10 08:24:03 -08:00
|
|
|
|
#include "lib/external_libraries/libsdl.h"
|
2011-03-21 10:53:13 -07:00
|
|
|
|
#include "lib/posix/posix_utsname.h"
|
2023-07-18 13:32:21 -07:00
|
|
|
|
#include "lib/timer.h"
|
2010-11-20 11:46:49 -08:00
|
|
|
|
#include "lib/sysdep/cpu.h"
|
2011-02-19 16:54:36 -08:00
|
|
|
|
#include "lib/sysdep/numa.h"
|
2010-11-20 11:46:49 -08:00
|
|
|
|
#include "lib/sysdep/os_cpu.h"
|
2023-07-18 13:32:21 -07:00
|
|
|
|
#include "lib/sysdep/smbios.h"
|
|
|
|
|
|
#include "lib/sysdep/sysdep.h" // sys_OpenFile
|
|
|
|
|
|
#include "lib/utf8.h"
|
2020-12-10 10:36:05 -08:00
|
|
|
|
#if CONFIG2_AUDIO
|
|
|
|
|
|
#include "soundmanager/SoundManager.h"
|
|
|
|
|
|
#endif
|
2010-11-20 11:46:49 -08:00
|
|
|
|
#include "ps/CLogger.h"
|
2011-03-02 17:49:49 -08:00
|
|
|
|
#include "ps/ConfigDB.h"
|
2010-11-20 11:46:49 -08:00
|
|
|
|
#include "ps/Filesystem.h"
|
2019-07-24 22:21:25 -07:00
|
|
|
|
#include "ps/GameSetup/Config.h"
|
2016-06-21 03:33:11 -07:00
|
|
|
|
#include "ps/Profile.h"
|
2023-07-18 13:32:21 -07:00
|
|
|
|
#include "ps/Pyrogenesis.h"
|
2020-06-07 13:11:37 -07:00
|
|
|
|
#include "ps/scripting/JSInterface_ConfigDB.h"
|
2019-07-24 22:21:25 -07:00
|
|
|
|
#include "ps/scripting/JSInterface_Debug.h"
|
2011-02-16 12:40:15 -08:00
|
|
|
|
#include "ps/UserReport.h"
|
2010-11-20 11:46:49 -08:00
|
|
|
|
#include "ps/VideoMode.h"
|
2022-05-08 15:02:46 -07:00
|
|
|
|
#include "renderer/backend/IDevice.h"
|
2021-03-01 12:52:24 -08:00
|
|
|
|
#include "scriptinterface/FunctionWrapper.h"
|
2021-05-14 03:18:03 -07:00
|
|
|
|
#include "scriptinterface/JSON.h"
|
2021-05-15 06:54:58 -07:00
|
|
|
|
#include "scriptinterface/Object.h"
|
|
|
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
2023-04-16 15:28:55 -07:00
|
|
|
|
#include "scriptinterface/StructuredClone.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <boost/version.hpp>
|
|
|
|
|
|
#include <fmt/format.h>
|
2010-12-04 11:42:50 -08:00
|
|
|
|
|
2021-12-08 14:14:43 -08:00
|
|
|
|
// FreeType headers might have an include order.
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
|
|
#include <freetype/freetype.h>
|
|
|
|
|
|
|
2021-03-04 00:55:49 -08:00
|
|
|
|
#if OS_LINUX
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2023-04-16 15:28:55 -07:00
|
|
|
|
#if CONFIG2_NVTT
|
|
|
|
|
|
#include "nvtt/nvtt.h"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <random>
|
2021-12-08 14:14:43 -08:00
|
|
|
|
#include <sstream>
|
2021-05-23 15:32:29 -07:00
|
|
|
|
#include <string>
|
2022-08-20 13:40:05 -07:00
|
|
|
|
#include <thread>
|
2021-05-23 15:32:29 -07:00
|
|
|
|
|
2023-04-16 15:28:55 -07:00
|
|
|
|
namespace
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class Reporter
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
Reporter(const ScriptRequest& rq)
|
|
|
|
|
|
: m_Rq(rq), m_LibrarySettings(rq.cx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Script::CreateObject(m_Rq, &m_LibrarySettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename PropertyType>
|
|
|
|
|
|
Reporter& Add(const char* propertyName, const PropertyType& propertyValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
Script::SetProperty(m_Rq, m_LibrarySettings, propertyName, propertyValue);
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JS::Value MakeReport()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Script::DeepCopy(m_Rq, m_LibrarySettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
const ScriptRequest& m_Rq;
|
|
|
|
|
|
JS::RootedValue m_LibrarySettings;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LibraryReporter : public Reporter
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
LibraryReporter(const ScriptRequest& rq, const char* name)
|
|
|
|
|
|
: Reporter(rq)
|
|
|
|
|
|
{
|
|
|
|
|
|
Add("name", name);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
JS::Value MakeSDLReport(const ScriptRequest& rq)
|
|
|
|
|
|
{
|
|
|
|
|
|
LibraryReporter reporter{rq, "sdl"};
|
|
|
|
|
|
|
|
|
|
|
|
SDL_version build, runtime;
|
|
|
|
|
|
SDL_VERSION(&build);
|
|
|
|
|
|
|
|
|
|
|
|
char version[16];
|
|
|
|
|
|
snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", build.major, build.minor, build.patch);
|
|
|
|
|
|
reporter.Add("build_version", version);
|
|
|
|
|
|
|
|
|
|
|
|
SDL_GetVersion(&runtime);
|
|
|
|
|
|
snprintf(version, ARRAY_SIZE(version), "%d.%d.%d", runtime.major, runtime.minor, runtime.patch);
|
|
|
|
|
|
reporter.Add("runtime_version", version);
|
|
|
|
|
|
|
|
|
|
|
|
// This is null in atlas (and further the call triggers an assertion).
|
|
|
|
|
|
const char* backend = g_VideoMode.GetWindow() ? GetSDLSubsystem(g_VideoMode.GetWindow()) : "none";
|
|
|
|
|
|
reporter.Add("video_backend", backend ? backend : "unknown");
|
|
|
|
|
|
|
|
|
|
|
|
reporter.Add("display_count", SDL_GetNumVideoDisplays());
|
|
|
|
|
|
|
|
|
|
|
|
reporter.Add("cpu_count", SDL_GetCPUCount());
|
|
|
|
|
|
reporter.Add("system_ram", SDL_GetSystemRAM());
|
|
|
|
|
|
|
|
|
|
|
|
return reporter.MakeReport();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JS::Value MakeFreeTypeReport(const ScriptRequest& rq)
|
|
|
|
|
|
{
|
|
|
|
|
|
FT_Library FTLibrary;
|
|
|
|
|
|
|
|
|
|
|
|
LibraryReporter libraryReporter{rq, "freetype"};
|
|
|
|
|
|
if (!FT_Init_FreeType(&FTLibrary))
|
|
|
|
|
|
{
|
|
|
|
|
|
FT_Int major, minor, patch;
|
|
|
|
|
|
FT_Library_Version(FTLibrary, &major, &minor, &patch);
|
|
|
|
|
|
FT_Done_FreeType(FTLibrary);
|
|
|
|
|
|
std::stringstream version;
|
|
|
|
|
|
version << major << "." << minor << "." << patch;
|
|
|
|
|
|
libraryReporter.Add("version", version.str());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
libraryReporter.Add("version", "unavailable");
|
|
|
|
|
|
return libraryReporter.MakeReport();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ReportLibraries(const ScriptRequest& rq, JS::HandleValue settings)
|
|
|
|
|
|
{
|
|
|
|
|
|
JS::RootedValue librariesSettings(rq.cx);
|
|
|
|
|
|
Script::CreateArray(rq, &librariesSettings);
|
|
|
|
|
|
int libraryCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
auto appendLibrary = [&rq, &librariesSettings, &libraryCount](const JS::Value& librarySettings)
|
|
|
|
|
|
{
|
|
|
|
|
|
JS::RootedValue value(rq.cx, librarySettings);
|
|
|
|
|
|
Script::SetPropertyInt(rq, librariesSettings, libraryCount++, value);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
appendLibrary(MakeSDLReport(rq));
|
|
|
|
|
|
appendLibrary(MakeFreeTypeReport(rq));
|
|
|
|
|
|
|
|
|
|
|
|
appendLibrary(LibraryReporter{rq, "boost"}.Add("version", BOOST_VERSION).MakeReport());
|
|
|
|
|
|
appendLibrary(LibraryReporter{rq, "fmt"}.Add("version", FMT_VERSION).MakeReport());
|
|
|
|
|
|
#if CONFIG2_NVTT
|
|
|
|
|
|
appendLibrary(LibraryReporter{rq, "nvtt"}
|
|
|
|
|
|
.Add("build_version", NVTT_VERSION)
|
|
|
|
|
|
.Add("runtime_version", nvtt::version())
|
|
|
|
|
|
.MakeReport());
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
Script::SetProperty(rq, settings, "libraries", librariesSettings);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-18 13:32:21 -07:00
|
|
|
|
void WriteSystemInfo(Renderer::Backend::IDevice* device, const utsname& un)
|
|
|
|
|
|
{
|
|
|
|
|
|
TIMER(L"write_sys_info");
|
|
|
|
|
|
|
|
|
|
|
|
OsPath pathname = psLogDir() / "system_info.txt";
|
|
|
|
|
|
FILE* f = sys_OpenFile(pathname, "w");
|
|
|
|
|
|
if(!f)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// current timestamp (redundant WRT OS timestamp, but that is not
|
|
|
|
|
|
// visible when people are posting this file's contents online)
|
|
|
|
|
|
{
|
|
|
|
|
|
wchar_t timestampBuf[100] = {'\0'};
|
|
|
|
|
|
time_t seconds;
|
|
|
|
|
|
time(&seconds);
|
|
|
|
|
|
struct tm* t = gmtime(&seconds);
|
|
|
|
|
|
const size_t charsWritten = wcsftime(timestampBuf, ARRAY_SIZE(timestampBuf), L"(generated %Y-%m-%d %H:%M:%S UTC)", t);
|
|
|
|
|
|
ENSURE(charsWritten != 0);
|
|
|
|
|
|
fprintf(f, "%ls\n\n", timestampBuf);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OS
|
|
|
|
|
|
fprintf(f, "OS : %s %s (%s)\n", un.sysname, un.release, un.version);
|
|
|
|
|
|
|
|
|
|
|
|
// CPU
|
|
|
|
|
|
fprintf(f, "CPU : %s, %s", un.machine, cpu_IdentifierString());
|
|
|
|
|
|
double cpuClock = os_cpu_ClockFrequency(); // query OS (may fail)
|
|
|
|
|
|
#if ARCH_X86_X64
|
|
|
|
|
|
if(cpuClock <= 0.0)
|
|
|
|
|
|
cpuClock = x86_x64::ClockFrequency(); // measure (takes a few ms)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
if(cpuClock > 0.0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(cpuClock < 1e9)
|
|
|
|
|
|
fprintf(f, ", %.2f MHz\n", cpuClock*1e-6);
|
|
|
|
|
|
else
|
|
|
|
|
|
fprintf(f, ", %.2f GHz\n", cpuClock*1e-9);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
|
|
|
|
|
|
|
|
|
// memory
|
|
|
|
|
|
fprintf(f, "Memory : %u MiB; %u MiB free\n", (unsigned)os_cpu_MemorySize(), (unsigned)os_cpu_MemoryAvailable());
|
|
|
|
|
|
|
|
|
|
|
|
// graphics
|
|
|
|
|
|
fprintf(f, "Video Card : %s\n", device->GetName().c_str());
|
|
|
|
|
|
fprintf(f, "Video Driver : %s\n", device->GetDriverInformation().c_str());
|
|
|
|
|
|
fprintf(f, "Video Mode : %dx%d:%d\n", g_VideoMode.GetXRes(), g_VideoMode.GetYRes(), g_VideoMode.GetBPP());
|
|
|
|
|
|
|
|
|
|
|
|
#if CONFIG2_AUDIO
|
|
|
|
|
|
if (g_SoundManager)
|
|
|
|
|
|
{
|
|
|
|
|
|
fprintf(f, "Sound Card : %s\n", g_SoundManager->GetSoundCardNames().c_str());
|
|
|
|
|
|
fprintf(f, "Sound Drivers : %s\n", g_SoundManager->GetOpenALVersion().c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(g_DisableAudio)
|
|
|
|
|
|
fprintf(f, "Sound : Game was ran without audio\n");
|
|
|
|
|
|
else
|
|
|
|
|
|
fprintf(f, "Sound : No audio device was found\n");
|
|
|
|
|
|
#else
|
|
|
|
|
|
fprintf(f, "Sound : Game was compiled without audio\n");
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// OpenGL extensions (write them last, since it's a lot of text)
|
|
|
|
|
|
fprintf(f, "\nBackend Extensions:\n");
|
|
|
|
|
|
if (device->GetExtensions().empty())
|
|
|
|
|
|
fprintf(f, "{unknown}\n");
|
|
|
|
|
|
else
|
|
|
|
|
|
for (const std::string& extension : device->GetExtensions())
|
|
|
|
|
|
fprintf(f, "%s\n", extension.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
// System Management BIOS (even more text than OpenGL extensions)
|
|
|
|
|
|
std::string smbios = SMBIOS::StringizeStructures(SMBIOS::GetStructures());
|
|
|
|
|
|
fprintf(f, "\nSMBIOS: \n%s\n", smbios.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
f = 0;
|
|
|
|
|
|
|
|
|
|
|
|
debug_printf("FILES| Hardware details written to '%s'\n", pathname.string8().c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-16 15:28:55 -07:00
|
|
|
|
} // anonymous namespace
|
2011-02-16 12:40:15 -08:00
|
|
|
|
|
2021-03-01 12:52:24 -08:00
|
|
|
|
void SetDisableAudio(bool disabled)
|
2011-02-24 17:31:00 -08:00
|
|
|
|
{
|
|
|
|
|
|
g_DisableAudio = disabled;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-18 13:32:21 -07:00
|
|
|
|
void RunHardwareDetection(bool writeSystemInfoBeforeDetection, Renderer::Backend::IDevice* device)
|
2010-11-20 11:46:49 -08:00
|
|
|
|
{
|
2023-07-18 13:32:21 -07:00
|
|
|
|
utsname un;
|
|
|
|
|
|
uname(&un);
|
|
|
|
|
|
|
|
|
|
|
|
if (writeSystemInfoBeforeDetection)
|
|
|
|
|
|
WriteSystemInfo(device, un);
|
|
|
|
|
|
|
2011-02-16 12:40:15 -08:00
|
|
|
|
TIMER(L"RunHardwareDetection");
|
|
|
|
|
|
|
2020-11-14 02:57:50 -08:00
|
|
|
|
ScriptInterface scriptInterface("Engine", "HWDetect", g_ScriptContext);
|
2020-11-13 05:18:22 -08:00
|
|
|
|
|
Improve JS Exception handling.
- Check for pending exceptions after function calls and script
executions.
- Call LOGERROR instead of JS_ReportError when there is a conversion
error in FromJSVal, since that can only be called from C++ (where JS
errors don't really make sense). Instead, C++ callers of FromJSVal
should handle the failure and, themselves, either report an error or
simply do something else.
- Wrap JS_ReportError since that makes updating it later easier.
This isn't a systematical fix since ToJSVal also ought return a boolean
for failures, and we probably should trigger errors instead of warnings
on 'implicit' conversions, rather a preparation diff.
Part of the SM52 migration, stage: SM45 compatible (actually SM52
incompatible, too).
Based on a patch by: Itms
Comments by: Vladislavbelov, Stan`
Refs #742, #4893
Differential Revision: https://code.wildfiregames.com/D3093
This was SVN commit r24187.
2020-11-15 10:29:17 -08:00
|
|
|
|
ScriptRequest rq(scriptInterface);
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2019-07-24 22:21:25 -07:00
|
|
|
|
JSI_Debug::RegisterScriptFunctions(scriptInterface); // Engine.DisplayErrorDialog
|
2020-06-07 13:11:37 -07:00
|
|
|
|
JSI_ConfigDB::RegisterScriptFunctions(scriptInterface);
|
2019-07-24 22:21:25 -07:00
|
|
|
|
|
2021-03-01 12:52:24 -08:00
|
|
|
|
ScriptFunction::Register<SetDisableAudio>(rq, "SetDisableAudio");
|
2010-12-04 11:42:50 -08:00
|
|
|
|
|
2010-11-20 11:46:49 -08:00
|
|
|
|
// Load the detection script:
|
|
|
|
|
|
|
|
|
|
|
|
const wchar_t* scriptName = L"hwdetect/hwdetect.js";
|
|
|
|
|
|
CVFSFile file;
|
|
|
|
|
|
if (file.Load(g_VFS, scriptName) != PSRETURN_OK)
|
|
|
|
|
|
{
|
2015-01-22 12:31:30 -08:00
|
|
|
|
LOGERROR("Failed to load hardware detection script");
|
2010-11-20 11:46:49 -08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-05-04 14:48:46 -07:00
|
|
|
|
std::string code = file.DecodeUTF8(); // assume it's UTF-8
|
2010-11-20 11:46:49 -08:00
|
|
|
|
scriptInterface.LoadScript(scriptName, code);
|
|
|
|
|
|
|
|
|
|
|
|
// Collect all the settings we'll pass to the script:
|
2011-02-16 12:40:15 -08:00
|
|
|
|
// (We'll use this same data for the opt-in online reporting system, so it
|
|
|
|
|
|
// includes some fields that aren't directly useful for the hwdetect script)
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2020-11-13 05:18:22 -08:00
|
|
|
|
JS::RootedValue settings(rq.cx);
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::CreateObject(rq, &settings);
|
|
|
|
|
|
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_unix", OS_UNIX);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_bsd", OS_BSD);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_linux", OS_LINUX);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_android", OS_ANDROID);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_macosx", OS_MACOSX);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "os_win", OS_WIN);
|
|
|
|
|
|
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_ia32", ARCH_IA32);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_amd64", ARCH_AMD64);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_arm", ARCH_ARM);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_aarch64", ARCH_AARCH64);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_e2k", ARCH_E2K);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "arch_ppc64", ARCH_PPC64);
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2011-02-16 12:40:15 -08:00
|
|
|
|
#ifdef NDEBUG
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "build_debug", 0);
|
2011-02-16 12:40:15 -08:00
|
|
|
|
#else
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "build_debug", 1);
|
2011-02-16 12:40:15 -08:00
|
|
|
|
#endif
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "build_opengles", CONFIG2_GLES);
|
2012-02-12 05:20:49 -08:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "build_datetime", std::string(__DATE__ " " __TIME__));
|
|
|
|
|
|
Script::SetProperty(rq, settings, "build_revision", std::wstring(svn_revision));
|
2012-02-12 05:20:49 -08:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "build_msc", (int)MSC_VERSION);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "build_icc", (int)ICC_VERSION);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "build_gcc", (int)GCC_VERSION);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "build_clang", (int)CLANG_VERSION);
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2023-07-18 13:32:21 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "gfx_card", device->GetName());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "gfx_drv_ver", device->GetDriverInformation());
|
2020-10-02 00:35:59 -07:00
|
|
|
|
#if CONFIG2_AUDIO
|
2021-01-11 10:56:33 -08:00
|
|
|
|
if (g_SoundManager)
|
|
|
|
|
|
{
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "snd_card", g_SoundManager->GetSoundCardNames());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "snd_drv_ver", g_SoundManager->GetOpenALVersion());
|
2021-01-11 10:56:33 -08:00
|
|
|
|
}
|
2020-10-02 00:35:59 -07:00
|
|
|
|
#endif
|
2020-01-18 08:45:50 -08:00
|
|
|
|
|
2023-04-16 15:28:55 -07:00
|
|
|
|
ReportLibraries(rq, settings);
|
2021-12-08 14:14:43 -08:00
|
|
|
|
|
2022-05-08 15:02:46 -07:00
|
|
|
|
JS::RootedValue backendDeviceSettings(rq.cx);
|
|
|
|
|
|
Script::CreateObject(rq, &backendDeviceSettings);
|
|
|
|
|
|
|
2023-07-18 13:32:21 -07:00
|
|
|
|
device->Report(rq, backendDeviceSettings);
|
2022-05-08 15:02:46 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "renderer_backend", backendDeviceSettings);
|
2011-02-16 12:40:15 -08:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "video_desktop_xres", g_VideoMode.GetDesktopXRes());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "video_desktop_yres", g_VideoMode.GetDesktopYRes());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "video_desktop_bpp", g_VideoMode.GetDesktopBPP());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "video_desktop_freq", g_VideoMode.GetDesktopFreq());
|
2011-08-22 15:34:59 -07:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "uname_sysname", std::string(un.sysname));
|
|
|
|
|
|
Script::SetProperty(rq, settings, "uname_release", std::string(un.release));
|
|
|
|
|
|
Script::SetProperty(rq, settings, "uname_version", std::string(un.version));
|
|
|
|
|
|
Script::SetProperty(rq, settings, "uname_machine", std::string(un.machine));
|
2011-02-16 12:40:15 -08:00
|
|
|
|
|
2011-02-21 10:56:23 -08:00
|
|
|
|
#if OS_LINUX
|
|
|
|
|
|
{
|
|
|
|
|
|
std::ifstream ifs("/etc/lsb-release");
|
|
|
|
|
|
if (ifs.good())
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "linux_release", str);
|
2011-02-21 10:56:23 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "cpu_identifier", std::string(cpu_IdentifierString()));
|
|
|
|
|
|
Script::SetProperty(rq, settings, "cpu_frequency", os_cpu_ClockFrequency());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "cpu_pagesize", (u32)os_cpu_PageSize());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "cpu_largepagesize", (u32)os_cpu_LargePageSize());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "cpu_numprocs", (u32)os_cpu_NumProcessors());
|
2011-02-19 16:54:36 -08:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "numa_numnodes", (u32)numa_NumNodes());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "numa_factor", numa_Factor());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "numa_interleaved", numa_IsMemoryInterleaved());
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "ram_total", (u32)os_cpu_MemorySize());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "ram_total_os", (u32)os_cpu_QueryMemorySize());
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
2011-02-18 16:39:32 -08:00
|
|
|
|
#if ARCH_X86_X64
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "x86_vendor", (u32)x86_x64::Vendor());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "x86_model", (u32)x86_x64::Model());
|
|
|
|
|
|
Script::SetProperty(rq, settings, "x86_family", (u32)x86_x64::Family());
|
2011-02-21 10:56:23 -08:00
|
|
|
|
|
2011-02-18 16:39:32 -08:00
|
|
|
|
u32 caps0, caps1, caps2, caps3;
|
2011-12-27 06:12:31 -08:00
|
|
|
|
x86_x64::GetCapBits(&caps0, &caps1, &caps2, &caps3);
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "x86_caps[0]", caps0);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "x86_caps[1]", caps1);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "x86_caps[2]", caps2);
|
|
|
|
|
|
Script::SetProperty(rq, settings, "x86_caps[3]", caps3);
|
2011-02-18 16:39:32 -08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2021-05-13 10:23:52 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "timer_resolution", timer_Resolution());
|
2020-12-10 10:36:05 -08:00
|
|
|
|
|
2022-08-20 13:40:05 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "hardware_concurrency", std::thread::hardware_concurrency());
|
2023-04-16 15:28:55 -07:00
|
|
|
|
Script::SetProperty(rq, settings, "random_device_entropy", std::random_device{}.entropy());
|
2022-08-20 13:40:05 -07:00
|
|
|
|
|
2019-01-06 13:18:55 -08:00
|
|
|
|
// The version should be increased for every meaningful change.
|
2023-04-16 15:28:55 -07:00
|
|
|
|
const int reportVersion = 21;
|
2012-01-22 05:49:09 -08:00
|
|
|
|
|
2011-02-16 12:40:15 -08:00
|
|
|
|
// Send the same data to the reporting system
|
2018-08-22 15:17:42 -07:00
|
|
|
|
g_UserReporter.SubmitReport(
|
|
|
|
|
|
"hwdetect",
|
2019-01-06 13:18:55 -08:00
|
|
|
|
reportVersion,
|
2021-05-14 03:18:03 -07:00
|
|
|
|
Script::StringifyJSON(rq, &settings, false),
|
|
|
|
|
|
Script::StringifyJSON(rq, &settings, true));
|
2010-11-20 11:46:49 -08:00
|
|
|
|
|
|
|
|
|
|
// Run the detection script:
|
2020-11-14 00:46:32 -08:00
|
|
|
|
JS::RootedValue global(rq.cx, rq.globalValue());
|
2021-05-01 07:04:53 -07:00
|
|
|
|
ScriptFunction::CallVoid(rq, global, "RunHardwareDetection", settings);
|
2010-11-20 11:46:49 -08:00
|
|
|
|
}
|