Add KiCad WASM build infrastructure and dependency scripts
- 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>
This commit is contained in:
parent
756feb35da
commit
3034d9d76f
36 changed files with 3708 additions and 0 deletions
76
wasm/kiplatform/secrets.cpp
Normal file
76
wasm/kiplatform/secrets.cpp
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* WASM implementation of kiplatform/secrets.h
|
||||
* Uses browser localStorage for basic secret storage
|
||||
* Note: localStorage is NOT secure for sensitive secrets, but provides
|
||||
* the same API for KiCad functionality that expects secret storage
|
||||
*/
|
||||
|
||||
#include <kiplatform/secrets.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
namespace KIPLATFORM
|
||||
{
|
||||
namespace SECRETS
|
||||
{
|
||||
|
||||
bool StoreSecret( const wxString& aService, const wxString& aKey, const wxString& aSecret )
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
int result = EM_ASM_INT({
|
||||
try {
|
||||
var service = UTF8ToString($0);
|
||||
var key = UTF8ToString($1);
|
||||
var secret = UTF8ToString($2);
|
||||
var storageKey = 'kicad_secret_' + service + '_' + key;
|
||||
localStorage.setItem(storageKey, secret);
|
||||
return 1;
|
||||
} catch(e) {
|
||||
console.warn('Failed to store secret:', e);
|
||||
return 0;
|
||||
}
|
||||
}, aService.utf8_str().data(), aKey.utf8_str().data(), aSecret.utf8_str().data());
|
||||
return result == 1;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GetSecret( const wxString& aService, const wxString& aKey, wxString& aSecret )
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
char* result = (char*)EM_ASM_PTR({
|
||||
try {
|
||||
var service = UTF8ToString($0);
|
||||
var key = UTF8ToString($1);
|
||||
var storageKey = 'kicad_secret_' + service + '_' + key;
|
||||
var secret = localStorage.getItem(storageKey);
|
||||
if (secret === null) {
|
||||
return 0;
|
||||
}
|
||||
var len = lengthBytesUTF8(secret) + 1;
|
||||
var buf = _malloc(len);
|
||||
stringToUTF8(secret, buf, len);
|
||||
return buf;
|
||||
} catch(e) {
|
||||
console.warn('Failed to get secret:', e);
|
||||
return 0;
|
||||
}
|
||||
}, aService.utf8_str().data(), aKey.utf8_str().data());
|
||||
|
||||
if (result) {
|
||||
aSecret = wxString::FromUTF8(result);
|
||||
free(result);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace SECRETS
|
||||
} // namespace KIPLATFORM
|
||||
Loading…
Reference in a new issue