mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 03:10:57 +08:00
Fix bug in .vcpkg-root
detection that breaks --overlay-triplets
(#7954)
* - Added scripts variable to ports file. - Added check if triplet file is not available (NPE). * - Fixed line endings. * Provide location of .vcpkg-root to ports.cmake * vcpkg sets VCPKG_ROOT_PATH in ports.cmake * [vcpkg] Fail if VCPKG_ROOT_PATH is not passed from vcpkg.exe * [vcpkg] Fix vcpkg rooth path * [vcpkg] Make --x-scripts-root an experimental command
This commit is contained in:
parent
0e23cd50fe
commit
191c864927
@ -108,7 +108,7 @@ function(vcpkg_build_msbuild)
|
|||||||
if(_csc_USE_VCPKG_INTEGRATION)
|
if(_csc_USE_VCPKG_INTEGRATION)
|
||||||
list(
|
list(
|
||||||
APPEND _csc_OPTIONS
|
APPEND _csc_OPTIONS
|
||||||
/p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
|
/p:ForceImportBeforeCppTargets=${SCRIPTS}/buildsystems/msbuild/vcpkg.targets
|
||||||
"/p:VcpkgTriplet=${TARGET_TRIPLET}"
|
"/p:VcpkgTriplet=${TARGET_TRIPLET}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -198,15 +198,15 @@ function(vcpkg_configure_cmake)
|
|||||||
|
|
||||||
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
||||||
if(NOT DEFINED VCPKG_CMAKE_SYSTEM_NAME OR _TARGETTING_UWP)
|
if(NOT DEFINED VCPKG_CMAKE_SYSTEM_NAME OR _TARGETTING_UWP)
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/windows.cmake")
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
|
||||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/linux.cmake")
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
|
||||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
|
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/android.cmake")
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake")
|
||||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/osx.cmake")
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake")
|
||||||
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/freebsd.cmake")
|
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ function(vcpkg_configure_cmake)
|
|||||||
"-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE"
|
"-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE"
|
||||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||||
"-DVCPKG_APPLOCAL_DEPS=OFF"
|
"-DVCPKG_APPLOCAL_DEPS=OFF"
|
||||||
"-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT_DIR}/scripts/buildsystems/vcpkg.cmake"
|
"-DCMAKE_TOOLCHAIN_FILE=${SCRIPTS}/buildsystems/vcpkg.cmake"
|
||||||
"-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON"
|
"-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON"
|
||||||
"-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}"
|
"-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}"
|
||||||
"-DVCPKG_CXX_FLAGS_RELEASE=${VCPKG_CXX_FLAGS_RELEASE}"
|
"-DVCPKG_CXX_FLAGS_RELEASE=${VCPKG_CXX_FLAGS_RELEASE}"
|
||||||
|
@ -21,7 +21,7 @@ function(vcpkg_copy_tool_dependencies TOOL_DIR)
|
|||||||
file(GLOB TOOLS ${TOOL_DIR}/*.exe ${TOOL_DIR}/*.dll)
|
file(GLOB TOOLS ${TOOL_DIR}/*.exe ${TOOL_DIR}/*.dll)
|
||||||
foreach(TOOL ${TOOLS})
|
foreach(TOOL ${TOOLS})
|
||||||
execute_process(COMMAND powershell -noprofile -executionpolicy Bypass -nologo
|
execute_process(COMMAND powershell -noprofile -executionpolicy Bypass -nologo
|
||||||
-file ${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/applocal.ps1
|
-file ${SCRIPTS}/buildsystems/msbuild/applocal.ps1
|
||||||
-targetBinary ${TOOL}
|
-targetBinary ${TOOL}
|
||||||
-installedDir ${PATH_TO_SEARCH}
|
-installedDir ${PATH_TO_SEARCH}
|
||||||
OUTPUT_VARIABLE OUT)
|
OUTPUT_VARIABLE OUT)
|
||||||
|
@ -144,7 +144,7 @@ function(vcpkg_install_msbuild)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(_csc_USE_VCPKG_INTEGRATION)
|
if(_csc_USE_VCPKG_INTEGRATION)
|
||||||
list(APPEND _csc_OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets /p:VcpkgApplocalDeps=false)
|
list(APPEND _csc_OPTIONS /p:ForceImportBeforeCppTargets=${SCRIPTS}/buildsystems/msbuild/vcpkg.targets /p:VcpkgApplocalDeps=false)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
get_filename_component(SOURCE_PATH_SUFFIX "${_csc_SOURCE_PATH}" NAME)
|
get_filename_component(SOURCE_PATH_SUFFIX "${_csc_SOURCE_PATH}" NAME)
|
||||||
|
@ -7,22 +7,28 @@ macro(debug_message)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
#Detect .vcpkg-root to figure VCPKG_ROOT_DIR, starting from triplet folder.
|
#Detect .vcpkg-root to figure VCPKG_ROOT_DIR, starting from triplet folder.
|
||||||
get_filename_component(TARGET_TRIPLET_DIR ${TARGET_TRIPLET_FILE} DIRECTORY)
|
set(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
|
||||||
SET(VCPKG_ROOT_DIR_CANDIDATE ${TARGET_TRIPLET_DIR})
|
|
||||||
while(IS_DIRECTORY ${VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
|
if(DEFINED VCPKG_ROOT_PATH)
|
||||||
get_filename_component(VCPKG_ROOT_DIR_TEMP ${VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY)
|
set(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_PATH})
|
||||||
if (VCPKG_ROOT_DIR_TEMP STREQUAL VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive
|
else()
|
||||||
message(FATAL_ERROR "Could not find .vcpkg-root")
|
message(FATAL_ERROR [[
|
||||||
else()
|
Your vcpkg executable is outdated and is not compatible with the current CMake scripts.
|
||||||
SET(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_DIR_TEMP})
|
Please re-build vcpkg by running bootstrap-vcpkg.
|
||||||
endif()
|
]])
|
||||||
endwhile()
|
endif()
|
||||||
|
|
||||||
|
# Validate VCPKG_ROOT_DIR_CANDIDATE
|
||||||
|
if (NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
|
||||||
|
message(FATAL_ERROR "Could not find .vcpkg-root")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
|
set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||||
set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
|
set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
|
||||||
set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")
|
set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")
|
||||||
|
set(SCRIPTS ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Location to stored scripts")
|
||||||
set(PACKAGES_DIR ${VCPKG_ROOT_DIR}/packages CACHE PATH "Location to store package images")
|
set(PACKAGES_DIR ${VCPKG_ROOT_DIR}/packages CACHE PATH "Location to store package images")
|
||||||
set(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build")
|
set(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build")
|
||||||
|
|
||||||
@ -80,8 +86,8 @@ if(CMD MATCHES "^BUILD$")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_definitions.cmake)
|
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_functions.cmake)
|
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
|
||||||
include(${CURRENT_PORT_DIR}/portfile.cmake)
|
include(${CURRENT_PORT_DIR}/portfile.cmake)
|
||||||
|
|
||||||
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
|
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
|
||||||
@ -131,8 +137,8 @@ elseif(CMD MATCHES "^CREATE$")
|
|||||||
file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512)
|
file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ports/${PORT})
|
file(MAKE_DIRECTORY ports/${PORT})
|
||||||
configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY)
|
configure_file(${SCRIPTS}/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY)
|
||||||
configure_file(scripts/templates/CONTROL.in ports/${PORT}/CONTROL @ONLY)
|
configure_file(${SCRIPTS}/templates/CONTROL.in ports/${PORT}/CONTROL @ONLY)
|
||||||
|
|
||||||
message(STATUS "Generated portfile: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake")
|
message(STATUS "Generated portfile: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake")
|
||||||
message(STATUS "Generated CONTROL: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\CONTROL")
|
message(STATUS "Generated CONTROL: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\CONTROL")
|
||||||
|
@ -1 +1 @@
|
|||||||
"2019.08.27"
|
"2019.09.12"
|
||||||
|
@ -13,7 +13,7 @@ TEST_CASE ("VcpkgCmdArguments from lowercase argument sequence", "[arguments]")
|
|||||||
{
|
{
|
||||||
std::vector<std::string> t = {"--vcpkg-root",
|
std::vector<std::string> t = {"--vcpkg-root",
|
||||||
"C:\\vcpkg",
|
"C:\\vcpkg",
|
||||||
"--scripts-root=C:\\scripts",
|
"--x-scripts-root=C:\\scripts",
|
||||||
"--debug",
|
"--debug",
|
||||||
"--sendmetrics",
|
"--sendmetrics",
|
||||||
"--printmetrics",
|
"--printmetrics",
|
||||||
@ -45,7 +45,7 @@ TEST_CASE ("VcpkgCmdArguments from uppercase argument sequence", "[arguments]")
|
|||||||
{
|
{
|
||||||
std::vector<std::string> t = {"--VCPKG-ROOT",
|
std::vector<std::string> t = {"--VCPKG-ROOT",
|
||||||
"C:\\vcpkg",
|
"C:\\vcpkg",
|
||||||
"--SCRIPTS-ROOT=C:\\scripts",
|
"--X-SCRIPTS-ROOT=C:\\scripts",
|
||||||
"--DEBUG",
|
"--DEBUG",
|
||||||
"--SENDMETRICS",
|
"--SENDMETRICS",
|
||||||
"--PRINTMETRICS",
|
"--PRINTMETRICS",
|
||||||
|
@ -396,6 +396,7 @@ namespace vcpkg::Build
|
|||||||
{"CMD", "BUILD"},
|
{"CMD", "BUILD"},
|
||||||
{"PORT", config.scf.core_paragraph->name},
|
{"PORT", config.scf.core_paragraph->name},
|
||||||
{"CURRENT_PORT_DIR", config.port_dir},
|
{"CURRENT_PORT_DIR", config.port_dir},
|
||||||
|
{"VCPKG_ROOT_PATH", paths.root},
|
||||||
{"TARGET_TRIPLET", triplet.canonical_name()},
|
{"TARGET_TRIPLET", triplet.canonical_name()},
|
||||||
{"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()},
|
{"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()},
|
||||||
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
|
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
|
||||||
|
@ -125,7 +125,7 @@ namespace vcpkg::Help
|
|||||||
" (default: " ENVVAR(VCPKG_ROOT) //
|
" (default: " ENVVAR(VCPKG_ROOT) //
|
||||||
")\n"
|
")\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --scripts-root=<path> Specify the scripts root directory\n"
|
" --x-scripts-root=<path> (Experimental) Specify the scripts root directory\n"
|
||||||
"\n"
|
"\n"
|
||||||
" @response_file Specify a "
|
" @response_file Specify a "
|
||||||
"response file to provide additional parameters\n"
|
"response file to provide additional parameters\n"
|
||||||
|
@ -146,10 +146,10 @@ namespace vcpkg
|
|||||||
parse_value(arg_begin, arg_end, "--vcpkg-root", args.vcpkg_root_dir);
|
parse_value(arg_begin, arg_end, "--vcpkg-root", args.vcpkg_root_dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Strings::starts_with(arg, "--scripts-root="))
|
if (Strings::starts_with(arg, "--x-scripts-root="))
|
||||||
{
|
{
|
||||||
parse_cojoined_value(
|
parse_cojoined_value(
|
||||||
arg.substr(sizeof("--scripts-root=") - 1), "--scripts-root", args.scripts_root_dir);
|
arg.substr(sizeof("--x-scripts-root=") - 1), "--x-scripts-root", args.scripts_root_dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (arg == "--triplet")
|
if (arg == "--triplet")
|
||||||
@ -430,7 +430,7 @@ namespace vcpkg
|
|||||||
"--vcpkg-root <path>",
|
"--vcpkg-root <path>",
|
||||||
"Specify the vcpkg directory to use instead of current directory or tool directory");
|
"Specify the vcpkg directory to use instead of current directory or tool directory");
|
||||||
System::printf(" %-40s %s\n",
|
System::printf(" %-40s %s\n",
|
||||||
"--scripts-root=<path>",
|
"--x-scripts-root=<path>",
|
||||||
"Specify the scripts directory to use instead of default vcpkg scripts directory");
|
"(Experimental) Specify the scripts directory to use instead of default vcpkg scripts directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace vcpkg
|
|||||||
Checks::exit_with_message(
|
Checks::exit_with_message(
|
||||||
VCPKG_LINE_INFO,
|
VCPKG_LINE_INFO,
|
||||||
"Invalid scripts override directory: %s; "
|
"Invalid scripts override directory: %s; "
|
||||||
"create that directory or unset --scripts-root to use the default scripts location.",
|
"create that directory or unset --x-scripts-root to use the default scripts location.",
|
||||||
scripts_dir->u8string());
|
scripts_dir->u8string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user