-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup-hook.sh
56 lines (47 loc) · 1.61 KB
/
setup-hook.sh
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
# This setup hook adds every propagated lisp system to CL_SOURCE_REGISTRY
buildAsdfPath () {
declare -A seen=()
for dep in $propagatedBuildInputs; do
_addToAsdfPath $dep
done
}
addFileToSearchPathWithCustomDelimiter() {
local delimiter="$1"
local varName="$2"
local file="$3"
if [[ -f "$file" && "${!varName:+${delimiter}${!varName}${delimiter}}" \
!= *"${delimiter}${file}${delimiter}"* ]]; then
export "${varName}=${!varName:+${!varName}${delimiter}}${file}"
fi
}
addFileToSearchPath() {
addFileToSearchPathWithCustomDelimiter ":" "$@"
}
_addToAsdfPath () {
local dep="$1"
if [ -v seen[$dep] ]; then
return
else
seen[$dep]=1
local path="$dep"
# FIXME slow
while read file; do
case "${file##*.}" in
jar) addFileToSearchPath "CLASSPATH" "$file" ;;
class) addToSearchPath "CLASSPATH" "${file%/*}" ;;
so) addToSearchPath "LD_LIBRARY_PATH" "${file%/*}" ;;
dylib) addToSearchPath "DYLD_LIBRARY_PATH" "${file%/*}" ;;
asd) addToSearchPath "CL_SOURCE_REGISTRY" "$path//" ;;
esac
done < <(find "$path" -type f,l -name '*.asd' -o -name '*.jar' \
-o -name '*.class' -o -name '*.so' -o -name '*.dylib')
local prop="$dep/nix-support/propagated-build-inputs"
if [ -e "$prop" ]; then
local new_system
for new_system in $(cat $prop); do
_addToAsdfPath "$new_system"
done
fi
fi
}
# addEnvHooks "$targetOffset" buildAsdfPath