@echo off chcp 65001 > nul color 0A title Chahuadev Hub - Python Desktop Builder setlocal enabledelayedexpansion set PROJECT_DIR=%~dp0 set SCRIPT=chahuadev_hub.py set ICON=icons\icon.ico cd /d "%PROJECT_DIR%" echo. echo ╔════════════════════════════════════════════════════════════════════════════════╗ echo ║ 🚀 Chahuadev Hub ^| Python Desktop Builder ║ echo ║ สร้าง .exe (Windows) และ Linux Executable ด้วย PyInstaller ║ echo ╚════════════════════════════════════════════════════════════════════════════════╝ echo. echo 📂 โครงการ: %PROJECT_DIR% echo. :menu echo ═══════════════════════════════════════ echo เลือกคำสั่ง: echo. echo [1] ▶ รันแอป (python) echo [2] 🪟 Build Windows .exe echo [3] 🐧 Build Linux Executable (ผ่าน WSL) echo [4] 🌐 Build ทั้ง Windows + Linux echo [5] 🧹 ล้างโฟลเดอร์ build + dist echo [6] 📊 ดูสถานะ / ไฟล์ที่สร้าง echo [7] 🚪 ออก echo. set /p choice= กรุณาเลือก (1-7): if "%choice%"=="1" goto run_app if "%choice%"=="2" goto build_windows if "%choice%"=="3" goto build_linux if "%choice%"=="4" goto build_all if "%choice%"=="5" goto clean_all if "%choice%"=="6" goto show_status if "%choice%"=="7" goto exit_prog echo. echo [!] ตัวเลือกไม่ถูกต้อง กรุณาลองใหม่ timeout /t 2 >nul goto menu REM ───────────────────────────────────────────────────────────────────────────── :run_app echo. echo ▶ กำลังรัน %SCRIPT% ... echo. python "%PROJECT_DIR%%SCRIPT%" echo. pause goto menu REM ───────────────────────────────────────────────────────────────────────────── :build_windows echo. echo 🪟 กำลัง Build Windows .exe ด้วย PyInstaller... echo. call :check_pyinstaller if errorlevel 1 goto menu if exist "%ICON%" ( python -m PyInstaller --noconsole --onefile --icon="%ICON%" "%SCRIPT%" ) else ( python -m PyInstaller --noconsole --onefile "%SCRIPT%" ) if %errorlevel% neq 0 ( echo. echo [ERROR] Build Windows ล้มเหลว! pause goto menu ) echo. echo ✅ Build Windows สำเร็จ! goto show_results REM ───────────────────────────────────────────────────────────────────────────── :build_linux echo. echo 🐧 กำลัง Build Linux Executable ผ่าน WSL... echo. call :check_wsl if errorlevel 1 goto menu REM แปลง path Windows → WSL for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p wsl bash -c "cd '%WSL_DIR%' && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --noconsole --onefile %SCRIPT%" if %errorlevel% neq 0 ( echo. echo [ERROR] Build Linux ล้มเหลว! pause goto menu ) echo. echo ✅ Build Linux สำเร็จ! (ไฟล์อยู่ใน dist\chahuadev_hub) goto show_results REM ───────────────────────────────────────────────────────────────────────────── :build_all echo. echo 🌐 Build ทั้ง Windows และ Linux... echo. call :check_pyinstaller if errorlevel 1 goto menu echo ─── [1/2] Windows .exe ─────────────────────────────── if exist "%ICON%" ( python -m PyInstaller --noconsole --onefile --icon="%ICON%" "%SCRIPT%" ) else ( python -m PyInstaller --noconsole --onefile "%SCRIPT%" ) if %errorlevel% neq 0 ( echo [ERROR] Build Windows ล้มเหลว! pause goto menu ) echo ✅ Windows .exe สำเร็จ echo. echo ─── [2/2] Linux Executable (WSL) ──────────────────── call :check_wsl if errorlevel 1 ( echo [SKIP] ข้ามขั้นตอน Linux เนื่องจากไม่พบ WSL ) else ( for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p wsl bash -c "cd '%WSL_DIR%' && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --noconsole --onefile %SCRIPT%" if !errorlevel! neq 0 ( echo [ERROR] Build Linux ล้มเหลว! ) else ( echo ✅ Linux Executable สำเร็จ ) ) goto show_results REM ───────────────────────────────────────────────────────────────────────────── :clean_all echo. echo 🧹 กำลังล้างโฟลเดอร์ build และ dist... if exist "dist" rmdir /s /q "dist" && echo ✅ ลบ dist สำเร็จ if exist "build" rmdir /s /q "build" && echo ✅ ลบ build สำเร็จ if exist "*.spec" del /q "*.spec" && echo ✅ ลบ .spec สำเร็จ echo. echo ✅ ล้างเสร็จแล้ว pause goto menu REM ───────────────────────────────────────────────────────────────────────────── :show_status echo. echo 📊 สถานะไฟล์ที่สร้าง: echo. if exist "dist\chahuadev_hub.exe" ( for %%f in ("dist\chahuadev_hub.exe") do ( echo 🪟 Windows .exe : dist\chahuadev_hub.exe ^(%%~zf bytes^) ) ) else ( echo 🪟 Windows .exe : [ยังไม่ได้ build] ) if exist "dist\chahuadev_hub" ( for %%f in ("dist\chahuadev_hub") do ( echo 🐧 Linux Exec : dist\chahuadev_hub ^(%%~zf bytes^) ) ) else ( echo 🐧 Linux Exec : [ยังไม่ได้ build] ) echo. pause goto menu REM ───────────────────────────────────────────────────────────────────────────── :show_results echo. echo ╔════════════════════════════════════════════════════════════════════════════════╗ echo ║ 🎉 Build เสร็จสิ้น! ║ echo ╚════════════════════════════════════════════════════════════════════════════════╝ echo. if exist "dist\chahuadev_hub.exe" echo 🪟 Windows : dist\chahuadev_hub.exe if exist "dist\chahuadev_hub" echo 🐧 Linux : dist\chahuadev_hub echo. set /p open_dist=📂 เปิดโฟลเดอร์ dist? (y/n): if /i "%open_dist%"=="y" start "" "%PROJECT_DIR%dist" echo. pause goto menu REM ───────────────────────────────────────────────────────────────────────────── :check_pyinstaller python -m PyInstaller --version >nul 2>&1 if %errorlevel% neq 0 ( echo [!] ไม่พบ PyInstaller กำลังติดตั้ง... python -m pip install pyinstaller requests customtkinter if %errorlevel% neq 0 ( echo [ERROR] ติดตั้ง PyInstaller ล้มเหลว! exit /b 1 ) ) exit /b 0 :check_wsl wsl --status >nul 2>&1 if %errorlevel% neq 0 ( echo [ERROR] ไม่พบ WSL บนเครื่องนี้ echo ติดตั้ง WSL ด้วยคำสั่ง: wsl --install exit /b 1 ) exit /b 0 REM ───────────────────────────────────────────────────────────────────────────── :exit_prog echo. echo 👋 ขอบคุณที่ใช้ Chahuadev Hub Builder! echo. timeout /t 2 >nul endlocal exit