Skip to content

Commit

Permalink
[skia] Use vcpkg port vulkan-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt committed Jul 25, 2023
1 parent 52cba7a commit 1291eed
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
7 changes: 2 additions & 5 deletions ports/skia/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ declare_external_from_git(tint
REF "200492e32b94f042d9942154fb4fa7f93bb8289a"
LICENSE_FILE LICENSE
)
declare_external_from_git(vulkan-headers
URL "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers"
REF "c896e2f920273bfee852da9cca2a356bc1c2031e"
LICENSE_FILE LICENSE.txt
)
declare_external_from_git(vulkan-tools
URL "https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools"
REF "d55c7aaf041af331bee8c22fb448a6ff4c797f73"
Expand All @@ -98,6 +93,8 @@ declare_external_from_pkgconfig(libpng)
declare_external_from_pkgconfig(libwebp MODULES libwebpdecoder libwebpdemux libwebpmux libwebp)
declare_external_from_pkgconfig(zlib)

declare_external_from_vcpkg(vulkan-headers)

set(known_cpus x86 x64 arm arm64 wasm)
if(NOT VCPKG_TARGET_ARCHITECTURE IN_LIST known_cpus)
message(WARNING "Unknown target cpu '${VCPKG_TARGET_ARCHITECTURE}'.")
Expand Down
39 changes: 39 additions & 0 deletions ports/skia/skia-functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function(declare_external_from_pkgconfig name)
set(skia_external_pkgconfig_${name} "${ARGN}" PARENT_SCOPE)
endfunction()

# Declare a named external dependencies to be resolved via vcpkg installed tree.
function(declare_external_from_vcpkg name)
set(skia_external_vcpkg_${name} "${ARGN}" PARENT_SCOPE)
endfunction()

# Download and integrate named external dependencies.
# Downlods must be handled before vcpkg in order to support --only-downloads mode.
function(get_externals)
Expand All @@ -32,11 +37,14 @@ function(get_externals)
list(REMOVE_DUPLICATES ARGN)
set(from_git "")
set(from_pkgconfig "")
set(from_vcpkg "")
foreach(name IN LISTS ARGN)
if(DEFINED "skia_external_git_${name}")
list(APPEND from_git "${name}")
elseif(DEFINED "skia_external_pkgconfig_${name}")
list(APPEND from_pkgconfig "${name}")
elseif(DEFINED "skia_external_vcpkg_${name}")
list(APPEND from_vcpkg "${name}")
else()
message(FATAL_ERROR "Unknown external dependency '${name}'")
endif()
Expand All @@ -62,6 +70,9 @@ function(get_externals)
foreach(name IN LISTS from_pkgconfig)
third_party_from_pkgconfig("${name}" ${skia_external_pkgconfig_${name}})
endforeach()
foreach(name IN LISTS from_vcpkg)
third_party_from_vcpkg("${name}" ${skia_external_vcpkg_${name}})
endforeach()
endfunction()

# Setup a third-party dependency from pkg-config data
Expand Down Expand Up @@ -109,6 +120,34 @@ function(third_party_from_pkgconfig gn_group)
configure_file("${CMAKE_CURRENT_LIST_DIR}/third-party.gn.in" "${SOURCE_PATH}/${arg_PATH}/BUILD.gn" @ONLY)
endfunction()

# Setup a third-party dependency from vcpkg installed tree
function(third_party_from_vcpkg gn_group)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "PATH" "")
if(NOT arg_PATH)
set(arg_PATH "third_party/${gn_group}")
endif()
if(arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unparsed arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()
set(defines "")
set(include_dirs "${CURRENT_INSTALLED_DIR}/include")
set(libdirs_RELEASE "${CURRENT_INSTALLED_DIR}/lib")
set(libdirs_DEBUG "${CURRENT_INSTALLED_DIR}/lib/debug")
set(ldflags "")
foreach(config IN ITEMS DEBUG RELEASE)
set(lib_dirs "${libdirs_${config}}")
set(GN_OUT_${config} "")
foreach(item IN ITEMS defines include_dirs lib_dirs ldflags)
set("gn_${item}_${config}" "")
if(NOT "${${item}}" STREQUAL "")
list(JOIN ${item} [[", "]] list)
set("gn_${item}_${config}" "\"${list}\"")
endif()
endforeach()
endforeach()
configure_file("${CMAKE_CURRENT_LIST_DIR}/third-party.gn.in" "${SOURCE_PATH}/${arg_PATH}/BUILD.gn" @ONLY)
endfunction()

# Turn a space separated string into a gn list:
# "a b c" -> ["a","b","c"]
function(string_to_gn_list out_var input)
Expand Down
6 changes: 5 additions & 1 deletion ports/skia/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
],
"features": {
"dawn": {
"description": "dawn support for skia"
"description": "dawn support for skia",
"dependencies": [
"vulkan-headers"
]
},
"default-features": {
"description": "Default feature configuration",
Expand Down Expand Up @@ -136,6 +139,7 @@
"vulkan": {
"description": "Vulkan support for skia",
"dependencies": [
"vulkan-headers",
"vulkan-memory-allocator"
]
}
Expand Down
2 changes: 1 addition & 1 deletion versions/s-/skia.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"versions": [
{
"git-tree": "49678515153e01e17bca9a3b2cd0445af43d1ebf",
"git-tree": "8cb4d130308a468fb8c2989a0440b2b6a9cc2bff",
"version": "0.36.0",
"port-version": 8
},
Expand Down

0 comments on commit 1291eed

Please sign in to comment.