Bug 1415335 - Move Windows line endings detection to configure; r?Build draft
authorGregory Szorc <gps@mozilla.com>
Tue, 07 Nov 2017 17:16:39 -0800
changeset 694654 795b850fb336200bf7383fc6b33c860d174775d3
parent 694653 f4f46beee36bf70ef59957c8029853931e313408
child 694655 1109816b92b73f5f4011594fc2b03f5330610a18
push id88184
push userbmo:gps@mozilla.com
push dateWed, 08 Nov 2017 01:21:12 +0000
reviewersBuild
bugs1415335
milestone58.0a1
Bug 1415335 - Move Windows line endings detection to configure; r?Build 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.