59d5e9f4cf719dfcc690f59e6b487f8aba83c732
[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 --- 2019-07-24 02:47:02.000000000 +0200
81 +++ IDEEnvs 2019-07-24 08:22:52.713808372 +0200
82 @@ -45,7 +45,42 @@
83 Path: {Application}/lib/Platform/Deprecated/StdLib
84 Path: {Application}/lib/ABCInterpreter
85 Path: {Application}/lib/GraphCopy
86 - Path: {Application}/lib/iTasks
87 + Path: {Application}/lib/iTasks
88 + Path: {Application}/lib/Gast
89 + EnvironmentCompiler: lib/exe/cocl::-dynamics
90 + EnvironmentCodeGen: lib/exe/cg
91 + EnvironmentLinker: lib/exe/linker|lib/exe/itasks-web-collector
92 + EnvironmentDynLink: lib/exe/linker
93 + EnvironmentABCOptimise: lib/exe/abcopt
94 + EnvironmentByteCodeGen: lib/exe/bcgen
95 + EnvironmentByteCodeLink: lib/exe/bclink
96 + EnvironmentByteCodeStrip: lib/exe/bcstrip
97 + EnvironmentByteCodePrelink: lib/exe/bcprelink
98 + EnvironmentVersion: 920
99 + EnvironmentRedirect: False
100 + EnvironmentCompileMethod: Pers
101 + EnvironmentProcessor: I386
102 + Environment64BitProcessor: True
103 + Environment
104 + EnvironmentName: iTasks-git
105 + EnvironmentPaths
106 + Path: {Application}/lib/StdEnv
107 + Path: {Application}/lib/Dynamics
108 + Path: {Application}/lib/TCPIP
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: {Application}/lib/ABCInterpreter
119 + Path: {Application}/lib/GraphCopy
120 + Path: /home/mrl/projects/clean/iTasks-SDK/Libraries
121 + Path: {Application}/lib/iTasks
122 + Path: {Application}/lib/Gast
123 EnvironmentCompiler: lib/exe/cocl::-dynamics
124 EnvironmentCodeGen: lib/exe/cg
125 EnvironmentLinker: lib/exe/linker|lib/exe/itasks-web-collector
126 EOPATCH