mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-15 02:08:15 +08:00
[vcpkg] Add support for muslc, static crt linkage, and forcing the system binaries for cmake and ninja
This commit is contained in:
parent
cf7e2f3906
commit
828cedb755
@ -1,12 +1,23 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
vcpkgDisableMetrics="OFF"
|
vcpkgDisableMetrics="OFF"
|
||||||
|
vcpkgUseSystem=false
|
||||||
for var in "$@"
|
for var in "$@"
|
||||||
do
|
do
|
||||||
if [ "$var" = "-disableMetrics" ]; then
|
if [ "$var" = "-disableMetrics" -o "$var" = "--disableMetrics" ]; then
|
||||||
vcpkgDisableMetrics="ON"
|
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
|
else
|
||||||
echo "Unknown argument $var"
|
echo "Unknown argument $var. Use '-help' for help."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -191,13 +202,13 @@ selectCXX()
|
|||||||
if [ "$gccversion" -lt "6" ]; then
|
if [ "$gccversion" -lt "6" ]; then
|
||||||
echo "CXX ($CXX) is too old; please install a newer compiler such as g++-7."
|
echo "CXX ($CXX) is too old; please install a newer compiler such as g++-7."
|
||||||
echo "On Ubuntu try the following:"
|
echo "On Ubuntu try the following:"
|
||||||
echo "sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y"
|
echo " sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y"
|
||||||
echo "sudo apt-get update -y"
|
echo " sudo apt-get update -y"
|
||||||
echo "sudo apt-get install g++-7 -y"
|
echo " sudo apt-get install g++-7 -y"
|
||||||
echo "On CentOS try the following:"
|
echo "On CentOS try the following:"
|
||||||
echo "sudo yum install centos-release-scl"
|
echo " sudo yum install centos-release-scl"
|
||||||
echo "sudo yum install devtoolset-7"
|
echo " sudo yum install devtoolset-7"
|
||||||
echo "scl enable devtoolset-7 bash"
|
echo " scl enable devtoolset-7 bash"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -206,8 +217,14 @@ selectCXX()
|
|||||||
|
|
||||||
# Preparation
|
# Preparation
|
||||||
UNAME="$(uname)"
|
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
|
selectCXX CXX || exit 1
|
||||||
|
|
||||||
# Do the build
|
# Do the build
|
||||||
|
@ -16,5 +16,9 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
|
|||||||
|
|
||||||
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
|
||||||
string(APPEND CMAKE_EXE_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()
|
||||||
endif()
|
endif()
|
||||||
|
@ -171,8 +171,10 @@ static void inner(const VcpkgCmdArguments& args)
|
|||||||
default_triplet = Triplet::from_canonical_name("x64-osx");
|
default_triplet = Triplet::from_canonical_name("x64-osx");
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
default_triplet = Triplet::from_canonical_name("x64-freebsd");
|
default_triplet = Triplet::from_canonical_name("x64-freebsd");
|
||||||
#else
|
#elif defined(__GLIBC__)
|
||||||
default_triplet = Triplet::from_canonical_name("x64-linux");
|
default_triplet = Triplet::from_canonical_name("x64-linux");
|
||||||
|
#else
|
||||||
|
default_triplet = Triplet::from_canonical_name("x64-linux-musl");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,6 +253,11 @@ namespace vcpkg
|
|||||||
|
|
||||||
static PathAndVersion get_path(const VcpkgPaths& paths)
|
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;
|
std::vector<fs::path> candidate_paths;
|
||||||
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
|
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
|
||||||
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "cmake");
|
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)
|
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");
|
static const ToolData TOOL_DATA = parse_tool_data_from_xml(paths, "ninja");
|
||||||
|
|
||||||
std::vector<fs::path> candidate_paths;
|
std::vector<fs::path> candidate_paths;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user