[vcpkg] Add support for muslc, static crt linkage, and forcing the system binaries for cmake and ninja

This commit is contained in:
Robert Schumacher 2018-12-11 10:15:44 -08:00
parent cf7e2f3906
commit 828cedb755
4 changed files with 44 additions and 11 deletions

View File

@ -1,12 +1,23 @@
#!/bin/sh
vcpkgDisableMetrics="OFF"
vcpkgUseSystem=false
for var in "$@"
do
if [ "$var" = "-disableMetrics" ]; then
if [ "$var" = "-disableMetrics" -o "$var" = "--disableMetrics" ]; then
vcpkgDisableMetrics="ON"
elif [ "$var" = "-useSystemBinaries" -o "$var" = "--useSystemBinaries" ]; then
vcpkgUseSystem=true
elif [ "$var" = "-help" -o "$var" = "--help" ]; then
echo "Usage: ./bootstrap-vcpkg.sh [options]"
echo
echo "Options:"
echo " -help Display usage help"
echo " -disableMetrics Do not build metrics reporting into the executable"
echo " -useSystemBinaries Force use of the system utilities for building vcpkg"
exit 1
else
echo "Unknown argument $var"
echo "Unknown argument $var. Use '-help' for help."
exit 1
fi
done
@ -191,13 +202,13 @@ selectCXX()
if [ "$gccversion" -lt "6" ]; then
echo "CXX ($CXX) is too old; please install a newer compiler such as g++-7."
echo "On Ubuntu try the following:"
echo "sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y"
echo "sudo apt-get update -y"
echo "sudo apt-get install g++-7 -y"
echo " sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y"
echo " sudo apt-get update -y"
echo " sudo apt-get install g++-7 -y"
echo "On CentOS try the following:"
echo "sudo yum install centos-release-scl"
echo "sudo yum install devtoolset-7"
echo "scl enable devtoolset-7 bash"
echo " sudo yum install centos-release-scl"
echo " sudo yum install devtoolset-7"
echo " scl enable devtoolset-7 bash"
return 1
fi
@ -206,8 +217,14 @@ selectCXX()
# Preparation
UNAME="$(uname)"
fetchTool "cmake" "$UNAME" cmakeExe || exit 1
fetchTool "ninja" "$UNAME" ninjaExe || exit 1
if $vcpkgUseSystem; then
cmakeExe="cmake"
ninjaExe="ninja"
else
fetchTool "cmake" "$UNAME" cmakeExe || exit 1
fetchTool "ninja" "$UNAME" ninjaExe || exit 1
fi
selectCXX CXX || exit 1
# Do the build

View File

@ -16,5 +16,9 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
if(VCPKG_CRT_LINKAGE STREQUAL "static")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT "-static ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT "-static ")
endif()
endif()
endif()

View File

@ -171,8 +171,10 @@ static void inner(const VcpkgCmdArguments& args)
default_triplet = Triplet::from_canonical_name("x64-osx");
#elif defined(__FreeBSD__)
default_triplet = Triplet::from_canonical_name("x64-freebsd");
#else
#elif defined(__GLIBC__)
default_triplet = Triplet::from_canonical_name("x64-linux");
#else
default_triplet = Triplet::from_canonical_name("x64-linux-musl");
#endif
}
}

View File

@ -253,6 +253,11 @@ namespace vcpkg
static PathAndVersion get_path(const VcpkgPaths& paths)
{
if (System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
{
return {"cmake", "0"};
}
std::vector<fs::path> candidate_paths;
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "cmake");
@ -317,6 +322,11 @@ namespace vcpkg
static PathAndVersion get_path(const VcpkgPaths& paths)
{
if (System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
{
return {"ninja", "0"};
}
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "ninja");
std::vector<fs::path> candidate_paths;