-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
75 lines (57 loc) · 2.19 KB
/
Vagrantfile
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
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.post_up_message = <<-MSG
Welcome to Haskell backend of ABS language.
1) Compiling an ABS program to Haskell:
habs File1.abs File2.abs
# creates under gen/haskell/ the Haskell files: File1.hs, File2.hs
2) Compiling the resulting Haskell program to native code:
ghc --make -O gen/haskell/File1.hs gen/haskell/File2.hs -main-is File2
# creates a File2 executable with its entry point being the ABS main block of File2
3) Running the final ABS-program executable:
./File2 # runs the program
MSG
config.vm.provider "virtualbox" do |vb|
vb.memory = 4096
vb.cpus = 2
vb.name = "habs_vagrant"
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] # fix for ubuntu DNS problems
end
# Install necessary software
config.vm.provision "shell",
privileged: false,
inline: <<-SHELL
# Set up paths
cat >~/.abstoolsrc <<EOF
PATH=\$PATH:/opt/ghc/8.2.2/bin:/opt/cabal/2.0/bin:/opt/happy/1.19.5/bin:~/habs/.cabal-sandbox/bin
export GHC_PACKAGE_PATH=~/habs/.cabal-sandbox/x86_64-linux-ghc-8.2.2-packages.conf.d:
EOF
if [ -z "$(grep abstoolsrc ~/.bashrc)" ] ; then
cat >>~/.bashrc <<EOF
. .abstoolsrc
EOF
fi
echo
echo "Installing prerequisites"
echo
sudo add-apt-repository ppa:hvr/ghc
sudo apt-get update -y -q
sudo apt-get install -y -q ghc-8.2.2 cabal-install-2.0 happy-1.19.5 git zlib1g-dev
# clone habs repo and subrepos
rm -rf ~/habs
git clone https://github.com/abstools/habs ~/habs
cd ~/habs
git submodule update --init
# build habs parser + transcompiler + runtime + stdlib and all of their dependencies
export PATH=$PATH:/opt/ghc/8.2.2/bin:/opt/cabal/2.0/bin:/opt/happy/1.19.5/bin # needed to find haskell tools
unset GHC_PACKAGE_PATH # otherwise cabal will complain
cabal sandbox init
cabal update
cabal sandbox add-source habs-parser
cabal sandbox add-source habs-runtime
cabal sandbox add-source haskell-src-exts-qq
cabal install -j1 habs-runtime -fwait-all-cogs # explicitly installing runtime to pass wait-all-cogs compile flag
cabal install -j1 # install the transcompiler (will also install parser, stdlib)
SHELL
end