From b739c319dd56fa2aabd8007cc200eafb3c7651a7 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Mon, 25 May 2020 17:56:07 -0400
Subject: [PATCH] gitlab-ci: Add usage message to ci.sh

---
 .gitlab/ci.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index b1c53ded2dce..5bcc6f5c5b04 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -2,6 +2,8 @@
 # shellcheck disable=SC2230
 
 # This is the primary driver of the GitLab CI infrastructure.
+# Run `ci.sh usage` for usage information.
+
 
 set -e -o pipefail
 
@@ -17,6 +19,61 @@ fi
 
 source $TOP/.gitlab/common.sh
 
+function usage() {
+  cat <<EOF
+$0 - GHC continuous integration driver
+
+Common Modes:
+
+  usage         Show this usage message.
+  setup         Prepare environment for a build.
+  configure     Run ./configure.
+  clean         Clean the tree
+  shell         Run an interactive shell with a configured build environment.
+
+Make build system:
+
+  build_make    Build GHC via the make build system
+  test_make     Test GHC via the make build system
+
+Hadrian build system
+  build_hadrian Build GHC via the Hadrian build system
+  test_hadrian  Test GHC via the Hadrian build system
+
+
+Environment variables affecting both build systems:
+
+  MSYSTEM           (Windows-only) Which platform to build form (MINGW64 or MINGW32).
+
+Environment variables determining build configuration of Make system:
+
+  BUILD_FLAVOUR     Which flavour to build.
+  BUILD_SPHINX_HTML Whether to build Sphinx HTML documentation.
+  BUILD_SPHINX_PDF  Whether to build Sphinx PDF documentation.
+  INTEGER_LIBRARY   Which integer library to use (integer-simple or integer-gmp).
+  HADDOCK_HYPERLINKED_SOURCES
+                    Whether to build hyperlinked Haddock sources.
+  TEST_TYPE         Which test rule to run.
+
+Environment variables determining build configuration of Hadrian system:
+
+  BUILD_FLAVOUR     Which flavour to build.
+
+Environment variables determining bootstrap toolchain (Linux):
+
+  GHC           Path of GHC executable to use for bootstrapping.
+  CABAL         Path of cabal-install executable to use for bootstrapping.
+  ALEX          Path of alex executable to use for bootstrapping.
+  HAPPY         Path of alex executable to use for bootstrapping.
+
+Environment variables determining bootstrap toolchain (non-Linux):
+
+  GHC_VERSION   Which GHC version to fetch for bootstrapping.
+  CABAL_INSTALL_VERSION
+                Cabal-install version to fetch for bootstrapping.
+EOF
+}
+
 function setup_locale() {
   # Musl doesn't provide locale support at all...
   if ! which locale > /dev/null; then
@@ -476,6 +533,7 @@ esac
 set_toolchain_paths
 
 case $1 in
+  usage) usage ;;
   setup) setup && cleanup_submodules ;;
   configure) configure ;;
   build_make) build_make ;;
-- 
GitLab