- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh) - Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo - Add placeholder scripts for OpenCASCADE, ngspice, protobuf - Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/) - Add CMake modules for KiCad WASM cross-compilation - Add PCBnew test infrastructure (tests/kicad/) - Add build plan documentation Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2, HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
123 lines
3.2 KiB
C++
123 lines
3.2 KiB
C++
/*
|
|
* WASM implementation of kiplatform/sysinfo.h
|
|
* Provides limited system info available in browser environment
|
|
*/
|
|
|
|
#include <kiplatform/sysinfo.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
#include <emscripten.h>
|
|
#endif
|
|
|
|
namespace KIPLATFORM
|
|
{
|
|
|
|
class SYSINFO_WASM : public SYSINFO_BASE
|
|
{
|
|
public:
|
|
bool GetGPUInfo( std::vector<GPU_INFO>& aGpuInfos ) override
|
|
{
|
|
#ifdef __EMSCRIPTEN__
|
|
GPU_INFO info;
|
|
|
|
// Try to get WebGL renderer info
|
|
char* renderer = (char*)EM_ASM_PTR({
|
|
try {
|
|
var canvas = document.createElement('canvas');
|
|
var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
|
|
if (gl) {
|
|
var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
|
|
if (debugInfo) {
|
|
var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
|
|
var len = lengthBytesUTF8(renderer) + 1;
|
|
var buf = _malloc(len);
|
|
stringToUTF8(renderer, buf, len);
|
|
return buf;
|
|
}
|
|
}
|
|
return 0;
|
|
} catch(e) {
|
|
return 0;
|
|
}
|
|
});
|
|
|
|
if (renderer) {
|
|
info.Name = renderer;
|
|
free(renderer);
|
|
} else {
|
|
info.Name = "WebGL Renderer";
|
|
}
|
|
|
|
info.MemorySize = 0; // Not available in browser
|
|
info.DriverVersion = "WebGL";
|
|
info.Manufacturer = "Browser";
|
|
|
|
aGpuInfos.push_back(info);
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool GetCPUInfo( std::vector<CPU_INFO>& aCpuInfos ) override
|
|
{
|
|
#ifdef __EMSCRIPTEN__
|
|
CPU_INFO info;
|
|
|
|
// Get hardware concurrency (number of logical processors)
|
|
int cores = EM_ASM_INT({
|
|
return navigator.hardwareConcurrency || 1;
|
|
});
|
|
|
|
info.Name = "WebAssembly CPU";
|
|
info.Manufacturer = "Browser";
|
|
info.NumberCores = cores;
|
|
info.NumberLogical = cores;
|
|
|
|
aCpuInfos.push_back(info);
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool GetMemoryInfo( MEMORY_INFO& aMemoryInfo ) override
|
|
{
|
|
#ifdef __EMSCRIPTEN__
|
|
// Try to get memory info from performance.memory (Chrome only)
|
|
// or estimate from WASM heap
|
|
long long heapSize = EM_ASM_INT({
|
|
if (performance && performance.memory) {
|
|
return performance.memory.jsHeapSizeLimit || 0;
|
|
}
|
|
// Return WASM memory size as fallback
|
|
return HEAPU8.length;
|
|
});
|
|
|
|
aMemoryInfo.Usage = 0;
|
|
aMemoryInfo.TotalPhysical = heapSize;
|
|
aMemoryInfo.FreePhysical = heapSize / 2; // Estimate
|
|
aMemoryInfo.TotalPaging = 0;
|
|
aMemoryInfo.FreePaging = 0;
|
|
aMemoryInfo.TotalVirtual = heapSize;
|
|
aMemoryInfo.FreeVirtual = heapSize / 2;
|
|
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
};
|
|
|
|
} // namespace KIPLATFORM
|
|
|
|
// Global instance for the WASM sysinfo implementation
|
|
static KIPLATFORM::SYSINFO_WASM s_sysInfoWasm;
|
|
|
|
// Provide access to the sysinfo implementation
|
|
KIPLATFORM::SYSINFO_BASE* GetSysInfo()
|
|
{
|
|
return &s_sysInfoWasm;
|
|
}
|