-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gn, crashpad] Add GN build support and crashpad port (#10505)
* [vcpkg_find_acquire_program] Add gn * [GN] Add build system support * [crashpad] Add new port
- Loading branch information
Showing
17 changed files
with
514 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# vcpkg_build_gn | ||
|
||
Build a GN project | ||
|
||
## Usage: | ||
```cmake | ||
vcpkg_build_gn( | ||
[TARGETS <target>...] | ||
) | ||
``` | ||
|
||
## Parameters: | ||
### TARGETS | ||
Only build the specified targets. | ||
|
||
## Source | ||
[scripts/cmake/vcpkg_build_gn.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_build_gn.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# vcpkg_build_ninja | ||
|
||
Build a ninja project | ||
|
||
## Usage: | ||
```cmake | ||
vcpkg_build_ninja( | ||
[TARGETS <target>...] | ||
) | ||
``` | ||
|
||
## Parameters: | ||
### TARGETS | ||
Only build the specified targets. | ||
|
||
## Source | ||
[scripts/cmake/vcpkg_build_ninja.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_build_ninja.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# vcpkg_configure_gn | ||
|
||
Generate Ninja (GN) targets | ||
|
||
## Usage: | ||
```cmake | ||
vcpkg_configure_gn( | ||
SOURCE_PATH <SOURCE_PATH> | ||
[OPTIONS <OPTIONS>] | ||
[OPTIONS_DEBUG <OPTIONS_DEBUG>] | ||
[OPTIONS_RELEASE <OPTIONS_RELEASE>] | ||
) | ||
``` | ||
|
||
## Parameters: | ||
### SOURCE_PATH (required) | ||
The path to the GN project. | ||
|
||
### OPTIONS | ||
Options to be passed to both the debug and release targets. | ||
Note: Must be provided as a space-separated string. | ||
|
||
### OPTIONS_DEBUG (space-separated string) | ||
Options to be passed to the debug target. | ||
|
||
### OPTIONS_RELEASE (space-separated string) | ||
Options to be passed to the release target. | ||
|
||
## Source | ||
[scripts/cmake/vcpkg_configure_gn.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_configure_gn.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ The current list of programs includes: | |
- PYTHON2 | ||
- PYTHON3 | ||
- GIT | ||
- GN | ||
- GO | ||
- JOM | ||
- MESON | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# vcpkg_install_gn | ||
|
||
Installs a GN project | ||
|
||
## Usage: | ||
```cmake | ||
vcpkg_install_gn( | ||
SOURCE_PATH <SOURCE_PATH> | ||
[TARGETS <target>...] | ||
) | ||
``` | ||
|
||
## Parameters: | ||
### SOURCE_PATH | ||
The path to the source directory | ||
|
||
### TARGETS | ||
Only install the specified targets. | ||
|
||
Note: includes must be handled separately | ||
|
||
## Source | ||
[scripts/cmake/vcpkg_install_gn.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_install_gn.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Source: crashpad | ||
Version: 2020-03-18 | ||
Homepage: https://chromium.googlesource.com/crashpad/crashpad/+/master/README.md | ||
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. | ||
Build-Depends: zlib | ||
Supports: x64 & (osx|windows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compute the installation prefix relative to this file. | ||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) | ||
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) | ||
if(_IMPORT_PREFIX STREQUAL "/") | ||
set(_IMPORT_PREFIX "") | ||
endif() | ||
|
||
add_library(crashpad INTERFACE) | ||
add_library(crashpad::crashpad ALIAS crashpad) | ||
|
||
set(CRASHPAD_LIBRARIES client util base) | ||
|
||
if(WIN32) | ||
target_compile_definitions(crashpad INTERFACE NOMINMAX) | ||
elseif(APPLE) | ||
list(APPEND CRASHPAD_LIBRARIES ApplicationServices | ||
CoreFoundation Foundation IOKit Security bsm) | ||
endif() | ||
|
||
foreach(LIB_NAME ${CRASHPAD_LIBRARIES}) | ||
find_library(_LIB ${LIB_NAME}) | ||
target_link_libraries(crashpad INTERFACE ${_LIB}) | ||
unset(_LIB CACHE) | ||
endforeach() | ||
|
||
find_package(ZLIB REQUIRED) | ||
target_link_libraries(crashpad INTERFACE ZLIB::ZLIB) | ||
|
||
target_include_directories(crashpad | ||
INTERFACE ${_IMPORT_PREFIX}/include/crashpad) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
vcpkg_fail_port_install( | ||
ON_ARCH "x86" "arm" "arm64" | ||
ON_TARGET "UWP" "LINUX") | ||
|
||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) | ||
|
||
vcpkg_from_git( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
URL https://chromium.googlesource.com/crashpad/crashpad | ||
REF 9a31d3f8e9815774026a753a1ff6155347cd549f | ||
) | ||
|
||
function(checkout_in_path PATH URL REF) | ||
if(EXISTS "${PATH}") | ||
return() | ||
endif() | ||
|
||
vcpkg_from_git( | ||
OUT_SOURCE_PATH DEP_SOURCE_PATH | ||
URL "${URL}" | ||
REF "${REF}" | ||
) | ||
file(RENAME "${DEP_SOURCE_PATH}" "${PATH}") | ||
file(REMOVE_RECURSE "${DEP_SOURCE_PATH}") | ||
endfunction() | ||
|
||
# mini_chromium contains the toolchains and build configuration | ||
checkout_in_path( | ||
"${SOURCE_PATH}/third_party/mini_chromium/mini_chromium" | ||
"https://chromium.googlesource.com/chromium/mini_chromium" | ||
"c426ff98e1d9e9d59777fe8b883a5c0ceeca9ca3" | ||
) | ||
|
||
function(replace_gn_dependency INPUT_FILE OUTPUT_FILE LIBRARY_NAMES) | ||
unset(_LIBRARY_DEB CACHE) | ||
find_library(_LIBRARY_DEB NAMES ${LIBRARY_NAMES} | ||
PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" | ||
NO_DEFAULT_PATH) | ||
|
||
if(_LIBRARY_DEB MATCHES "-NOTFOUND") | ||
message(FATAL_ERROR "Could not find debug library with names: ${LIBRARY_NAMES}") | ||
endif() | ||
|
||
unset(_LIBRARY_REL CACHE) | ||
find_library(_LIBRARY_REL NAMES ${LIBRARY_NAMES} | ||
PATHS "${CURRENT_INSTALLED_DIR}/lib" | ||
NO_DEFAULT_PATH) | ||
|
||
if(_LIBRARY_REL MATCHES "-NOTFOUND") | ||
message(FATAL_ERROR "Could not find library with names: ${LIBRARY_NAMES}") | ||
endif() | ||
|
||
set(_INCLUDE_DIR "${CURRENT_INSTALLED_DIR}/include") | ||
|
||
file(REMOVE "${OUTPUT_FILE}") | ||
configure_file("${INPUT_FILE}" "${OUTPUT_FILE}" @ONLY) | ||
endfunction() | ||
|
||
replace_gn_dependency( | ||
"${CMAKE_CURRENT_LIST_DIR}/zlib.gn" | ||
"${SOURCE_PATH}/third_party/zlib/BUILD.gn" | ||
"z;zlib;zlibd" | ||
) | ||
|
||
set(OPTIONS_DBG "is_debug=true") | ||
set(OPTIONS_REL "") | ||
|
||
if(CMAKE_HOST_WIN32) | ||
# Load toolchains | ||
if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE) | ||
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake") | ||
endif() | ||
include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") | ||
|
||
foreach(_VAR CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS | ||
CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE) | ||
string(STRIP "${${_VAR}}" ${_VAR}) | ||
endforeach() | ||
|
||
set(OPTIONS_DBG "${OPTIONS_DBG} \ | ||
extra_cflags_c=\"${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}\" \ | ||
extra_cflags_cc=\"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}\"") | ||
|
||
set(OPTIONS_REL "${OPTIONS_REL} \ | ||
extra_cflags_c=\"${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}\" \ | ||
extra_cflags_cc=\"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}\"") | ||
|
||
set(DISABLE_WHOLE_PROGRAM_OPTIMIZATION "\ | ||
extra_cflags=\"/GL-\" \ | ||
extra_ldflags=\"/LTCG:OFF\" \ | ||
extra_arflags=\"/LTCG:OFF\"") | ||
|
||
set(OPTIONS_DBG "${OPTIONS_DBG} ${DISABLE_WHOLE_PROGRAM_OPTIMIZATION}") | ||
set(OPTIONS_REL "${OPTIONS_REL} ${DISABLE_WHOLE_PROGRAM_OPTIMIZATION}") | ||
endif() | ||
|
||
vcpkg_configure_gn( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS_DEBUG "${OPTIONS_DBG}" | ||
OPTIONS_RELEASE "${OPTIONS_REL}" | ||
) | ||
|
||
vcpkg_install_gn( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
TARGETS client util third_party/mini_chromium/mini_chromium/base handler:crashpad_handler | ||
) | ||
|
||
message(STATUS "Installing headers...") | ||
set(PACKAGES_INCLUDE_DIR "${CURRENT_PACKAGES_DIR}/include/${PORT}") | ||
function(install_headers DIR) | ||
file(COPY "${DIR}" DESTINATION "${PACKAGES_INCLUDE_DIR}" FILES_MATCHING PATTERN "*.h") | ||
endfunction() | ||
install_headers("${SOURCE_PATH}/client") | ||
install_headers("${SOURCE_PATH}/util") | ||
install_headers("${SOURCE_PATH}/third_party/mini_chromium/mini_chromium/base") | ||
install_headers("${SOURCE_PATH}/third_party/mini_chromium/mini_chromium/build") | ||
|
||
# remove empty directories | ||
file(REMOVE_RECURSE | ||
"${PACKAGES_INCLUDE_DIR}/util/net/testdata" | ||
"${PACKAGES_INCLUDE_DIR}/build/ios") | ||
|
||
configure_file("${CMAKE_CURRENT_LIST_DIR}/crashpadConfig.cmake.in" | ||
"${CURRENT_PACKAGES_DIR}/share/${PORT}/crashpadConfig.cmake" @ONLY) | ||
|
||
vcpkg_copy_pdbs() | ||
file(INSTALL "${SOURCE_PATH}/LICENSE" | ||
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" | ||
RENAME copyright) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import("../../build/crashpad_buildconfig.gni") | ||
|
||
config("zlib_config") { | ||
defines = [ "CRASHPAD_ZLIB_SOURCE_EXTERNAL" ] | ||
include_dirs = [ "@_INCLUDE_DIR@" ] | ||
} | ||
|
||
source_set("zlib") { | ||
public_configs = [ ":zlib_config" ] | ||
if(is_debug) { | ||
libs = [ "@_LIBRARY_DEB@" ] | ||
} else { | ||
libs = [ "@_LIBRARY_REL@" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## # vcpkg_build_gn | ||
## | ||
## Build a GN project | ||
## | ||
## ## Usage: | ||
## ```cmake | ||
## vcpkg_build_gn( | ||
## [TARGETS <target>...] | ||
## ) | ||
## ``` | ||
## | ||
## ## Parameters: | ||
## ### TARGETS | ||
## Only build the specified targets. | ||
|
||
function(vcpkg_build_gn) | ||
vcpkg_build_ninja(${ARGN}) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## # vcpkg_build_ninja | ||
## | ||
## Build a ninja project | ||
## | ||
## ## Usage: | ||
## ```cmake | ||
## vcpkg_build_ninja( | ||
## [TARGETS <target>...] | ||
## ) | ||
## ``` | ||
## | ||
## ## Parameters: | ||
## ### TARGETS | ||
## Only build the specified targets. | ||
|
||
function(vcpkg_build_ninja) | ||
cmake_parse_arguments(_vbn "" "" "TARGETS" ${ARGN}) | ||
|
||
vcpkg_find_acquire_program(NINJA) | ||
|
||
function(build CONFIG) | ||
message(STATUS "Building (${CONFIG})...") | ||
vcpkg_execute_build_process( | ||
COMMAND "${NINJA}" -C "${CURRENT_BUILDTREES_DIR}/${CONFIG}" ${_vbn_TARGETS} | ||
WORKING_DIRECTORY "${SOURCE_PATH}" | ||
LOGNAME build-${CONFIG} | ||
) | ||
endfunction() | ||
|
||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") | ||
build(${TARGET_TRIPLET}-dbg) | ||
endif() | ||
|
||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") | ||
build(${TARGET_TRIPLET}-rel) | ||
endif() | ||
endfunction() |
Oops, something went wrong.