Preface
It can take a while to wade through the docs about SML toolchain because it isn't very mainstream. Also, I think that automating dev box setup is very useful. Let's get started; you'll need an Ubuntu 16.10 box.
The setup
Below, we are setting up everything to be able to compile Ur/Web from sources.
sudo apt-get install emacs-goodies-el
sudo apt-get install build-essential git mlton autoconf libssl-dev
sudo apt-get install libpq-dev libmysqlclient-dev libsqlite3-dev
git clone https://github.com/urweb/urweb.git
cd urweb
./autogen.sh
# we install this in order to have the emacs modes ready
apt-get install emacs-goodies-el
./configure
make
sudo make install
# install a mode for emacs
touch ~/.emacs
echo '(add-to-list '"'"'load-path "/usr/local/share/emacs/site-lisp/urweb-mode")' >> ~/.emacs
echo '(load "urweb-mode-startup")' >> ~/.emacs
Next, we'll be setting up Emacs to work with MLton using the corresponding tools: Def-Use Mode (allows Emacs to parse a pre-existing def-use file and use the information to allow user to jump from uses to definitions) and Bg-Build (allows Emacs to invoke a build tool in background as soon as a source file is changed, refreshing the def-use file).
cd
git clone https://github.com/ramLlama/mlton-emacs
echo "(add-to-list 'load-path \"`pwd`/mlton-emacs/\")" >> ~/.emacs
echo "(require 'esml-du-mlton)" >> ~/.emacs
echo "(def-use-mode)" >> ~/.emacs
echo "(require 'bg-build-mode)" >> ~/.emacs
echo "(bg-build-mode)" >> ~/.emacs
Finally, please fire-up Emacs and do the following:
M-x package-list-packages
C-x s sml-mode
- Hit
i
thenx
- Finally, answer positively to any prompts
How to use bg-build
?
In Emacs, please do the following:
M-x bg-build-add-project
- then point it to urweb's
build.bgb
- Finally:
M-x esml-du-mlton
and navigate to thecompiler.du
file