调整文件目录
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,209 @@
|
||||
param(
|
||||
[string]$AppsDir = "",
|
||||
[string]$AdbPath = "",
|
||||
[string]$ShellPassword = "adb36987"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
if (-not $AppsDir) {
|
||||
$AppsDir = Join-Path $ScriptDir "apps"
|
||||
}
|
||||
|
||||
function Find-AdbPath {
|
||||
param(
|
||||
[string]$BaseDir
|
||||
)
|
||||
|
||||
$candidates = @(
|
||||
(Join-Path $BaseDir "adb.exe"),
|
||||
(Join-Path $BaseDir "tools\adb.exe"),
|
||||
(Join-Path $BaseDir "..\adb.exe"),
|
||||
(Join-Path $BaseDir "..\tools\adb.exe"),
|
||||
(Join-Path $BaseDir "..\..\tools\adb.exe"),
|
||||
"D:\Code\language-installer\tools\adb.exe",
|
||||
"D:\apk_tools\platform-tools\adb.exe"
|
||||
)
|
||||
|
||||
foreach ($candidate in $candidates) {
|
||||
try {
|
||||
$resolved = Resolve-Path -LiteralPath $candidate -ErrorAction Stop
|
||||
if ($resolved) {
|
||||
return $resolved.Path
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
$pathAdb = Get-Command adb.exe -ErrorAction SilentlyContinue
|
||||
if ($pathAdb) {
|
||||
return $pathAdb.Source
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
if (-not $AdbPath) {
|
||||
$AdbPath = Find-AdbPath -BaseDir $ScriptDir
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $AdbPath)) {
|
||||
throw "adb.exe not found. Put adb.exe next to this script or run with -AdbPath `"D:\path\adb.exe`""
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $AppsDir)) {
|
||||
throw "apps directory not found: $AppsDir"
|
||||
}
|
||||
|
||||
function Quote-ProcessArgument {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Value
|
||||
)
|
||||
|
||||
if ($Value -notmatch '[\s"]') {
|
||||
return $Value
|
||||
}
|
||||
|
||||
return '"' + $Value.Replace('"', '\"') + '"'
|
||||
}
|
||||
|
||||
function Invoke-Adb {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string[]]$Arguments
|
||||
)
|
||||
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $AdbPath
|
||||
$psi.Arguments = (($Arguments | ForEach-Object { Quote-ProcessArgument $_ }) -join " ")
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
|
||||
$proc = [System.Diagnostics.Process]::Start($psi)
|
||||
$stdout = $proc.StandardOutput.ReadToEnd()
|
||||
$stderr = $proc.StandardError.ReadToEnd()
|
||||
$proc.WaitForExit()
|
||||
|
||||
return [pscustomobject]@{
|
||||
Code = $proc.ExitCode
|
||||
Out = ($stdout + $stderr).Trim()
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-AdbShellWithPassword {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Command,
|
||||
[int]$TimeoutMs = 60000
|
||||
)
|
||||
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $AdbPath
|
||||
$psi.Arguments = "-d shell"
|
||||
$psi.RedirectStandardInput = $true
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
|
||||
$proc = New-Object System.Diagnostics.Process
|
||||
$proc.StartInfo = $psi
|
||||
[void]$proc.Start()
|
||||
|
||||
Start-Sleep -Milliseconds 500
|
||||
$proc.StandardInput.WriteLine($ShellPassword)
|
||||
Start-Sleep -Milliseconds 300
|
||||
$proc.StandardInput.WriteLine($Command)
|
||||
$proc.StandardInput.WriteLine("exit")
|
||||
$proc.StandardInput.Close()
|
||||
|
||||
if (-not $proc.WaitForExit($TimeoutMs)) {
|
||||
try { $proc.Kill() } catch {}
|
||||
return [pscustomobject]@{
|
||||
Code = -1
|
||||
Out = "shell command timeout: $Command"
|
||||
}
|
||||
}
|
||||
|
||||
$stdout = $proc.StandardOutput.ReadToEnd()
|
||||
$stderr = $proc.StandardError.ReadToEnd()
|
||||
return [pscustomobject]@{
|
||||
Code = $proc.ExitCode
|
||||
Out = ($stdout + $stderr).Trim()
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "ADB: $AdbPath"
|
||||
Write-Host "Apps: $AppsDir"
|
||||
|
||||
$devices = Invoke-Adb -Arguments @("-d", "devices")
|
||||
if ($devices.Code -ne 0 -or $devices.Out -notmatch "`tdevice") {
|
||||
Write-Host "[ERROR] No adb device connected." -ForegroundColor Red
|
||||
if ($devices.Out) { Write-Host $devices.Out }
|
||||
exit 1
|
||||
}
|
||||
|
||||
$root = Invoke-Adb -Arguments @("-d", "root")
|
||||
if ($root.Out) {
|
||||
Write-Host $root.Out
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
$apks = Get-ChildItem -LiteralPath $AppsDir -Filter "*.apk" -File | Sort-Object Name
|
||||
if (-not $apks) {
|
||||
Write-Host "[ERROR] No APK files found in apps directory." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$total = $apks.Count
|
||||
$index = 0
|
||||
$success = 0
|
||||
|
||||
foreach ($apk in $apks) {
|
||||
$index++
|
||||
$apkName = [System.IO.Path]::GetFileNameWithoutExtension($apk.Name)
|
||||
$targetDir = "/system/app/$apkName"
|
||||
$targetApk = "$targetDir/$($apk.Name)"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "[$index/$total] $($apk.Name)" -ForegroundColor Cyan
|
||||
|
||||
$mkdir = Invoke-AdbShellWithPassword -Command "mkdir -p '$targetDir'"
|
||||
if ($mkdir.Code -ne 0) {
|
||||
Write-Host "[ERROR] mkdir failed: $targetDir" -ForegroundColor Red
|
||||
if ($mkdir.Out) { Write-Host $mkdir.Out }
|
||||
exit 1
|
||||
}
|
||||
|
||||
$push = Invoke-Adb -Arguments @("-d", "push", $apk.FullName, $targetApk)
|
||||
if ($push.Code -ne 0) {
|
||||
Write-Host "[ERROR] push failed: $($apk.Name)" -ForegroundColor Red
|
||||
if ($push.Out) { Write-Host $push.Out }
|
||||
exit 1
|
||||
}
|
||||
if ($push.Out) {
|
||||
Write-Host $push.Out
|
||||
}
|
||||
|
||||
$chmodDir = Invoke-AdbShellWithPassword -Command "chmod 755 '$targetDir'"
|
||||
if ($chmodDir.Code -ne 0) {
|
||||
Write-Host "[ERROR] chmod 755 failed: $targetDir" -ForegroundColor Red
|
||||
if ($chmodDir.Out) { Write-Host $chmodDir.Out }
|
||||
exit 1
|
||||
}
|
||||
|
||||
$chmodApk = Invoke-AdbShellWithPassword -Command "chmod 644 '$targetApk'"
|
||||
if ($chmodApk.Code -ne 0) {
|
||||
Write-Host "[ERROR] chmod 644 failed: $targetApk" -ForegroundColor Red
|
||||
if ($chmodApk.Out) { Write-Host $chmodApk.Out }
|
||||
exit 1
|
||||
}
|
||||
|
||||
$success++
|
||||
Write-Host "[OK] $($apk.Name)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "[DONE] Pushed $success/$total APK files." -ForegroundColor Green
|
||||
@@ -1,100 +0,0 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
cd /d "%~dp0"
|
||||
set "ROOT=%~dp0.."
|
||||
set "TOOLS=%ROOT%\tools"
|
||||
set "NAME=Mazda-EZ60-Language-Installer"
|
||||
set "SRC=Mazda-EZ60.py"
|
||||
title %NAME% - Build
|
||||
|
||||
echo ============================================================
|
||||
echo %NAME% - Cython Build
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
where python >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python not found
|
||||
pause
|
||||
exit /b
|
||||
)
|
||||
for /f "delims=" %%i in ('where python') do set "PY=%%i"
|
||||
echo Python: %PY%
|
||||
|
||||
echo [1/6] Installing deps...
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q
|
||||
if errorlevel 1 (
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
)
|
||||
|
||||
echo [2/6] Clean...
|
||||
if exist "dist_cy" rmdir /s /q dist_cy 2>nul
|
||||
if exist "build" rmdir /s /q build 2>nul
|
||||
if exist "dist" rmdir /s /q dist 2>nul
|
||||
|
||||
echo [3/6] Cython compile...
|
||||
mkdir dist_cy 2>nul
|
||||
copy "%SRC%" dist_cy\_core.py >nul
|
||||
if errorlevel 1 (
|
||||
echo [WARN] Copy source failed, fallback
|
||||
goto :NORMAL
|
||||
)
|
||||
|
||||
"%PY%" -c "open('dist_cy/setup_cython.py','w').write('from setuptools import setup\nfrom Cython.Build import cythonize\nsetup(ext_modules=cythonize(\"_core.py\", compiler_directives={\"language_level\":\"3\"}))\n')"
|
||||
|
||||
cd dist_cy
|
||||
"%PY%" setup_cython.py build_ext --inplace
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [WARN] Cython failed, fallback
|
||||
goto :NORMAL
|
||||
)
|
||||
|
||||
for %%f in (_core*.pyd) do set PYD=%%f
|
||||
if "%PYD%"=="" (
|
||||
cd ..
|
||||
echo [WARN] No pyd, fallback
|
||||
goto :NORMAL
|
||||
)
|
||||
echo PYD: %PYD%
|
||||
copy "%PYD%" _core.pyd >nul
|
||||
|
||||
"%PY%" -c "open('launcher.py','w').write('# -*- coding: utf-8 -*-\nfrom _core import main\nmain()\n')"
|
||||
|
||||
echo [4/6] Copy resources...
|
||||
copy "%TOOLS%\adb.exe" . >nul
|
||||
copy "%TOOLS%\AdbWinApi.dll" . >nul
|
||||
copy "%TOOLS%\AdbWinUsbApi.dll" . >nul
|
||||
copy "%TOOLS%\7za.exe" . >nul
|
||||
if exist "%ROOT%\app.ico" copy "%ROOT%\app.ico" . >nul
|
||||
|
||||
echo [5/6] PyInstaller...
|
||||
"%PY%" -m PyInstaller --onefile --windowed --name="%NAME%" --icon="%ROOT%\app.ico" --add-data "%TOOLS%\adb.exe;." --add-data "%TOOLS%\AdbWinApi.dll;." --add-data "%TOOLS%\AdbWinUsbApi.dll;." --add-data "%TOOLS%\7za.exe;." --add-binary "_core.pyd;." --hidden-import=queue --hidden-import=threading --hidden-import=tkinter --hidden-import=zipfile --hidden-import=json --hidden-import=urllib --collect-all tkinter --uac-admin launcher.py
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] PyInstaller failed
|
||||
pause
|
||||
exit /b
|
||||
)
|
||||
|
||||
echo [6/6] Cleanup...
|
||||
del /q _core.py _core.c _core.pyd %PYD% launcher.py setup_cython.py 2>nul
|
||||
rmdir /s /q build 2>nul
|
||||
cd ..
|
||||
goto :DONE
|
||||
|
||||
:NORMAL
|
||||
echo [INFO] Normal PyInstaller...
|
||||
"%PY%" -m PyInstaller --onefile --windowed --name="%NAME%" --icon="%ROOT%\app.ico" --add-data "%TOOLS%\adb.exe;." --add-data "%TOOLS%\AdbWinApi.dll;." --add-data "%TOOLS%\AdbWinUsbApi.dll;." --add-data "%TOOLS%\7za.exe;." --hidden-import=queue --hidden-import=threading --hidden-import=tkinter --hidden-import=zipfile --hidden-import=json --hidden-import=urllib --collect-all tkinter --uac-admin "%SRC%"
|
||||
|
||||
:DONE
|
||||
echo.
|
||||
echo Done.
|
||||
if exist "dist_cy\dist\%NAME%.exe" (
|
||||
echo Output: dist_cy\dist\%NAME%.exe
|
||||
) else if exist "dist\%NAME%.exe" (
|
||||
echo Output: dist\%NAME%.exe
|
||||
) else (
|
||||
echo Check dist folder
|
||||
)
|
||||
pause
|
||||
@@ -0,0 +1,159 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
cd /d "%~dp0"
|
||||
set "ROOT=%~dp0.."
|
||||
set "TOOLS=%ROOT%\tools"
|
||||
set "NAME=Mazda_EZ60-Language-Install_v1.0"
|
||||
set "SRC=Mazda_EZ60-Language-Install_v1.0.py"
|
||||
set "ICON=%~dp0app.ico"
|
||||
title %NAME% - Cython Build
|
||||
|
||||
echo ============================================================
|
||||
echo %NAME% - Cython Build
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
where python >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
for /f "delims=" %%i in ('where python') do set "PY=%%i"
|
||||
echo Python: %PY%
|
||||
|
||||
if not exist "%SRC%" (
|
||||
echo [ERROR] Source not found: %SRC%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%ICON%" (
|
||||
echo [ERROR] Icon not found: %ICON%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\adb.exe" (
|
||||
echo [ERROR] adb.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinApi.dll" (
|
||||
echo [ERROR] AdbWinApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinUsbApi.dll" (
|
||||
echo [ERROR] AdbWinUsbApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\7za.exe" (
|
||||
echo [ERROR] 7za.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/6] Installing deps...
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q
|
||||
if errorlevel 1 (
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
)
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Dependency install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/6] Clean...
|
||||
if exist "dist_cy" rmdir /s /q dist_cy 2>nul
|
||||
if exist "build" rmdir /s /q build 2>nul
|
||||
if exist "dist" rmdir /s /q dist 2>nul
|
||||
if exist "%NAME%.spec" del /q "%NAME%.spec" 2>nul
|
||||
|
||||
echo [3/6] Cython compile...
|
||||
mkdir dist_cy 2>nul
|
||||
copy "%SRC%" dist_cy\_core.py >nul
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Copy source failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('dist_cy/setup_cython.py','w',encoding='utf-8').write('from setuptools import setup\nfrom Cython.Build import cythonize\nsetup(ext_modules=cythonize(\"_core.py\", compiler_directives={\"language_level\":\"3\"}))\n')"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to create Cython setup script
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
cd dist_cy
|
||||
"%PY%" setup_cython.py build_ext --inplace
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Cython failed. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "PYD="
|
||||
for %%f in (_core*.pyd) do set "PYD=%%f"
|
||||
if "%PYD%"=="" (
|
||||
cd ..
|
||||
echo [ERROR] No Cython PYD generated. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo PYD: %PYD%
|
||||
copy "%PYD%" _core.pyd >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to copy Cython PYD
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('launcher.py','w',encoding='utf-8').write('# -*- coding: utf-8 -*-\nfrom _core import main\nmain()\n')"
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to create launcher.py
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [4/6] Copy resources...
|
||||
copy "%TOOLS%\adb.exe" . >nul
|
||||
copy "%TOOLS%\AdbWinApi.dll" . >nul
|
||||
copy "%TOOLS%\AdbWinUsbApi.dll" . >nul
|
||||
copy "%TOOLS%\7za.exe" . >nul
|
||||
copy "%ICON%" . >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Copy resources failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [5/6] PyInstaller...
|
||||
"%PY%" -m PyInstaller --onefile --windowed --name="%NAME%" --icon="app.ico" --add-data "adb.exe;." --add-data "AdbWinApi.dll;." --add-data "AdbWinUsbApi.dll;." --add-data "7za.exe;." --add-data "app.ico;." --add-binary "_core.pyd;." --hidden-import=queue --hidden-import=threading --hidden-import=tkinter --hidden-import=tkinter.simpledialog --hidden-import=zipfile --hidden-import=json --hidden-import=urllib --hidden-import=urllib.parse --collect-all tkinter --uac-admin launcher.py
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] PyInstaller failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [6/6] Cleanup...
|
||||
del /q _core.py _core.c _core.pyd %PYD% launcher.py setup_cython.py app.ico 2>nul
|
||||
rmdir /s /q build 2>nul
|
||||
cd ..
|
||||
|
||||
echo.
|
||||
echo Done.
|
||||
if exist "dist_cy\dist\%NAME%.exe" (
|
||||
echo Output: dist_cy\dist\%NAME%.exe
|
||||
) else (
|
||||
echo [ERROR] Output exe was not generated
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
pause
|
||||
@@ -0,0 +1,159 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
cd /d "%~dp0"
|
||||
set "ROOT=%~dp0.."
|
||||
set "TOOLS=%ROOT%\tools"
|
||||
set "NAME=Mazda_EZ60-Language-Install_v1.0-direct-push"
|
||||
set "SRC=Mazda_EZ60-Language-Install_v1.0_direct_push.py"
|
||||
set "ICON=%~dp0app.ico"
|
||||
title %NAME% - Cython Build
|
||||
|
||||
echo ============================================================
|
||||
echo %NAME% - Cython Build
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
where python >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
for /f "delims=" %%i in ('where python') do set "PY=%%i"
|
||||
echo Python: %PY%
|
||||
|
||||
if not exist "%SRC%" (
|
||||
echo [ERROR] Source not found: %SRC%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%ICON%" (
|
||||
echo [ERROR] Icon not found: %ICON%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\adb.exe" (
|
||||
echo [ERROR] adb.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinApi.dll" (
|
||||
echo [ERROR] AdbWinApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinUsbApi.dll" (
|
||||
echo [ERROR] AdbWinUsbApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\7za.exe" (
|
||||
echo [ERROR] 7za.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/6] Installing deps...
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q
|
||||
if errorlevel 1 (
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper -q -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
)
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Dependency install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/6] Clean...
|
||||
if exist "dist_cy" rmdir /s /q dist_cy 2>nul
|
||||
if exist "build" rmdir /s /q build 2>nul
|
||||
if exist "dist" rmdir /s /q dist 2>nul
|
||||
if exist "%NAME%.spec" del /q "%NAME%.spec" 2>nul
|
||||
|
||||
echo [3/6] Cython compile...
|
||||
mkdir dist_cy 2>nul
|
||||
copy "%SRC%" dist_cy\_core.py >nul
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Copy source failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('dist_cy/setup_cython.py','w',encoding='utf-8').write('from setuptools import setup\nfrom Cython.Build import cythonize\nsetup(ext_modules=cythonize(\"_core.py\", compiler_directives={\"language_level\":\"3\"}))\n')"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to create Cython setup script
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
cd dist_cy
|
||||
"%PY%" setup_cython.py build_ext --inplace
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Cython failed. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "PYD="
|
||||
for %%f in (_core*.pyd) do set "PYD=%%f"
|
||||
if "%PYD%"=="" (
|
||||
cd ..
|
||||
echo [ERROR] No Cython PYD generated. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo PYD: %PYD%
|
||||
copy "%PYD%" _core.pyd >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to copy Cython PYD
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('launcher.py','w',encoding='utf-8').write('# -*- coding: utf-8 -*-\nfrom _core import main\nmain()\n')"
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to create launcher.py
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [4/6] Copy resources...
|
||||
copy "%TOOLS%\adb.exe" . >nul
|
||||
copy "%TOOLS%\AdbWinApi.dll" . >nul
|
||||
copy "%TOOLS%\AdbWinUsbApi.dll" . >nul
|
||||
copy "%TOOLS%\7za.exe" . >nul
|
||||
copy "%ICON%" . >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Copy resources failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [5/6] PyInstaller...
|
||||
"%PY%" -m PyInstaller --onefile --windowed --name="%NAME%" --icon="app.ico" --add-data "adb.exe;." --add-data "AdbWinApi.dll;." --add-data "AdbWinUsbApi.dll;." --add-data "7za.exe;." --add-data "app.ico;." --add-binary "_core.pyd;." --hidden-import=queue --hidden-import=threading --hidden-import=tkinter --hidden-import=tkinter.simpledialog --hidden-import=zipfile --hidden-import=json --hidden-import=urllib --hidden-import=urllib.parse --collect-all tkinter --uac-admin launcher.py
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] PyInstaller failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [6/6] Cleanup...
|
||||
del /q _core.py _core.c _core.pyd %PYD% launcher.py setup_cython.py app.ico 2>nul
|
||||
rmdir /s /q build 2>nul
|
||||
cd ..
|
||||
|
||||
echo.
|
||||
echo Done.
|
||||
if exist "dist_cy\dist\%NAME%.exe" (
|
||||
echo Output: dist_cy\dist\%NAME%.exe
|
||||
) else (
|
||||
echo [ERROR] Output exe was not generated
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
pause
|
||||
@@ -0,0 +1,194 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
cd /d "%~dp0"
|
||||
set "ROOT=%~dp0.."
|
||||
set "TOOLS=%ROOT%\tools"
|
||||
set "NAME=Mazda-EZ60-Language-Installer_v1.2"
|
||||
set "SRC=Mazda-EZ60_1.2.py"
|
||||
set "ICON=%~dp0app.ico"
|
||||
title %NAME% - Cython Build
|
||||
|
||||
echo ============================================================
|
||||
echo %NAME% - Cython Build
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
where python >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Python not found
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
for /f "delims=" %%i in ('where python') do set "PY=%%i"
|
||||
echo Python: %PY%
|
||||
|
||||
if not exist "%SRC%" (
|
||||
echo [ERROR] Source not found: %SRC%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%ICON%" (
|
||||
echo [ERROR] Icon not found: %ICON%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\adb.exe" (
|
||||
echo [ERROR] adb.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinApi.dll" (
|
||||
echo [ERROR] AdbWinApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\AdbWinUsbApi.dll" (
|
||||
echo [ERROR] AdbWinUsbApi.dll not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\7za.exe" (
|
||||
echo [ERROR] 7za.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\fastboot.exe" (
|
||||
echo [ERROR] fastboot.exe not found in %TOOLS%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%TOOLS%\usb_driver\android_winusb.inf" (
|
||||
echo [ERROR] usb_driver not found at %TOOLS%\usb_driver
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%~dp0runtime.dat" (
|
||||
echo [ERROR] runtime.dat not found at %~dp0runtime.dat
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/6] Installing deps...
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper cryptography -q
|
||||
if errorlevel 1 (
|
||||
"%PY%" -m pip install pyinstaller cython pyzipper cryptography -q -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
)
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Dependency install failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [2/6] Clean...
|
||||
if exist "dist_cy" rmdir /s /q dist_cy 2>nul
|
||||
if exist "build" rmdir /s /q build 2>nul
|
||||
if exist "dist" rmdir /s /q dist 2>nul
|
||||
if exist "%NAME%.spec" del /q "%NAME%.spec" 2>nul
|
||||
|
||||
echo [3/6] Cython compile...
|
||||
mkdir dist_cy 2>nul
|
||||
copy "%SRC%" dist_cy\_core.py >nul
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Copy source failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('dist_cy/setup_cython.py','w',encoding='utf-8').write('from setuptools import setup\nfrom Cython.Build import cythonize\nsetup(ext_modules=cythonize(\"_core.py\", compiler_directives={\"language_level\":\"3\"}))\n')"
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Failed to create Cython setup script
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
cd dist_cy
|
||||
"%PY%" setup_cython.py build_ext --inplace
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Cython failed. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "PYD="
|
||||
for %%f in (_core*.pyd) do set "PYD=%%f"
|
||||
if "%PYD%"=="" (
|
||||
cd ..
|
||||
echo [ERROR] No Cython PYD generated. Build stopped.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo PYD: %PYD%
|
||||
copy "%PYD%" _core.pyd >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to copy Cython PYD
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PY%" -c "open('launcher.py','w',encoding='utf-8').write('# -*- coding: utf-8 -*-\nfrom _core import main\nmain()\n')"
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Failed to create launcher.py
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [4/6] Copy resources...
|
||||
copy "%TOOLS%\adb.exe" . >nul
|
||||
copy "%TOOLS%\AdbWinApi.dll" . >nul
|
||||
copy "%TOOLS%\AdbWinUsbApi.dll" . >nul
|
||||
copy "%TOOLS%\7za.exe" . >nul
|
||||
copy "%TOOLS%\fastboot.exe" . >nul
|
||||
copy "%ICON%" . >nul
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] Copy resources failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
if exist "%~dp0EZ60_resource.dat" copy "%~dp0EZ60_resource.dat" . >nul
|
||||
|
||||
echo [5/6] PyInstaller...
|
||||
set ADD_PERMISSION_RESOURCE=
|
||||
if exist "EZ60_resource.dat" set ADD_PERMISSION_RESOURCE=--add-data "EZ60_resource.dat;."
|
||||
"%PY%" -m PyInstaller --onefile --windowed --name="%NAME%" --icon="app.ico" --add-data "adb.exe;." --add-data "AdbWinApi.dll;." --add-data "AdbWinUsbApi.dll;." --add-data "7za.exe;." --add-data "fastboot.exe;." --add-data "app.ico;." --add-data "%TOOLS%\usb_driver;usb_driver" %ADD_PERMISSION_RESOURCE% --add-binary "_core.pyd;." --hidden-import=queue --hidden-import=threading --hidden-import=tkinter --hidden-import=tkinter.simpledialog --hidden-import=zipfile --hidden-import=json --hidden-import=urllib --hidden-import=urllib.parse --hidden-import=cryptography --collect-all tkinter --collect-all cryptography --uac-admin launcher.py
|
||||
if errorlevel 1 (
|
||||
cd ..
|
||||
echo [ERROR] PyInstaller failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [6/6] Cleanup...
|
||||
del /q _core.py _core.c _core.pyd %PYD% launcher.py setup_cython.py app.ico fastboot.exe EZ60_resource.dat 2>nul
|
||||
rmdir /s /q build 2>nul
|
||||
cd ..
|
||||
|
||||
if not exist "dist_cy\dist\%NAME%.exe" (
|
||||
echo [ERROR] Output exe was not generated
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
copy "runtime.dat" "dist_cy\dist\runtime.dat" >nul
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Copy runtime.dat failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if exist "package_voice-assistant.bin" (
|
||||
copy "package_voice-assistant.bin" "dist_cy\dist\package_voice-assistant.bin" >nul
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Copy package_voice-assistant.bin failed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Done.
|
||||
echo Output: dist_cy\dist\%NAME%.exe
|
||||
pause
|
||||
Reference in New Issue
Block a user