c3435724303dba52530c149ff959518487831152
[dotfiles.git] / clean / .local / bin / install_clean.sh
1 #!/bin/bash
2 set -e
3
4 DISTRO="https://ftp.cs.ru.nl/Clean/builds/linux-x64/clean-bundle-complete-linux-x64-latest.tgz"
5 TAGS="https://gitlab.science.ru.nl/cloogle/cloogle-tags/-/jobs/artifacts/master/raw/cloogletags?job=build"
6 CLMMAN="https://gitlab.science.ru.nl/clean-and-itasks/clm/raw/master/clm.1"
7 CP2CG="https://gitlab.science.ru.nl/clean-and-itasks/cleanprof2callgrind/-/jobs/artifacts/master/raw/cleanprof2callgrind?job=test"
8 CLEAN_HOME="${CLEAN_HOME:-/opt/clean}"
9
10 echo "Cleaning up the old distro"
11 rm -rf "$CLEAN_HOME"/*
12 echo "Downloading clean"
13 curl -sSL "$DISTRO" | tar -C "$CLEAN_HOME" --strip-components=1 -xz
14 echo "Installing manpages"
15 mkdir -p ~/.local/man/man1
16 curl -sSLo ~/.local/man/man1/clm.1 "$CLMMAN"
17 echo "Downloading cleanprof2callgrind"
18 curl -sSLo "$CLEAN_HOME/bin/cleanprof2callgrind" "$CP2CG"
19 chmod +x "$CLEAN_HOME"/bin/cleanprof2callgrind
20 echo "Downloading cloogletags"
21 curl -sSLo "$CLEAN_HOME"/bin/cloogletags "$TAGS"
22 chmod +x "$CLEAN_HOME"/bin/cloogletags
23 echo "Generating tags"
24 cloogletags -a -c -d "$CLEAN_HOME"/lib -o "$CLEAN_HOME"/lib/tags 2>/dev/null
25
26 echo "Patching StdEnv for binumap"
27 patch /opt/clean/lib/StdEnv/StdGeneric.dcl <<EOPATCH
28 --- StdGeneric.dcl 2018-12-17 02:43:55.000000000 +0100
29 +++ StdGeneric.dcl 2018-12-17 11:06:09.196234236 +0100
30 @@ -64,6 +64,16 @@
31 derive bimap FIELD
32 derive bimap (->)
33
34 +generic binumap a b | binumap b a :: a -> b
35 +derive binumap c
36 +derive binumap PAIR
37 +derive binumap EITHER
38 +derive binumap OBJECT
39 +derive binumap CONS
40 +derive binumap RECORD
41 +derive binumap FIELD
42 +derive binumap (->)
43 +
44 // HACK: dictionaries for all generics.
45 // It works since all generic classes have only one method and do not inherit
46 // from other classes
47 EOPATCH
48
49 patch /opt/clean/lib/StdEnv/StdGeneric.icl <<EOPATCH
50 --- StdGeneric.icl 2018-12-17 02:43:55.000000000 +0100
51 +++ StdGeneric.icl 2018-12-17 11:06:09.196234236 +0100
52 @@ -21,6 +21,23 @@
53
54 bimap{|(->)|} _ ba fr _ f = comp3 fr f ba
55
56 +binumap{|c|} x = x
57 +
58 +binumap{|PAIR|} fx _ fy _ (PAIR x y) = PAIR (fx x) (fy y)
59 +
60 +binumap{|EITHER|} fl _ fr _ (LEFT x) = LEFT (fl x)
61 +binumap{|EITHER|} fl _ fr _ (RIGHT x) = RIGHT (fr x)
62 +
63 +binumap{|CONS|} fx _ (CONS x) = CONS (fx x)
64 +
65 +binumap{|RECORD|} fx _ (RECORD x) = RECORD (fx x)
66 +
67 +binumap{|FIELD|} fx _ (FIELD x) = FIELD (fx x)
68 +
69 +binumap{|OBJECT|} fx _ (OBJECT x) = OBJECT (fx x)
70 +
71 +binumap{|(->)|} _ ba fr _ f = comp3 fr f ba
72 +
73 comp3 :: !(.a -> .b) u:(.c -> .a) !(.d -> .c) -> u:(.d -> .b)
74 comp3 f g h
75 | is_id f
76 EOPATCH
77
78 echo "Adding the iTasks-git environment"
79 patch /opt/clean/etc/IDEEnvs <<EOPATCH
80 --- IDEEnvs.orig 2019-11-19 08:13:53.243123284 +0100
81 +++ IDEEnvs 2019-11-19 08:15:02.819053965 +0100
82 @@ -61,6 +61,39 @@
83 Path: {Application}/lib/ABCInterpreter
84 Path: {Application}/lib/GraphCopy
85 Path: {Application}/lib/iTasks
86 + Path: {Application}/lib/Gast
87 + EnvironmentCompiler: lib/exe/cocl-itasks::-dynamics
88 + EnvironmentCodeGen: lib/exe/cg
89 + EnvironmentLinker: /usr/bin/gcc::-Wl,--gc-sections|lib/exe/itasks-web-collector
90 + EnvironmentABCOptimise: lib/exe/abcopt
91 + EnvironmentByteCodeGen: lib/exe/bcgen
92 + EnvironmentByteCodeLink: lib/exe/bclink
93 + EnvironmentByteCodeStrip: lib/exe/bcstrip
94 + EnvironmentByteCodePrelink: lib/exe/bcprelink
95 + EnvironmentVersion: 920
96 + EnvironmentRedirect: False
97 + EnvironmentCompileMethod: Pers
98 + EnvironmentProcessor: I386
99 + Environment64BitProcessor: True
100 + Environment
101 + EnvironmentName: iTasks-git
102 + EnvironmentPaths
103 + Path: {Application}/lib/StdEnv
104 + Path: {Application}/lib/Dynamics
105 + Path: {Application}/lib/TCPIP
106 + Path: {Application}/lib/ABCInterpreter
107 + Path: {Application}/lib/GraphCopy
108 + Path: {Application}/lib/Gast
109 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/Platform-x86
110 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Posix
111 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Linux
112 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Linux-64
113 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Independent
114 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Independent/Deprecated/Generics
115 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Independent/Deprecated/StdLib
116 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Independent/Deprecated/ArgEnv
117 + Path: /home/mrl/projects/clean/clean-platform/src/libraries/OS-Independent/Deprecated/MersenneTwister
118 + Path: /home/mrl/projects/clean/iTasks-SDK/Libraries
119 EnvironmentCompiler: lib/exe/cocl-itasks::-dynamics
120 EnvironmentCodeGen: lib/exe/cg
121 EnvironmentLinker: /usr/bin/gcc::-Wl,--gc-sections|lib/exe/itasks-web-collector
122 EOPATCH