build: bundle adb platform tools

This commit is contained in:
Your Name committed 2026-06-27 17:59:36 +08:00
1 parent ecbd07cea0
commit f257c4e3fc
11 files changed
+207 -6

No files matched your search

+3 -2
View File
@@ -69,6 +69,7 @@ dist\DouyinGuaji-<version>\
- `web_gui.exe`:Web GUI 服务入口
- `run_cli.exe`:后台运行入口,桌面 GUI / Web GUI 会调用它
- `assets/`、`webui/`、`config/`:运行所需资源
- `platform-tools/`:随包 ADB 运行组件,至少包含 `adb.exe`、`AdbWinApi.dll`、`AdbWinUsbApi.dll`
- `logs/`、`pic/`、`state/`:运行时输出目录
- `license.dat`:默认不随包分发;仅本地测试包需要时才使用 `-IncludeLicense` 显式复制
@@ -95,8 +96,8 @@ dist\installer\DouyinGuaji-3.3.3-Setup.exe
## 发给别人前检查
- 打包脚本会自动运行 `python -m tools.distribution_manifest dist\DouyinGuaji-<version>`,防止源码、调试产物、个人配置和旧日志混入分发目录。
- 最终分发目录只应保留根目录三个 exe、一个 `_internal/`、运行时白名单 `assets/`、运行时白名单 `webui/`、`config/README.md`、`logs/.keep`、`pic/.keep`、`state/.keep`。正式分发不要包含 `license.dat`、`README.md`、`artifacts/`、`tests/`、源码目录、调试截图、临时模板或 debug/README 页面。
- 目标电脑需要能使用 ADB,或者把 Android platform-tools 加入 PATH。
- 最终分发目录只应保留根目录三个 exe、一个 `_internal/`、运行时白名单 `assets/`、运行时白名单 `webui/`、`platform-tools/` 中的 ADB 白名单文件、`config/README.md`、`logs/.keep`、`pic/.keep`、`state/.keep`。正式分发不要包含 `license.dat`、`README.md`、`artifacts/`、`tests/`、源码目录、调试截图、临时模板或 debug/README 页面。
- 正式包会自带 ADB,不要求目标电脑额外安装 Android platform-tools 或配置 PATH。新电脑仍需要在手机上开启开发者选项/USB 调试并允许本机 RSA 授权;部分品牌手机首次 USB 识别还需要 Windows 能正确安装对应 USB 驱动。
- 首次启动 PaddleOCR 相关组件可能较慢,杀毒软件也可能扫描 exe。
- `config/config.json` 是本地运行配置,默认不随安装包带个人配置;让使用者首次打开后在 GUI 中保存配置。
- 默认 Cython 编译后仍要以 `python -m tools.distribution_manifest dist\DouyinGuaji-<version>` 的结果为准;PASS 才能发给别人。使用 `-NoCythonForDevOnly` 生成的明文包禁止分发。
+57
View File
@@ -8,6 +8,7 @@ param(
[switch]$PackExeForce,
[switch]$IncludeLicense,
[switch]$ReuseCache,
[string]$PlatformToolsDir = "",
[string]$UpxDir = ""
)
@@ -185,6 +186,62 @@ foreach ($dir in @("logs", "pic", "state")) {
New-Item -ItemType File -Force (Join-Path $runtimeDir ".keep") | Out-Null
}
$PlatformToolCandidates = @()
if ($PlatformToolsDir) {
$PlatformToolCandidates += $PlatformToolsDir
}
foreach ($envName in @("ANDROID_PLATFORM_TOOLS", "ANDROID_HOME", "ANDROID_SDK_ROOT")) {
$envValue = [Environment]::GetEnvironmentVariable($envName)
if (-not $envValue) {
continue
}
if ($envName -eq "ANDROID_PLATFORM_TOOLS") {
$PlatformToolCandidates += $envValue
} else {
$PlatformToolCandidates += (Join-Path $envValue "platform-tools")
}
}
if ($env:LOCALAPPDATA) {
$PlatformToolCandidates += (Join-Path $env:LOCALAPPDATA "platform-tools")
}
$PlatformToolCandidates += (Join-Path $Root "platform-tools")
$ResolvedPlatformTools = ""
foreach ($candidate in $PlatformToolCandidates) {
if (-not $candidate) {
continue
}
$adbCandidate = Join-Path $candidate "adb.exe"
if (Test-Path $adbCandidate) {
$ResolvedPlatformTools = (Resolve-Path $candidate).Path
break
}
}
if (-not $ResolvedPlatformTools) {
throw "Missing Android platform-tools. Provide -PlatformToolsDir or install it under LOCALAPPDATA\platform-tools."
}
$PlatformToolsTarget = Join-Path $DistRoot "platform-tools"
if (Test-Path $PlatformToolsTarget) {
Remove-Item -LiteralPath $PlatformToolsTarget -Recurse -Force
}
New-Item -ItemType Directory -Force $PlatformToolsTarget | Out-Null
$PlatformToolFiles = @(
"adb.exe",
"AdbWinApi.dll",
"AdbWinUsbApi.dll",
"NOTICE.txt",
"source.properties"
)
foreach ($name in $PlatformToolFiles) {
$src = Join-Path $ResolvedPlatformTools $name
if ($name -in @("adb.exe", "AdbWinApi.dll", "AdbWinUsbApi.dll") -and -not (Test-Path $src)) {
throw "Missing required platform-tools file: $name"
}
if (Test-Path $src) {
Copy-Item -LiteralPath $src -Destination (Join-Path $PlatformToolsTarget $name) -Force
}
}
$licensePath = Join-Path $Root "license.dat"
if ($IncludeLicense -and (Test-Path $licensePath)) {
Copy-Item -LiteralPath $licensePath -Destination (Join-Path $DistRoot "license.dat") -Force