2017-05-25 14:33:16 +08:00
|
|
|
## # vcpkg_acquire_msys
|
|
|
|
##
|
|
|
|
## Download and prepare an MSYS2 instance.
|
|
|
|
##
|
|
|
|
## ## Usage
|
|
|
|
## ```cmake
|
|
|
|
## vcpkg_acquire_msys(<MSYS_ROOT_VAR>)
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
## ## Parameters
|
|
|
|
## ### MSYS_ROOT_VAR
|
|
|
|
## An out-variable that will be set to the path to MSYS2.
|
|
|
|
##
|
|
|
|
## ## 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
|
|
|
|
## )
|
|
|
|
## ```
|
|
|
|
## To ensure a package is available:
|
|
|
|
## ```cmake
|
|
|
|
## vcpkg_acquire_msys(MSYS_ROOT)
|
|
|
|
## set(BASH ${MSYS_ROOT}/usr/bin/bash.exe)
|
|
|
|
##
|
|
|
|
## message(STATUS "Installing MSYS Packages")
|
|
|
|
## vcpkg_execute_required_process(
|
|
|
|
## COMMAND
|
|
|
|
## ${BASH} --noprofile --norc -c
|
2017-08-02 07:03:40 +08:00
|
|
|
## 'PATH=/usr/bin:\$PATH pacman -Sy --noconfirm --needed make'
|
2017-05-25 14:33:16 +08:00
|
|
|
## WORKING_DIRECTORY ${MSYS_ROOT}
|
|
|
|
## LOGNAME pacman-${TARGET_TRIPLET})
|
|
|
|
## ```
|
|
|
|
##
|
|
|
|
## ## 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 23:29:00 +08:00
|
|
|
function(vcpkg_acquire_msys PATH_TO_ROOT_OUT)
|
|
|
|
set(TOOLPATH ${DOWNLOADS}/tools/msys2)
|
2017-04-25 13:47:50 +08:00
|
|
|
|
|
|
|
# detect host architecture
|
2017-05-04 01:11:29 +08:00
|
|
|
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
|
2017-04-25 13:47:50 +08:00
|
|
|
set(_vam_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITEW6432})
|
|
|
|
else()
|
|
|
|
set(_vam_HOST_ARCHITECTURE $ENV{PROCESSOR_ARCHITECTURE})
|
|
|
|
endif()
|
|
|
|
|
2017-04-26 04:47:28 +08:00
|
|
|
if(_vam_HOST_ARCHITECTURE STREQUAL "AMD64")
|
2017-04-24 20:19:26 +08:00
|
|
|
set(TOOLSUBPATH msys64)
|
2017-04-25 01:29:34 +08:00
|
|
|
set(URL "https://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-base-x86_64-20161025.tar.xz/download")
|
2017-04-24 20:19:26 +08:00
|
|
|
set(ARCHIVE "msys2-base-x86_64-20161025.tar.xz")
|
|
|
|
set(HASH 6c4c18ec59db80b8269698d074866438a624f1ce735ee5005a01b148b02e8f2e966ae381aa1cb4c50f6226c3b7feb271e36907cf26580df084d695b3c9f5c0eb)
|
2017-08-23 04:41:32 +08:00
|
|
|
set(STAMP "initialized-msys2_64.stamp")
|
2017-04-24 20:19:26 +08:00
|
|
|
else()
|
|
|
|
set(TOOLSUBPATH msys32)
|
|
|
|
set(URL "https://sourceforge.net/projects/msys2/files/Base/i686/msys2-base-i686-20161025.tar.xz/download")
|
|
|
|
set(ARCHIVE "msys2-base-i686-20161025.tar.xz")
|
|
|
|
set(HASH c9260a38e0c6bf963adeaea098c4e376449c1dd0afe07480741d6583a1ac4c138951ccb0c5388bd148e04255a5c1a23bf5ee2d58dcd6607c14f1eaa5639a7c85)
|
2017-08-23 04:41:32 +08:00
|
|
|
set(STAMP "initialized-msys2_32.stamp")
|
2017-04-24 20:19:26 +08:00
|
|
|
endif()
|
2017-03-02 23:29:00 +08:00
|
|
|
|
|
|
|
set(PATH_TO_ROOT ${TOOLPATH}/${TOOLSUBPATH})
|
|
|
|
|
2017-04-25 13:47:50 +08:00
|
|
|
if(NOT EXISTS "${TOOLPATH}/${STAMP}")
|
2017-11-03 10:14:10 +08:00
|
|
|
|
2017-03-02 23:29:00 +08:00
|
|
|
message(STATUS "Acquiring MSYS2...")
|
2017-11-03 10:14:10 +08:00
|
|
|
vcpkg_download_distfile(ARCHIVE_PATH
|
|
|
|
URLS ${URL}
|
|
|
|
FILENAME ${ARCHIVE}
|
|
|
|
SHA512 ${HASH}
|
2017-03-02 23:29:00 +08:00
|
|
|
)
|
2017-11-03 10:14:10 +08:00
|
|
|
|
2017-04-25 13:47:50 +08:00
|
|
|
file(REMOVE_RECURSE ${TOOLPATH}/${TOOLSUBPATH})
|
2017-03-02 23:29:00 +08:00
|
|
|
file(MAKE_DIRECTORY ${TOOLPATH})
|
|
|
|
execute_process(
|
2017-11-03 10:14:10 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar xzf ${ARCHIVE_PATH}
|
2017-03-02 23:29:00 +08:00
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "PATH=/usr/bin:\$PATH;pacman-key --init;pacman-key --populate"
|
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
2017-06-18 02:30:03 +08:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${PATH_TO_ROOT}/usr/bin/bash.exe --noprofile --norc -c "PATH=/usr/bin:\$PATH;pacman -Syu --noconfirm"
|
|
|
|
WORKING_DIRECTORY ${TOOLPATH}
|
|
|
|
)
|
2017-04-25 13:47:50 +08:00
|
|
|
file(WRITE "${TOOLPATH}/${STAMP}" "0")
|
2017-03-02 23:29:00 +08:00
|
|
|
message(STATUS "Acquiring MSYS2... OK")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(${PATH_TO_ROOT_OUT} ${PATH_TO_ROOT} PARENT_SCOPE)
|
2017-04-24 20:19:26 +08:00
|
|
|
endfunction()
|