-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.pe.bat
88 lines (64 loc) · 3.08 KB
/
make.pe.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
@echo off
setlocal
REM This file is for building the Poker Enlighter executable.
REM The build log file:
set buildlog=build_.%1_%2.log
REM Some very important notes:
REM - The script expects 2 parameters: the version of Poker Enlighter followed
REM by the build number. For example: "myscript.bat 2.3 538"
REM - The script assumes the availability of the java, javac, jar, xcopy, winrar and md5sum commands.
REM - The script makes very specific assumptions of the structure of the JAR file, in the packaging
REM stage. Please keep this script in sync with this structure.
REM We're going to count execution time. So, remeber start time. Note that we don't look at the date, so this
REM calculation won't work right if the program run spans local midnight.
set t0=%time: =0%
REM First, let's define some variables that contain most used names and paths
REM throughout the build script. Changes of these variables will propagate down the script.
set manifestfile=Manifest.txt
set clijar=poker_enlighter_cli.jar
set mainclass=org/javafling/pokerenlighter/main/PokerEnlighterCLI
set simulatorjar=lib/simulator/simulator.jar
REM The actual compilation command. It is compiled without any debugging
REM symbols, to add some obfuscation. These symbols will probably be removed by Proguard anyway, but
REM it's not a bad thing to be extra-careful.
javac -g:none -Xlint:unchecked -classpath .;%simulatorjar% %mainclass%.java > %buildlog% 2>&1
timeout /t 1 /nobreak > NUL
REM Next, the script will move inside the "org/" folder and delete all the source code files.
REM This is to ensure that the resulting executable will not contain the source code.
REM The script will move back to the build folder root after it's done deleting.
cd org
del /s *.java >> %buildlog% 2>&1
timeout /t 1 /nobreak > NUL
cd..
REM Next, the Manifest file is built. This is needed for the JAR file.
echo Main-Class: %mainclass% > %manifestfile%
echo Class-Path: %simulatorjar% >> %manifestfile%
REM Package everything in a JAR file.
jar cfm0 %clijar% %manifestfile% org/* >> %buildlog% 2>&1
REM Next, we package everything in a zip file.
REM - "a" means create archive.
REM - "-afzip" means make it a ZIP archive
REM - "-m0" means no compression
winrar a -afzip -r -m0 "poker.enlighter.cli.%1.%2.zip" LICENSE.txt %clijar% lib/* >> %buildlog% 2>&1
REM Finally, we need a MD5 hash value for the archive.
md5sum "poker.enlighter.cli.%1.%2.zip" > md5sum.txt
REM And we are done. Enjoy.
REM Capture the end time before doing anything else
set t=%time: =0%
REM make t0 into a scaler in 100ths of a second, being careful not
REM to let SET/A misinterpret 08 and 09 as octal
set /a h=1%t0:~0,2%-100
set /a m=1%t0:~3,2%-100
set /a s=1%t0:~6,2%-100
set /a c=1%t0:~9,2%-100
set /a starttime = %h% * 360000 + %m% * 6000 + 100 * %s% + %c%
REM make t into a scaler in 100ths of a second
set /a h=1%t:~0,2%-100
set /a m=1%t:~3,2%-100
set /a s=1%t:~6,2%-100
set /a c=1%t:~9,2%-100
set /a endtime = %h% * 360000 + %m% * 6000 + 100 * %s% + %c%
REM runtime in 100ths is now just end - start
set /a runtime = %endtime% - %starttime%
set runtime = %s%.%c%
echo Ran for %runtime%0 ms