From da9912f33ace6dec1213127f7b638f557a9bcb86 Mon Sep 17 00:00:00 2001
From: Matthew Pickering <matthewtpickering@gmail.com>
Date: Mon, 26 Feb 2024 11:35:52 +0000
Subject: [PATCH] ci: Enable more documentation building

Here we enable documentation building on

1. Darwin: The sphinx toolchain was already installed so we enable html
   and manpages.
2. Rocky8: Full documentation (toolchain already installed)
3. Alpine: Full documetnation (toolchain already installed)
4. Windows: HTML and manpages (toolchain already installed)

Fixes #24465

(cherry picked from commit 67ace1c59dd582919bceb4fdadbefc1d98d3449a)
---
 .gitlab/ci.sh     |  6 ++++--
 .gitlab/gen_ci.hs | 10 +++-------
 .gitlab/jobs.yaml | 38 ++++++++++++++++----------------------
 3 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index 8c00753fa35..ca0147763f5 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -160,6 +160,8 @@ function mingw_init() {
 
   # We always use mingw64 Python to avoid path length issues like #17483.
   export PYTHON="/mingw64/bin/python3"
+  # And need to use sphinx-build from the environment
+  export SPHINXBUILD="/mingw64/bin/sphinx-build.exe"
 }
 
 # This will contain GHC's local native toolchain
@@ -315,7 +317,7 @@ function fetch_cabal() {
           fail "neither CABAL nor CABAL_INSTALL_VERSION are not set"
       fi
 
-      start_section "fetch GHC"
+      start_section "fetch cabal"
       case "$(uname)" in
         # N.B. Windows uses zip whereas all others use .tar.xz
         MSYS_*|MINGW*)
@@ -342,7 +344,7 @@ function fetch_cabal() {
           mv cabal "$toolchain/bin"
           ;;
       esac
-      end_section "fetch GHC"
+      end_section "fetch cabal"
   fi
 }
 
diff --git a/.gitlab/gen_ci.hs b/.gitlab/gen_ci.hs
index 139e5466732..d8b60977b9f 100755
--- a/.gitlab/gen_ci.hs
+++ b/.gitlab/gen_ci.hs
@@ -408,7 +408,7 @@ opsysVariables AArch64 (Darwin {}) =
           , "LANG" =: "en_US.UTF-8"
           , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi"
           -- Fonts can't be installed on darwin
-          , "HADRIAN_ARGS" =: "--docs=no-sphinx"
+          , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs"
           ]
 opsysVariables Amd64 (Darwin {}) =
   mconcat [ "NIX_SYSTEM" =: "x86_64-darwin"
@@ -422,12 +422,12 @@ opsysVariables Amd64 (Darwin {}) =
           , "LANG" =: "en_US.UTF-8"
           , "CONFIGURE_ARGS" =: "--with-intree-gmp --with-system-libffi"
           -- Fonts can't be installed on darwin
-          , "HADRIAN_ARGS" =: "--docs=no-sphinx"
+          , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs"
 
           ]
 opsysVariables _ (Windows {}) =
   mconcat [ "MSYSTEM" =: "CLANG64"
-          , "HADRIAN_ARGS" =: "--docs=no-sphinx"
+          , "HADRIAN_ARGS" =: "--docs=no-sphinx-pdfs"
           , "LANG" =: "en_US.UTF-8"
           , "CABAL_INSTALL_VERSION" =: "3.8.1.0"
           , "GHC_VERSION" =: "9.4.3" ]
@@ -437,7 +437,6 @@ alpineVariables = mconcat
   [ -- Due to #20266
     "CONFIGURE_ARGS" =: "--disable-ld-override"
   , "INSTALL_CONFIGURE_ARGS" =: "--disable-ld-override"
-  , "HADRIAN_ARGS" =: "--docs=no-sphinx"
     -- encoding004: due to lack of locale support
     -- T10458, ghcilink002: due to #17869
     -- linker_unload_native: due to lack of dlinfo() support
@@ -452,9 +451,6 @@ distroVariables Centos7 = mconcat [
     "HADRIAN_ARGS" =: "--docs=no-sphinx"
   , "BROKEN_TESTS" =: "T22012" -- due to #23979
   ]
-distroVariables Rocky8 = mconcat [
-  "HADRIAN_ARGS" =: "--docs=no-sphinx"
-  ]
 distroVariables Fedora33 = mconcat
   -- LLC/OPT do not work for some reason in our fedora images
   -- These tests fail with this error: T11649 T5681 T7571 T8131b
diff --git a/.gitlab/jobs.yaml b/.gitlab/jobs.yaml
index ff039ec6bfc..1ac28925acd 100644
--- a/.gitlab/jobs.yaml
+++ b/.gitlab/jobs.yaml
@@ -55,7 +55,7 @@
       "BIN_DIST_NAME": "ghc-aarch64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "11.0",
       "NIX_SYSTEM": "aarch64-darwin",
@@ -233,7 +233,7 @@
       "BIN_DIST_NAME": "ghc-aarch64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "11.0",
       "NIX_SYSTEM": "aarch64-darwin",
@@ -297,7 +297,6 @@
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "aarch64-linux-alpine3_18-validate",
       "XZ_OPT": "-9"
@@ -594,7 +593,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "10.13",
       "NIX_SYSTEM": "x86_64-darwin",
@@ -722,7 +721,6 @@
       "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-int_native-validate+fully_static",
       "XZ_OPT": "-9"
@@ -784,7 +782,6 @@
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-validate",
       "XZ_OPT": "-9"
@@ -846,7 +843,6 @@
       "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static",
       "XZ_OPT": "-9"
@@ -2229,7 +2225,6 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "TEST_ENV": "x86_64-linux-rocky8-validate",
       "XZ_OPT": "-9"
     }
@@ -2404,7 +2399,7 @@
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
       "TEST_ENV": "x86_64-windows-int_native-validate",
@@ -2463,7 +2458,7 @@
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
       "TEST_ENV": "x86_64-windows-validate",
@@ -2525,7 +2520,7 @@
       "BIN_DIST_NAME": "ghc-aarch64-darwin-release",
       "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "11.0",
@@ -2590,7 +2585,7 @@
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+no_split_sections",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "aarch64-linux-alpine3_18-release+no_split_sections",
@@ -2835,7 +2830,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-darwin-release",
       "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "10.13",
@@ -2903,7 +2898,7 @@
       "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+fully_static",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-int_native-release+fully_static",
@@ -2966,7 +2961,7 @@
       "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+fully_static+no_split_sections",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
@@ -3029,7 +3024,7 @@
       "BROKEN_TESTS": "encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "release+no_split_sections",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-release+no_split_sections",
@@ -3708,7 +3703,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-linux-rocky8-release",
       "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "TEST_ENV": "x86_64-linux-rocky8-release",
       "XZ_OPT": "-9"
@@ -3888,7 +3883,7 @@
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
@@ -3948,7 +3943,7 @@
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
-      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
+      "HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx-pdfs",
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
@@ -4011,7 +4006,7 @@
       "BIN_DIST_NAME": "ghc-x86_64-darwin-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "--with-intree-gmp --with-system-libffi ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MACOSX_DEPLOYMENT_TARGET": "10.13",
       "NIX_SYSTEM": "x86_64-darwin",
@@ -4137,7 +4132,6 @@
       "BROKEN_TESTS": "ghcilink002 linker_unload_native encoding004 T10458 linker_unload_native",
       "BUILD_FLAVOUR": "validate+fully_static",
       "CONFIGURE_ARGS": "--disable-ld-override ",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
       "INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
       "TEST_ENV": "x86_64-linux-alpine3_12-validate+fully_static"
     }
@@ -5085,7 +5079,7 @@
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
-      "HADRIAN_ARGS": "--docs=no-sphinx",
+      "HADRIAN_ARGS": "--docs=no-sphinx-pdfs",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
       "TEST_ENV": "x86_64-windows-validate"
-- 
GitLab