-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.testmodcompiler.bmx
139 lines (104 loc) · 3.14 KB
/
app.testmodcompiler.bmx
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
Rem
===========================================================
MOD SPECIFIC COMPILER TEST CLASS
===========================================================
Class to compile a given code with a compiler with options and
parameters compatible to "BlitzMax' bmk".
EndRem
SuperStrict
Import "base.testbase.bmx"
Import "base.processes.bmx"
Type TTestModCompiler Extends TTestBase
Field compileMod:String = ""
'the complete path (including filename)
Global compilerUri:String = ""
Global baseConfig:TConfigMap = New TConfigMap.Init()
Method Init:TTestModCompiler( name:String="" )
Super.Init(name)
Return Self
End Method
Method SetCompileFile:TTestModCompiler( file:String )
compileMod = file
Return Self
End Method
Method GetTestType:String()
Return "MODULE"
End Method
Function SetCompilerURI:Int( uri:String )
If Not uri
Print "ERROR: Compiler was not defined in option 'bmk_path'"
Return False
EndIf
If FileType(uri) = FILETYPE_NONE
' try real path
Local dir:String = CurrentDir()
ChangeDir baseConfig.GetString("test_base", "")
uri = RealPath(uri)
'move back into current dir
ChangeDir dir
If Not FileType(uri)
Print "ERROR: Compiler not found: ~q"+uri+"~q"
Return False
End If
EndIf
' bmxpath is not set, we should try to set it to bmk's root path. (one up from bmk's bin path)
If Not baseConfig.GetString("bmxpath", "")
' bin dir
Local bmxpath:String = ExtractDir(uri)
' parent dir
bmxpath = bmxpath[..bmxpath.FindLast("/")]
If FileType(bmxpath) = FILETYPE_DIR
baseConfig.Add("bmxpath", bmxpath)
putenv_("BMXPATH=" + bmxpath)
End If
End If
compilerUri = uri
Return True
End Function
'override cleanup to delete the binary afterwards
Method CleanUp:Int()
End Method
Method GetParams:String()
Local result:String = ""
'build flags
result :+ "makemods"
result :+ " -a" 'recompile
If config.GetInt("threaded", 0) = 1
result :+ " -h"
EndIf
If Not config.GetInt("debug", 0)
result :+ " -r"
EndIf
If config.GetString("app_arch", "")
result :+ " -g " + config.GetString("app_arch", "")
EndIf
'file
result :+ " " + compileMod
Return result
End Method
'override to allow
Method IsErrorLine:Int(line:string)
'this is no true error
'eg. ar: Erzeugen von /path/to/BlitzMax/mod/pub.mod/oggvorbis.mod/oggvorbis.release.linux.x64.a
If line.Find("ar:") >= 0 and line.Find("/mod/") >= 0 and line.EndsWith(".a") then return False
Return Super.IsErrorLine(line)
End Method
'override generation of the commandline
Method GetCommandline:String()
'try to use a instance specific URI, if none is given
'use the default type specific compiler URI
Local useCommandURI:String = commandURI
If useCommandURI = "" Then
If Not compilerUri
If Not SetCompilerURI(config.GetString("bmk_path", ""))
End
End If
End If
useCommandURI = compilerUri
End If
Return usecommandURI + " " + GetParams()
End Method
Method Validate:Int()
return True
End Method
End Type