From 04e1f2d02129bc377fd1fbe7b5fb4e080bc13ad4 Mon Sep 17 00:00:00 2001
From: Nicolas Richart <nicolas.richart@epfl.ch>
Date: Wed, 31 Jan 2024 23:29:40 +0100
Subject: [PATCH] Corrected definitions of compilers

---
 .gitlab-ci.yml | 18 +++++++++++++++---
 config.json    |  2 +-
 spack.yaml     |  4 +++-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6771bf2..78c6ecf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -148,8 +148,20 @@ spack:install_compilers:
       --key EDC904DCE3D2E84E
       /buildcache ${hashes}
 
-    - |
-      echo 'definitions: [ compilers: ' $(jq -Mrc '.stack | .core_compiler as $core | .compilers | map("\(.spec)@\(.version) %\($core)")' config.json) ']' > compiler_definitions.yaml
+    - >
+      core_compiler=$(jq -Mrc '.stack | .core_compiler' config.json)
+
+      compilers=$(jq -Mrc '.stack | .compilers | to_entries | map("\(.key)@\(.value.version)")' config.json)
+
+      compilers_specs=$(jq -Mrc '.stack | .core_compiler as $core | .compilers | map("\(.spec)@\(.version) %\($core)")' config.json)
+
+      cat > compiler_definitions.yaml << EOF
+      definitions:
+        - core_compiler: [ ${core_compiler} ]
+        - compilers: ${compilers}
+        - compilers_specs: ${compilers_specs}
+      EOF
+
       cat compiler_definitions.yaml
 
     - |
@@ -178,7 +190,7 @@ spack:concretize:
     - .spack_cache
     - .parallel_job
   script:
-    - spack/bin/spack -e . config blame definitions
+    - spack/bin/spack -e . config blame
     - spack/bin/spack -e . concretize
   needs:
     - job: spack:install_compilers
diff --git a/config.json b/config.json
index 402235a..0a3fe77 100644
--- a/config.json
+++ b/config.json
@@ -16,7 +16,7 @@
         "core_compiler": "gcc@11.4.1 arch=linux-rhel9-x86_64_v2",
         "compilers": {
             "gcc": { "spec": "gcc", "version": "12.2.0" },
-            "intel": { "spec": "intel-oneapi-compilers", "version": "2023.2.1" }
+            "oneapi": { "spec": "intel-oneapi-compilers", "version": "2023.2.1" }
         }
     }
 }
diff --git a/spack.yaml b/spack.yaml
index d465981..0390d2a 100644
--- a/spack.yaml
+++ b/spack.yaml
@@ -34,7 +34,9 @@ spack:
         - $mpis
 
   specs:
-  - $compilers
+  - matrix:
+    - [$compilers_specs]
+    - [$%core_compiler]
   - matrix:
     - [$all_serial_codes]
     - [$%compilers]
-- 
GitLab