Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1434943 - Support for MSVC in build.sh, r=jcj
This adds basic support for MSVC to build.sh. It uses the registry and vswhere (which is part of the standard mozilla-build setup now) to work out paths and set them properly. It's probably a little fragile, but it's better than the shoestring and tape we have in builds right now. I took the liberty of sanitizing the command-line options a little here. Mostly that is sorting them, but I also deprecated the -m32 option in favour of specifying target architecture with -t. That turned out to be a lot cleaner. --HG-- extra : rebase_source : 5f62c7a277de0c13f7a2c0ac1e495095dc803841 extra : amend_source : e6db2463ea560ada42ca091023e87adce284a853
- Loading branch information
1 parent
efd8876
commit 762709e
Showing
6 changed files
with
193 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/bash | ||
# This configures the environment for running MSVC. It uses vswhere, the | ||
# registry, and a little knowledge of how MSVC is laid out. | ||
|
||
if ! hash vswhere 2>/dev/null; then | ||
echo "Can't find vswhere on the path, aborting" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
if ! hash reg 2>/dev/null; then | ||
echo "Can't find reg on the path, aborting" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# Turn a unix-y path into a windows one. | ||
fixpath() { | ||
if hash cygpath 2>/dev/null; then | ||
cygpath --unix "$1" | ||
else # haxx | ||
echo "$1" | sed -e 's,\\,/,g;s,^\(.\):,/\L\1,;s,/$,,' | ||
fi | ||
} | ||
|
||
# Query the registry. This takes $1 and tags that on the end of several | ||
# different paths, looking for a value called $2 at that location. | ||
# e.g., | ||
# regquery Microsoft\Microsoft SDKs\Windows\v10.0 ProductVersion | ||
# looks for a REG_SZ value called ProductVersion at | ||
# HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 | ||
# HKLU\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0 | ||
# etc... | ||
regquery() { | ||
search=("HKLM\\SOFTWARE\\Wow6432Node" \ | ||
"HKCU\\SOFTWARE\\Wow6432Node" \ | ||
"HKLM\\SOFTWARE" \ | ||
"HKCU\\SOFTWARE") | ||
for i in "${search[@]}"; do | ||
r=$(reg query "${i}\\${1}" -v "$2" | sed -e 's/ *'"$2"' *REG_SZ *//;t;d') | ||
if [ -n "$r" ]; then | ||
echo "$r" | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
case "$target_arch" in | ||
ia32) m=x86 ;; | ||
x64) m="$target_arch" ;; | ||
*) | ||
echo "No support for target architecture '$target_arch' with MSVC." 1>&2 | ||
exit 1 | ||
esac | ||
|
||
VSCOMPONENT=Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | ||
VSPATH=$(vswhere -latest -requires "$VSCOMPONENT" -property installationPath) | ||
export VSPATH=$(fixpath "$VSPATH") | ||
export WINDOWSSDKDIR="${VSPATH}/SDK" | ||
export VCINSTALLDIR="${VSPATH}/VC" | ||
|
||
CRTREG="Microsoft\\Microsoft SDKs\\Windows\\v10.0" | ||
UniversalCRTSdkDir=$(regquery "$CRTREG" InstallationFolder) | ||
UniversalCRTSdkDir=$(fixpath "$UniversalCRTSdkDir") | ||
UCRTVersion=$(regquery "$CRTREG" ProductVersion) | ||
UCRTVersion=$(cd "${UniversalCRTSdkDir}/include"; ls -d "${UCRTVersion}"* | tail -1) | ||
|
||
VCVER=$(cat "${VCINSTALLDIR}/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt") | ||
REDISTVER=$(cat "${VCINSTALLDIR}/Auxiliary/Build/Microsoft.VCRedistVersion.default.txt") | ||
export WIN32_REDIST_DIR="${VCINSTALLDIR}/Redist/MSVC/${REDISTVER}/${m}/Microsoft.VC141.CRT" | ||
export WIN_UCRT_REDIST_DIR="${UniversalCRTSdkDir}/Redist/ucrt/DLLs/${m}" | ||
|
||
if [ "$m" == "x86" ]; then | ||
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/HostX64/x86" | ||
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/Hostx86/x86" | ||
fi | ||
PATH="${PATH}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/bin/HostX64/x64" | ||
PATH="${PATH}:${UniversalCRTSdkDir}/bin/${UCRTVersion}/x64" | ||
PATH="${PATH}:${UniversalCRTSdkDir}/bin/${UCRTVersion}/x86" | ||
PATH="${PATH}:${WIN32_REDIST_DIR}" | ||
export PATH | ||
|
||
INCLUDE="${VCINSTALLDIR}/Tools/MSVC/${VCVER}/ATLMFC/include" | ||
INCLUDE="${INCLUDE}:${VCINSTALLDIR}/Tools/MSVC/${VCVER}/include" | ||
INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/ucrt" | ||
INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/shared" | ||
INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/um" | ||
INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/winrt" | ||
INCLUDE="${INCLUDE}:${UniversalCRTSdkDir}/include/${UCRTVersion}/cppwinrt" | ||
export INCLUDE | ||
|
||
LIB="${VCINSTALLDIR}/lib/${m}" | ||
LIB="${VCINSTALLDIR}/Tools/MSVC/${VCVER}/lib/${m}" | ||
LIB="${LIB}:${UniversalCRTSdkDir}/lib/${UCRTVersion}/ucrt/${m}" | ||
LIB="${LIB}:${UniversalCRTSdkDir}/lib/${UCRTVersion}/um/${m}" | ||
export LIB | ||
|
||
export GYP_MSVS_OVERRIDE_PATH="${VSPATH}" | ||
export GYP_MSVS_VERSION=$(vswhere -latest -requires "$VSCOMPONENT" -property catalog_productLineVersion) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.