@elurjs/universal 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/create-app.mjs +15 -8
- package/cli/dev.mjs +45 -16
- package/cli/doctor.mjs +40 -14
- package/cli/elur.mjs +18 -4
- package/docs/INSTALACION-Y-DEV.md +13 -6
- package/package.json +5 -1
- package/targets/linux/CMakeLists.txt +196 -0
- package/targets/linux/README.md +422 -0
- package/targets/linux/ci/tsan.supp +15 -0
- package/targets/linux/generated/elur_module_registrar.cpp +14 -0
- package/targets/linux/generated/module_sources.cmake +5 -0
- package/targets/linux/src/elur_applicator.cpp +5073 -0
- package/targets/linux/src/elur_applicator.h +387 -0
- package/targets/linux/src/elur_clip.cpp +76 -0
- package/targets/linux/src/elur_clip.h +23 -0
- package/targets/linux/src/elur_crypto_module.cpp +121 -0
- package/targets/linux/src/elur_events.h +57 -0
- package/targets/linux/src/elur_fonts.cpp +106 -0
- package/targets/linux/src/elur_fonts.h +31 -0
- package/targets/linux/src/elur_host.cpp +1041 -0
- package/targets/linux/src/elur_host.h +66 -0
- package/targets/linux/src/elur_http_module.cpp +437 -0
- package/targets/linux/src/elur_js.h +40 -0
- package/targets/linux/src/elur_modules.cpp +453 -0
- package/targets/linux/src/elur_modules.h +159 -0
- package/targets/linux/src/elur_renderer.h +46 -0
- package/targets/linux/src/elur_shot.cpp +64 -0
- package/targets/linux/src/elur_shot.h +17 -0
- package/targets/linux/src/elur_skia_a11y.cpp +987 -0
- package/targets/linux/src/elur_skia_a11y.h +146 -0
- package/targets/linux/src/elur_skia_app.cpp +1770 -0
- package/targets/linux/src/elur_skia_app.h +18 -0
- package/targets/linux/src/elur_state_module.cpp +99 -0
- package/targets/linux/src/elur_tck_module.cpp +186 -0
- package/targets/linux/src/elur_ui_module.cpp +84 -0
- package/targets/linux/src/elur_yoga.cpp +452 -0
- package/targets/linux/src/elur_yoga.h +95 -0
- package/targets/linux/src/main.cpp +294 -0
- package/targets/windows/Package.appxmanifest +28 -0
- package/targets/windows/README.md +44 -0
- package/targets/windows/elur-windows.vcxproj +133 -0
- package/targets/windows/packages.config +10 -0
- package/targets/windows/src/elur_crypto_module_win.cpp +106 -0
- package/targets/windows/src/elur_events.h +58 -0
- package/targets/windows/src/elur_host_win.cpp +645 -0
- package/targets/windows/src/elur_host_win.h +75 -0
- package/targets/windows/src/elur_http_module_win.cpp +331 -0
- package/targets/windows/src/elur_js.h +40 -0
- package/targets/windows/src/elur_modules.cpp +460 -0
- package/targets/windows/src/elur_modules.h +159 -0
- package/targets/windows/src/elur_state_module.cpp +99 -0
- package/targets/windows/src/elur_ui_module_win.cpp +75 -0
- package/targets/windows/src/elur_uia_host.h +129 -0
- package/targets/windows/src/elur_win_applicator.cpp +3118 -0
- package/targets/windows/src/elur_win_applicator.h +186 -0
- package/targets/windows/src/elur_yoga.cpp +452 -0
- package/targets/windows/src/elur_yoga.h +95 -0
- package/targets/windows/src/main.cpp +321 -0
package/cli/create-app.mjs
CHANGED
|
@@ -105,9 +105,14 @@ Prerequisitos por plataforma:
|
|
|
105
105
|
compila aparte: \`cmake -B targets/linux/build && cmake --build
|
|
106
106
|
targets/linux/build\` (el scaffold no copia \`targets/linux\` — el
|
|
107
107
|
source está en \`node_modules/@elurjs/universal/targets/linux\`).
|
|
108
|
-
- windows —
|
|
109
|
-
|
|
110
|
-
/
|
|
108
|
+
- windows — nativo: VS Build Tools 2022 (VCTools + MSBuild + Windows
|
|
109
|
+
11 SDK) + clone de \`quickjs-ng\` (el host enlaza \`qjs.lib\`);
|
|
110
|
+
\`msbuild node_modules/@elurjs/universal/targets/windows/
|
|
111
|
+
elur-windows.vcxproj /restore /p:ElurQjsDir=<clone>\` compila el
|
|
112
|
+
exe y resuelve los NuGet (WindowsAppSDK/CppWinRT). El loop dev es
|
|
113
|
+
local — \`dev:windows\` relanza \`elur-windows.exe\`. Desde
|
|
114
|
+
Linux/macOS hacia un host remoto: \`ELUR_WIN_SSH=user@host[:port]\`
|
|
115
|
+
habilita scp + relanzado por \`schtasks\` (ADR-0220).
|
|
111
116
|
|
|
112
117
|
Qué hace cada script:
|
|
113
118
|
- \`bun run dev\` — web: \`targets/web/dist\` + servidor en
|
|
@@ -122,10 +127,11 @@ Qué hace cada script:
|
|
|
122
127
|
- \`bun run dev:linux\` — \`generated/elurApp.js\` + relanza
|
|
123
128
|
\`targets/linux/build/elur-linux\` si hay binario + display;
|
|
124
129
|
\`--full\` además corre \`cmake --build\` del host.
|
|
125
|
-
- \`bun run dev:windows\` —
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
- \`bun run dev:windows\` — en Windows relanza
|
|
131
|
+
\`elur-windows.exe\` compilado (loop local nativo); desde
|
|
132
|
+
Linux/macOS con \`ELUR_WIN_SSH\` hace scp a \`ELUR_WIN_DIR\` y
|
|
133
|
+
relanza remoto por \`schtasks\` (ADR-0220); sin host disponible
|
|
134
|
+
solo deja el bundle en \`generated/\`.
|
|
129
135
|
- \`bun run gen:routes\` — regenera \`src/routes.gen.ts\` cuando hay
|
|
130
136
|
\`app/\` con \`page.ts\` (\`elur dev\` lo corre solo al detectarlo).
|
|
131
137
|
- Builds — \`build:web\` → \`targets/web/dist\` (app.js IIFE +
|
|
@@ -444,7 +450,8 @@ ${agentsDev}
|
|
|
444
450
|
- Prerequisitos: \`bun run gateway\` corriendo + un cliente abierto
|
|
445
451
|
(\`bun run dev\`, \`dev:android\` con APK instalado, \`dev:linux\`
|
|
446
452
|
con el binario en \`targets/linux/build/elur-linux\`, o
|
|
447
|
-
\`dev:windows\` con
|
|
453
|
+
\`dev:windows\` con el host compilado en Windows o remoto por
|
|
454
|
+
\`ELUR_WIN_SSH\`).
|
|
448
455
|
- Guía detallada del flujo y anti-patrones:
|
|
449
456
|
\`docs/skills/elur-sdui-mcp/SKILL.md\`
|
|
450
457
|
- Arquitectura código+superficie y modelo responsive:
|
package/cli/dev.mjs
CHANGED
|
@@ -93,11 +93,23 @@ function restartLinuxHost() {
|
|
|
93
93
|
linuxProc.on("exit", () => { /* el próximo rebuild relanza */ });
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
96
|
-
// ADR-0220: el
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
96
|
+
// ADR-0220: en Windows nativo el loop es local (rebuild → relaunch de
|
|
97
|
+
// elur-windows.exe, igual que Linux). Desde Linux/macOS el host corre
|
|
98
|
+
// remoto (VM/otra máquina) alcanzado por SSH — ELUR_WIN_SSH=user@host
|
|
99
|
+
// [:port] habilita scp a ELUR_WIN_DIR + relanzado por la scheduled task
|
|
100
|
+
// ELUR_WIN_TASK (debe existir y ejecutar elur-windows.exe sin --shot).
|
|
101
|
+
let winProc = null;
|
|
102
|
+
function findWindowsHostBin() {
|
|
103
|
+
for (const p of [
|
|
104
|
+
join(process.cwd(), "targets/windows/x64/Release/elur-windows.exe"),
|
|
105
|
+
join(process.cwd(), "targets/windows/x64/Debug/elur-windows.exe"),
|
|
106
|
+
join(root, "targets/windows/x64/Release/elur-windows.exe"),
|
|
107
|
+
join(root, "targets/windows/x64/Debug/elur-windows.exe"),
|
|
108
|
+
]) {
|
|
109
|
+
if (existsSync(p)) return p;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
101
113
|
function winSshTarget() {
|
|
102
114
|
const raw = process.env.ELUR_WIN_SSH;
|
|
103
115
|
if (!raw) return null;
|
|
@@ -108,14 +120,26 @@ function winSshTarget() {
|
|
|
108
120
|
return { dest: raw, port: "22" };
|
|
109
121
|
}
|
|
110
122
|
function restartWindowsHost() {
|
|
111
|
-
|
|
112
|
-
if (!sshT || noServe) return false;
|
|
113
|
-
const winDir = process.env.ELUR_WIN_DIR ?? "C:/elur/generated";
|
|
114
|
-
const task = process.env.ELUR_WIN_TASK ?? "elur-app-dev";
|
|
123
|
+
if (noServe) return false;
|
|
115
124
|
const genDir = join(process.cwd(), "generated");
|
|
116
125
|
const appName = !devFast && existsSync(join(genDir, "elurApp.es5.qjsc"))
|
|
117
126
|
? "elurApp.es5.qjsc"
|
|
118
127
|
: "elurApp.js";
|
|
128
|
+
if (process.platform === "win32") {
|
|
129
|
+
const bin = findWindowsHostBin();
|
|
130
|
+
if (!bin) return false;
|
|
131
|
+
try { winProc?.kill(); } catch { }
|
|
132
|
+
winProc = spawn(bin, ["--dir", genDir, "--app", appName], {
|
|
133
|
+
cwd: process.cwd(),
|
|
134
|
+
stdio: jsonLogs ? ["ignore", 2, 2] : "inherit",
|
|
135
|
+
});
|
|
136
|
+
winProc.on("exit", () => { /* el próximo rebuild relanza */ });
|
|
137
|
+
return "local";
|
|
138
|
+
}
|
|
139
|
+
const sshT = winSshTarget();
|
|
140
|
+
if (!sshT) return false;
|
|
141
|
+
const winDir = process.env.ELUR_WIN_DIR ?? "C:/elur/generated";
|
|
142
|
+
const task = process.env.ELUR_WIN_TASK ?? "elur-app-dev";
|
|
119
143
|
const scpArgs = ["-P", sshT.port];
|
|
120
144
|
try {
|
|
121
145
|
run("scp", ...scpArgs, join(genDir, "elurSignals.js"),
|
|
@@ -124,22 +148,23 @@ function restartWindowsHost() {
|
|
|
124
148
|
`${sshT.dest}:${winDir}/`);
|
|
125
149
|
run("ssh", "-p", sshT.port, sshT.dest,
|
|
126
150
|
`taskkill /f /im elur-windows.exe 2>nul & schtasks /run /tn ${task}`);
|
|
127
|
-
return
|
|
151
|
+
return "ssh";
|
|
128
152
|
} catch {
|
|
129
153
|
return false;
|
|
130
154
|
}
|
|
131
155
|
}
|
|
132
156
|
const killSsr = () => { try { ssrProc?.kill("SIGKILL"); } catch { } };
|
|
133
157
|
const killLinux = () => { try { linuxProc?.kill("SIGTERM"); } catch { } };
|
|
158
|
+
const killWin = () => { try { winProc?.kill(); } catch { } };
|
|
134
159
|
const stopWeb = () => {
|
|
135
160
|
for (const c of webClients) c.close();
|
|
136
161
|
webClients.clear();
|
|
137
162
|
try { webServer?.stop(true); } catch { }
|
|
138
163
|
webServer = null;
|
|
139
164
|
};
|
|
140
|
-
process.on("exit", () => { killSsr(); killLinux(); stopWeb(); });
|
|
141
|
-
process.on("SIGINT", () => { killSsr(); killLinux(); stopWeb(); process.exit(130); });
|
|
142
|
-
process.on("SIGTERM", () => { killSsr(); killLinux(); stopWeb(); process.exit(143); });
|
|
165
|
+
process.on("exit", () => { killSsr(); killLinux(); killWin(); stopWeb(); });
|
|
166
|
+
process.on("SIGINT", () => { killSsr(); killLinux(); killWin(); stopWeb(); process.exit(130); });
|
|
167
|
+
process.on("SIGTERM", () => { killSsr(); killLinux(); killWin(); stopWeb(); process.exit(143); });
|
|
143
168
|
|
|
144
169
|
const WEB_DIST = () => join(process.cwd(), "targets/web/dist");
|
|
145
170
|
const WEB_MIME = {
|
|
@@ -410,9 +435,13 @@ function rebuild() {
|
|
|
410
435
|
log("dev.build.end", {
|
|
411
436
|
ok: true, ms: Date.now() - t0,
|
|
412
437
|
launch: launched,
|
|
413
|
-
msg: launched
|
|
414
|
-
? "bundle Windows
|
|
415
|
-
:
|
|
438
|
+
msg: launched === "local"
|
|
439
|
+
? "bundle Windows + elur-windows.exe relanzado"
|
|
440
|
+
: launched === "ssh"
|
|
441
|
+
? "bundle Windows copiado + app relanzada (SSH)"
|
|
442
|
+
: process.platform === "win32"
|
|
443
|
+
? "bundle Windows en generated/ (host sin compilar: msbuild node_modules/@elurjs/universal/targets/windows/elur-windows.vcxproj /restore — exige clone quickjs-ng, /p:ElurQjsDir=…)"
|
|
444
|
+
: "bundle Windows en generated/ (ELUR_WIN_SSH no definido)",
|
|
416
445
|
});
|
|
417
446
|
return;
|
|
418
447
|
}
|
package/cli/doctor.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
9
9
|
import { join, relative } from "node:path";
|
|
10
|
-
import { execFileSync } from "node:child_process";
|
|
10
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
11
11
|
|
|
12
12
|
const args = process.argv.slice(2);
|
|
13
13
|
const target = args.includes("--target")
|
|
@@ -25,6 +25,18 @@ function cmdVersion(cmd, argv = ["--version"]) {
|
|
|
25
25
|
} catch { return null; }
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// Binarios cuya versión sale por stderr (ssh -V, scp -V) o cuyo éxito es
|
|
29
|
+
// simplemente resolver — devuelve la primera línea de cualquier stream.
|
|
30
|
+
function cmdProbe(cmd, argv) {
|
|
31
|
+
try {
|
|
32
|
+
const r = spawnSync(cmd, argv, { stdio: ["ignore", "pipe", "pipe"] });
|
|
33
|
+
if (r.error) return null;
|
|
34
|
+
const out = (r.stdout?.toString() || r.stderr?.toString() || "")
|
|
35
|
+
.split("\n")[0].trim();
|
|
36
|
+
return out || "presente";
|
|
37
|
+
} catch { return null; }
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
// T-6 — Google Play exige alineación 16KB en .so (nov 2025). Se leen
|
|
29
41
|
// los program headers ELF sin depender de readelf: PT_LOAD debe tener
|
|
30
42
|
// p_align ≥ 0x4000. Devuelve { align } o null si no es ELF válido.
|
|
@@ -200,19 +212,33 @@ if (target === "linux" || !target) {
|
|
|
200
212
|
|
|
201
213
|
if (target === "windows" || !target) {
|
|
202
214
|
console.log("[doctor] windows");
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
if (process.platform === "win32") {
|
|
216
|
+
// Desarrollo nativo (ADR-0220): VS Build Tools 2022 —
|
|
217
|
+
// VCTools + MSBuild + Windows 11 SDK; NuGet resuelve
|
|
218
|
+
// WindowsAppSDK/CppWinRT con msbuild /restore.
|
|
219
|
+
const msbuild = cmdVersion("msbuild", ["-version"])
|
|
220
|
+
?? cmdVersion("vswhere", ["-latest", "-property", "installationVersion"]);
|
|
221
|
+
msbuild ? ok(`msbuild/vswhere ${msbuild}`)
|
|
222
|
+
: fail("VS Build Tools 2022 ausente — msbuild no resoluble en PATH");
|
|
223
|
+
const cmakeW = cmdVersion("cmake");
|
|
224
|
+
cmakeW ? ok(`${cmakeW}`)
|
|
225
|
+
: warn("cmake ausente — solo se usa para quickjs.lib (prebuilt ya enlazado)");
|
|
226
|
+
const exe = existsSync("targets/windows/x64/Release/elur-windows.exe")
|
|
227
|
+
|| existsSync("targets/windows/x64/Debug/elur-windows.exe");
|
|
228
|
+
exe ? ok("elur-windows.exe compilado — dev:windows lo relanza")
|
|
229
|
+
: warn("host sin compilar: msbuild targets/windows/elur-windows.vcxproj /restore");
|
|
230
|
+
} else {
|
|
231
|
+
// Desarrollo hacia un host remoto (VM/otra máquina): el loop por
|
|
232
|
+
// SSH es opción, no requisito — en Windows el loop es local.
|
|
233
|
+
process.env.ELUR_WIN_SSH
|
|
234
|
+
? ok(`ELUR_WIN_SSH=${process.env.ELUR_WIN_SSH} — push+relaunch remoto`)
|
|
235
|
+
: warn("ELUR_WIN_SSH sin definir — dev:windows solo emite el bundle (loop remoto opcional)");
|
|
236
|
+
const ssh = cmdProbe("ssh", ["-V"]);
|
|
237
|
+
ssh ? ok(`ssh presente (${ssh})`)
|
|
238
|
+
: warn("ssh ausente — scp/relaunch remoto no disponible");
|
|
239
|
+
const scp = cmdProbe("scp", ["-V"]);
|
|
240
|
+
scp ? ok("scp presente") : warn("scp ausente — el bundle no viaja");
|
|
241
|
+
}
|
|
216
242
|
}
|
|
217
243
|
|
|
218
244
|
// ── Firma de release (T-6/3.4): qué fuente resuelve el signingConfig
|
package/cli/elur.mjs
CHANGED
|
@@ -383,10 +383,24 @@ if (target === "web" && args.includes("--ssr")) {
|
|
|
383
383
|
if (existsSync(staleQjsc)) rmSync(staleQjsc, { force: true });
|
|
384
384
|
console.log(`[elur] ${target} (dev-fast) → generated/elurApp.js`);
|
|
385
385
|
} else {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
// QJSC es optimización (init −40%, ADR-0157): sin qjsc disponible
|
|
387
|
+
// el host cae a source JS — misma política graceful que android.
|
|
388
|
+
let qjscOk = false;
|
|
389
|
+
try {
|
|
390
|
+
run("bun", pkg("cli/gen-es5.mjs"),
|
|
391
|
+
"generated/elurApp.js", "generated/elurApp.es5.js");
|
|
392
|
+
run("bun", pkg("cli/gen-qjsc.mjs"), "generated/elurApp.es5.js");
|
|
393
|
+
qjscOk = true;
|
|
394
|
+
} catch (e) {
|
|
395
|
+
const stale = join(project, "generated/elurApp.es5.qjsc");
|
|
396
|
+
if (existsSync(stale)) rmSync(stale, { force: true });
|
|
397
|
+
if (requireQjsc) {
|
|
398
|
+
console.error(`[elur] gen:qjsc FALLÓ con --require-qjsc: ${e.message?.split("\n")[0]}`);
|
|
399
|
+
process.exit(1);
|
|
400
|
+
}
|
|
401
|
+
console.warn(`[elur] gen:qjsc omitido (${e.message?.split("\n")[0]}) — el host cargará source JS`);
|
|
402
|
+
}
|
|
403
|
+
console.log(`[elur] ${target} → generated/elurApp.js${qjscOk ? " + elurApp.es5.qjsc" : " (source — sin qjsc)"}`);
|
|
390
404
|
}
|
|
391
405
|
} else {
|
|
392
406
|
console.error(`[elur] target desconocido: ${target} (web|android|linux|ios|windows)`);
|
|
@@ -111,12 +111,19 @@ Scripts del scaffold (`create-app.mjs`):
|
|
|
111
111
|
`generated/` sin lanzar. `--full` además corre `cmake --build
|
|
112
112
|
targets/linux/build -j4`. Sin dev-fast el host carga
|
|
113
113
|
`elurApp.es5.qjsc` (bytecode) si existe.
|
|
114
|
-
- `bun run dev:windows` → `elur dev --target windows` (ADR-0220):
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
(
|
|
119
|
-
`
|
|
114
|
+
- `bun run dev:windows` → `elur dev --target windows` (ADR-0220): en
|
|
115
|
+
Windows el loop es **nativo local** — relanza `elur-windows.exe`
|
|
116
|
+
(`node_modules/@elurjs/universal/targets/windows/x64/{Release,Debug}/`)
|
|
117
|
+
igual que el loop GTK en Linux. Toolchain: VS Build Tools 2022
|
|
118
|
+
(VCTools + MSBuild + Windows 11 SDK) + clone de `quickjs-ng` (el host
|
|
119
|
+
enlaza `qjs.lib`/`qjs-libc.lib` — `cmake -B build -DQJS_ENABLE_LIBC=ON`
|
|
120
|
+
dentro del clone); `msbuild node_modules/@elurjs/universal/targets/
|
|
121
|
+
windows/elur-windows.vcxproj /restore /p:ElurQjsDir=<clone>` compila
|
|
122
|
+
el exe y resuelve los NuGet (WindowsAppSDK 1.6+, CppWinRT 2.0+). Desde
|
|
123
|
+
Linux/macOS el host corre remoto: `ELUR_WIN_SSH=user@host[:port]`
|
|
124
|
+
habilita `scp` de `elurSignals.js`+bundle a `ELUR_WIN_DIR` (default
|
|
125
|
+
`C:/elur/generated`) + `schtasks /run /tn ELUR_WIN_TASK` (default
|
|
126
|
+
`elur-app-dev`; la tarea debe existir y lanzar `elur-windows.exe`).
|
|
120
127
|
|
|
121
128
|
## 4. Build y distribución
|
|
122
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elurjs/universal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"targets/android/gradle",
|
|
39
39
|
"targets/android/gradlew",
|
|
40
40
|
"targets/android/gradlew.bat",
|
|
41
|
+
"targets/windows",
|
|
42
|
+
"targets/linux",
|
|
43
|
+
"!targets/linux/build*",
|
|
44
|
+
"!targets/linux/skia-libs",
|
|
41
45
|
"NOTICE",
|
|
42
46
|
"THIRD_PARTY_NOTICES.md",
|
|
43
47
|
"!docs/benchmarks",
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.22)
|
|
2
|
+
project(elur-linux CXX C)
|
|
3
|
+
|
|
4
|
+
# Host nativo Linux de Elur Universal (§19.4): QuickJS-ng embebido
|
|
5
|
+
# in-process + GTK4 + Pango + Yoga compartido (native/yoga, fase 0).
|
|
6
|
+
#
|
|
7
|
+
# Deps: pkg-config gtk4 (dev files). En máquinas sin libgtk-4-dev del
|
|
8
|
+
# sistema, los .pc locales se resuelven por PKG_CONFIG_PATH (ver
|
|
9
|
+
# targets/linux/README.md).
|
|
10
|
+
#
|
|
11
|
+
# QuickJS-ng: clone de referencia en <repo>/quickjs-ng (mismo árbol que
|
|
12
|
+
# el vendored Android, pin 60984dc / BC 28 — ADR-0156). Override con
|
|
13
|
+
# -DELUR_QJS_DIR=/ruta/quickjs-ng o cae a FetchContent del tarball pin.
|
|
14
|
+
|
|
15
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
16
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
17
|
+
|
|
18
|
+
find_package(PkgConfig REQUIRED)
|
|
19
|
+
pkg_check_modules(GTK4 REQUIRED IMPORTED_TARGET gtk4 fontconfig libsoup-3.0)
|
|
20
|
+
# ADR-0182: libcrypto (OpenSSL EVP) para el módulo builtin "crypto" —
|
|
21
|
+
# verificación ed25519 de envelopes SDUI. Opcional: sin él el módulo
|
|
22
|
+
# no se compila ni registra y negocia unavailable (fail-loud, no stub).
|
|
23
|
+
pkg_check_modules(LIBCRYPTO IMPORTED_TARGET libcrypto)
|
|
24
|
+
|
|
25
|
+
set(ELUR_NATIVE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../native)
|
|
26
|
+
|
|
27
|
+
# ── QuickJS-ng ─────────────────────────────────────────────────────
|
|
28
|
+
set(ELUR_QJS_DIR "" CACHE PATH "clone local de quickjs-ng (default ../../quickjs-ng)")
|
|
29
|
+
if(NOT ELUR_QJS_DIR)
|
|
30
|
+
set(ELUR_QJS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../quickjs-ng)
|
|
31
|
+
endif()
|
|
32
|
+
if(EXISTS ${ELUR_QJS_DIR}/quickjs.c)
|
|
33
|
+
set(QJS_SRC ${ELUR_QJS_DIR})
|
|
34
|
+
message(STATUS "quickjs-ng desde clone local: ${QJS_SRC}")
|
|
35
|
+
else()
|
|
36
|
+
include(FetchContent)
|
|
37
|
+
FetchContent_Declare(
|
|
38
|
+
quickjs
|
|
39
|
+
URL https://github.com/quickjs-ng/quickjs/archive/60984dc07cbb6b7885303b9542944b114203e918.tar.gz
|
|
40
|
+
)
|
|
41
|
+
FetchContent_MakeAvailable(quickjs)
|
|
42
|
+
set(QJS_SRC ${quickjs_SOURCE_DIR})
|
|
43
|
+
message(STATUS "quickjs-ng via FetchContent: ${QJS_SRC}")
|
|
44
|
+
endif()
|
|
45
|
+
|
|
46
|
+
# 4 fuentes core (mismo set que el cmake de Android)
|
|
47
|
+
add_library(elur-quickjs STATIC
|
|
48
|
+
${QJS_SRC}/dtoa.c
|
|
49
|
+
${QJS_SRC}/libregexp.c
|
|
50
|
+
${QJS_SRC}/libunicode.c
|
|
51
|
+
${QJS_SRC}/quickjs.c
|
|
52
|
+
)
|
|
53
|
+
target_include_directories(elur-quickjs PUBLIC ${QJS_SRC})
|
|
54
|
+
target_compile_definitions(elur-quickjs PRIVATE _GNU_SOURCE)
|
|
55
|
+
target_compile_definitions(elur-quickjs PRIVATE QJS_DISABLE_DEBUGGER)
|
|
56
|
+
set_target_properties(elur-quickjs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
57
|
+
|
|
58
|
+
# ── Yoga compartido (native/yoga — fase 0, ADR-0110: 3.2.1 exige C++20)
|
|
59
|
+
file(GLOB_RECURSE YOGA_SOURCES ${ELUR_NATIVE_DIR}/yoga/*.cpp)
|
|
60
|
+
add_library(elur-yogacore STATIC ${YOGA_SOURCES})
|
|
61
|
+
target_include_directories(elur-yogacore PUBLIC ${ELUR_NATIVE_DIR})
|
|
62
|
+
target_compile_options(elur-yogacore PRIVATE -fexceptions -frtti)
|
|
63
|
+
set_target_properties(elur-yogacore PROPERTIES
|
|
64
|
+
CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON POSITION_INDEPENDENT_CODE ON)
|
|
65
|
+
|
|
66
|
+
# ── Host ───────────────────────────────────────────────────────────
|
|
67
|
+
# Módulos de paquetes (bindings.linux, ADR-0076/0103): el toolchain
|
|
68
|
+
# emite generated/module_sources.cmake con las rutas de los .cpp de
|
|
69
|
+
# cada packages/*/linux + generated/elur_module_registrar.cpp con las
|
|
70
|
+
# llamadas register*. Sin bindings el archivo no existe — el weak
|
|
71
|
+
# symbol de elur_modules.cpp deja el registry vacío.
|
|
72
|
+
set(ELUR_MODULE_SOURCES "")
|
|
73
|
+
set(ELUR_MODULE_REGISTRAR "")
|
|
74
|
+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/generated/module_sources.cmake)
|
|
75
|
+
include(${CMAKE_CURRENT_SOURCE_DIR}/generated/module_sources.cmake)
|
|
76
|
+
set(ELUR_MODULE_REGISTRAR
|
|
77
|
+
${CMAKE_CURRENT_SOURCE_DIR}/generated/elur_module_registrar.cpp)
|
|
78
|
+
endif()
|
|
79
|
+
|
|
80
|
+
# ADR-0187 — perfil de hilos. OFF (default): perfil S, js = ui = hilo
|
|
81
|
+
# GTK. ON: perfil D, el runtime QuickJS corre en un hilo propio con
|
|
82
|
+
# cola de tareas; las ops cruzan al ui como JSON (boundary de marshal
|
|
83
|
+
# real — flushOps/JSValue no cruzan hilos). Pensado para ejercitar el
|
|
84
|
+
# interleaving que Android ya tiene; combinar con -DCMAKE_BUILD_TYPE=
|
|
85
|
+
# Debug + sanitizers para CI de carreras.
|
|
86
|
+
option(ELUR_THREAD_MODEL_D "Perfil D: hilo JS propio + GTK como ui" OFF)
|
|
87
|
+
# TSan sobre el perfil D: -DELUR_TSAN=ON -DELUR_THREAD_MODEL_D=ON.
|
|
88
|
+
option(ELUR_TSAN "ThreadSanitizer (build de CI para perfil D)" OFF)
|
|
89
|
+
|
|
90
|
+
# Carril Skia opt-in (ADR-0123, propuesta skia-renderer-arbol fase 0):
|
|
91
|
+
# libskia.a estática local en targets/linux/skia-libs (gitignored,
|
|
92
|
+
# mismo patrón que skia-libs/<ABI> de Android). Sin la lib el host
|
|
93
|
+
# compila igual — el aplicador queda como stub y renderer=skia cae a
|
|
94
|
+
# views con warn explícito.
|
|
95
|
+
set(ELUR_SKIA_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/skia-libs)
|
|
96
|
+
if(EXISTS ${ELUR_SKIA_LIBS_DIR}/libskia.a)
|
|
97
|
+
pkg_check_modules(FREETYPE REQUIRED IMPORTED_TARGET freetype2)
|
|
98
|
+
add_library(elur-skiatree STATIC
|
|
99
|
+
${ELUR_NATIVE_DIR}/skia-tree/elur_skia_tree.cpp)
|
|
100
|
+
target_include_directories(elur-skiatree PUBLIC
|
|
101
|
+
${ELUR_NATIVE_DIR}/skia-tree ${ELUR_SKIA_LIBS_DIR})
|
|
102
|
+
target_compile_options(elur-skiatree PRIVATE -fexceptions -frtti)
|
|
103
|
+
set_target_properties(elur-skiatree PROPERTIES
|
|
104
|
+
CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON)
|
|
105
|
+
set(ELUR_SKIA_LIB ${ELUR_SKIA_LIBS_DIR}/libskia.a
|
|
106
|
+
${ELUR_SKIA_LIBS_DIR}/libskcms.a)
|
|
107
|
+
message(STATUS "skia opt-in: ${ELUR_SKIA_LIBS_DIR}/libskia.a")
|
|
108
|
+
# Fase 3 — módulos de texto (rebuild con harfbuzz+icu bundled,
|
|
109
|
+
# args del vendor/skia out/linux-text): paragraph+shaper+unicode.
|
|
110
|
+
# Sin libskparagraph.a el árbol cae al path measureText/drawString
|
|
111
|
+
# (ELUR_SKIA_TEXT=1 marca el path completo — PUBLIC: la cabecera
|
|
112
|
+
# cambia de layout y el flag debe llegar a todo consumidor).
|
|
113
|
+
if(EXISTS ${ELUR_SKIA_LIBS_DIR}/libskparagraph.a)
|
|
114
|
+
target_compile_definitions(elur-skiatree PUBLIC ELUR_SKIA_TEXT=1)
|
|
115
|
+
foreach(m skparagraph skshaper skunicode_icu skunicode_core
|
|
116
|
+
icu harfbuzz)
|
|
117
|
+
if(EXISTS ${ELUR_SKIA_LIBS_DIR}/lib${m}.a)
|
|
118
|
+
list(APPEND ELUR_SKIA_LIB ${ELUR_SKIA_LIBS_DIR}/lib${m}.a)
|
|
119
|
+
endif()
|
|
120
|
+
endforeach()
|
|
121
|
+
endif()
|
|
122
|
+
# Fase 4 — backend GPU opt-in: si la libskia trae Ganesh GL
|
|
123
|
+
# (rebuild con skia_use_gl/egl/epoxy_egl) expone ELUR_SKIA_GL y
|
|
124
|
+
# enlaza epoxy; sin esos símbolos backend=gl cae a raster con warn.
|
|
125
|
+
find_program(NM_EXECUTABLE nm)
|
|
126
|
+
if(NM_EXECUTABLE)
|
|
127
|
+
execute_process(COMMAND ${NM_EXECUTABLE} ${ELUR_SKIA_LIBS_DIR}/libskia.a
|
|
128
|
+
OUTPUT_VARIABLE ELUR_SKIA_SYMS ERROR_QUIET)
|
|
129
|
+
if(ELUR_SKIA_SYMS MATCHES "GrDirectContexts6MakeGL")
|
|
130
|
+
target_compile_definitions(elur-skiatree PUBLIC ELUR_SKIA_GL=1)
|
|
131
|
+
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
|
|
132
|
+
list(APPEND ELUR_SKIA_LIB PkgConfig::EPOXY)
|
|
133
|
+
message(STATUS "skia gpu: backend gl disponible (--skia-backend gl)")
|
|
134
|
+
endif()
|
|
135
|
+
endif()
|
|
136
|
+
endif()
|
|
137
|
+
|
|
138
|
+
add_executable(elur-linux
|
|
139
|
+
src/main.cpp
|
|
140
|
+
src/elur_host.cpp
|
|
141
|
+
src/elur_applicator.cpp
|
|
142
|
+
src/elur_skia_app.cpp
|
|
143
|
+
src/elur_skia_a11y.cpp
|
|
144
|
+
src/elur_shot.cpp
|
|
145
|
+
src/elur_yoga.cpp
|
|
146
|
+
${ELUR_NATIVE_DIR}/layout/elur_layout_style.cpp
|
|
147
|
+
src/elur_modules.cpp
|
|
148
|
+
src/elur_state_module.cpp
|
|
149
|
+
src/elur_http_module.cpp
|
|
150
|
+
src/elur_ui_module.cpp
|
|
151
|
+
src/elur_crypto_module.cpp
|
|
152
|
+
src/elur_fonts.cpp
|
|
153
|
+
src/elur_clip.cpp
|
|
154
|
+
src/elur_tck_module.cpp
|
|
155
|
+
${ELUR_MODULE_REGISTRAR}
|
|
156
|
+
${ELUR_MODULE_SOURCES}
|
|
157
|
+
)
|
|
158
|
+
target_include_directories(elur-linux PRIVATE
|
|
159
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
160
|
+
${ELUR_NATIVE_DIR}
|
|
161
|
+
${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
|
162
|
+
target_link_libraries(elur-linux PRIVATE
|
|
163
|
+
elur-quickjs elur-yogacore PkgConfig::GTK4 m dl pthread)
|
|
164
|
+
if(ELUR_SKIA_LIB)
|
|
165
|
+
target_include_directories(elur-linux PRIVATE
|
|
166
|
+
${ELUR_SKIA_LIBS_DIR})
|
|
167
|
+
target_compile_definitions(elur-linux PRIVATE ELUR_HAS_SKIA=1)
|
|
168
|
+
# Skia estático: fontconfig del sistema (ya viene por GTK4) +
|
|
169
|
+
# freetype (skia_use_system_freetype2 de la build oficial).
|
|
170
|
+
target_link_libraries(elur-linux PRIVATE elur-skiatree
|
|
171
|
+
${ELUR_SKIA_LIB} PkgConfig::FREETYPE fontconfig)
|
|
172
|
+
endif()
|
|
173
|
+
if(ELUR_THREAD_MODEL_D)
|
|
174
|
+
target_compile_definitions(elur-linux PRIVATE ELUR_THREAD_MODEL_D=1)
|
|
175
|
+
message(STATUS "perfil de hilos: D (hilo js propio + ui GTK)")
|
|
176
|
+
else()
|
|
177
|
+
message(STATUS "perfil de hilos: S (js = ui = GTK)")
|
|
178
|
+
endif()
|
|
179
|
+
if(ELUR_TSAN)
|
|
180
|
+
target_compile_options(elur-linux PRIVATE -fsanitize=thread -g)
|
|
181
|
+
target_link_options(elur-linux PRIVATE -fsanitize=thread)
|
|
182
|
+
# quickjs/yoga también bajo TSan — un .o sin instrumentar deja
|
|
183
|
+
# huecos en el grafo de happens-before.
|
|
184
|
+
target_compile_options(elur-quickjs PRIVATE -fsanitize=thread -g)
|
|
185
|
+
target_compile_options(elur-yogacore PRIVATE -fsanitize=thread -g)
|
|
186
|
+
target_link_libraries(elur-quickjs PRIVATE -fsanitize=thread)
|
|
187
|
+
target_link_libraries(elur-yogacore PRIVATE -fsanitize=thread)
|
|
188
|
+
message(STATUS "TSan habilitado (usar con ELUR_THREAD_MODEL_D=ON)")
|
|
189
|
+
endif()
|
|
190
|
+
if(LIBCRYPTO_FOUND)
|
|
191
|
+
target_link_libraries(elur-linux PRIVATE PkgConfig::LIBCRYPTO)
|
|
192
|
+
target_compile_definitions(elur-linux PRIVATE ELUR_HAVE_CRYPTO)
|
|
193
|
+
message(STATUS "módulo crypto: OpenSSL EVP Ed25519 habilitado")
|
|
194
|
+
else()
|
|
195
|
+
message(STATUS "módulo crypto: sin libcrypto — negociará unavailable")
|
|
196
|
+
endif()
|