Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get cargo working on i686-pc-windows-msvc #1825

Merged
merged 9 commits into from
Jul 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 41 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ threadpool = "0.1"
time = "0.1"
toml = "0.1"
url = "0.2"
winapi = "0.1"
winapi = "0.2"

[dev-dependencies]
tempdir = "0.3"
Expand Down
13 changes: 0 additions & 13 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ BIN_TARGETS := cargo
BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))

ifdef CFG_MSVC_INCLUDE_PATH
export INCLUDE := $(CFG_MSVC_INCLUDE_PATH)
endif
ifdef CFG_MSVC_LIB_PATH
export LIB := $(CFG_MSVC_LIB_PATH)
endif
ifdef CFG_MSVC_BIN
export PATH := $(CFG_MSVC_BIN):$(PATH)
endif
ifdef CFG_MSVC_WINDOWS_SDK_DIR
export PATH := $(CFG_MSVC_WINDOWS_SDK_DIR):$(PATH)
endif

define DIST_TARGET
ifdef CFG_ENABLE_OPTIMIZE
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
environment:
CFG_DISABLE_CROSS_TESTS: 1
matrix:
- MSVC: 1
BITS: 64
Expand Down
46 changes: 0 additions & 46 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -369,52 +369,6 @@ if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then
err "cargo does not currently support an out-of-tree build dir"
fi

for i in $CFG_TARGET
do
case $i in
x86_64-*-msvc)
# Use the REG program to figure out where VS is installed
# We need to figure out where cl.exe and link.exe are, so we do some
# munging and some probing here. We also look for the default
# INCLUDE and LIB variables for MSVC so we can set those in the
# build system as well.
install=$(reg QUERY \
'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0' \
-v InstallDir)
need_ok "couldn't find visual studio install root"
CFG_MSVC_ROOT=$(echo "$install" | grep InstallDir | sed 's/.*REG_SZ[ ]*//')
CFG_MSVC_ROOT=$(dirname "$CFG_MSVC_ROOT")
CFG_MSVC_ROOT=$(dirname "$CFG_MSVC_ROOT")
CFG_MSVC_BIN="${CFG_MSVC_ROOT}/VC/bin/amd64"
CFG_MSVC_CL="${CFG_MSVC_BIN}/cl.exe"
CFG_MSVC_LIB="${CFG_MSVC_BIN}/lib.exe"
CFG_MSVC_LINK="${CFG_MSVC_BIN}/link.exe"

vcvarsall="${CFG_MSVC_ROOT}/VC/vcvarsall.bat"
CFG_MSVC_INCLUDE_PATH=$(cmd /c "\"$vcvarsall\" amd64 && cmd /c echo %INCLUDE%")
need_ok "failed to learn about MSVC's INCLUDE"
CFG_MSVC_LIB_PATH=$(cmd /c "\"$vcvarsall\" amd64 && cmd /c echo %LIB%")
need_ok "failed to learn about MSVC's LIB"
CFG_MSVC_WINDOWS_SDK_DIR=$(cmd /c \
"\"$vcvarsall\" amd64 && cmd /c echo %WindowsSdkDir%")
need_ok "failed to learn about MSVC's WindowsSdkDir"
export CFG_MSVC_WINDOWS_SDK_DIR="${CFG_MSVC_WINDOWS_SDK_DIR}bin/x64"

putvar CFG_MSVC_ROOT
putvar CFG_MSVC_BIN
putvar CFG_MSVC_CL
putvar CFG_MSVC_LIB
putvar CFG_MSVC_LINK
putvar CFG_MSVC_INCLUDE_PATH
putvar CFG_MSVC_LIB_PATH
putvar CFG_MSVC_WINDOWS_SDK_DIR
;;

*)
;;
esac
done

if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then
if [ ! -f .cargo/config ]; then
mkdir -p .cargo
Expand Down
27 changes: 19 additions & 8 deletions src/etc/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import sys
import tarfile

def get(url, path):
def get(url, path, quiet=False):
# see http://serverfault.com/questions/301128/how-to-download
if sys.platform == 'win32':
run(["PowerShell.exe", "/nologo", "-Command",
"(New-Object System.Net.WebClient).DownloadFile('" + url +
"', '" + path + "')"])
"', '" + path + "')"], quiet=quiet)
else:
run(["curl", "-o", path, url])
run(["curl", "-o", path, url], quiet=quiet)

def unpack(tarball, dst, quiet=False):
if quiet:
Expand All @@ -31,8 +31,19 @@ def unpack(tarball, dst, quiet=False):
shutil.move(tp, fp)
shutil.rmtree(os.path.join(dst, fname))

def run(args):
print("running: " + ' '.join(args))
ret = subprocess.call(args)
if ret != 0:
raise Exception("failed to fetch url: " + url)
def run(args, quiet=False):
if not quiet:
print("running: " + ' '.join(args))
sys.stdout.flush()
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
ret = subprocess.Popen(args,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
out, err = ret.communicate()
code = ret.wait()
if code != 0:
print("stdout: \n\n" + out)
print("stderr: \n\n" + err)
raise Exception("failed to fetch url")
10 changes: 5 additions & 5 deletions src/etc/install-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
extra_bits = 'i686'

extra = None
libdir = 'lib'

# Figure out our target triple
if sys.platform == 'linux' or sys.platform == 'linux2':
Expand All @@ -24,8 +25,10 @@
host = host_bits + '-apple-darwin'
extra = extra_bits + '-apple-darwin'
elif sys.platform == 'win32':
libdir = 'bin'
if os.environ.get('MSVC') == '1':
host = host_bits + '-pc-windows-msvc'
extra = extra_bits + '-pc-windows-msvc'
else:
host = host_bits + '-pc-windows-gnu'
else:
Expand All @@ -47,21 +50,18 @@ def install_via_tarballs():
extra_fname = 'rustc-nightly-' + extra + '.tar.gz'
print("adding target libs for " + extra)
download.get(url + '/' + extra_fname, extra_fname)
manifest = open("rustc-install/rustc/manifest.in", "a")
folder = extra_fname.replace(".tar.gz", "")
with contextlib.closing(tarfile.open(extra_fname)) as tar:
for p in tar.getnames():
if not "rustc/lib/rustlib/" + extra in p:
if not "rustc/" + libdir + "/rustlib/" + extra in p:
continue
name = p.replace(folder + "/", "", 1)
dst = "rustc-install/" + name
f = tar.extract(p, "rustc-install")
tar.extract(p, "rustc-install")
tp = os.path.join("rustc-install", p)
if os.path.isdir(tp) and os.path.exists(dst):
continue
shutil.move(tp, dst)
if not os.path.isdir(dst):
manifest.write(p.replace(folder + "/rustc/", "file:") + "\n")
shutil.rmtree("rustc-install/" + folder)
os.remove(extra_fname)

Expand Down
Loading