forked from vakdev/VakScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto_Build_VakScript.bat
83 lines (69 loc) · 2.3 KB
/
Auto_Build_VakScript.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@echo off
REM Check if pip is installed
pip --version > nul 2>&1
if %errorlevel%==0 (
echo Pip is already installed.
echo Installing requirements...
pip install -r requirements.txt
) else (
echo Pip is not installed.
echo Installing pip...
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
echo Pip installed successfully.
echo Installing requirements...
pip install -r requirements.txt
)
REM Check if PyInstaller is installed
pyinstaller --version >nul 2>&1
if %errorlevel% neq 0 (
echo PyInstaller is not installed. Installing...
pip install pyinstaller
pyinstaller --version >nul 2>&1
if %errorlevel% neq 0 (
echo Failed to install PyInstaller.
echo.
echo Press any key to exit...
pause >nul
exit /b
)
)
REM Get the version from data.py
for /f "tokens=2 delims=''" %%G in ('findstr "script_version" vakscript\offsets.ini') do (
set "version=%%G"
)
REM Set the target folder name using the extracted version
set "target_folder=VakScript v%version%"
REM Build the Python code using PyInstaller and specify the output folder
pyinstaller --onefile --noconsole --hidden-import script_class --distpath "%target_folder%" vakscript\main.py
REM Copy required files to the target folder
copy vakscript\drawings_font.ttf "%target_folder%"
copy vakscript\settings.json "%target_folder%"
copy vakscript\offsets.ini "%target_folder%"
REM Copy wards folder to the target folder
xcopy /E /I /Y vakscript\wards "%target_folder%\wards"
REM Copy scripts folder to the target folder
xcopy /E /I /Y vakscript\scripts "%target_folder%\scripts"
@echo off
setlocal EnableDelayedExpansion
REM Generate a random alphanumeric string with length 12
set "characters=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
set "random_name="
for /L %%i in (1,1,12) do (
set /a "rand=!random! %% 62"
for %%j in (!rand!) do set "random_name=!random_name!!characters:~%%j,1!"
)
REM Rename the main.exe file to a random string
ren "%target_folder%\main.exe" "!random_name!.exe"
REM Remove the build folder if it exists
if exist "%cd%\build" (
rmdir /s /q "%cd%\build"
)
REM Remove all .spec files
for %%i in (*.spec) do (
del "%%i"
)
echo Build completed successfully!
echo.
echo Press any key to exit...
pause >nul