diff options
| author | LiGuilin <liguilin0522@qq.com> | 2016-10-08 08:34:12 +0800 |
|---|---|---|
| committer | LiGuilin <liguilin0522@qq.com> | 2016-10-08 08:34:12 +0800 |
| commit | c91da2b0c4c3d9218c0b4d1712d744bb35245a61 (patch) | |
| tree | e1ae0664a4f21f3948bde8c8f9f9e55dea0cb11f /scripts | |
| parent | 280d88b34033ab728e02f725d8d8ff5f9250c6de (diff) | |
| parent | a0f621c0fca2c3de8bd5249f023979b800c543cf (diff) | |
| download | vcpkg-c91da2b0c4c3d9218c0b4d1712d744bb35245a61.tar.gz vcpkg-c91da2b0c4c3d9218c0b4d1712d744bb35245a61.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/buildsystems/vcpkg.cmake | 14 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_build_cmake.cmake | 4 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_build_msbuild.cmake | 46 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_configure_cmake.cmake | 14 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_download_distfile.cmake | 58 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_extract_source_archive.cmake | 14 | ||||
| -rw-r--r-- | scripts/cmake/vcpkg_find_acquire_program.cmake | 8 | ||||
| -rw-r--r-- | scripts/doVcpkgRelease.ps1 | 11 | ||||
| -rw-r--r-- | scripts/ports.cmake | 89 | ||||
| -rw-r--r-- | scripts/templates/CONTROL.in | 3 | ||||
| -rw-r--r-- | scripts/templates/portfile.in.cmake | 19 |
11 files changed, 198 insertions, 82 deletions
diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index 26cc8a57b..ca0900b89 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -21,29 +21,29 @@ if(NOT VCPKG_TOOLCHAIN) set(_VCPKG_TARGET_TRIPLET_PLAT windows) endif() - set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT}) - + set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)") + set(_VCPKG_INSTALLED_DIR ${CMAKE_CURRENT_LIST_DIR}/../../installed) set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) list(APPEND CMAKE_PREFIX_PATH - ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/debug + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug ) endif() list(APPEND CMAKE_PREFIX_PATH - ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET} + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} ) - include_directories(${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/include) + include_directories(${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include) option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON) if(OVERRIDE_ADD_EXECUTABLE) function(add_executable name) _add_executable(${ARGV}) add_custom_command(TARGET ${name} POST_BUILD - COMMAND powershell -executionpolicy remotesigned -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 + COMMAND powershell -executionpolicy UnRestricted -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 -targetBinary $<TARGET_FILE:${name}> - -installedDir "${_VCPKG_TOOLCHAIN_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin" + -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$<CONFIG:Debug>:/debug>/bin" -OutVariable out ) endfunction() diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake index 33990d9b0..8ba4b9fae 100644 --- a/scripts/cmake/vcpkg_build_cmake.cmake +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -1,7 +1,7 @@ function(vcpkg_build_cmake) message(STATUS "Build ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release -- /p:VCPkgLocalAppDataDisabled=true + COMMAND ${CMAKE_COMMAND} --build . --config Release -- /p:VCPkgLocalAppDataDisabled=true /m WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME build-${TARGET_TRIPLET}-rel ) @@ -9,7 +9,7 @@ function(vcpkg_build_cmake) message(STATUS "Build ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${CMAKE_COMMAND} --build . --config Debug -- /p:VCPkgLocalAppDataDisabled=true + COMMAND ${CMAKE_COMMAND} --build . --config Debug -- /p:VCPkgLocalAppDataDisabled=true /m WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME build-${TARGET_TRIPLET}-dbg ) diff --git a/scripts/cmake/vcpkg_build_msbuild.cmake b/scripts/cmake/vcpkg_build_msbuild.cmake index bf7c1b546..5b422fe5e 100644 --- a/scripts/cmake/vcpkg_build_msbuild.cmake +++ b/scripts/cmake/vcpkg_build_msbuild.cmake @@ -1,5 +1,42 @@ +#.rst: +# .. command:: vcpkg_build_msbuild +# +# Build a msbuild-based project. +# +# :: +# vcpkg_build_msbuild(PROJECT_PATH <sln_project_path> +# [RELEASE_CONFIGURATION <release_configuration>] # (default = "Release") +# [DEBUG_CONFIGURATION <debug_configuration>] @ (default = "Debug") +# [PLATFORM <platform>] # (default = "${TRIPLET_SYSTEM_ARCH}") +# [OPTIONS arg1 [arg2 ...]] +# [OPTIONS_RELEASE arg1 [arg2 ...]] +# [OPTIONS_DEBUG arg1 [arg2 ...]] +# ) +# +# ``PROJECT_PATH`` +# The path to the *.sln msbuild project file. +# ``RELEASE_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Release builds. +# ``DEBUG_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Debug builds. +# ``DEBUG_CONFIGURATION`` +# The configuration (``/p:Configuration`` msbuild parameter) +# used for Debug builds. +# ``PLATFORM`` +# The platform (``/p:Platform`` msbuild parameter) +# used for the build. +# ``OPTIONS`` +# The options passed to msbuild for all builds. +# ``OPTIONS_RELEASE`` +# The options passed to msbuild for Release builds. +# ``OPTIONS_DEBUG`` +# The options passed to msbuild for Debug builds. +# + function(vcpkg_build_msbuild) - cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION;PLATFORM" "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG" ${ARGN}) if(NOT DEFINED _csc_RELEASE_CONFIGURATION) set(_csc_RELEASE_CONFIGURATION Release) @@ -7,13 +44,16 @@ function(vcpkg_build_msbuild) if(NOT DEFINED _csc_DEBUG_CONFIGURATION) set(_csc_DEBUG_CONFIGURATION Debug) endif() + if(NOT DEFINED _csc_PLATFORM) + set(_csc_PLATFORM ${TRIPLET_SYSTEM_ARCH}) + endif() message(STATUS "Building ${_csc_PROJECT_PATH} for Release") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE} /p:Configuration=${_csc_RELEASE_CONFIGURATION} - /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:Platform=${_csc_PLATFORM} /p:VCPkgLocalAppDataDisabled=true WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel LOGNAME build-${TARGET_TRIPLET}-rel @@ -24,7 +64,7 @@ function(vcpkg_build_msbuild) vcpkg_execute_required_process( COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG} /p:Configuration=${_csc_DEBUG_CONFIGURATION} - /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:Platform=${_csc_PLATFORM} /p:VCPkgLocalAppDataDisabled=true WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg LOGNAME build-${TARGET_TRIPLET}-dbg diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index aa85c8ff4..954c75b82 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -22,6 +22,16 @@ function(vcpkg_configure_cmake) file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + if(DEFINED VCPKG_CMAKE_SYSTEM_NAME) + list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}) + endif() + if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}) + endif() + if(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=ON) + endif() + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process( @@ -29,7 +39,7 @@ function(vcpkg_configure_cmake) -G ${GENERATOR} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TRIPLET_FILE} -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR} -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR} WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel @@ -44,7 +54,7 @@ function(vcpkg_configure_cmake) -G ${GENERATOR} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TRIPLET_FILE} -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR}/debug\\\\\\\;${CURRENT_INSTALLED_DIR} -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake index 7c36f5d97..44b562573 100644 --- a/scripts/cmake/vcpkg_download_distfile.cmake +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -1,20 +1,52 @@ -# Usage: vcpkg_download_distfile(<VAR> URL <http://...> FILENAME <output.zip> MD5 <5981de...>) +# Usage: vcpkg_download_distfile(<VAR> URLS <http://mainUrl> <http://mirror1> <http://mirror2> FILENAME <output.zip> SHA512 <5981de...>) function(vcpkg_download_distfile VAR) - set(oneValueArgs URL FILENAME MD5) - cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "" ${ARGN}) + set(oneValueArgs FILENAME SHA512) + set(multipleValuesArgs URLS) + cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "${multipleValuesArgs}" ${ARGN}) + set(downloaded_file_path ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) - if(EXISTS ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) - message(STATUS "Using cached ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}") - file(MD5 ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} FILE_HASH) - if(NOT FILE_HASH MATCHES ${vcpkg_download_distfile_MD5}) + function(test_hash FILE_KIND CUSTOM_ERROR_ADVICE) + message(STATUS "Testing integrity of ${FILE_KIND}...") + file(SHA512 ${downloaded_file_path} FILE_HASH) + if(NOT "${FILE_HASH}" STREQUAL "${vcpkg_download_distfile_SHA512}") message(FATAL_ERROR - "File does not have expected hash: ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}\n" - " ${FILE_HASH} <> ${vcpkg_download_distfile_MD5}\n" - "Please delete the file and try again if this file should be downloaded again.") + "\nFile does not have expected hash:\n" + " File path: [ ${downloaded_file_path} ]\n" + " Expected hash: [ ${vcpkg_download_distfile_SHA512} ]\n" + " Actual hash: [ ${FILE_HASH} ]\n" + "${CUSTOM_ERROR_ADVICE}\n") endif() + message(STATUS "Testing integrity of ${FILE_KIND}... OK") + endfunction() + + if(EXISTS ${downloaded_file_path}) + message(STATUS "Using cached ${downloaded_file_path}") + test_hash("cached file" "Please delete the file and retry if this file should be downloaded again.") else() - message(STATUS "Downloading ${vcpkg_download_distfile_URL}") - file(DOWNLOAD ${vcpkg_download_distfile_URL} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} EXPECTED_HASH MD5=${vcpkg_download_distfile_MD5}) + # Tries to download the file. + foreach(url IN LISTS vcpkg_download_distfile_URLS) + message(STATUS "Downloading ${url}...") + file(DOWNLOAD ${url} ${downloaded_file_path} STATUS download_status) + list(GET download_status 0 status_code) + if (NOT "${status_code}" STREQUAL "0") + message(STATUS "Downloading ${url}... Failed. Status: ${download_status}") + file(REMOVE ${downloaded_file_path}) + set(download_success 0) + else() + message(STATUS "Downloading ${url}... OK") + set(download_success 1) + break() + endif() + endforeach(url) + + if (NOT ${download_success}) + message(FATAL_ERROR + "\n" + " Failed to download file.\n" + " Add mirrors or submit an issue at https://github.com/Microsoft/vcpkg/issues\n") + else() + test_hash("downloaded file" "The file may be corrupted.") + endif() endif() - set(${VAR} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} PARENT_SCOPE) + set(${VAR} ${downloaded_file_path} PARENT_SCOPE) endfunction() diff --git a/scripts/cmake/vcpkg_extract_source_archive.cmake b/scripts/cmake/vcpkg_extract_source_archive.cmake index 7e4efde07..70c9fe06b 100644 --- a/scripts/cmake/vcpkg_extract_source_archive.cmake +++ b/scripts/cmake/vcpkg_extract_source_archive.cmake @@ -1,16 +1,22 @@ include(vcpkg_execute_required_process) function(vcpkg_extract_source_archive ARCHIVE) + if(NOT ARGC EQUAL 2) + set(WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) + else() + set(WORKING_DIRECTORY ${ARGV1}) + endif() + get_filename_component(ARCHIVE_FILENAME ${ARCHIVE} NAME) - if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src/${ARCHIVE_FILENAME}.extracted) + if(NOT EXISTS ${WORKING_DIRECTORY}/${ARCHIVE_FILENAME}.extracted) message(STATUS "Extracting source ${ARCHIVE}") - file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) + file(MAKE_DIRECTORY ${WORKING_DIRECTORY}) vcpkg_execute_required_process( COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} - WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src + WORKING_DIRECTORY ${WORKING_DIRECTORY} LOGNAME extract ) - file(WRITE ${CURRENT_BUILDTREES_DIR}/src/${ARCHIVE_FILENAME}.extracted) + file(WRITE ${WORKING_DIRECTORY}/${ARCHIVE_FILENAME}.extracted) endif() message(STATUS "Extracting done") endfunction() diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index ce2cdaa26..8f974240f 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -10,20 +10,20 @@ function(vcpkg_find_acquire_program VAR) set(PATHS ${DOWNLOADS}/tools/perl/perl/bin) set(URL "http://strawberryperl.com/download/5.20.2.1/strawberry-perl-5.20.2.1-64bit-portable.zip") set(ARCHIVE "strawberry-perl-5.20.2.1-64bit-portable.zip") - set(HASH 5fca4b3cfa7c9cc95e0c4fd8652eba80) + set(HASH 6e14e5580e52da5d35f29b67a52ef9db0e021af1575b4bbd84ebdbf18580522287890bdc21c0d21ddc1b2529d888f8e159dcaa017a3ff06d8fd23d16901bcc8b) elseif(VAR MATCHES "NASM") set(PROGNAME nasm) set(PATHS ${DOWNLOADS}/tools/nasm/nasm-2.11.08) set(URL "http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/win32/nasm-2.11.08-win32.zip") set(ARCHIVE "nasm-2.11.08-win32.zip") - set(HASH 46a31e22be69637f7a9ccba12874133f) + set(HASH cd80b540530d3995d15dc636e97673f1d34f471baadf1dac993165232c61efefe7f8ec10625f8f718fc89f0dd3dcb6a4595e0cf40c5fd7cbac1b71672b644d2d) elseif(VAR MATCHES "YASM") set(PROGNAME yasm) set(PATHS ${DOWNLOADS}/tools/yasm) set(URL "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe") set(ARCHIVE "yasm.exe") set(NOEXTRACT ON) - set(HASH 51e967dceddd1f84e67bff255df977b3) + set(HASH 850b26be5bbbdaeaf45ac39dd27f69f1a85e600c35afbd16b9f621396b3c7a19863ea3ff316b025b578fce0a8280eef2203306a2b3e46ee1389abb65313fb720) else() message(FATAL "unknown tool ${VAR} -- unable to acquire.") endif() @@ -31,7 +31,7 @@ function(vcpkg_find_acquire_program VAR) find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) if(${VAR} MATCHES "-NOTFOUND") file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} - EXPECTED_MD5 ${HASH} + EXPECTED_HASH SHA512=${HASH} SHOW_PROGRESS ) file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}) diff --git a/scripts/doVcpkgRelease.ps1 b/scripts/doVcpkgRelease.ps1 index 3b3021286..97656ba69 100644 --- a/scripts/doVcpkgRelease.ps1 +++ b/scripts/doVcpkgRelease.ps1 @@ -2,7 +2,7 @@ param( ) - +$ErrorActionPreference = "Stop" $version = git show HEAD:toolsrc/VERSION.txt #Remove the quotes from the string $version = $version.Substring(1, $version.length - 2) @@ -51,11 +51,9 @@ for ($disableMetrics = 0; $disableMetrics -le 1; $disableMetrics++) # Partial checkout for building vcpkg $dotGitDir = "$vcpkgRootDir\.git" $workTreeForBuildOnly = "$buildPath" - $checkoutThisDirForBuildOnly1 = ".\scripts" # Must be relative to the root of the repository - $checkoutThisDirForBuildOnly2 = ".\toolsrc" # Must be relative to the root of the repository + $checkoutForBuildOnly = ".\scripts",".\toolsrc",".vcpkg-root" # Must be relative to the root of the repository Write-Verbose("Creating partial temporary checkout: $buildPath") - git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly1 - git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly2 + git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutForBuildOnly & "$buildPath\scripts\bootstrap.ps1" -disableMetrics $disableMetrics @@ -81,5 +79,4 @@ for ($disableMetrics = 0; $disableMetrics -le 1; $disableMetrics++) Remove-Item -recurse $releasePath | Out-Null Write-Verbose("Redistributable archive is: $outputArchive") -} -git tag $gitTagString
\ No newline at end of file +}
\ No newline at end of file diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 51afc8d61..44cb386be 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -1,14 +1,24 @@ cmake_minimum_required(VERSION 3.5) -get_filename_component(VCPKG_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) -string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) -string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) +macro(debug_message) + if(DEFINED PORT_DEBUG AND PORT_DEBUG) + message(STATUS "[DEBUG] ${ARGN}") + endif() +endmacro() -if(NOT EXISTS ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) - message(FATAL_ERROR "Unsupported target triplet. Toolchain file does not exist: ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake") -endif() +#Detect .vcpkg-root to figure VCPKG_ROOT_DIR +SET(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR}) +while(IS_DIRECTORY ${VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root") + get_filename_component(VCPKG_ROOT_DIR_TEMP ${VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY) + if (VCPKG_ROOT_DIR_TEMP STREQUAL VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive + message(FATAL_ERROR "Could not find .vcpkg-root") + else() + SET(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_DIR_TEMP}) + endif() +endwhile() + +set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE}) -set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake) set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages") set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools") @@ -20,37 +30,16 @@ if(PORT) set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET}) endif() -macro(debug_message) - if(DEFINED PORT_DEBUG AND PORT_DEBUG) - message(STATUS "[DEBUG] ${ARGN}") - endif() -endmacro() -if(CMD MATCHES "^SCAFFOLD$") - if(EXISTS ports/${PORT}/portfile.cmake) - message(FATAL_ERROR "Portfile already exists: '${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake'") - endif() - if(NOT FILENAME) - get_filename_component(FILENAME "${URL}" NAME) - endif() - string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME}) - if(EXISTS ${DOWNLOADS}/${FILENAME}) - message(STATUS "Using pre-downloaded: ${DOWNLOADS}/${FILENAME}") - message(STATUS "If this is not desired, delete the file and ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") - else() - include(vcpkg_download_distfile) - file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) - if(NOT error_code MATCHES "0;") - message(FATAL_ERROR "Error downloading file: ${error_code}") - endif() - endif() - file(MD5 ${DOWNLOADS}/${FILENAME} MD5) +if(CMD MATCHES "^BUILD$") + string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) + string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) - file(MAKE_DIRECTORY ports/${PORT}) - configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY) + set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) + if(NOT EXISTS ${CMAKE_TRIPLET_FILE}) + message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}") + endif() - message(STATUS "Generated portfile: ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") -elseif(CMD MATCHES "^BUILD$") if(NOT DEFINED CURRENT_PORT_DIR) message(FATAL_ERROR "CURRENT_PORT_DIR was not defined") endif() @@ -82,4 +71,34 @@ elseif(CMD MATCHES "^BUILD$") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR}) include(${CURRENT_PORT_DIR}/portfile.cmake) +elseif(CMD MATCHES "^CREATE$") + file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR) + file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS) + if(EXISTS ports/${PORT}/portfile.cmake) + message(FATAL_ERROR "Portfile already exists: '${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake'") + endif() + if(NOT FILENAME) + get_filename_component(FILENAME "${URL}" NAME) + endif() + string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME}) + if(EXISTS ${DOWNLOADS}/${FILENAME}) + message(STATUS "Using pre-downloaded: ${NATIVE_DOWNLOADS}\\${FILENAME}") + message(STATUS "If this is not desired, delete the file and ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}") + else() + include(vcpkg_download_distfile) + file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) + if(NOT error_code MATCHES "0;") + message(FATAL_ERROR "Error downloading file: ${error_code}") + endif() + endif() + file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512) + + file(MAKE_DIRECTORY ports/${PORT}) + configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY) + configure_file(scripts/templates/CONTROL.in ports/${PORT}/CONTROL @ONLY) + + message(STATUS "Generated portfile: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake") + message(STATUS "Generated CONTROL: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\CONTROL") + message(STATUS "To launch an editor for these new files, run") + message(STATUS " vcpkg edit ${PORT}") endif() diff --git a/scripts/templates/CONTROL.in b/scripts/templates/CONTROL.in new file mode 100644 index 000000000..c5b706861 --- /dev/null +++ b/scripts/templates/CONTROL.in @@ -0,0 +1,3 @@ +Source: @PORT@ +Version: +Description:
\ No newline at end of file diff --git a/scripts/templates/portfile.in.cmake b/scripts/templates/portfile.in.cmake index b29e2b682..804d8d216 100644 --- a/scripts/templates/portfile.in.cmake +++ b/scripts/templates/portfile.in.cmake @@ -1,21 +1,30 @@ +# Common Ambient Variables: +# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg> +# TARGET_TRIPLET is the current triplet (x86-windows, etc) +# PORT is the current port name (zlib, etc) +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# + +include(${CMAKE_TRIPLET_FILE}) include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@) vcpkg_download_distfile(ARCHIVE - URL "@URL@" + URLS "@URL@" FILENAME "@FILENAME@" - MD5 @MD5@ + SHA512 @SHA512@ ) vcpkg_extract_source_archive(${ARCHIVE}) vcpkg_configure_cmake( - SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@ + SOURCE_PATH ${SOURCE_PATH} # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 # OPTIONS_RELEASE -DOPTIMIZE=1 # OPTIONS_DEBUG -DDEBUGGABLE=1 ) -vcpkg_build_cmake() vcpkg_install_cmake() # Handle copyright -#file(COPY ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/@PORT@) +#file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/@PORT@) #file(RENAME ${CURRENT_PACKAGES_DIR}/share/@PORT@/LICENSE ${CURRENT_PACKAGES_DIR}/share/@PORT@/copyright)
\ No newline at end of file |
