-
Notifications
You must be signed in to change notification settings - Fork 4
Building Athena
First, ensure that both ml-yacc
and ml-ulex
are installed (on Unix machines this can be done with apt, e.g., sudo apt-get install ml-yacc
).
Then ensure that smlnj
(and preferably mlton
as well) is also installed.
Developing Athena is best done with smlnj
. Bring up smlnj
and then do:
- CM.make("sources.cm");
This will compile the entire project. After compilation is done, type:
- Athena.run();
to enter Athena's main REPL (read-eval-print loop). You can then go back and make more code changes, remake the project
(by executing - CM.make("sources.cm");
again), enter the REPL, and so on.
-
Make an Athena heap image by starting smlnj, compiling (with
- CM.make("sources.cm");
), and then doing one of the following, depending on how you prefer to use the stand-alone:-
- SMLofNJ.exportFn("athena_image",fn (_) => (Athena.run()); OS.Process.success));
if you want the executable to start up in its REPL. This will save a fileathena_image.x86-linux
(the extension is OS-specific). -
- SMLofNJ.exportFn("athena_image",fn (_,arg1::_) => (Athena.runWithStarterFileAndQuit(SOME(arg1)); OS.Process.success));
if you want the executable to take as input an Athena file, execute that file, and then quit. This will save a fileathena_image.x86-linux
(the extension is OS-specific). -
- SMLofNJ.exportFn("athena_image",fn (_,arg1::_) => (Athena.runWithStarterFile(SOME(arg1)); OS.Process.success));
if you want the executable to take as input an initial Athena file, execute it, and then go into the usual Athena REPL.
This will also save a fileathena_image.x86-linux
locally.
-
-
To start athena without an input file, do the following:
sml @SMLload=athena_image.x86-linux
-
To start the program with an input file, do the following:
sml @SMLload=athenaImage.x86-linux input_file.ath
Simply run ./make_mlton_binary
. By default, the output will be a natively compiled executable named athena
.
You can run that executable by itself (without any arguments), or you can pass it as an argument the name of an initial
Athena file to load upon starting. After loading, Athena will enter its REPL. If you want Athena to quit after loading
the initial file, pass 'quit' as the second argument to the executable (e.g., athena some_file.ath quit
).
Note: The file athena.mlb
contains the list of source files used by MLton. If you add/delete source files to/from
Athena, you must update both sources.cm
and athena.mlb
as needed.
To make Athena with C (using MLton's FFI) and assuming you have XSB on ~/.xsb, do:
mlton -default-ann 'allowFFI true' -export-header athena.h -stop tc athena.mlb
XSB_arch='ls ~/.xsb/config'
gcc -c -I/$XSB_HOME/emu -I/$XSB_HOME/config/$XSB_arch -O3 -fno-strict-aliasing -Wall -pipe -D_GNU_SOURCE athena_with_xsb.c
Finally:
if [ 'uname -s' == 'Darwin' ]
then mlton -drop-pass deepFlatten -default-ann 'allowFFI true' -output athena-mac -link-opt -lm -ldl -Wl -lpthread' athena.mlb $XSB_HOME/config/$XSB_arch/saved.o/xsb.o athena_with_xsb.o
else mlton -drop-pass deepFlatten -default-ann 'allowFFI true' -output athena-linux -link-opt -lm -ldl -Wl -export-dynamic -lpthread' athena.mlb $XSB_HOME/config/$XSB_arch/saved.o/xsb.o athena_with_xsb.o
fi