[commit: ghc] ghc-7.10: Make configure error out on missing ghc-tarballs on Windows (778bd43)

git at git.haskell.org git at git.haskell.org
Thu Oct 22 15:09:24 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/778bd43fb36e47b5cf2593ddb597ab81ce6ac5ff/ghc

>---------------------------------------------------------------

commit 778bd43fb36e47b5cf2593ddb597ab81ce6ac5ff
Author: Tamar Christina <tamar at zhox.com>
Date:   Thu Jul 30 10:36:45 2015 +0200

    Make configure error out on missing ghc-tarballs on Windows
    
    Currently checking out the source on windows requires two git
    checkouts. One for the GHC sources and one for the GHC-tarballs.
    
    This patch will make configure issue an error if compiling under
    windows and the GHC-tarballs folder is missing.
    
    On failure the user is told which command they need to run to get the
    tarballs or if they want configure to handle it for them configure
    provide the `--enable-tarballs-autodownload` flag.
    
    Test Plan:
    1. make sure ghc-tarballs folder is not present
    2. run ./configure which should fail giving an error that tarballs is
    missing and how to get it
    3. run ./configure --enable-tarballs-autodownload and the tarballs
    should be downloaded and configure finishes
    4. rerun the command in 3, no new download should be done.
    5. run configure without --enable-tarballs-autodownload, configure
    should finish correctly.
    
    Reviewers: bgamari, austin, thomie
    
    Reviewed By: thomie
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1108
    
    GHC Trac Issues: #10705


>---------------------------------------------------------------

778bd43fb36e47b5cf2593ddb597ab81ce6ac5ff
 HACKING.md   |  6 +++---
 INSTALL.md   |  5 +++++
 README.md    | 10 +++++-----
 configure.ac | 43 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/HACKING.md b/HACKING.md
index b59e747..6ed39ea 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -33,11 +33,11 @@ Next, clone the repository and all the associated libraries:
 $ git clone --recursive git://git.haskell.org/ghc.git
 ```
 
-On Windows, you need an extra repository containing some build tools:
+On Windows, you need an extra repository containing some build tools.
+These can be downloaded for you by configure. This only needs to be done once by running:
 
 ```
-$ cd ghc/
-$ git clone git://git.haskell.org/ghc-tarballs.git
+$ ./configure --enable-tarballs-autodownload
 ```
 
 First copy `mk/build.mk.sample` to `mk/build.mk` and ensure it has
diff --git a/INSTALL.md b/INSTALL.md
index 1db2595..58930af 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -23,6 +23,11 @@ Quick start:  the following gives you a default build:
     $ make
     $ make install
 
+  On Windows, you need an extra repository containing some build tools.
+  These can be downloaded for you by configure. This only needs to be done once by running:
+
+    $ ./configure --enable-tarballs-autodownload
+
 The "perl boot" step is only necessary if this is a tree checked out
 from git.  For source distributions downloaded from GHC's web site,
 this step has already been performed.
diff --git a/README.md b/README.md
index 5ad1adb..025140c 100644
--- a/README.md
+++ b/README.md
@@ -28,11 +28,6 @@ There are two ways to get a source tree:
 
         $ git clone --recursive git://git.haskell.org/ghc.git
 
-  On Windows, you need an extra repository containing some build tools:
-
-        $ cd ghc/
-        $ git clone git://git.haskell.org/ghc-tarballs.git
-
   Note: cloning GHC from Github requires a special setup. See [Getting a GHC
   repository from Github] [7].
 
@@ -66,6 +61,11 @@ dblatex.
     $ make         # can also say 'make -jX' for X number of jobs
     $ make install
 
+  On Windows, you need an extra repository containing some build tools.
+  These can be downloaded for you by configure. This only needs to be done once by running:
+
+    $ ./configure --enable-tarballs-autodownload
+
 (NB: **Do you have multiple cores? Be sure to tell that to `make`!** This can
 save you hours of build time depending on your system configuration, and is
 almost always a win regardless of how many cores you have. As a simple rule,
diff --git a/configure.ac b/configure.ac
index 5e0ab79..23f89d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,12 @@ AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
         EnableBootstrapWithDevelSnaphost=NO
 )
 
+AC_ARG_ENABLE(tarballs-autodownload,
+[AC_HELP_STRING([--enable-tarballs-autodownload],
+                [Automatically download Windows distribution binaries if needed.])],
+        TarballsAutodownload=YES,
+        TarballsAutodownload=NO
+)
 if test "$WithGhc" != ""; then
   FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
 
@@ -267,12 +273,49 @@ AC_SUBST(WithHc)
 FP_INTREE_GHC_PWD
 FP_FIND_ROOT
 
+function fail() {
+    echo >&2
+    echo "$1" >&2
+    exit 1
+}
+
+function set_up_tarballs() {
+    local tarball_repo_url="$1"
+    local tarball_dir="$2"
+
+    if ! test -d "${tarball_dir}"
+    then
+        local git_cmd="git clone ${tarball_repo_url} ${tarball_dir}"
+        if test "$TarballsAutodownload" = "NO"
+        then
+            echo >&2
+            echo "ERROR: Windows tarball binary distributions not found." >&2
+            echo "Please rerun configure with --enable-tarballs-autodownload, or clone the repository manually:" >&2
+            echo "  $git_cmd" >&2
+            exit 1
+        fi
+        AC_MSG_NOTICE([Downloading Windows tarball distributions to ${tarball_dir}...])
+        $git_cmd || {
+            rm -f "${tarball_dir}"
+            fail "ERROR: Git clone failed."
+        }
+    else
+        AC_MSG_NOTICE([Using Windows tarball distributions found in ${tarball_dir}...])
+    fi
+}
+
 if test "$HostOS" = "mingw32"
 then
     test -d inplace || mkdir inplace
 
+    # NB. For now just run git clone on the tarball repo
+    ghc_tarball_repo='git://git.haskell.org/ghc-tarballs.git'
+    ghc_tarball_dir='ghc-tarballs'
+    set_up_tarballs "${ghc_tarball_repo}" "${ghc_tarball_dir}"
+
     if test "$HostArch" = "i386"
     then
+
         # NB. If you update the tarballs to a new version of gcc, don't
         # forget to tweak the paths in driver/gcc/gcc.c.
         if ! test -d inplace/mingw ||



More information about the ghc-commits mailing list