Skip to content

Commit 793156e

Browse files
committed
feat: add Windows x86 (win-x86) release support
1 parent a93d34e commit 793156e

5 files changed

Lines changed: 26 additions & 16 deletions

File tree

docs/printing/render.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ easyink-render render
3434
| 平台 | 产物 |
3535
| --- | --- |
3636
| Windows x64 | `easyink-render-*-win-x64.zip` |
37+
| Windows x86 | `easyink-render-*-win-x86.zip` |
3738
| Linux x64 | `easyink-render-*-linux-x64.tar.gz` |
3839
| Linux arm64 | `easyink-render-*-linux-arm64.tar.gz` |
3940
| macOS x64 | `easyink-render-*-darwin-x64.tar.gz` |
@@ -365,6 +366,6 @@ pnpm render:release:test
365366
pnpm render:host:docker -- --platforms all
366367
```
367368

368-
Windows 手动发布可运行 `lib\EasyInk.Render\build-host.bat`。该脚本使用 Docker 内的 `golang:1.23-bookworm` 交叉编译 host 包,不依赖本机 Go 环境;默认构建 `win-x64`,传入 `all` 可构建全部平台,例如 `lib\EasyInk.Render\build-host.bat all`,也可用 `lib\EasyInk.Render\build-host.bat 0.1.0 all` 指定版本。
369+
Windows 手动发布可运行 `lib\EasyInk.Render\build-host.bat`。该脚本使用 Docker 内的 `golang:1.23-bookworm` 交叉编译 host 包,不依赖本机 Go 环境;默认构建 `win-x64,win-x86`,传入 `all` 可构建全部平台,例如 `lib\EasyInk.Render\build-host.bat all`,也可用 `lib\EasyInk.Render\build-host.bat 0.1.0 all` 指定版本。
369370

370371
`runtime-manifest` 继续描述 host、browser、EasyInk Runtime、平台、版本、下载地址、SHA256 和协议兼容性。新增平台或浏览器包时,需要同步更新 manifest、release tests 和本文档。

lib/EasyInk.Render/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pnpm render:release:test
6363
pnpm render:host:docker -- --platforms all
6464
```
6565

66-
Windows 手动构建发布 host 包时,可直接运行 `build-host.bat`。该脚本通过 Docker 中的 `golang:1.23-bookworm` 交叉编译,不要求本机安装 Go;默认只构建 `win-x64`,例如 `build-host.bat all` 会构建所有 host 平台,`build-host.bat 0.1.0 all` 可指定版本。
66+
Windows 手动构建发布 host 包时,可直接运行 `build-host.bat`。该脚本通过 Docker 中的 `golang:1.23-bookworm` 交叉编译,不要求本机安装 Go;默认构建 `win-x64,win-x86`,例如 `build-host.bat all` 会构建所有 host 平台,`build-host.bat 0.1.0 all` 可指定版本。
6767

6868
## 文档维护约定
6969

lib/EasyInk.Render/build-host.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ set ARG1=%~1
77
set ARG2=%~2
88
set ARG3=%~3
99
set VERSION=
10-
set PLATFORMS=win-x64
10+
set PLATFORMS=win-x64,win-x86
1111
set URL_BASE=
1212
set OUT_DIR=lib/EasyInk.Render/releases
1313

1414
if defined ARG1 (
15-
echo %ARG1% | findstr /i /r "^all$ x64 arm64" >nul
16-
if errorlevel 1 (
15+
echo %ARG1% | findstr /i /r "^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" >nul
16+
if not errorlevel 1 (
1717
set VERSION=%ARG1%
1818
if defined ARG2 set PLATFORMS=%ARG2%
1919
if defined ARG3 set URL_BASE=%ARG3%
@@ -57,4 +57,4 @@ if not "%BUILD_EXIT%"=="0" (
5757

5858
echo.
5959
echo Done: %OUT_DIR%\host
60-
exit /b 0
60+
exit /b 0

lib/EasyInk.Render/tools/render-release.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ const requiredRuntimeMaterials = [
4747
'svg-heart',
4848
'svg',
4949
]
50-
const supportedPlatforms = new Set(['win-x64', 'linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64'])
50+
const supportedPlatforms = new Set(['win-x64', 'win-x86', 'linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64'])
5151
const defaultPlatforms = Array.from(supportedPlatforms)
5252
const defaultChromeForTestingDownloadsURL = 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json'
5353
const hostTargets = {
5454
'win-x64': { goos: 'windows', goarch: 'amd64', executable: 'easyink-render.exe', archive: 'zip' },
55+
'win-x86': { goos: 'windows', goarch: '386', executable: 'easyink-render.exe', archive: 'zip' },
5556
'linux-x64': { goos: 'linux', goarch: 'amd64', executable: 'easyink-render', archive: 'tar.gz' },
5657
'linux-arm64': { goos: 'linux', goarch: 'arm64', executable: 'easyink-render', archive: 'tar.gz' },
5758
'darwin-x64': { goos: 'darwin', goarch: 'amd64', executable: 'easyink-render', archive: 'tar.gz' },
5859
'darwin-arm64': { goos: 'darwin', goarch: 'arm64', executable: 'easyink-render', archive: 'tar.gz' },
5960
}
6061
const browserTargets = {
6162
'win-x64': { cftPlatform: 'win64', executable: 'chrome-headless-shell.exe' },
63+
'win-x86': { cftPlatform: 'win32', executable: 'chrome-headless-shell.exe' },
6264
'linux-x64': { cftPlatform: 'linux64', executable: 'chrome-headless-shell' },
6365
'linux-arm64': { cftPlatform: 'linux-arm64', executable: 'chrome-headless-shell' },
6466
'darwin-x64': { cftPlatform: 'mac-x64', executable: 'chrome-headless-shell' },
@@ -321,11 +323,11 @@ export async function buildBrowserBundle(options) {
321323
}
322324
const outDir = resolve(options.outDir ?? resolve(renderRoot, 'releases'), `browser/${version}/${platform}`)
323325
await mkdir(outDir, { recursive: true })
324-
const archiveName = platform === 'win-x64'
326+
const archiveName = platform.startsWith('win-')
325327
? `chrome-for-testing-${version}-${platform}.zip`
326328
: `chrome-for-testing-${version}-${platform}.tar.gz`
327329
const archivePath = resolve(outDir, archiveName)
328-
if (platform === 'win-x64') {
330+
if (platform.startsWith('win-')) {
329331
await writeFile(archivePath, zipSync(await collectZipTree(browserDir), { level: 9 }))
330332
}
331333
else {

lib/EasyInk.Render/tools/render-release.test.mjs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ describe('render release tooling', () => {
154154
it('parsePlatformList accepts all and comma-separated platform lists', () => {
155155
expect(parsePlatformList('linux-x64,darwin-arm64')).toEqual(['linux-x64', 'darwin-arm64'])
156156
expect(parsePlatformList('all')).toContain('win-x64')
157+
expect(parsePlatformList('all')).toContain('win-x86')
157158
expect(() => parsePlatformList('freebsd-x64')).toThrow('Unsupported platform')
158159
})
159160

@@ -213,7 +214,7 @@ describe('render release tooling', () => {
213214
expect(verified.errors).toEqual([])
214215
})
215216

216-
it('buildHostPackage creates a Windows zip host archive', async () => {
217+
it('buildHostPackage creates a Windows x86 zip host archive', async () => {
217218
const dir = await mkdtemp(join(tmpdir(), 'easyink-render-package-'))
218219
const fakeGo = join(dir, 'fake-go.mjs')
219220
await writeFile(fakeGo, `import { mkdirSync, writeFileSync } from 'node:fs'
@@ -224,19 +225,23 @@ if (outIndex === -1 || !process.argv[outIndex + 1]) {
224225
process.exit(1)
225226
}
226227
const out = process.argv[outIndex + 1]
228+
if (process.env.GOOS !== 'windows' || process.env.GOARCH !== '386') {
229+
process.exit(2)
230+
}
227231
mkdirSync(dirname(out), { recursive: true })
228232
writeFileSync(out, 'fake-host')
229233
`)
230234

231235
const hostPackage = await buildHostPackage({
232-
platform: 'win-x64',
236+
platform: 'win-x86',
233237
version: '0.1.0',
234238
outDir: join(dir, 'out'),
235239
goCommand: process.execPath,
236240
goCommandArgs: [fakeGo],
237241
})
238242

239243
expect(hostPackage.archiveName).toMatch(/\.zip$/)
244+
expect(hostPackage.archiveName).toContain('win-x86')
240245
expect(hostPackage.executable).toBe('easyink-render.exe')
241246
const verified = await verifyPackageReference(
242247
{ size: hostPackage.size, sha256: hostPackage.sha256, executable: hostPackage.executable },
@@ -273,14 +278,15 @@ writeFileSync(out, 'fake-host')
273278
const outDir = join(dir, 'out')
274279

275280
const bundle = await buildBrowserBundle({
276-
platform: 'win-x64',
281+
platform: 'win-x86',
277282
version: '148.0.7778.97',
278283
outDir,
279284
browserDir,
280285
executable: 'headless-shell',
281286
})
282287

283288
expect(bundle.archiveName).toMatch(/\.zip$/)
289+
expect(bundle.archiveName).toContain('win-x86')
284290
const verified = await verifyPackageReference(
285291
{ size: bundle.size, sha256: bundle.sha256, executable: 'headless-shell' },
286292
bundle.archivePath,
@@ -290,14 +296,14 @@ writeFileSync(out, 'fake-host')
290296

291297
it('resolveChromeForTestingDownload maps EasyInk platforms to Chrome for Testing downloads', () => {
292298
const download = resolveChromeForTestingDownload(cftIndex(), {
293-
platform: 'darwin-arm64',
299+
platform: 'win-x86',
294300
version: '148.0.7778.97',
295301
binary: 'chrome-headless-shell',
296302
})
297303

298-
expect(download.cftPlatform).toBe('mac-arm64')
299-
expect(download.executable).toBe('chrome-headless-shell')
300-
expect(download.url).toBe('https://example.test/chrome-headless-shell-mac-arm64.zip')
304+
expect(download.cftPlatform).toBe('win32')
305+
expect(download.executable).toBe('chrome-headless-shell.exe')
306+
expect(download.url).toBe('https://example.test/chrome-headless-shell-win32.zip')
301307
})
302308

303309
it('resolveChromeForTestingDownload fails when a platform is not published', () => {
@@ -365,6 +371,7 @@ function cftIndex() {
365371
{ platform: 'linux64', url: 'https://example.test/chrome-headless-shell-linux64.zip' },
366372
{ platform: 'mac-arm64', url: 'https://example.test/chrome-headless-shell-mac-arm64.zip' },
367373
{ platform: 'win64', url: 'https://example.test/chrome-headless-shell-win64.zip' },
374+
{ platform: 'win32', url: 'https://example.test/chrome-headless-shell-win32.zip' },
368375
],
369376
},
370377
},

0 commit comments

Comments
 (0)