From 0b0ad4acd697ade79a39f5a6cebd9fe9a5f21006 Mon Sep 17 00:00:00 2001 From: Yule Date: Fri, 10 Apr 2026 03:55:23 +0800 Subject: [PATCH] fix: android target_os is android not linux --- deploy.ps1 | 96 ------------------------------------------------ rust/Cargo.toml | 2 +- rust/src/main.rs | 6 +-- 3 files changed, 4 insertions(+), 100 deletions(-) delete mode 100644 deploy.ps1 diff --git a/deploy.ps1 b/deploy.ps1 deleted file mode 100644 index 443dbaa..0000000 --- a/deploy.ps1 +++ /dev/null @@ -1,96 +0,0 @@ -# LuminPro 一键构建部署脚本 -# 用法: .\deploy.ps1 [-Message "commit message"] -param( - [string]$Message = "chore: update" -) - -Set-StrictMode -Version Latest -$ErrorActionPreference = "Stop" - -$repo = "YuleBest/LuminPro" -$distDir = Join-Path $PSScriptRoot ".dist" - -# ── 1. git add + commit + push ──────────────────────────────────────────────── -Write-Host "`n[1/4] 提交并推送..." -ForegroundColor Cyan - -$dirty = git status --porcelain -if (-not $dirty) { - Write-Host " 工作区无改动,仍继续等待最新 Run(若需强制触发请手动改动文件)" -ForegroundColor Yellow -} else { - git add -A - git commit -m $Message - git push - Write-Host " 推送完成" -ForegroundColor Green -} - -# ── 2. 取最新触发的 Run ID(等待 CI 开始排队) ────────────────────────────── -Write-Host "`n[2/4] 等待 GitHub Actions 开始..." -ForegroundColor Cyan - -$commitSha = git rev-parse HEAD -$runId = $null -$waited = 0 - -while (-not $runId) { - Start-Sleep -Seconds 3 - $waited += 3 - if ($waited -gt 60) { - Write-Error "等待超时:60 秒内未找到对应 Run,请检查 Actions 是否已触发。" - } - $runId = gh run list --repo $repo --commit $commitSha --limit 1 --json databaseId -q ".[0].databaseId" 2>$null -} - -Write-Host " Run ID: $runId" -ForegroundColor Green - -# ── 3. 等待 CI 完成 ─────────────────────────────────────────────────────────── -Write-Host "`n[3/4] 等待构建完成(可能需要数分钟)..." -ForegroundColor Cyan - -$spinChars = '|', '/', '-', '\' -$spinIdx = 0 -while ($true) { - Start-Sleep -Seconds 5 - $json = gh run view $runId --repo $repo --json status,conclusion 2>$null | ConvertFrom-Json - $status = $json.status - $conclusion = $json.conclusion - - $spin = $spinChars[$spinIdx % $spinChars.Count] - $spinIdx++ - Write-Host "`r $spin 状态: $status " -NoNewline - - if ($status -eq "completed") { - Write-Host "" - if ($conclusion -ne "success") { - Write-Error "构建失败($conclusion),请前往 https://github.com/$repo/actions/runs/$runId 查看日志。" - } - break - } -} - -Write-Host " 构建成功!" -ForegroundColor Green - -# ── 4. 下载 artifact 到 .dist ───────────────────────────────────────────────── -Write-Host "`n[4/4] 下载 artifact 到 .dist ..." -ForegroundColor Cyan - -if (Test-Path $distDir) { - Remove-Item $distDir -Recurse -Force -} -New-Item -ItemType Directory -Path $distDir | Out-Null - -# gh run download 把 artifact 内容放入 --dir// 子目录。 -# artifact 内只有一个模块 zip,把它移到 .dist 根,删掉空子目录。 -gh run download $runId --repo $repo --dir $distDir - -$subdirs = @(Get-ChildItem $distDir -Directory) -if ($subdirs.Count -eq 1) { - $sub = $subdirs[0].FullName - Get-ChildItem $sub | Move-Item -Destination $distDir -Force - Remove-Item $sub -Force -} - -# 打印结果 -$zipInDist = Get-ChildItem $distDir -Filter "*.zip" | Select-Object -First 1 -Write-Host "`n完成!" -ForegroundColor Green -Write-Host " 本地目录 : $distDir" -ForegroundColor White -Write-Host " Actions : https://github.com/$repo/actions/runs/$runId" -ForegroundColor White -if ($zipInDist) { - Write-Host " ZIP 文件 : $($zipInDist.FullName)" -ForegroundColor White -} diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1d7b7c9..0938dcf 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,7 +8,7 @@ name = "lumipro" path = "src/main.rs" # Linux/Android 专用依赖(本地 Windows 不编译,仅 GitHub Actions 使用) -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] inotify = "0.10" libc = "0.2" diff --git a/rust/src/main.rs b/rust/src/main.rs index f1c22e1..8247b05 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -10,7 +10,7 @@ //! 防抖机制: 在指定窗口期内多次触发时,只执行最后一次;handler 执行期间 //! 积压的事件(如亮度渐变写入)在 handler 返回后统一丢弃。 -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] mod linux { use std::collections::HashMap; use std::os::unix::io::AsRawFd; @@ -194,10 +194,10 @@ mod linux { } fn main() { - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "android"))] linux::run(); - #[cfg(not(target_os = "linux"))] + #[cfg(not(any(target_os = "linux", target_os = "android")))] { eprintln!("lumipro: only supported on Linux/Android"); std::process::exit(1);