feat(jobs): implementacion Win32 — wsl.exe + path translation (issue 0026)
Sustituye el stub Windows por la implementacion real:
C++:
- Bloque #ifdef _WIN32 con CreateProcessW + 3 anonymous pipes
(CreatePipe + SetHandleInformation), STARTF_USESTDHANDLES,
CREATE_NO_WINDOW, ReadFile/WriteFile, WaitForSingleObject con polling
para soportar cancelacion via TerminateProcess.
- Helper to_wsl_path: convierte paths Windows a WSL antes de mandarlos
al subprocess. Soporta:
* "C:\\..." -> "/mnt/c/..."
* "\\\\wsl.localhost\\<distro>\\..." -> "/..."
* "\\\\wsl$\\<distro>\\..." -> "/..."
* "/..." -> tal cual
En POSIX la funcion es no-op.
- build_stdin_json siempre normaliza ops_db_path/app_dir/cache_dir/
registry_root a paths WSL — el run.py corre dentro de WSL y solo
entiende paths /home, /mnt, etc.
- Subprocess invocacion: `wsl.exe --cd <root_wsl> -- <python_wsl> <run_wsl>`.
Asume que el usuario tiene WSL instalado y la distro Ubuntu (o ajusta
FN_REGISTRY_ROOT al UNC adecuado).
- kill_proc unificado: TerminateProcess en Win32, kill(SIGTERM) en POSIX.
- JobControl con HANDLE+pid en Win32, pid_t en POSIX.
main.cpp:
- resolve_registry_root con fallback Windows: si FN_REGISTRY_ROOT env
no esta y getcwd no encuentra registry.db (caso del .exe en Desktop),
usa "\\\\wsl.localhost\\Ubuntu\\home\\lucas\\fn_registry". El usuario
cambia el UNC via env var si su distro tiene otro nombre.
Build:
- cpp/build/windows/apps/graph_explorer/graph_explorer.exe linkea limpio
contra MinGW; solo dependencias windows.h estandar (kernel32, etc.).
- Linux smoke test sigue detectando los 4 enrichers tras la
refactorizacion compartida.
Notas operativas para el usuario Windows:
- Ejecutar el .exe desde C:\\Users\\lucas\\Desktop\\apps\\graph_explorer\\
(doble clic). El primer arranque tarda ~1 s mas por cold-start de wsl.exe.
- Si la distro no es Ubuntu, setear FN_REGISTRY_ROOT con el UNC correcto
(ej. "\\\\wsl.localhost\\Debian\\home\\lucas\\fn_registry").
- Cancelar un job en Windows usa TerminateProcess (mas brutal que SIGTERM
pero los run.py no tienen estado critico — sqlite3 rollback automatico
por la transaccion implicita).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -253,25 +253,40 @@ static bool load_input(bool first_load = true);
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Devuelve el path absoluto al root de fn_registry. Estrategia:
|
||||
// 1) FN_REGISTRY_ROOT env var
|
||||
// 2) Sube desde getcwd() buscando un dir con `registry.db`
|
||||
// 3) "" si no se encuentra
|
||||
// 1) FN_REGISTRY_ROOT env var (acepta path Linux o UNC Windows
|
||||
// `\\\\wsl.localhost\\Ubuntu\\home\\...`).
|
||||
// 2) Sube desde getcwd() buscando un dir con `registry.db`.
|
||||
// 3) En Windows, fallback al UNC default `\\\\wsl.localhost\\Ubuntu\\home\\
|
||||
// lucas\\fn_registry` (la build se distribuye al desktop fuera del
|
||||
// arbol del registry, asi que getcwd nunca lo encuentra).
|
||||
// 4) "" si no se encuentra.
|
||||
static std::string resolve_registry_root() {
|
||||
if (const char* env = std::getenv("FN_REGISTRY_ROOT")) {
|
||||
if (env && *env) return env;
|
||||
}
|
||||
char cwd[4096];
|
||||
if (getcwd(cwd, sizeof(cwd)) == nullptr) return "";
|
||||
std::string p = cwd;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::string probe = p + "/registry.db";
|
||||
FILE* f = std::fopen(probe.c_str(), "rb");
|
||||
if (f) { std::fclose(f); return p; }
|
||||
size_t s = p.find_last_of('/');
|
||||
if (s == std::string::npos || s == 0) break;
|
||||
p = p.substr(0, s);
|
||||
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
|
||||
std::string p = cwd;
|
||||
#ifdef _WIN32
|
||||
// Normalizar separadores para comparar.
|
||||
for (char& c : p) if (c == '\\') c = '/';
|
||||
#endif
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::string probe = p + "/registry.db";
|
||||
FILE* f = std::fopen(probe.c_str(), "rb");
|
||||
if (f) { std::fclose(f); return p; }
|
||||
size_t s = p.find_last_of('/');
|
||||
if (s == std::string::npos || s == 0) break;
|
||||
p = p.substr(0, s);
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
// Fallback Windows: el UNC apunta al WSL del usuario. Ajustar el nombre
|
||||
// de la distro si no es "Ubuntu". La build Linux/WSL nunca llega aqui.
|
||||
return "\\\\wsl.localhost\\Ubuntu\\home\\lucas\\fn_registry";
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user