2017-05-24 23:33:16 -07:00
|
|
|
## # vcpkg_acquire_msys
|
|
|
|
##
|
|
|
|
## Download and prepare an MSYS2 instance.
|
|
|
|
##
|
|
|
|
## ## Usage
|
|
|
|
## ```cmake
|
2018-02-24 16:00:51 +08:00
|
|
|
## vcpkg_acquire_msys(<MSYS_ROOT_VAR> [PACKAGES <package>...])
|
2017-05-24 23:33:16 -07:00
|
|
|
## ```
|
|
|
|
##
|
|
|
|
## ## Parameters
|
|
|
|
## ### MSYS_ROOT_VAR
|
|
|
|
## An out-variable that will be set to the path to MSYS2.
|
|
|
|
##
|
2018-02-24 16:00:51 +08:00
|
|
|
## ### PACKAGES
|
|
|
|
## A list of packages to acquire in msys.
|
|
|
|
##
|
|
|
|
## To ensure a package is available: `vcpkg_acquire_msys(MSYS_ROOT PACKAGES make automake1.15)`
|
|
|
|
##
|
2017-05-24 23:33:16 -07:00
|
|
|
## ## Notes
|
|
|
|
## A call to `vcpkg_acquire_msys` will usually be followed by a call to `bash.exe`:
|
|
|
|
## ```cmake
|
|
|
|
## vcpkg_acquire_msys(MSYS_ROOT)
|
|
|
|
## set(BASH ${MSYS_ROOT}/usr/bin/bash.exe)
|
|
|
|
##
|
|
|
|
## vcpkg_execute_required_process(
|
|
|
|
## COMMAND ${BASH} --noprofile --norc "${CMAKE_CURRENT_LIST_DIR}\\build.sh"
|
|
|
|
## WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
|
|
|
|
## LOGNAME build-${TARGET_TRIPLET}-rel
|
|
|
|
## )
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
## ## Examples
|
|
|
|
##
|
|
|
|
## * [ffmpeg](https://github.com/Microsoft/vcpkg/blob/master/ports/ffmpeg/portfile.cmake)
|
|
|
|
## * [icu](https://github.com/Microsoft/vcpkg/blob/master/ports/icu/portfile.cmake)
|
|
|
|
## * [libvpx](https://github.com/Microsoft/vcpkg/blob/master/ports/libvpx/portfile.cmake)
|
|
|
|
|
2017-03-02 07:29:00 -08:00
|
|
|
function(vcpkg_acquire_msys PATH_TO_ROOT_OUT)
|
|
|
|
set(TOOLPATH ${DOWNLOADS}/tools/msys2)
|
2018-02-24 16:00:51 +08:00
|
|
|
cmake_parse_arguments(_am "" "" "PACKAGES" ${ARGN})
|
2017-04-24 22:47:50 -07:00
|
|
|
|
2018-08-08 10:51:33 -07:00
|
|
|
if(NOT CMAKE_HOST_WIN32)
|
|
|
|
message(FATAL_ERROR "vcpkg_acquire_msys() can only be used on Windows hosts")
|
|
|
|
endif()
|
|
|
|
|
2017-04-24 22:47:50 -07:00
|
|
|
# detect host architecture
|
2017-05-03 19:11:29 +02:00
|
|
|
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
|
2017-04-24 22:47:50 -07:00
|
|
|
set(_vam_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITEW6432})
|
|
|
|
else()
|
|
|
|
set(_vam_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITECTURE})
|
|
|
|
endif()
|
|
|
|
|
2017-04-25 13:47:28 -07:00
|
|
|
if(_vam_HOST_ARCHITECTURE STREQUAL "AMD64")
|
2017-04-24 14:19:26 +02:00
|
|
|
set(TOOLSUBPATH msys64)
|
2018-03-03 10:46:07 -08:00
|
|
|
set(URLS
|
2018-12-17 09:34:45 +01:00
|
|
|
"http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20181211.tar.xz"
|
2018-03-03 10:46:07 -08:00
|
|
|
)
|
2018-12-17 09:34:45 +01:00
|
|
|
set(ARCHIVE "msys2-base-x86_64-20181211.tar.xz")
|
|
|
|
set(HASH 1efb9a7ff1daa2d3147ac0fda8e9a645696dbd19a33c986b844bc037d946dddb3353db5a52794ac668718812854400d918e4db13b4a2d0e6f5a9dfe716b48056)
|
2017-08-22 13:41:32 -07:00
|
|
|
set(STAMP "initialized-msys2_64.stamp")
|
2017-04-24 14:19:26 +02:00
|
|
|
else()
|
|
|
|
set(TOOLSUBPATH msys32)
|
2018-03-03 10:46:07 -08:00
|
|
|
set(URLS
|
2018-12-17 09:34:45 +01:00
|
|
|
"http://repo.msys2.org/distrib/i686/msys2-base-i686-20181211.tar.xz"
|
2018-03-03 10:46:07 -08:00
|
|
|
)
|
2018-12-17 09:34:45 +01:00
|
|
|
set(ARCHIVE "msys2-base-i686-20181211.tar.xz")
|
|
|
|
set(HASH a9b9680a511bb205b87811b303eb29d62e2fd851000304f8b087c5893a3891c2aa2d46217ae989e31b5d52a6ba34ac5e6a5e624d9c917df00a752ade4debc20f)
|
2017-08-22 13:41:32 -07:00
|
|
|
set(STAMP "initialized-msys2_32.stamp")
|
2017-04-24 14:19:26 +02:00
|
|
|
endif()
|
2017-03-02 07:29:00 -08:00
|
|
|
|
|
|
|
set(PATH_TO_ROOT ${TOOLPATH}/${TOOLSUBPATH})
|
|
|
|
|
2017-04-24 22:47:50 -07:00
|
|
|
if(NOT EXISTS "${TOOLPATH}/${STAMP}")
|
2017-11-02 19:14:10 -07:00
|
|
|
|
2017-03-02 07:29:00 -08:00
|
|
|
message(STATUS "Acquiring MSYS2...")
|
2017-11-02 19:14:10 -07:00
|
|
|
vcpkg_download_distfile(ARCHIVE_PATH
|
2018-03-03 10:46:07 -08:00
|
|
|
URLS ${URLS}
|
2017-11-02 19:14:10 -07:00
|
|
|
FILENAME ${ARCHIVE}
|
|
|
|
SHA512 ${HASH}
|
2017-03-02 07:29:00 -08:00
|
|
|
)
|
2017-11-02 19:14:10 -07:00
|
|
|
|
2017-04-24 22:47:50 -07:00
|
|
|
file(REMOVE_RECURSE ${TOOLPATH}/${TOOLSUBPATH})
|
2017-03-02 07:29:00 -08:00
|
|
|
file(MAKE_DIRECTORY ${TOOLPATH})
|
2019-08-28 13:49:29 -07:00
|
|
|
_execute_process(
|
2017-11-02 19:14:10 -07:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar xzf ${ARCHIVE_PATH}
|
2017-03-02 07:29:00 -08:00
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
2019-08-28 13:49:29 -07:00
|
|
|
_execute_process(
|
2018-02-24 16:00:51 +08:00
|
|
|
COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "PATH=/usr/bin;pacman-key --init;pacman-key --populate"
|
2017-03-02 07:29:00 -08:00
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
2019-08-28 13:49:29 -07:00
|
|
|
_execute_process(
|
2018-02-24 16:00:51 +08:00
|
|
|
COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "PATH=/usr/bin;pacman -Syu --noconfirm"
|
2017-06-17 11:30:03 -07:00
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
2017-04-24 22:47:50 -07:00
|
|
|
file(WRITE "${TOOLPATH}/${STAMP}" "0")
|
2017-03-02 07:29:00 -08:00
|
|
|
message(STATUS "Acquiring MSYS2... OK")
|
|
|
|
endif()
|
|
|
|
|
2018-02-24 16:00:51 +08:00
|
|
|
if(_am_PACKAGES)
|
|
|
|
message(STATUS "Acquiring MSYS Packages...")
|
|
|
|
string(REPLACE ";" " " _am_PACKAGES "${_am_PACKAGES}")
|
|
|
|
|
|
|
|
set(_ENV_ORIGINAL $ENV{PATH})
|
|
|
|
set(ENV{PATH} ${PATH_TO_ROOT}/usr/bin)
|
|
|
|
vcpkg_execute_required_process(
|
2019-08-28 13:49:29 -07:00
|
|
|
ALLOW_IN_DOWNLOAD_MODE
|
2018-02-24 16:00:51 +08:00
|
|
|
COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "pacman -Sy --noconfirm --needed ${_am_PACKAGES}"
|
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
LOGNAME msys-pacman-${TARGET_TRIPLET}
|
|
|
|
)
|
|
|
|
set(ENV{PATH} "${_ENV_ORIGINAL}")
|
|
|
|
|
|
|
|
message(STATUS "Acquiring MSYS Packages... OK")
|
|
|
|
endif()
|
|
|
|
|
2019-06-02 22:26:04 +07:00
|
|
|
# Deal with a stale process created by MSYS
|
|
|
|
if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
|
|
|
vcpkg_execute_required_process(
|
2019-08-28 13:49:29 -07:00
|
|
|
ALLOW_IN_DOWNLOAD_MODE
|
2019-06-02 22:26:04 +07:00
|
|
|
COMMAND TASKKILL /F /IM gpg-agent.exe /fi "memusage gt 2"
|
|
|
|
WORKING_DIRECTORY ${SOURCE_PATH}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2017-03-02 07:29:00 -08:00
|
|
|
set(${PATH_TO_ROOT_OUT} ${PATH_TO_ROOT} PARENT_SCOPE)
|
2017-04-24 14:19:26 +02:00
|
|
|
endfunction()
|