-
Notifications
You must be signed in to change notification settings - Fork 0
/
matlab.jam
132 lines (109 loc) · 2.83 KB
/
matlab.jam
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
import os ;
import project ;
import common ;
import path ;
import errors ;
project.initialize $(__name__) ;
project matlab ;
# Save the project so that we tolerate 'import + using' combo.
.project = [ project.current ] ;
# Helper utils for easy debug output
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
.debug-configuration = TRUE ;
}
rule init ( version ? : command * : options * )
{
project.push-current $(.project) ;
command = [ common.get-invocation-command matlab : matlab : $(command) ] ;
if $(command)
{
local output-lines = [ SPLIT_BY_CHARACTERS [ SHELL "\"$(command)\" -n" ] : "\n" ] ;
local detected-version-components = [ MATCH "(R[0-9][0-9][0-9][0-9][a-z])" : $(output-lines) ] ;
local detected-version = $(detected-version-components[1]) ;
if ! $(detected-version)
{
errors.warning "MATLAB not detected at" $(command) ;
}
if $(version)
{
if $(detected-version) != $(version)
{
errors.user-error "detected version of MATLAB (" $(detected-version) ") does not match desired (" $(version) ")" ;
}
}
if $(detected-version)
{
version = $(detected-version) ;
}
local output-lines = [ SPLIT_BY_CHARACTERS [ SHELL "\"$(command)\" -n" ] : "\n" ] ;
local matlab-root-components = [ MATCH "MATLAB += +(.+)" : $(output-lines) ] ;
local matlab-arch-components = [ MATCH "ARCH += +(.+)" : $(output-lines) ] ;
local matlab-root = $(matlab-root-components[1]) ;
local matlab-arch = $(matlab-arch-components[1]) ;
local matlab-lib = [ path.join $(matlab-root) bin $(matlab-arch) ] ;
local matlab-include = [ path.join $(matlab-root) extern include ] ;
if $(.debug-configuration) = TRUE
{
echo "notice: using MATLAB $(version) at $(matlab-root) " ;
}
alias matlab
: # sources
eng
mex
mat
mx
;
lib eng
: # sources
: # requirements
<name>eng
<search>$(matlab-lib)
: # default-build
: # usage-requirements
<include>$(matlab-include)
;
lib mex
: # sources
: # requirements
<name>mex
<search>$(matlab-lib)
: # default-build
: # usage-requirements
<include>$(matlab-include)
;
lib mat
: # sources
: # requirements
<name>mat
<search>$(matlab-lib)
: # default-build
: # usage-requirements
<include>$(matlab-include)
;
lib mx
: # sources
: # requirements
<name>mx
<search>$(matlab-lib)
: # default-build
: # usage-requirements
<include>$(matlab-include)
;
.matlab-root = $(matlab-root) ;
.matlab-bin = [ path.join [ common.get-absolute-tool-path $(command) ] matlab ] ;
}
else
{
errors.warning "MATLAB not found" ;
}
project.pop-current ;
}
rule root ( )
{
return $(.matlab-root) ;
}
rule executable ( )
{
return $(.matlab-bin) ;
}