From b0a9937a6d252eaf6c936284c377227ae510cc0f Mon Sep 17 00:00:00 2001 From: klutzy Date: Tue, 17 Dec 2013 14:35:22 +0900 Subject: [PATCH] mklldeps.py: Write to file instead of print It seems that msys automatically converts `\n` to `\r\n` on pipe redirection, which causes `make tidy` failure. --- mk/llvm.mk | 3 +-- src/etc/mklldeps.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mk/llvm.mk b/mk/llvm.mk index cf4e98c6dba..c85a4687613 100644 --- a/mk/llvm.mk +++ b/mk/llvm.mk @@ -51,8 +51,7 @@ $(S)src/librustc/lib/llvmdeps.rs: \ $(LLVM_CONFIGS) \ $(S)src/etc/mklldeps.py $(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \ - "$(LLVM_COMPONENTS)" $(LLVM_CONFIGS) \ - > $@ + "$@" "$(LLVM_COMPONENTS)" $(LLVM_CONFIGS) $(foreach host,$(CFG_HOST), \ $(eval $(call DEF_LLVM_RULES,$(host)))) diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index cea86b7a4f9..5b1abdf68a3 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -4,9 +4,11 @@ import os import sys import subprocess -components = sys.argv[1].split(' ') +f = open(sys.argv[1], 'wb') -print """// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +components = sys.argv[2].split(' ') + +f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -18,10 +20,10 @@ print """// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // WARNING: THIS IS A GENERATED FILE, DO NOT MODIFY // take a look at src/etc/mklldeps.py if you're interested -""" +""") -for llconfig in sys.argv[2:]: - print +for llconfig in sys.argv[3:]: + f.write("\n") proc = subprocess.Popen([llconfig, '--host-target'], stdout = subprocess.PIPE) out, err = proc.communicate() @@ -42,7 +44,7 @@ for llconfig in sys.argv[2:]: "target_os = \"" + os + "\"", ] - print "#[cfg(" + ', '.join(cfg) + ")]" + f.write("#[cfg(" + ', '.join(cfg) + ")]\n") args = [llconfig, '--libs'] args.extend(components) @@ -51,7 +53,7 @@ for llconfig in sys.argv[2:]: for lib in out.strip().split(' '): lib = lib[2:] # chop of the leading '-l' - print "#[link(name = \"" + lib + "\", kind = \"static\")]" + f.write("#[link(name = \"" + lib + "\", kind = \"static\")]\n") if os == 'win32': - print "#[link(name = \"imagehlp\")]" - print "extern {}" + f.write("#[link(name = \"imagehlp\")]\n") + f.write("extern {}\n")