-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparams.stanza
121 lines (99 loc) · 3.81 KB
/
params.stanza
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
;See License.txt for details about licensing.
defpackage stz/params :
import core
import collections
import core/parsed-path
;========= Compilation Flags ===========
val COMPILE-FLAGS = Vector<Symbol>()
public defn flag-defined? (s:Symbol) :
contains?(COMPILE-FLAGS, s)
public defn add-flag (s:Symbol) :
add(COMPILE-FLAGS, s)
public defn compiler-flags () :
to-tuple(COMPILE-FLAGS)
;========= Stanza Configuration ========
public val STANZA-VERSION = [0 18 76]
public var STANZA-INSTALL-DIR:String = ""
public var OUTPUT-PLATFORM:Symbol = `platform
public var STANZA-PKG-DIRS:List<String> = List()
public val STANZA-PROJ-FILES = Vector<String>()
public var EXPERIMENTAL-FEATURES:Tuple<Symbol> = []
public var AUX-FILE-OVERRIDE:String|False = false
;====== Currently-Supported Experimental Features =====
public val SUPPORTED-EXPERIMENTAL-FEATURES = `(
jit)
;====== Compiler Configuration =====
public var STANZA-MAX-COMPILER-HEAP-SIZE = 4L * 1024L * 1024L * 1024L
;======== Output Symbol Manging =========
public defn make-external-symbol (x:Symbol) :
switch {OUTPUT-PLATFORM == _} :
`os-x : symbol-join(["_", x])
`linux : x
`windows : x
;======== Platforms =========
public defn supported-platform? (p:Symbol) :
contains?([`os-x, `linux, `windows], p)
public defn ensure-supported-platform (p:Symbol) :
if not supported-platform?(p) :
throw $ Exception("'%_' is not a supported platform." % [p])
public defn platform-flag (platform:Symbol) -> Symbol :
switch(platform) :
`os-x : `PLATFORM-OS-X
`linux : `PLATFORM-LINUX
`windows : `PLATFORM-WINDOWS
;======== Link Types =========
public defn supported-link-type? (l:Symbol) :
contains?([`dynamic, `static], l)
public defn ensure-supported-link-types (l:Symbol) :
if not supported-link-type?(l) :
throw $ Exception("'%_' is not a supported link-type." % [l])
public defn link-flag (link-type:Symbol) -> Symbol :
switch(link-type) :
`static : `LINK-STATIC
`dynamic : `LINK-DYNAMIC
;If an explicit link type is not provided, then return the default
;link type (`static). Otherwise return the provided link type unchanged.
public defn default-link-type (link:Symbol|False) -> Symbol :
match(link) :
(l:Symbol) : l
(l:False) : `static
;======= Versions ========
public defn valid-stanza-version-format? (xs:Tuple<Int>) -> True|False :
if length(xs) == 3 :
for x in xs all? :
x >= 0 and x <= 1000
;============================================================
;===================== System Files =========================
;============================================================
public defenum SystemFile :
DotStanza
StanzaCompiler
StanzaLicense
StanzaRuntimeDriver
StanzaIncludeDir
StanzaAuxFile
StanzaPkgsDir
StanzaREPLHistory
StanzaPkgCacheDir
public defn system-filepath (install-dir:String, file:SystemFile) -> String :
;Compute path relative to installation folder.
defn relative-to-install (file-path:String) :
val install-path = parse-path(install-dir)
to-string(relative-to-dir(install-path, file-path))
switch(file) :
DotStanza : relative-to-install(".stanza")
StanzaCompiler :
match(CURRENT-PLATFORM) :
(p:OS-X|Linux) : relative-to-install("stanza")
(p:Windows) : relative-to-install("stanza.exe")
StanzaLicense : relative-to-install("License.txt")
StanzaRuntimeDriver : relative-to-install("runtime/driver.c")
StanzaIncludeDir : relative-to-install("include")
StanzaAuxFile :
match(AUX-FILE-OVERRIDE:String) : AUX-FILE-OVERRIDE
else : relative-to-install("stanza.aux")
StanzaPkgsDir : relative-to-install("pkgs")
StanzaPkgCacheDir : relative-to-install("pkg-cache")
StanzaREPLHistory : relative-to-install("repl-history.txt")
public defn system-filepath (file:SystemFile) -> String :
system-filepath(STANZA-INSTALL-DIR, file)