From 989efa7a51d2699325de20561c8d917d47d659c8 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Tue, 7 Nov 2017 17:16:39 -0800 Subject: [PATCH] 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 --HG-- extra : rebase_source : dc79d3f6aa4e91a12cab0e26d5fc0a3e15afa833 extra : source : 2eceb30625acd8cfadda0baa6326a7e9fd07dece --- build/moz.configure/init.configure | 24 ++++++++++++++++++++++++ client.mk | 8 -------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index 04c5a718f3f4..49af6e526ab3 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -14,6 +14,7 @@ option(env='DIST', nargs=1, help='DIST directory') @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('.')) @@ -61,6 +62,29 @@ def check_build_environment(help, dist): ' ***' ) + # 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') diff --git a/client.mk b/client.mk index b9403e2146aa..7627cadcbb7e 100644 --- a/client.mk +++ b/client.mk @@ -56,14 +56,6 @@ CONFIG_GUESS := $(shell $(TOPSRCDIR)/build/autoconf/config.guess) # Windows checks. ifneq (,$(findstring mingw,$(CONFIG_GUESS))) -# check for CRLF line endings -ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while () { 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