1 |
(* |
(* |
2 |
* This is a stub providing "slave" functionality for CMB. |
* This is a stub providing "slave" functionality for CMB. |
3 |
* (We use dynamic linking technology to avoid loading host-cmb.cm |
* (We use dynamic linking technology to avoid loading target-compilers.cm |
4 |
* on the slave side unless it is really needed.) |
* on the slave side unless it is really needed.) |
5 |
* |
* |
6 |
* (C) 1999 Lucent Technologies, Bell Laboratories |
* (C) 1999 Lucent Technologies, Bell Laboratories |
9 |
*) |
*) |
10 |
structure CMBSlave = struct |
structure CMBSlave = struct |
11 |
local |
local |
12 |
val initialized = ref false |
val lib = "target-compilers.cm" |
13 |
|
val loaded = ref false |
14 |
|
val table = |
15 |
|
foldl StringMap.insert' StringMap.empty |
16 |
|
[("alpha32-unix", "Alpha32UnixCMB.make"), |
17 |
|
("hppa-unix", "HppaUnixCMB.make"), |
18 |
|
("ppc-macos", "PPCMacOSCMB.make"), |
19 |
|
("ppc-unix", "PPCUnixCMB.make"), |
20 |
|
("sparc-unix", "SparcUnixCMB.make"), |
21 |
|
("x86-unix", "X86UnixCMB.make"), |
22 |
|
("x86-win32", "X86Win32CMB.make")] |
23 |
in |
in |
24 |
fun slave make s = |
(* "load" is supposed to be CM.autoload and "touch" should be |
25 |
(if !initialized then () |
* (Compiler.Interact.useStream o TextIO.openString) *) |
26 |
else if make "host-cmb.cm" then initialized := true |
fun slave { load, touch } arch s = |
27 |
else raise Fail "dynamic linkage for CMB slave failed"; |
case StringMap.find (table, arch) of |
28 |
CMBSlaveHook.slave s) |
NONE => NONE |
29 |
|
| SOME cmd => |
30 |
|
(if !loaded then () |
31 |
|
else if load lib then loaded := true |
32 |
|
else raise Fail (concat ["dynamic linkage for CMB slave ", |
33 |
|
arch, " failed"]); |
34 |
|
touch cmd; |
35 |
|
CMBSlaveHook.slave arch s) |
36 |
end |
end |
37 |
end |
end |