forked from eatonphil/ponyo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sml
22 lines (20 loc) · 903 Bytes
/
build.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fun cleanPath (path: string, right: bool) : string =
if right andalso String.isSuffix "/" path
then cleanPath (String.substring (path, 0, String.size path - 1), true)
else if not right andalso String.isPrefix "/" path
then cleanPath (String.extract (path, 1, NONE), false)
else path;
val PONYO_ROOT =
case OS.Process.getEnv "PONYO_ROOT" of
NONE => (print "PONYO_ROOT must be set. (Directory of source is a good default.)\n"; raise Fail "")
| SOME root =>
case String.isPrefix "~/" root of
false => root
| true =>
case OS.Process.getEnv "HOME" of
NONE => (print "Bad PONYO_ROOT: HOME undefined.\n"; raise Fail "")
| SOME home =>
cleanPath(home, true) ^ "/" ^ (cleanPath (String.extract (root, 2, NONE), false));
val oldUse = use;
fun use (path: string) = oldUse (PONYO_ROOT ^ "/" ^ path);
use "src/build.sml";