-
Notifications
You must be signed in to change notification settings - Fork 29
/
build_clean_win64.bat
160 lines (126 loc) · 6.43 KB
/
build_clean_win64.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
echo off
set GO111MODULE=off
set basepath=%~dp0
echo %basepath%
set builddir=%basepath%build_win64
set outputdir=%builddir%\Output
if not exist "%builddir%" (mkdir "%builddir%")
if not exist "%outputdir%" (mkdir "%outputdir%")
if not exist "%outputdir%\data" (mkdir "%outputdir%\data")
if not exist "%builddir%\Artifacts" (mkdir "%builddir%\Artifacts")
if not exist "%builddir%\DevPackage" (mkdir "%builddir%\DevPackage")
if not exist "%builddir%\DevPackage\Framework" (mkdir "%builddir%\DevPackage\Framework")
if not exist "%builddir%\DevPackage\Framework\HeadersDev" (mkdir "%builddir%\DevPackage\Framework\HeadersDev")
if not exist "%builddir%\DevPackage\Framework\HeadersDev\CppDynamic" (mkdir "%builddir%\DevPackage\Framework\HeadersDev\CppDynamic")
if not exist "%builddir%\DevPackage\Framework\HeadersDriver" (mkdir "%builddir%\DevPackage\Framework\HeadersDriver")
if not exist "%builddir%\DevPackage\Framework\HeadersDriver\CppDynamic" (mkdir "%builddir%\DevPackage\Framework\HeadersDriver\CppDynamic")
if not exist "%builddir%\DevPackage\Framework\InterfacesDev" (mkdir "%builddir%\DevPackage\Framework\InterfacesDev")
if not exist "%builddir%\DevPackage\Framework\PluginCpp" (mkdir "%builddir%\DevPackage\Framework\PluginCpp")
if not exist "%builddir%\DevPackage\Framework\Dist" (mkdir "%builddir%\DevPackage\Framework\Dist")
if not exist "%builddir%\DevPackage\Framework\ClientSource" (mkdir "%builddir%\DevPackage\Framework\ClientSource")
if not exist "%builddir%\Framework" (mkdir "%builddir%\Framework")
if not exist "%builddir%\Framework\HeadersDev" (mkdir "%builddir%\Framework\HeadersDev")
if not exist "%builddir%\Framework\HeadersDev\CppDynamic" (mkdir "%builddir%\Framework\HeadersDev\CppDynamic")
if not exist "%builddir%\Framework\HeadersDriver" (mkdir "%builddir%\Framework\HeadersDriver")
if not exist "%builddir%\Framework\HeadersDriver\CppDynamic" (mkdir "%builddir%\Framework\HeadersDriver\CppDynamic")
if not exist "%builddir%\Framework\InterfacesDev" (mkdir "%builddir%\Framework\InterfacesDev")
if not exist "%builddir%\Framework\PluginCpp" (mkdir "%builddir%\Framework\PluginCpp")
if not exist "%builddir%\Framework\ClientSource" (mkdir "%builddir%\Framework\ClientSource")
copy /y "%basepath%\Framework\PluginCpp\*.*" "%builddir%\Framework\PluginCpp"
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
copy /y "%basepath%\Framework\InterfacesDev\*.*" "%builddir%\Framework\InterfacesDev"
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
git rev-parse --verify --short HEAD >"%builddir%\githash.txt"
SET /p GITHASH=<"%builddir%\githash.txt"
echo git hash: %GITHASH%
git rev-parse --verify HEAD >"%builddir%\longgithash.txt"
SET /p LONGGITHASH=<"%builddir%\longgithash.txt"
echo long git hash: %LONGGITHASH%
git log -n 1 --format="%%H" -- "%basepath%\Client" >"%builddir%\clientdirhash.txt"
SET /p CLIENTDIRHASH=<"%builddir%\clientdirhash.txt"
SET /p CLIENTDISTHASH=<"%basepath%\Artifacts\clientdist\_githash_client.txt"
REM Trim Strings
for /f "tokens=* delims= " %%a in ("%CLIENTDIRHASH%") do set CLIENTDIRHASH=%%a
for /l %%a in (1,1,100) do if "!CLIENTDIRHASH:~-1!"==" " set CLIENTDIRHASH=!CLIENTDIRHASH:~0,-1!
for /f "tokens=* delims= " %%a in ("%CLIENTDISTHASH%") do set CLIENTDISTHASH=%%a
for /l %%a in (1,1,100) do if "!CLIENTDIRHASH:~-1!"==" " set CLIENTDIRHASH=!CLIENTDIRHASH:~0,-1!
echo client hash: %CLIENTDIRHASH%
echo client dist hash: %CLIENTDISTHASH%
if "%CLIENTDIRHASH%" neq "%CLIENTDISTHASH%" (
echo "Please rebuild client!"
goto ERROR
)
cd /d "%basepath%"
echo "Building Resource builder (Win64)..."
set GOARCH=amd64
set GOOS=windows
go build -o "%builddir%/DevPackage/Framework/buildresources.exe" -ldflags="-s -w" "%basepath%/BuildScripts/buildresources.go"
REM echo "Building Resource builder (Linux64)..."
REM set GOARCH=amd64
REM set GOOS=linux
REM go build -o "%builddir%/DevPackage/Framework/buildresources.linux" -ldflags="-s -w" "%basepath%/BuildScripts/buildresources.go"
REM echo "Building Resource builder (LinuxARM)..."
REM set GOARCH=arm
REM set GOOS=linux
REM set GOARM=5
REM go build -o "%builddir%/DevPackage/Framework/buildresources.arm" -ldflags="-s -w" "%basepath%/BuildScripts/buildresources.go"
copy /y "%basepath%Artifacts\clientdist\clientpackage.zip" "%builddir%\Output\%GITHASH%_core.client"
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
cd "%builddir%"
echo "Building Core Modules"
call cmake ..
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
REM call cmake -G "MinGW Makefiles" ..
call cmake --build . --config Release
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
echo "Building Package XML"
"%builddir%\DevPackage\Framework\create_package_xml.exe" --config "%builddir%\Output\%GITHASH%_config.xml" --devpackage %GITHASH% --output "%builddir%\Output\%GITHASH%_package.xml" --serveroutput "%builddir%\Output\amc_server.xml"
echo "Building Developer Package"
cd "%builddir%\DevPackage"
copy "%basepath%\Artifacts\clientdist\clientsourcepackage.zip" Framework\ClientSource\%GITHASH%_client_source.zip
if "%ERRORLEVEL%" neq "0" (
goto ERROR
)
copy ..\githash.txt Framework\Dist\disthash.txt
copy ..\Output\amc_win32.exe Framework\Dist\
copy ..\Output\amc_server.exe Framework\Dist\
copy ..\Output\%GITHASH%_core_libmc.dll Framework\Dist\
copy ..\Output\%GITHASH%_core_lib3mf.dll Framework\Dist\
copy ..\Output\%GITHASH%_core_libmcdata.dll Framework\Dist\
copy ..\Output\%GITHASH%_core.client Framework\Dist\
copy ..\Output\%GITHASH%_*.data Framework\Dist\
copy ..\Output\%GITHASH%_driver_*.dll Framework\Dist\
copy ..\..\Framework\HeadersDev\CppDynamic\*.* Framework\HeadersDev\CppDynamic
copy ..\..\Framework\InterfacesDev\*.* Framework\InterfacesDev
copy ..\..\Framework\PluginCpp\*.* Framework\PluginCpp
del Framework\Dist\%GITHASH%_core.data
cd %builddir%
go run "%basepath%/BuildScripts/createDevPackage.go" .\DevPackage\Framework .\DevPackage\ %LONGGITHASH% win64
copy "%builddir%\DevPackage\amcf_win64_%LONGGITHASH%.zip" "%builddir%\Artifacts\devpackage_win64.zip" /Y
echo "Build done!"
IF "%UPLOADTOPACKAGEREPOSITORY%"=="true" (
echo "Uploading to package repository: %AMCF_PACKAGE_REPOSITORY%"
echo "Using key file: %AMCF_PACKAGE_REPOSITORY_KEYFILE%"
cd "%basepath%"
"%basepath%\DevTools\pscp.exe" -hostkey %AMCF_HOSTKEY% -batch -i "%AMCF_PACKAGE_REPOSITORY_KEYFILE%" -v "%builddir%\DevPackage\amcf_win64_%LONGGITHASH%.zip" %AMCF_PACKAGE_REPOSITORY%
)
goto END
:ERROR
echo "------------------------------------------------------------"
echo "FATAL BUILD ERROR!"
echo "------------------------------------------------------------"
:END
if "%1" neq "NOPAUSE" (
pause
)
exit 0