mirror of
https://github.com/cemu-project/vcpkg.git
synced 2024-11-27 05:00:42 +00: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)
|
||||
list(
|
||||
APPEND _csc_OPTIONS
|
||||
/p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
|
||||
/p:ForceImportBeforeCppTargets=${SCRIPTS}/buildsystems/msbuild/vcpkg.targets
|
||||
"/p:VcpkgTriplet=${TARGET_TRIPLET}"
|
||||
)
|
||||
endif()
|
||||
|
@ -198,15 +198,15 @@ function(vcpkg_configure_cmake)
|
||||
|
||||
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${VCPKG_ROOT_DIR}/scripts/toolchains/freebsd.cmake")
|
||||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -222,7 +222,7 @@ function(vcpkg_configure_cmake)
|
||||
"-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE"
|
||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
"-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"
|
||||
"-DVCPKG_CXX_FLAGS=${VCPKG_CXX_FLAGS}"
|
||||
"-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)
|
||||
foreach(TOOL ${TOOLS})
|
||||
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}
|
||||
-installedDir ${PATH_TO_SEARCH}
|
||||
OUTPUT_VARIABLE OUT)
|
||||
|
@ -144,7 +144,7 @@ function(vcpkg_install_msbuild)
|
||||
endif()
|
||||
|
||||
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()
|
||||
|
||||
get_filename_component(SOURCE_PATH_SUFFIX "${_csc_SOURCE_PATH}" NAME)
|
||||
|
@ -7,22 +7,28 @@ macro(debug_message)
|
||||
endmacro()
|
||||
|
||||
#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 ${TARGET_TRIPLET_DIR})
|
||||
while(IS_DIRECTORY ${VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
|
||||
get_filename_component(VCPKG_ROOT_DIR_TEMP ${VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY)
|
||||
if (VCPKG_ROOT_DIR_TEMP STREQUAL VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive
|
||||
message(FATAL_ERROR "Could not find .vcpkg-root")
|
||||
else()
|
||||
SET(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_DIR_TEMP})
|
||||
endif()
|
||||
endwhile()
|
||||
set(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if(DEFINED VCPKG_ROOT_PATH)
|
||||
set(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_PATH})
|
||||
else()
|
||||
message(FATAL_ERROR [[
|
||||
Your vcpkg executable is outdated and is not compatible with the current CMake scripts.
|
||||
Please re-build vcpkg by running bootstrap-vcpkg.
|
||||
]])
|
||||
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})
|
||||
|
||||
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(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(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build")
|
||||
|
||||
@ -80,8 +86,8 @@ if(CMD MATCHES "^BUILD$")
|
||||
endif()
|
||||
|
||||
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_definitions.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_common_functions.cmake)
|
||||
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
|
||||
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
|
||||
include(${CURRENT_PORT_DIR}/portfile.cmake)
|
||||
|
||||
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
|
||||
@ -131,8 +137,8 @@ elseif(CMD MATCHES "^CREATE$")
|
||||
file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512)
|
||||
|
||||
file(MAKE_DIRECTORY ports/${PORT})
|
||||
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/portfile.in.cmake ports/${PORT}/portfile.cmake @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 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",
|
||||
"C:\\vcpkg",
|
||||
"--scripts-root=C:\\scripts",
|
||||
"--x-scripts-root=C:\\scripts",
|
||||
"--debug",
|
||||
"--sendmetrics",
|
||||
"--printmetrics",
|
||||
@ -45,7 +45,7 @@ TEST_CASE ("VcpkgCmdArguments from uppercase argument sequence", "[arguments]")
|
||||
{
|
||||
std::vector<std::string> t = {"--VCPKG-ROOT",
|
||||
"C:\\vcpkg",
|
||||
"--SCRIPTS-ROOT=C:\\scripts",
|
||||
"--X-SCRIPTS-ROOT=C:\\scripts",
|
||||
"--DEBUG",
|
||||
"--SENDMETRICS",
|
||||
"--PRINTMETRICS",
|
||||
|
@ -396,6 +396,7 @@ namespace vcpkg::Build
|
||||
{"CMD", "BUILD"},
|
||||
{"PORT", config.scf.core_paragraph->name},
|
||||
{"CURRENT_PORT_DIR", config.port_dir},
|
||||
{"VCPKG_ROOT_PATH", paths.root},
|
||||
{"TARGET_TRIPLET", triplet.canonical_name()},
|
||||
{"TARGET_TRIPLET_FILE", paths.get_triplet_file_path(triplet).u8string()},
|
||||
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
|
||||
|
@ -125,7 +125,7 @@ namespace vcpkg::Help
|
||||
" (default: " ENVVAR(VCPKG_ROOT) //
|
||||
")\n"
|
||||
"\n"
|
||||
" --scripts-root=<path> Specify the scripts root directory\n"
|
||||
" --x-scripts-root=<path> (Experimental) Specify the scripts root directory\n"
|
||||
"\n"
|
||||
" @response_file Specify a "
|
||||
"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);
|
||||
continue;
|
||||
}
|
||||
if (Strings::starts_with(arg, "--scripts-root="))
|
||||
if (Strings::starts_with(arg, "--x-scripts-root="))
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (arg == "--triplet")
|
||||
@ -430,7 +430,7 @@ namespace vcpkg
|
||||
"--vcpkg-root <path>",
|
||||
"Specify the vcpkg directory to use instead of current directory or tool directory");
|
||||
System::printf(" %-40s %s\n",
|
||||
"--scripts-root=<path>",
|
||||
"Specify the scripts directory to use instead of default vcpkg scripts directory");
|
||||
"--x-scripts-root=<path>",
|
||||
"(Experimental) Specify the scripts directory to use instead of default vcpkg scripts directory");
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace vcpkg
|
||||
Checks::exit_with_message(
|
||||
VCPKG_LINE_INFO,
|
||||
"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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user