diff --git a/appveyor.yml b/appveyor.yml index eba88de5aa..89eb4f250a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,11 +11,11 @@ clone_script: - cmd: git init . - cmd: git remote add origin https://github.com/whistlegraph/aesthetic-computer.git - cmd: git config core.sparseCheckout true - - cmd: echo xbox/native-latency/>>.git\info\sparse-checkout - - cmd: echo xbox/dynamic-shell/>>.git\info\sparse-checkout - cmd: echo xbox/assets/>>.git\info\sparse-checkout + - cmd: echo xbox/live/>>.git\info\sparse-checkout - cmd: echo xbox/native-bios/>>.git\info\sparse-checkout - cmd: echo xbox/runtime/>>.git\info\sparse-checkout + - cmd: echo xbox/test-native-windows.cmd>>.git\info\sparse-checkout - cmd: echo appveyor.yml>>.git\info\sparse-checkout - cmd: git fetch --depth=1 --filter=blob:none origin %APPVEYOR_REPO_COMMIT% - cmd: git checkout --detach FETCH_HEAD @@ -43,7 +43,7 @@ install: $graphics.Dispose(); $bitmap.Dispose() } $password = ConvertTo-SecureString $env:cert_password -AsPlainText -Force - foreach ($project in @('xbox\native-latency', 'xbox\dynamic-shell', 'xbox\native-bios')) { + foreach ($project in @('xbox\native-bios')) { $root = Join-Path $env:APPVEYOR_BUILD_FOLDER $project $assets = Join-Path $root 'Assets' New-Item -ItemType Directory -Force $assets | Out-Null @@ -56,26 +56,13 @@ install: -KeyUsage DigitalSignature -KeyExportPolicy Exportable -HashAlgorithm SHA256 ` -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3') ` -FriendlyName 'AC Xbox CI' -CertStoreLocation 'Cert:\CurrentUser\My' - $key = if ($project -like '*native-latency') { 'XboxLatency_TemporaryKey.pfx' } elseif ($project -like '*native-bios') { 'NativeBios_TemporaryKey.pfx' } else { 'DynamicShell_TemporaryKey.pfx' } + $key = 'NativeBios_TemporaryKey.pfx' Export-PfxCertificate -Cert $cert -FilePath (Join-Path $root $key) -Password $password | Out-Null } $master.Dispose() build_script: - - cmd: >- - msbuild "xbox\native-latency\XboxLatency.sln" /restore /m - /p:Configuration=Release /p:Platform=x64 - /p:GenerateAppxPackageOnBuild=true /p:AppxBundle=Never - /p:UapAppxPackageBuildMode=SideloadOnly - /p:PackageCertificatePassword=%cert_password% - /p:AppxPackageDir=%package_dir%native-latency\ - - cmd: >- - msbuild "xbox\dynamic-shell\DynamicShell.sln" /restore /m - /p:Configuration=Release /p:Platform=x64 - /p:GenerateAppxPackageOnBuild=true /p:AppxBundle=Never - /p:UapAppxPackageBuildMode=SideloadOnly - /p:PackageCertificatePassword=%cert_password% - /p:AppxPackageDir=%package_dir%dynamic-shell\ + - cmd: call xbox\test-native-windows.cmd - cmd: >- msbuild "xbox\native-bios\NativeBios.sln" /restore /m /p:Configuration=Release /p:Platform=x64 @@ -84,13 +71,7 @@ build_script: /p:PackageCertificatePassword=%cert_password% /p:AppxPackageDir=%package_dir%native-bios\ -test: off - artifacts: - - path: artifacts\native-latency\**\* - name: xbox-native-latency-x64 - - path: artifacts\dynamic-shell\**\* - name: xbox-dynamic-shell-x64 - path: artifacts\native-bios\**\* name: xbox-native-bios-x64 diff --git a/xbox/live/tests/controller-probe.test.mjs b/xbox/live/tests/controller-probe.test.mjs index e383b0eb24..390d3dc884 100644 --- a/xbox/live/tests/controller-probe.test.mjs +++ b/xbox/live/tests/controller-probe.test.mjs @@ -10,7 +10,7 @@ function harness({ online = true, pads = [] } = {}) { let input = { leftX: 0, leftY: 0, rightX: 0, rightY: 0, leftTrigger: 0, rightTrigger: 0, down: [] }; const caps = { online, networkLevel: online ? "internet" : "none", - networkName: online ? "TEST LAN" : "", version: "1.0.0.9", + networkName: online ? "TEST LAN" : "", version: "1.0.0.10", width: 1920, height: 1080 }; const globals = { Math, JSON, diff --git a/xbox/native-bios/App.cpp b/xbox/native-bios/App.cpp index 9b38e79bf9..1bd46f23d3 100644 --- a/xbox/native-bios/App.cpp +++ b/xbox/native-bios/App.cpp @@ -139,7 +139,7 @@ public: m_sound->on_stop = [this]() { if (m_voice) { m_voice->Stop(0); m_voice->FlushSourceBuffers(); } }; m_sound->get_rate = [this]() { return static_cast(m_sampleRate); }; m_api = std::make_unique(Api{{1920, 1080, 1}, {}, {}, {}, *m_graphics, *m_sound}); - m_api->system.version = "1.0.0.9"; + m_api->system.version = "1.0.0.10"; m_api->telemetry = [](std::string_view line) { std::string safe(line); for (auto& character : safe) if (character == '\n' || character == '\r') character = ' '; diff --git a/xbox/native-bios/Package.appxmanifest b/xbox/native-bios/Package.appxmanifest index 8184147ce9..6fa058d63e 100644 --- a/xbox/native-bios/Package.appxmanifest +++ b/xbox/native-bios/Package.appxmanifest @@ -5,7 +5,7 @@ IgnorableNamespaces="uap mp"> + Version="1.0.0.10" /> diff --git a/xbox/native-bios/README.md b/xbox/native-bios/README.md index f545e4be60..1a32d5750f 100644 --- a/xbox/native-bios/README.md +++ b/xbox/native-bios/README.md @@ -29,6 +29,7 @@ credentials never enter the repository or command output. ```bash node xbox/tools/live.mjs status +node xbox/tools/live.mjs install xbox/builds/1.0.0.10/NativeBios_1.0.0.10_x64.msix xbox/builds/1.0.0.10/Microsoft.VCLibs.x64.14.00.appx node xbox/tools/live.mjs deploy xbox/live/controller-probe.js node xbox/tools/live.mjs logs 100 ``` @@ -37,6 +38,12 @@ The `deploy` command publishes sandboxed JavaScript into the installed package's `LocalState/live-piece.js`, launches the newest installed BIOS revision, and prints recent telemetry. +After a successful Native BIOS install, the tool removes stale uninstallable AC +development packages from earlier experiments. Cleanup is restricted to our +`CN=AestheticComputerDev` publisher or `AestheticComputer.*` package namespace, +and always preserves `AestheticComputer.NativeBios`; system and unrelated dev +packages are never targeted. `prune` is also available as an explicit command. + ## Build AppVeyor builds `NativeBios.sln` for Release x64 and emits the distinct diff --git a/xbox/test-native-windows.cmd b/xbox/test-native-windows.cmd new file mode 100644 index 0000000000..ac50f6cfd4 --- /dev/null +++ b/xbox/test-native-windows.cmd @@ -0,0 +1,39 @@ +@echo off +setlocal enabledelayedexpansion + +for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do set "VSROOT=%%i" +if not defined VSROOT exit /b 2 +call "%VSROOT%\VC\Auxiliary\Build\vcvars64.bat" >nul || exit /b 2 + +set "ROOT=%~dp0.." +set "BUILD=%TEMP%\ac-xbox-native-tests" +if exist "%BUILD%" rmdir /s /q "%BUILD%" +mkdir "%BUILD%" || exit /b 2 + +node --check "%ROOT%\xbox\live\controller-probe.js" || exit /b 1 +node "%ROOT%\xbox\live\tests\controller-probe.test.mjs" || exit /b 1 + +cl /nologo /std:c++20 /EHsc /W4 ^ + /I"%ROOT%\xbox\runtime\include" ^ + "%ROOT%\xbox\runtime\tests\runtime_contract.cpp" ^ + /Fe:"%BUILD%\runtime-contract.exe" || exit /b 1 +"%BUILD%\runtime-contract.exe" || exit /b 1 + +set "QJS=%ROOT%\xbox\native-bios\third_party\quickjs-ng" +for %%f in (quickjs dtoa libregexp libunicode) do ( + cl /nologo /c /O2 /TC /std:c17 /experimental:c11atomics ^ + /DQUICKJS_NG_BUILD /wd4146 /wd4703 /I"%QJS%" ^ + "%QJS%\%%f.c" /Fo:"%BUILD%\%%f.obj" || exit /b 1 +) + +cl /nologo /O2 /EHsc /std:c++17 /W4 /DQUICKJS_NG_BUILD ^ + /I"%ROOT%\xbox\native-bios" /I"%ROOT%\xbox\runtime\include" /I"%QJS%" ^ + "%ROOT%\xbox\native-bios\QuickJsEngine.cpp" ^ + "%ROOT%\xbox\native-bios\tests\quickjs_engine_smoke.cpp" ^ + "%BUILD%\quickjs.obj" "%BUILD%\dtoa.obj" ^ + "%BUILD%\libregexp.obj" "%BUILD%\libunicode.obj" ^ + /Fe:"%BUILD%\quickjs-smoke.exe" || exit /b 1 +"%BUILD%\quickjs-smoke.exe" || exit /b 1 + +echo xbox native Windows preflight: all tests passed +exit /b 0 diff --git a/xbox/tools/live.mjs b/xbox/tools/live.mjs index f053cee3ee..3f98ac7235 100644 --- a/xbox/tools/live.mjs +++ b/xbox/tools/live.mjs @@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process"; import { existsSync, readFileSync } from "node:fs"; import { homedir } from "node:os"; -import { resolve } from "node:path"; +import { basename, resolve } from "node:path"; const defaultEnv = resolve(homedir(), "aesthetic-computer/aesthetic-computer-vault/xbox/device-portal.env"); @@ -61,6 +61,47 @@ function installed() { return item; } +const sleep = (milliseconds) => + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds); + +function prune() { + const stale = curl(["-u", auth, `${base}/api/app/packagemanager/packages`], { json: true }) + .InstalledPackages.filter((item) => item.PackageFamilyName !== "AestheticComputer.NativeBios") + .filter((item) => item.CanUninstall !== false) + .filter((item) => item.Publisher === "CN=AestheticComputerDev" || + item.PackageFamilyName.startsWith("AestheticComputer.")); + for (const item of stale) { + const query = new URLSearchParams({ package: item.PackageFullName }); + curl(["-u", autoAuth, "-X", "DELETE", + `${base}/api/app/packagemanager/package?${query}`]); + console.log(`removed stale AC dev package ${item.PackageFullName}`); + } + if (stale.length === 0) console.log("no stale AC dev packages installed"); + return stale.length; +} + +function install(packagePath, dependencyPaths = []) { + if (!packagePath) throw new Error("usage: xbox-live install [dependency.appx ...]"); + const main = resolve(packagePath); + const dependencies = dependencyPaths.map((item) => resolve(item)); + for (const file of [main, ...dependencies]) + if (!existsSync(file)) throw new Error(`package file not found: ${file}`); + const revision = Number.parseInt(basename(main).match(/_1\.0\.0\.(\d+)_/)?.[1] || "0", 10); + const form = [main, ...dependencies].flatMap((file) => ["-F", `file=@${file}`]); + const query = new URLSearchParams({ package: basename(main) }); + curl(["-u", autoAuth, "-X", "POST", ...form, + `${base}/api/app/packagemanager/package?${query}`]); + let ready = false; + for (let attempt = 0; attempt < 60; attempt++) { + sleep(1000); + const current = packages()[0]; + if (current && current.Version.Revision >= revision) { ready = true; break; } + } + if (!ready) throw new Error(`timed out waiting for Native BIOS revision ${revision}`); + console.log(`installed ${installed().PackageFullName}`); + prune(); +} + function appFileUrl(item, filename) { const query = new URLSearchParams({ knownfolderid: "LocalAppData", packagefullname: item.PackageFullName, path: "\\LocalState", @@ -105,13 +146,15 @@ function logs(tail = "80") { } function main() { - const [command = "status", argument] = process.argv.slice(2); + const [command = "status", argument, ...rest] = process.argv.slice(2); if (command === "status") status(); + else if (command === "install") install(argument, rest); + else if (command === "prune") prune(); else if (command === "launch") launch(); else if (command === "publish") publish(argument); else if (command === "logs") logs(argument); else if (command === "deploy") { publish(argument); launch(); logs("20"); } - else throw new Error("commands: status | launch | publish | logs [lines] | deploy "); + else throw new Error("commands: status | install [deps...] | prune | launch | publish | logs [lines] | deploy "); } try { main(); } catch (error) { console.error(error.message); process.exit(1); }