blob: 7e3d83c384613942ef31f5b08b19738247cb5185 (
plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
@echo off
rem
rem Copyright 2021 Michael Buesch <m@bues.ch>
rem
rem This program is free software; you can redistribute it and/or modify
rem it under the terms of the GNU General Public License as published by
rem the Free Software Foundation; either version 2 of the License, or
rem (at your option) any later version.
rem
rem This program is distributed in the hope that it will be useful,
rem but WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rem GNU General Public License for more details.
rem
rem You should have received a copy of the GNU General Public License along
rem with this program; if not, write to the Free Software Foundation, Inc.,
rem 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
rem
setlocal ENABLEDELAYEDEXPANSION
set project=wolfsmuehle
set exe=%project%.exe
set version_crate_subdir=.
set GTK_DIR=C:\gtk-build\gtk\x64\release
set GTK_BIN=%GTK_DIR%\bin
set PATH=%PATH%;C:\WINDOWS;C:\WINDOWS\SYSTEM32
set PATH=%GTK_BIN%;%PATH%
set PATH=%PATH%;%ProgramFiles%/7-Zip
cd ..
if ERRORLEVEL 1 goto error_basedir
call :detect_version
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
set winprefix=win32
) else (
set winprefix=win64
)
set distdir=%project%-%winprefix%-%version%
set sfxfile=%project%-%winprefix%-%version%.package.exe
call :prepare_env
call :build
call :copy_files
call :gen_wrapper
call :archive
echo Successfully built.
pause
exit /B 0
:detect_version
pushd %version_crate_subdir%
if not exist Cargo.lock (
cargo update
if ERRORLEVEL 1 goto error_version
)
for /f "tokens=2 delims=#" %%a in ('cargo pkgid') do set version=%%a
for /f "tokens=2 delims=:" %%a in ("%version%") do set version=%%a
if ERRORLEVEL 1 goto error_version
echo Detected version: %version%
popd
exit /B 0
:prepare_env
rd /S /Q %distdir% 2>NUL
del %sfxfile% 2>NUL
timeout \T 2 \NOBREAK 2>NUL
mkdir %distdir%
if ERRORLEVEL 1 goto error_prep
exit /B 0
:build
cargo clean
if ERRORLEVEL 1 goto error_build
cargo update
if ERRORLEVEL 1 goto error_build
cargo build --release
if ERRORLEVEL 1 goto error_build
exit /B 0
:copy_files
mkdir %distdir%\bin
if ERRORLEVEL 1 goto error_copy
copy target\release\%exe% %distdir%\bin\
if ERRORLEVEL 1 goto error_copy
xcopy /E /I %GTK_DIR% %distdir%\gtk
if ERRORLEVEL 1 goto error_copy
rd /S /Q %distdir%\gtk\include
if ERRORLEVEL 1 goto error_copy
exit /B 0
:gen_wrapper
set wrapper=%distdir%\wolfsmuehle.cmd
echo @echo off > %wrapper%
echo set PATH=gtk\bin;%%PATH%% >> %wrapper%
echo start bin\%exe% %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >> %wrapper%
if ERRORLEVEL 1 goto error_wrapper
exit /B 0
:archive
7z a -mx=9 -sfx7z.sfx %sfxfile% %distdir%
if ERRORLEVEL 1 goto error_7z
exit /B 0
:error_basedir
echo FAILED to CD to base directory.
goto error
:error_version
echo FAILED to detect version.
goto error
:error_prep
echo FAILED to prepare environment.
goto error
:error_build
echo FAILED to build.
goto error
:error_copy
echo FAILED to copy files.
goto error
:error_wrapper
echo FAILED to create wrapper.
goto error
:error_7z
echo FAILED to compress archive.
goto error
:error
pause
exit 1
|