Bug 1415335 - Move Windows line endings detection to configure; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Tue, 07 Nov 2017 17:16:39 -0800
changeset 443925 3894f3262cbcbf35bed76f691a3ab764f2b9cce3
parent 443924 9fd30a79e468d8fffe922ace03a8533b17c0978b
child 443926 270e0b97ec67b236515a1487fdab7a153f15d65f
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1415335
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415335 - Move Windows line endings detection to configure; r=nalexander This doesn't need to be in client.mk. Also, we inline the info to help people correct the failure, as this results in a better user experience. MozReview-Commit-ID: KURL3RIGzKf
build/moz.configure/init.configure
client.mk
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -9,16 +9,17 @@ include('checks.configure')
 
 option(env='DIST', nargs=1, help='DIST directory')
 
 # Do not allow objdir == srcdir builds.
 # ==============================================================
 
 
 @depends('--help', 'DIST')
+@imports(_from='__builtin__', _import='open')
 @imports(_from='os.path', _import='exists')
 def check_build_environment(help, dist):
     topobjdir = os.path.realpath(os.path.abspath('.'))
     topsrcdir = os.path.realpath(os.path.abspath(
         os.path.join(os.path.dirname(__file__), '..', '..')))
 
     if dist:
         dist = normsep(dist[0])
@@ -56,16 +57,39 @@ def check_build_environment(help, dist):
             '  * To build, you must run configure from a separate directory\n'
             '  * (referred to as an object directory).\n'
             '  *\n'
             '  * If you are building with a mozconfig, you will need to change your\n'
             '  * mozconfig to point to a different object directory.\n'
             '  ***'
             )
 
+    # Check for CRLF line endings.
+    with open(os.path.join(topsrcdir, 'configure.py'), 'rb') as fh:
+        data = fh.read()
+        if '\r' in data:
+            die('\n ***\n'
+                ' * The source tree appears to have Windows-style line endings.\n'
+                ' *\n'
+                ' * If using Git, Git is likely configured to use Windows-style\n'
+                ' * line endings.\n'
+                ' *\n'
+                ' * To convert the working copy to UNIX-style line endings, run\n'
+                ' * the following:\n'
+                ' *\n'
+                ' * $ git config core.autocrlf false\n'
+                ' * $ git config core.eof lf\n'
+                ' * $ git rm --cached -r .\n'
+                ' * $ git reset --hard\n'
+                ' *\n'
+                ' * If not using Git, the tool you used to obtain the source\n'
+                ' * code likely converted files to Windows line endings. See\n'
+                ' * usage information for that tool for more.\n'
+                ' ***')
+
     # Check for a couple representative files in the source tree
     conflict_files = [
         '*         %s' % f for f in ('Makefile', 'config/autoconf.mk')
         if exists(os.path.join(topsrcdir, f))
     ]
     if conflict_files:
         die('  ***\n'
             '  *   Your source tree contains these files:\n'
--- a/client.mk
+++ b/client.mk
@@ -51,24 +51,16 @@ PYTHON ?= $(shell which python2.7 > /dev
 CONFIG_GUESS := $(shell $(TOPSRCDIR)/build/autoconf/config.guess)
 
 ####################################
 # Sanity checks
 
 # Windows checks.
 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
 
-# check for CRLF line endings
-ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
-$(error This source tree appears to have Windows-style line endings. To \
-convert it to Unix-style line endings, check \
-"https://developer.mozilla.org/en-US/docs/Developer_Guide/Mozilla_build_FAQ\#Win32-specific_questions" \
-for a workaround of this issue.)
-endif
-
 # Set this for baseconfig.mk
 HOST_OS_ARCH=WINNT
 endif
 
 ####################################
 # Load mozconfig Options
 
 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.