Remove MSVC logic from the configure script

Cargo will soon support testing the cross compilation capabilities between 32/64
bit Windows, meaning that there's not "one true value" for any of these
environment variables that Cargo is setting (e.g. where to find `cl`, `link`,
etc). Instead, all dependencies have been updated to probe the system (in the
same manner as the compiler) for the tools that they're using.

All of the logic is housed in the `gcc` crate which now exposes a function to
probe the system for a particular tool. The updated crates here then use the
result of this probe to run the various build scripts. This all boils down to
being able to build MSVC targets inside an MSYS shell instead of requiring use
of a MSVC shell (which doesn't allow for simultaneous host builds and cross
builds).
This commit is contained in:
Alex Crichton 2015-07-22 14:38:35 -07:00
parent c814d85f39
commit a24ca998ba
4 changed files with 42 additions and 90 deletions

71
Cargo.lock generated
View File

@ -2,7 +2,7 @@
name = "cargo"
version = "0.4.0"
dependencies = [
"advapi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.67 (registry+https://github.com/rust-lang/crates.io-index)",
@ -13,9 +13,9 @@ dependencies = [
"git2-curl 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
"kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
@ -24,20 +24,21 @@ dependencies = [
"semver 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "advapi32-sys"
version = "0.1.0"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -63,7 +64,7 @@ name = "curl"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"curl-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
"curl-sys 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -72,11 +73,12 @@ dependencies = [
[[package]]
name = "curl-sys"
version = "0.1.24"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -116,8 +118,12 @@ dependencies = [
[[package]]
name = "gcc"
version = "0.3.8"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "git2"
@ -126,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -153,10 +159,11 @@ source = "git+https://github.com/carllerche/hamcrest-rust.git#b61fef3e6d47114f86
[[package]]
name = "kernel32-sys"
version = "0.1.0"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -166,12 +173,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libgit2-sys"
version = "0.2.19"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libssh2-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libssh2-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -186,20 +193,22 @@ dependencies = [
[[package]]
name = "libssh2-sys"
version = "0.1.26"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libz-sys"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -230,7 +239,7 @@ name = "miniz-sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -247,7 +256,7 @@ name = "openssl-sys"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libressl-pnacl-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -330,11 +339,11 @@ dependencies = [
[[package]]
name = "term"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -347,7 +356,7 @@ name = "time"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -370,9 +379,11 @@ dependencies = [
[[package]]
name = "winapi"
version = "0.1.22"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -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"

View File

@ -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

46
configure vendored
View File

@ -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