[gn-related-ports] Fix gn based projects build error on Windows (#29058)

* fix gn path error on windows

* add quotes

* vcpkg cmake guidelines

* Fix version database.

* Use Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL instead of WARNING

* Quotes 🤦

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
reito 2023-01-27 10:53:54 +08:00 коммит произвёл GitHub
Родитель ac12118f02
Коммит 75381ea7fa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 126 добавлений и 96 удалений

Просмотреть файл

@ -110,7 +110,7 @@ set(OPTIONS_REL "${OPTIONS} is_debug=false symbol_level=0")
set(DEFINITIONS_DBG ${DEFINITIONS})
set(DEFINITIONS_REL ${DEFINITIONS})
vcpkg_configure_gn(
vcpkg_gn_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG "${OPTIONS_DBG}"
OPTIONS_RELEASE "${OPTIONS_REL}"
@ -130,7 +130,7 @@ if(WIN32)
list(APPEND TARGETS base/win:pe_image)
endif()
vcpkg_install_gn(
vcpkg_gn_install(
SOURCE_PATH "${SOURCE_PATH}"
TARGETS ${TARGETS}
)

Просмотреть файл

@ -1,12 +1,16 @@
{
"name": "chromium-base",
"version": "86.0.4199.1",
"port-version": 4,
"port-version": 5,
"description": "Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.",
"homepage": "https://chromium.googlesource.com/chromium/src",
"license": "BSD-3-Clause",
"supports": "x64 & (osx | windows | linux) & !uwp",
"dependencies": [
{
"name": "vcpkg-gn",
"host": true
},
{
"name": "vcpkg-tool-gn",
"host": true

Просмотреть файл

@ -90,13 +90,14 @@ if(CMAKE_HOST_WIN32)
set(OPTIONS_REL "${OPTIONS_REL} ${DISABLE_WHOLE_PROGRAM_OPTIMIZATION}")
endif()
vcpkg_configure_gn(
vcpkg_gn_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS " target_cpu=\"${VCPKG_TARGET_ARCHITECTURE}\" "
OPTIONS_DEBUG "${OPTIONS_DBG}"
OPTIONS_RELEASE "${OPTIONS_REL}"
)
vcpkg_install_gn(
vcpkg_gn_install(
SOURCE_PATH "${SOURCE_PATH}"
TARGETS client client:common util third_party/mini_chromium/mini_chromium/base handler:crashpad_handler
)

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "crashpad",
"version-date": "2022-09-05",
"port-version": 1,
"port-version": 2,
"description": [
"Crashpad is a crash-reporting system.",
"Crashpad is a library for capturing, storing and transmitting postmortem crash reports from a client to an upstream collection server. Crashpad aims to make it possible for clients to capture process state at the time of crash with the best possible fidelity and coverage, with the minimum of fuss."
@ -14,6 +14,10 @@
"name": "vcpkg-cmake-get-vars",
"host": true
},
{
"name": "vcpkg-gn",
"host": true
},
{
"name": "vcpkg-tool-gn",
"host": true

Просмотреть файл

@ -268,7 +268,7 @@ if(VCPKG_TARGET_IS_UWP)
string(APPEND OPTIONS " extra_ldflags=${SKIA_LD_FLAGS}")
endif()
vcpkg_configure_gn(
vcpkg_gn_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS "${OPTIONS} skia_use_lua=false skia_enable_tools=false skia_enable_spirv_validation=false"
OPTIONS_DEBUG "${OPTIONS_DBG}"
@ -294,7 +294,7 @@ if(NOT VCPKG_BUILD_TYPE)
file(READ "${CURRENT_BUILDTREES_DIR}/desc-${TARGET_TRIPLET}-dbg-out.log" desc_debug)
endif()
vcpkg_install_gn(
vcpkg_gn_install(
SOURCE_PATH "${SOURCE_PATH}"
TARGETS ${SKIA_TARGETS}
)

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "skia",
"version": "0.36.0",
"port-version": 5,
"port-version": 6,
"description": [
"Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms.",
"It serves as the graphics engine for Google Chrome and Chrome OS, Android, Mozilla Firefox and Firefox OS, and many other products.",
@ -24,6 +24,10 @@
"name": "vcpkg-cmake-get-vars",
"host": true
},
{
"name": "vcpkg-gn",
"host": true
},
{
"name": "vcpkg-pkgconfig-get-modules",
"host": true

Просмотреть файл

@ -147,7 +147,7 @@ endif()
message(STATUS "Generating v8 build files. Please wait...")
vcpkg_configure_gn(
vcpkg_gn_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS "is_component_build=${is_component_build} target_cpu=\"${VCPKG_TARGET_ARCHITECTURE}\" v8_monolithic=${v8_monolithic} v8_use_external_startup_data=${v8_use_external_startup_data} use_sysroot=false is_clang=false use_custom_libcxx=false v8_enable_verify_heap=false icu_use_data_file=false"
OPTIONS_DEBUG "is_debug=true enable_iterator_debugging=true pkg_config_libdir=\"${UNIX_CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig\""
@ -156,7 +156,7 @@ vcpkg_configure_gn(
message(STATUS "Building v8. Please wait...")
vcpkg_install_gn(
vcpkg_gn_install(
SOURCE_PATH "${SOURCE_PATH}"
TARGETS ${targets}
)

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "v8",
"version": "9.1.269.39",
"port-version": 4,
"port-version": 5,
"description": "Google Chrome's JavaScript engine",
"homepage": "https://v8.dev",
"license": "BSD-3-Clause",
@ -16,6 +16,10 @@
"name": "pthread",
"platform": "linux"
},
{
"name": "vcpkg-gn",
"host": true
},
{
"name": "vcpkg-tool-python2",
"host": true

Просмотреть файл

@ -4,70 +4,9 @@ if(NOT TARGET_TRIPLET STREQUAL _HOST_TRIPLET)
message(FATAL_ERROR "vcpkg-gn is a host-only port; please mark it as a host port in your dependencies.")
endif()
set(BASE_URL "https://chrome-infra-packages.appspot.com/dl/gn/gn")
set(PLATFORM "")
set(ID "")
set(HASH "")
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(PLATFORM "windows-amd64")
set(ID "UXzb_By8w0nZJ4HNiOo0-ylLKn97JMEGeFgu7lh-5bYC")
set(HASH "4508eee7a8d594d31d34a9810371ba13f0b233642ed89b0185ef209165af1c1b2df49d4b5020e01f333a0724b66bcae80133db8f6256d37295b02927743eaddf")
else()
message(FATAL_ERROR "Only x64 is supported on Windows")
endif()
elseif(VCPKG_TARGET_IS_OSX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(PLATFORM "mac-amd64")
set(ID "Al2dYNoD4IBgOnjJSohdXIZMhZJIqHeyaE2AiqWYfIYC")
set(HASH "98b0f6c99ab5e9f6aac448e19aa22d6f2a4924cff51493ce905be7329e1575575c5b9be96e86b07eb0be7215718bf6384bcee01233c8ef0d5554bfa3f51fc811")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(PLATFORM "mac-arm64")
set(ID "WVStyq9u1pq0xScIl-o4nOlNBYTHCQQCV0KPhgRAAhEC")
set(HASH "ec7a46574d6dc4177e02ac0e558da59dfaa503bf2263c904b09145bc5cbee759c91f0b55b4bc9f372953af78eb3ac6ad98e0fc1b1cf419689a1f7615c786311d")
else()
message(FATAL_ERROR "Only x64 and arm64 are supported on osx")
endif()
elseif(VCPKG_TARGET_IS_LINUX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(PLATFORM "linux-amd64")
set(ID "bMLaJoqEAsCsT5M_sG6KxlaiRQ5aS2RVhrC2qLPilE8C")
set(HASH "fd073139b4ca816dd9f742232d565017237589ec62d02dcb2e54a1d22350450e61b11cc8aa9acd645565f7aac62f9d0bf64ca30f8e6c07f547c746cea3998064")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(PLATFORM "linux-arm64")
set(ID "A_VzbiVBrgO0cxX_Iyt8FomIH-WU8YAG2LW8FAhSaOgC")
set(HASH "71da448fd496f803d241ef3656a0c69889a7084624f7f6f92c5326b6e7c0a67b386c69f5cff1a07402b5aa57f5d754a23e09191bbecae8d443ad9896198e36a7")
else()
message(FATAL_ERROR "Only x64 and arm64 are supported on linux")
endif()
else()
message(FATAL_ERROR "Target not yet supported by '${PORT}'")
endif()
set(URL "${BASE_URL}/${PLATFORM}/+/${ID}")
message(STATUS "URL: '${URL}'")
vcpkg_download_distfile(ARCHIVE_PATH
URLS "${URL}"
SHA512 "${HASH}"
FILENAME "gn-${PLATFORM}-${ID}.zip"
#ALWAYS_REDOWNLOAD
#SKIP_SHA512
)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
message(STATUS "ARCHIVE_PATH: '${ARCHIVE_PATH}'")
vcpkg_execute_in_download_mode(
COMMAND ${CMAKE_COMMAND} -E tar xzf "${ARCHIVE_PATH}"
WORKING_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}"
)
file(GLOB_RECURSE folders "${CURRENT_PACKAGES_DIR}/tools/${PORT}/*" LIST_DIRECTORIES true)
message(STATUS "Files and Folders: '${folders}'")
file(INSTALL
"${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_gn_configure.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_gn_install.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake"
"${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_fixup_path.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

Просмотреть файл

@ -1,3 +1,3 @@
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_gn_configure.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_gn_install.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_real_path.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_fixup_path.cmake")

Просмотреть файл

@ -1,14 +1,14 @@
{
"name": "vcpkg-gn",
"version-date": "2021-11-16",
"port-version": 2,
"port-version": 3,
"description": "https://gn.googlesource.com/gn/+/4aa9bdfa05b688c58d3d7d3e496f3f18cbb3d89e",
"documentation": "https://vcpkg.io/en/docs/README.html",
"license": "MIT",
"supports": "native & !x86",
"supports": "native",
"dependencies": [
{
"name": "vcpkg-tool-python2",
"name": "vcpkg-tool-gn",
"host": true
}
]

Просмотреть файл

@ -1,5 +1,5 @@
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_real_path.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_fixup_path.cmake")
function(z_vcpkg_gn_configure_generate)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "SOURCE_PATH;CONFIG;ARGS" "")
@ -9,7 +9,7 @@ function(z_vcpkg_gn_configure_generate)
message(STATUS "Generating build (${arg_CONFIG})...")
vcpkg_execute_required_process(
COMMAND "${VCPKG_GN}" gen "${CURRENT_BUILDTREES_DIR}/${arg_CONFIG}" "${arg_ARGS}"
COMMAND "${GN}" gen "${CURRENT_BUILDTREES_DIR}/${arg_CONFIG}" "${arg_ARGS}"
WORKING_DIRECTORY "${arg_SOURCE_PATH}"
LOGNAME "generate-${arg_CONFIG}"
)
@ -25,9 +25,9 @@ function(vcpkg_gn_configure)
message(FATAL_ERROR "SOURCE_PATH must be specified.")
endif()
vcpkg_find_acquire_program(PYTHON2)
get_filename_component(PYTHON2_DIR "${PYTHON2}" DIRECTORY)
vcpkg_add_to_path(PREPEND "${PYTHON2_DIR}")
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path(PREPEND "${PYTHON3_DIR}")
vcpkg_find_acquire_program(GN)
@ -46,4 +46,6 @@ function(vcpkg_gn_configure)
ARGS "--args=${arg_OPTIONS} ${arg_OPTIONS_RELEASE}"
)
endif()
z_vcpkg_gn_fixup_path()
endfunction()

Просмотреть файл

@ -1,5 +1,4 @@
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_gn_real_path.cmake")
function(z_vcpkg_gn_install_get_target_type out_var)
cmake_parse_arguments(PARSE_ARGV 1 "arg" "" "SOURCE_PATH;BUILD_DIR;TARGET" "")
@ -8,7 +7,7 @@ function(z_vcpkg_gn_install_get_target_type out_var)
endif()
execute_process(
COMMAND "${VCPKG_GN}" desc "${arg_BUILD_DIR}" "${arg_TARGET}"
COMMAND "${GN}" desc "${arg_BUILD_DIR}" "${arg_TARGET}"
WORKING_DIRECTORY "${arg_SOURCE_PATH}"
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE
@ -27,7 +26,7 @@ function(z_vcpkg_gn_install_get_desc out_var)
endif()
execute_process(
COMMAND "${VCPKG_GN}" desc "${arg_BUILD_DIR}" "${arg_TARGET}" "${arg_WHAT_TO_DISPLAY}"
COMMAND "${GN}" desc "${arg_BUILD_DIR}" "${arg_TARGET}" "${arg_WHAT_TO_DISPLAY}"
WORKING_DIRECTORY "${arg_SOURCE_PATH}"
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE

Просмотреть файл

@ -0,0 +1,48 @@
function(z_vcpkg_gn_fixup_path_internal)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "BUILD_DIR" "")
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Internal error: install was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
if(NOT DEFINED arg_BUILD_DIR)
message(FATAL_ERROR "BUILD_DIR must be specified.")
endif()
file(GLOB_RECURSE NINJA_FILES LIST_DIRECTORIES false "${arg_BUILD_DIR}/*.ninja")
# replace all ../../../C$:/ pattern to C$:/ using regex: (\.\.\/)+([a-zA-Z]\$:\/)
# (cmake regex is function limited, any plan for implementing a vcpkg built-in full functional regex?)
set(NINJA_FIX_REGEX [=[(\.\.\/)+([a-zA-Z]\$:\/)]=])
foreach(NINJA_FILE IN LISTS NINJA_FILES)
file(READ "${NINJA_FILE}" NINJA_CONTENT)
string(REGEX REPLACE "${NINJA_FIX_REGEX}" "\\2" NINJA_CONTENT_PATH_FIXED "${NINJA_CONTENT}")
file(WRITE "${NINJA_FILE}" "${NINJA_CONTENT_PATH_FIXED}")
endforeach()
endfunction()
function(z_vcpkg_gn_fixup_path)
if (NOT VCPKG_HOST_IS_WINDOWS)
return()
endif()
message(STATUS "vcpkg-gn: fixing ninja paths for Windows")
cmake_parse_arguments(PARSE_ARGV 0 arg "" "" "")
if(DEFINED arg_UNPARSED_ARGUMENTS)
message(WARNING "vcpkg_fixup_gn_path was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
z_vcpkg_gn_fixup_path_internal(
BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
z_vcpkg_gn_fixup_path_internal(
BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
)
endif()
endfunction()

Просмотреть файл

@ -1,4 +0,0 @@
include_guard(GLOBAL)
file(REAL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../tools/vcpkg-gn/gn${CMAKE_EXECUTABLE_SUFFIX}" VCPKG_GN)
set(VCPKG_GN "${VCPKG_GN}" CACHE INTERNAL "")

Просмотреть файл

@ -16,6 +16,8 @@ endfunction()
function(vcpkg_configure_gn)
if(Z_VCPKG_GN_CONFIGURE_GUARD)
message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-gn; using both vcpkg-gn and vcpkg_configure_gn in the same port is unsupported.")
else()
message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "This function 'vcpkg_configure_gn' is obsolete. Use 'vcpkg_gn_configure' in port 'vcpkg-gn'.")
endif()
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "SOURCE_PATH;OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" "")

Просмотреть файл

@ -82,6 +82,8 @@ endfunction()
function(vcpkg_install_gn)
if(Z_VCPKG_GN_INSTALL_GUARD)
message(FATAL_ERROR "The ${PORT} port already depends on vcpkg-gn; using both vcpkg-gn and vcpkg_install_gn in the same port is unsupported.")
else()
message("${Z_VCPKG_BACKCOMPAT_MESSAGE_LEVEL}" "This function 'vcpkg_install_gn' is obsolete. Use 'vcpkg_gn_install' in port 'vcpkg-gn'.")
endif()
cmake_parse_arguments(PARSE_ARGV 0 arg "" "SOURCE_PATH" "TARGETS")

Просмотреть файл

@ -1434,7 +1434,7 @@
},
"chromium-base": {
"baseline": "86.0.4199.1",
"port-version": 4
"port-version": 5
},
"cimg": {
"baseline": "2.9.9",
@ -1754,7 +1754,7 @@
},
"crashpad": {
"baseline": "2022-09-05",
"port-version": 1
"port-version": 2
},
"crashrpt": {
"baseline": "1.4.3",
@ -7122,7 +7122,7 @@
},
"skia": {
"baseline": "0.36.0",
"port-version": 5
"port-version": 6
},
"skyr-url": {
"baseline": "1.13.0",
@ -7918,7 +7918,7 @@
},
"v8": {
"baseline": "9.1.269.39",
"port-version": 4
"port-version": 5
},
"valijson": {
"baseline": "0.6",
@ -7966,7 +7966,7 @@
},
"vcpkg-gn": {
"baseline": "2021-11-16",
"port-version": 2
"port-version": 3
},
"vcpkg-pkgconfig-get-modules": {
"baseline": "2022-02-10",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "08b399ae573db73407ae4095c79628553416a992",
"version": "86.0.4199.1",
"port-version": 5
},
{
"git-tree": "3dbf253ab140a0d754230e2cffa7b4f94686a9e9",
"version": "86.0.4199.1",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "37f155d62394f7faae4d48be6efcd81fce1587eb",
"version-date": "2022-09-05",
"port-version": 2
},
{
"git-tree": "f7ead3d493577856543add942c07776fe60ded9e",
"version-date": "2022-09-05",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0458cf18e0a28b607b8d3a2ca9fba56395d5f147",
"version": "0.36.0",
"port-version": 6
},
{
"git-tree": "924027b3a2eb2a09ca78c987f622ddc95d0eb500",
"version": "0.36.0",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "efe56a72380aed1323f5e19b4b20a3e02fae8112",
"version": "9.1.269.39",
"port-version": 5
},
{
"git-tree": "f57ec75cb9169900555359752c65e8e4c79c34ec",
"version": "9.1.269.39",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "91fca5269be57b055d067a6012dd79bca6a9dc70",
"version-date": "2021-11-16",
"port-version": 3
},
{
"git-tree": "119e620029e0579165590b4656882bd6c3ce297c",
"version-date": "2021-11-16",