Newer
Older
set -o errexit
set -o pipefail
set -o nounset
system_compiler=$(jq -Mrc '
.stack
| .system_arch as $arch
| .system_compiler
| map("\(.compiler)@\(.version) \($arch)")
' ${STACK_CONFIG})
_compilers=$(jq -Mrc '.stack
| .system_arch as $arch
| .compilers
| to_entries
| .[]
| {name: .key, arch: $arch} + .value
| select((.constraint == null) or (.constraint? | index(env.environment)))
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
compilers_names=$(echo ${_compilers} | jq -Mrc '. | "\(.name)"')
echo "List compilers:"
echo ${_compilers} | jq -C '.'
main_env_path=${STACK_LOCATION}/spack/var/spack/environments/${environment}
for name in ${compilers_names}
do
spec=$(echo $_compilers | jq --arg name $name -Mrc '. | select(.name==$name) | "\(.spec) \(.arch)"')
source ${CI_PROJECT_DIR}/ci/stack_env.sh ${name}
echo "definitions:" > ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
compilers=$(echo $_compilers | jq -Mrc --arg name "$name" '. | select(.name==$name) | ["\(.name)@\(.version) target=\(env.target)"]')
compilers_specs="[$spec]"
for c in "system_compiler" "compilers" "compilers_specs"; do
if [ "x${!c}" != "x" ]; then
echo " - ${c}: ${!c}" >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
fi
done
echo " - compiler_${name}: ${compilers}" >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
echo "Compilers for environmnent ${full_environment}"
cat ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
echo "Getting system compiler"
${STACK_LOCATION}/spack/bin/spack compiler find --scope system /usr
echo "Installing compiler ${name}: ${spec}"
${STACK_LOCATION}/spack/bin/spack \
--color always \
spec \
--install-status \
--namespaces \
--long \
--types \
${spec}
${STACK_LOCATION}/spack/bin/spack \
--color always \
spec \
--install-status \
--namespaces \
--long \
--types \
--json \
${spec} > compilers_spec.json
${STACK_LOCATION}/spack/bin/spack \
--color always \
install \
--log-file ${CI_PROJECT_DIR}/spack-install-${name}.xml \
--log-format junit \
--fail-fast \
--show-log-on-error \
${spec}
hashes=$(jq -Mr '.spec.nodes | map("/\(.hash)") | join(" ")' compilers_spec.json)
echo "Adding packages to buildcache"
${STACK_LOCATION}/spack/bin/spack \
--color always \
buildcache create \
--update-index \
--key ${GPG_KEY_ID} \
${MOUNT_POINT}/buildcache/${environment} ${hashes}
for compiler_hash in $(echo ${hashes}); do
location=$(${STACK_LOCATION}/spack/bin/spack location -i ${compiler_hash})
${STACK_LOCATION}/spack/bin/spack \
--color always \
compiler find \
--scope system \
${location} \
${location}/compiler/latest \
${location}/compiler/latest/linux \
${location}/Linux_x86_64/2024/compilers
done