-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathEVEBot.iss
144 lines (122 loc) · 4.5 KB
/
EVEBot.iss
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
#if ${ISXEVE(exists)}
#else
#error This script requires ISXEVE to be loaded before running
#endif
function MakeIncludeFiles(string RootDir, string SubDir, bool Define_Globals = TRUE, bool ClearFiles = FALSE, string BehaviorType)
{
variable file Includes_File = "${RootDir}${SubDir}/_includes.iss"
variable file Variables_File = "${RootDir}${SubDir}/_variables.iss"
Includes_File:Open[]
Includes_File:Seek[0]
Includes_File:Truncate[]
Includes_File:Write["; This file is automatically generated by the top-level EVEBot.iss\n\n"]
if ${Define_Globals}
{
Variables_File:Open[]
Variables_File:Seek[0]
Variables_File:Truncate[]
Variables_File:Write["; This file is automatically generated by the top-level EVEBot.iss\n\n"]
}
if ${ClearFiles}
{
return
}
variable filelist Script_List
variable filelist Subdir_list
Script_List:Reset
Subdir_List:Reset
Script_List:GetFiles["${RootDir}${SubDir}/\*"]
Subdir_list:GetDirectories["${RootDir}${SubDir}/\*"]
variable int Pos = 0
for (Pos:Set[1] ; ${Pos}<=${Subdir_list.Files} ; Pos:Inc)
{
if ${Subdir_list.File[${Pos}].Filename.Equal["Testcases"]} || \
${Subdir_list.File[${Pos}].Filename.Equal[".svn"]}
{
continue
}
Script_List:GetFiles["${Subdir_list.File[${Pos}].FullPath}/\*"]
}
variable string CurrentFile
variable string obj_name
variable string var_name
variable string logmsg
; This log message gets printed at startup and needs to fit in with the "Loading behaviors" section
logmsg:Set[" ${BehaviorType}: "]
for (Pos:Set[1] ; ${Pos}<=${Script_List.Files} ; Pos:Inc)
{
CurrentFile:Set[${Script_List.File[${Pos}].Filename}]
if ${CurrentFile.Equal["_includes.iss"]} || \
${CurrentFile.Equal["_variables.iss"]}
{
continue
}
if ${CurrentFile.Right[4].Equal[".iss"]}
{
obj_name:Set[${CurrentFile.Left[-4]}]
var_name:Set[${obj_name.Right[-4]}]
Disabled_File:Write["\tEVEBotBehaviors:Set[${obj_name}, TRUE]\n"]
Includes_File:Write["#if \${EVEBotBehaviors.Element[${obj_name}]}\n"]
Includes_File:Write["\t#include ${Script_List.File[${Pos}].FullPath.Right[-${RootDir.Length}]}\n"]
Includes_File:Write["#endif\n\n"]
if ${Define_Globals}
{
if ${CurrentFile.Left[4].Equal["obj_"]}
{
Variables_File:Write["#if \${EVEBotBehaviors.Element[${obj_name}]}\n"]
Variables_File:Write["\tLogger:Log[\"Creating global ${obj_name} as ${var_name}\", LOG_DEBUG]\n"]
Variables_File:Write["\tBehaviors.Loaded:Add[${var_name}]\n"]
Variables_File:Write["\tcall CreateVariable ${var_name} ${obj_name} global\n"]
Variables_File:Write["#endif\n\n"]
if ${logmsg.Right[2].Compare[": "]} != 0
{
logmsg:Concat[", "]
}
logmsg:Concat[${var_name}]
}
}
}
}
Includes_File:Close[]
if ${Define_Globals}
{
Variables_File:Write["Logger:Log[\"${logmsg}\", LOG_ECHOTOO]"]
Variables_File:Close[]
}
}
function main(string Branch = "Stable", string Param1 = "")
{
declarevariable EVEBotBehaviors collection:bool globalkeep
declarevariable Disabled_File file script
; TODO - check that branch dir exists first
if !${Param1.Find[-nocreate](exists)}
{
Disabled_File:SetFilename["${Script.CurrentDirectory}/Branches/${Branch}/_ActiveModules.iss"]
Disabled_File:Open[]
Disabled_File:Seek[0]
Disabled_File:Truncate[]
Disabled_File:Write["; This file is automatically generated by the top-level EVEBot.iss\n\n"]
Disabled_File:Write[";\t To disable a module:\n"]
Disabled_File:Write[";\t\t 1) Change TRUE to FALSE for the module you want\n"]
Disabled_File:Write[";\t\t 2) Run EVEBot.ISS with -nocreate option\n\n"]
Disabled_File:Write["function main()\n"]
Disabled_File:Write["{\n"]
if ${Param1.Find[-testcases](exists)}
{
; Include both regular modes and testcases
call MakeIncludeFiles "${Script.CurrentDirectory}/Branches/${Branch}/" "Behaviors" TRUE FALSE Stock
call MakeIncludeFiles "${Script.CurrentDirectory}/Branches/${Branch}/" "Behaviors/Testcases" TRUE FALSE Testcase
}
else
{
; Clear the testcase _includes and _variables, and only include regular behaviors
call MakeIncludeFiles "${Script.CurrentDirectory}/Branches/${Branch}/" "Behaviors" TRUE FALSE Stock
call MakeIncludeFiles "${Script.CurrentDirectory}/Branches/${Branch}/" "Behaviors/Testcases" TRUE TRUE Testcase
}
Disabled_File:Write["}\n"]
Disabled_File:Close[]
}
; Call _ActiveModules, which sets true/false for each module
waitscript "${Script.CurrentDirectory}/Branches/${Branch}/_ActiveModules.iss"
timedcommand 5 "runscript \"${Script.CurrentDirectory}/Branches/${Branch}/EVEBot.iss\""
}