mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-23 19:17:10 +01:00
Merge pull request #5719 from donny-dont/github-url
[vcpkg_from_github] Allow targeting Github Enterprise instances
This commit is contained in:
commit
ae74e0bfd3
@ -11,6 +11,8 @@ vcpkg_from_github(
|
|||||||
[SHA512 <45d0d7f8cc350...>]
|
[SHA512 <45d0d7f8cc350...>]
|
||||||
[HEAD_REF <master>]
|
[HEAD_REF <master>]
|
||||||
[PATCHES <patch1.patch> <patch2.patch>...]
|
[PATCHES <patch1.patch> <patch2.patch>...]
|
||||||
|
[GITHUB_HOST <https://github.com>]
|
||||||
|
[AUTHORIZATION_TOKEN <${SECRET_FROM_FILE}>]
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,6 +47,14 @@ A list of patches to be applied to the extracted sources.
|
|||||||
|
|
||||||
Relative paths are based on the port directory.
|
Relative paths are based on the port directory.
|
||||||
|
|
||||||
|
### GITHUB_HOST
|
||||||
|
A replacement host for enterprise GitHub instances.
|
||||||
|
|
||||||
|
This field should contain the scheme, host, and port of the desired URL without a trailing slash.
|
||||||
|
|
||||||
|
### AUTHORIZATION_TOKEN
|
||||||
|
A token to be passed via the Authorization HTTP header as "token ${AUTHORIZATION_TOKEN}".
|
||||||
|
|
||||||
## Notes:
|
## Notes:
|
||||||
At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
## [SHA512 <45d0d7f8cc350...>]
|
## [SHA512 <45d0d7f8cc350...>]
|
||||||
## [HEAD_REF <master>]
|
## [HEAD_REF <master>]
|
||||||
## [PATCHES <patch1.patch> <patch2.patch>...]
|
## [PATCHES <patch1.patch> <patch2.patch>...]
|
||||||
|
## [GITHUB_HOST <https://github.com>]
|
||||||
|
## [AUTHORIZATION_TOKEN <${SECRET_FROM_FILE}>]
|
||||||
## )
|
## )
|
||||||
## ```
|
## ```
|
||||||
##
|
##
|
||||||
@ -45,6 +47,14 @@
|
|||||||
##
|
##
|
||||||
## Relative paths are based on the port directory.
|
## Relative paths are based on the port directory.
|
||||||
##
|
##
|
||||||
|
## ### GITHUB_HOST
|
||||||
|
## A replacement host for enterprise GitHub instances.
|
||||||
|
##
|
||||||
|
## This field should contain the scheme, host, and port of the desired URL without a trailing slash.
|
||||||
|
##
|
||||||
|
## ### AUTHORIZATION_TOKEN
|
||||||
|
## A token to be passed via the Authorization HTTP header as "token ${AUTHORIZATION_TOKEN}".
|
||||||
|
##
|
||||||
## ## Notes:
|
## ## Notes:
|
||||||
## At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
## At least one of `REF` and `HEAD_REF` must be specified, however it is preferable for both to be present.
|
||||||
##
|
##
|
||||||
@ -56,7 +66,7 @@
|
|||||||
## * [ms-gsl](https://github.com/Microsoft/vcpkg/blob/master/ports/ms-gsl/portfile.cmake)
|
## * [ms-gsl](https://github.com/Microsoft/vcpkg/blob/master/ports/ms-gsl/portfile.cmake)
|
||||||
## * [beast](https://github.com/Microsoft/vcpkg/blob/master/ports/beast/portfile.cmake)
|
## * [beast](https://github.com/Microsoft/vcpkg/blob/master/ports/beast/portfile.cmake)
|
||||||
function(vcpkg_from_github)
|
function(vcpkg_from_github)
|
||||||
set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 HEAD_REF)
|
set(oneValueArgs OUT_SOURCE_PATH REPO REF SHA512 HEAD_REF GITHUB_HOST AUTHORIZATION_TOKEN)
|
||||||
set(multipleValuesArgs PATCHES)
|
set(multipleValuesArgs PATCHES)
|
||||||
cmake_parse_arguments(_vdud "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN})
|
cmake_parse_arguments(_vdud "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN})
|
||||||
|
|
||||||
@ -76,6 +86,20 @@ function(vcpkg_from_github)
|
|||||||
message(FATAL_ERROR "At least one of REF and HEAD_REF must be specified.")
|
message(FATAL_ERROR "At least one of REF and HEAD_REF must be specified.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED _vdud_GITHUB_HOST)
|
||||||
|
set(GITHUB_HOST https://github.com)
|
||||||
|
set(GITHUB_API_URL https://api.github.com)
|
||||||
|
else()
|
||||||
|
set(GITHUB_HOST ${_vdud_GITHUB_HOST})
|
||||||
|
set(GITHUB_API_URL ${_vdud_GITHUB_HOST}/api/v3)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _vdud_AUTHORIZATION_TOKEN)
|
||||||
|
set(HEADERS "HEADERS" "Authorization: token ${_vdud_AUTHORIZATION_TOKEN}")
|
||||||
|
else()
|
||||||
|
set(HEADERS)
|
||||||
|
endif()
|
||||||
|
|
||||||
string(REGEX REPLACE ".*/" "" REPO_NAME ${_vdud_REPO})
|
string(REGEX REPLACE ".*/" "" REPO_NAME ${_vdud_REPO})
|
||||||
string(REGEX REPLACE "/.*" "" ORG_NAME ${_vdud_REPO})
|
string(REGEX REPLACE "/.*" "" ORG_NAME ${_vdud_REPO})
|
||||||
|
|
||||||
@ -106,9 +130,10 @@ function(vcpkg_from_github)
|
|||||||
string(REPLACE "/" "-" SANITIZED_REF "${_vdud_REF}")
|
string(REPLACE "/" "-" SANITIZED_REF "${_vdud_REF}")
|
||||||
|
|
||||||
vcpkg_download_distfile(ARCHIVE
|
vcpkg_download_distfile(ARCHIVE
|
||||||
URLS "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_REF}.tar.gz"
|
URLS "${GITHUB_HOST}/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_REF}.tar.gz"
|
||||||
SHA512 "${_vdud_SHA512}"
|
SHA512 "${_vdud_SHA512}"
|
||||||
FILENAME "${ORG_NAME}-${REPO_NAME}-${SANITIZED_REF}.tar.gz"
|
FILENAME "${ORG_NAME}-${REPO_NAME}-${SANITIZED_REF}.tar.gz"
|
||||||
|
${HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
vcpkg_extract_source_archive_ex(
|
vcpkg_extract_source_archive_ex(
|
||||||
@ -123,7 +148,7 @@ function(vcpkg_from_github)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The following is for --head scenarios
|
# The following is for --head scenarios
|
||||||
set(URL "https://github.com/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_HEAD_REF}.tar.gz")
|
set(URL "${GITHUB_HOST}/${ORG_NAME}/${REPO_NAME}/archive/${_vdud_HEAD_REF}.tar.gz")
|
||||||
string(REPLACE "/" "-" SANITIZED_HEAD_REF "${_vdud_HEAD_REF}")
|
string(REPLACE "/" "-" SANITIZED_HEAD_REF "${_vdud_HEAD_REF}")
|
||||||
set(downloaded_file_name "${ORG_NAME}-${REPO_NAME}-${SANITIZED_HEAD_REF}.tar.gz")
|
set(downloaded_file_name "${ORG_NAME}-${REPO_NAME}-${SANITIZED_HEAD_REF}.tar.gz")
|
||||||
set(downloaded_file_path "${DOWNLOADS}/${downloaded_file_name}")
|
set(downloaded_file_path "${DOWNLOADS}/${downloaded_file_name}")
|
||||||
@ -147,15 +172,17 @@ function(vcpkg_from_github)
|
|||||||
|
|
||||||
# Try to download the file and version information from github.
|
# Try to download the file and version information from github.
|
||||||
vcpkg_download_distfile(ARCHIVE_VERSION
|
vcpkg_download_distfile(ARCHIVE_VERSION
|
||||||
URLS "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}"
|
URLS "${GITHUB_API_URL}/repos/${ORG_NAME}/${REPO_NAME}/git/refs/heads/${_vdud_HEAD_REF}"
|
||||||
FILENAME ${downloaded_file_name}.version
|
FILENAME ${downloaded_file_name}.version
|
||||||
SKIP_SHA512
|
SKIP_SHA512
|
||||||
|
${HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
vcpkg_download_distfile(ARCHIVE
|
vcpkg_download_distfile(ARCHIVE
|
||||||
URLS ${URL}
|
URLS ${URL}
|
||||||
FILENAME ${downloaded_file_name}
|
FILENAME ${downloaded_file_name}
|
||||||
SKIP_SHA512
|
SKIP_SHA512
|
||||||
|
${HEADERS}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user