diff --git a/azure-pipelines/e2e-ports/version-files/default-baseline-2/vcpkg.json b/azure-pipelines/e2e-ports/version-files/default-baseline-2/vcpkg.json deleted file mode 100644 index 0af3134646..0000000000 --- a/azure-pipelines/e2e-ports/version-files/default-baseline-2/vcpkg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "default-baseline-test-2", - "version-string": "0", - "builtin-baseline": "d5cd6b8c74ee548cfc9ff83cefdac4843cc1503f", - "dependencies": [ - "zlib" - ] -} diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch new file mode 100644 index 0000000000..8fe2b2f5a6 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch @@ -0,0 +1,53 @@ +diff --git a/zconf.h.cmakein b/zconf.h.cmakein +index a7f24cc..a1b359b 100644 +--- a/zconf.h.cmakein ++++ b/zconf.h.cmakein +@@ -434,11 +434,19 @@ typedef uLong FAR uLongf; + #endif + + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_UNISTD_H ++# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 ++# define Z_HAVE_UNISTD_H ++# elif HAVE_UNISTD_H != 0 ++# define Z_HAVE_UNISTD_H ++# endif + #endif + + #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_STDARG_H ++# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 ++# define Z_HAVE_STDARG_H ++# elif HAVE_STDARG_H != 0 ++# define Z_HAVE_STDARG_H ++# endif + #endif + + #ifdef STDC +diff --git a/zconf.h.in b/zconf.h.in +index 5e1d68a..32f53c8 100644 +--- a/zconf.h.in ++++ b/zconf.h.in +@@ -432,11 +432,19 @@ typedef uLong FAR uLongf; + #endif + + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_UNISTD_H ++# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 ++# define Z_HAVE_UNISTD_H ++# elif HAVE_UNISTD_H != 0 ++# define Z_HAVE_UNISTD_H ++# endif + #endif + + #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_STDARG_H ++# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 ++# define Z_HAVE_STDARG_H ++# elif HAVE_STDARG_H != 0 ++# define Z_HAVE_STDARG_H ++# endif + #endif + + #ifdef STDC + diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/CONTROL b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/CONTROL new file mode 100644 index 0000000000..3196577b55 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/CONTROL @@ -0,0 +1,5 @@ +Source: zlib +Version: 1.2.11 +Port-Version: 8 +Homepage: https://www.zlib.net/ +Description: A compression library diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/LICENSE b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/LICENSE new file mode 100644 index 0000000000..ca5fddfe0d --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/LICENSE @@ -0,0 +1,20 @@ + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu \ No newline at end of file diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/add_debug_postfix_on_mingw.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/add_debug_postfix_on_mingw.patch new file mode 100644 index 0000000000..22172ccfca --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/add_debug_postfix_on_mingw.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0fe939d..e4fc213 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -59,7 +59,7 @@ endif() + # + check_include_file(unistd.h Z_HAVE_UNISTD_H) + +-if(MSVC) ++if(WIN32) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/cmake_dont_build_more_than_needed.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/cmake_dont_build_more_than_needed.patch new file mode 100644 index 0000000000..a374f76d62 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/cmake_dont_build_more_than_needed.patch @@ -0,0 +1,74 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0fe939d..a1291d5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -7,6 +7,7 @@ set(VERSION "1.2.11") + + option(ASM686 "Enable building i686 assembly implementation") + option(AMD64 "Enable building amd64 assembly implementation") ++option(SKIP_BUILD_EXAMPLES "Skip build of the examples" OFF) + + set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") + set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +@@ -124,9 +125,11 @@ set(ZLIB_SRCS + ) + + if(NOT MINGW) +- set(ZLIB_DLL_SRCS +- win32/zlib1.rc # If present will override custom build rule below. +- ) ++ if(BUILD_SHARED_LIBS) ++ set(ZLIB_DLL_SRCS ++ win32/zlib1.rc # If present will override custom build rule below. ++ ) ++ endif() + endif() + + if(CMAKE_COMPILER_IS_GNUCC) +@@ -180,11 +183,12 @@ if(MINGW) + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) +- set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) ++ if(BUILD_SHARED_LIBS) ++ set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) ++ endif() + endif(MINGW) + +-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) ++add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) + set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) + set_target_properties(zlib PROPERTIES SOVERSION 1) + +@@ -201,7 +205,7 @@ endif() + + if(UNIX) + # On unix-like platforms the library is almost always called libz +- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) ++ set_target_properties(zlib PROPERTIES OUTPUT_NAME z) + if(NOT APPLE) + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") + endif() +@@ -211,7 +215,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32) + endif() + + if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) +- install(TARGETS zlib zlibstatic ++ install(TARGETS zlib + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) +@@ -230,6 +234,7 @@ endif() + # Example binaries + #============================================================================ + ++if (NOT SKIP_BUILD_EXAMPLES) + add_executable(example test/example.c) + target_link_libraries(example zlib) + add_test(example example) +@@ -247,3 +252,4 @@ if(HAVE_OFF64_T) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + endif() ++endif() diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/portfile.cmake b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/portfile.cmake new file mode 100644 index 0000000000..0d63291a28 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/portfile.cmake @@ -0,0 +1,54 @@ +set(VERSION 1.2.11) + +vcpkg_download_distfile(ARCHIVE_FILE + URLS "http://www.zlib.net/zlib-${VERSION}.tar.gz" "https://downloads.sourceforge.net/project/libpng/zlib/${VERSION}/zlib-${VERSION}.tar.gz" + FILENAME "zlib1211.tar.gz" + SHA512 73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE_FILE} + REF ${VERSION} + PATCHES + "cmake_dont_build_more_than_needed.patch" + "0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch" + "add_debug_postfix_on_mingw.patch" +) + +# This is generated during the cmake build +file(REMOVE ${SOURCE_PATH}/zconf.h) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + -DSKIP_INSTALL_FILES=ON + -DSKIP_BUILD_EXAMPLES=ON + OPTIONS_DEBUG + -DSKIP_INSTALL_HEADERS=ON +) + +vcpkg_install_cmake() + +# Install the pkgconfig file +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_replace_string(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/zlib.pc "-lz" "-lzlib") + endif() + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/zlib.pc DESTINATION ${CURRENT_PACKAGES_DIR}/lib/pkgconfig) +endif() +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_replace_string(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/zlib.pc "-lz" "-lzlibd") + endif() + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/zlib.pc DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig) +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +vcpkg_copy_pdbs() + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/usage b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/usage new file mode 100644 index 0000000000..0dfed74930 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-8/usage @@ -0,0 +1,4 @@ +The package zlib is compatible with built-in CMake targets: + + find_package(ZLIB REQUIRED) + target_link_libraries(main PRIVATE ZLIB::ZLIB) diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch new file mode 100644 index 0000000000..8fe2b2f5a6 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch @@ -0,0 +1,53 @@ +diff --git a/zconf.h.cmakein b/zconf.h.cmakein +index a7f24cc..a1b359b 100644 +--- a/zconf.h.cmakein ++++ b/zconf.h.cmakein +@@ -434,11 +434,19 @@ typedef uLong FAR uLongf; + #endif + + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_UNISTD_H ++# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 ++# define Z_HAVE_UNISTD_H ++# elif HAVE_UNISTD_H != 0 ++# define Z_HAVE_UNISTD_H ++# endif + #endif + + #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_STDARG_H ++# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 ++# define Z_HAVE_STDARG_H ++# elif HAVE_STDARG_H != 0 ++# define Z_HAVE_STDARG_H ++# endif + #endif + + #ifdef STDC +diff --git a/zconf.h.in b/zconf.h.in +index 5e1d68a..32f53c8 100644 +--- a/zconf.h.in ++++ b/zconf.h.in +@@ -432,11 +432,19 @@ typedef uLong FAR uLongf; + #endif + + #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_UNISTD_H ++# if ~(~HAVE_UNISTD_H + 0) == 0 && ~(~HAVE_UNISTD_H + 1) == 1 ++# define Z_HAVE_UNISTD_H ++# elif HAVE_UNISTD_H != 0 ++# define Z_HAVE_UNISTD_H ++# endif + #endif + + #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +-# define Z_HAVE_STDARG_H ++# if ~(~HAVE_STDARG_H + 0) == 0 && ~(~HAVE_STDARG_H + 1) == 1 ++# define Z_HAVE_STDARG_H ++# elif HAVE_STDARG_H != 0 ++# define Z_HAVE_STDARG_H ++# endif + #endif + + #ifdef STDC + diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/CONTROL b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/CONTROL new file mode 100644 index 0000000000..3196577b55 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/CONTROL @@ -0,0 +1,5 @@ +Source: zlib +Version: 1.2.11 +Port-Version: 8 +Homepage: https://www.zlib.net/ +Description: A compression library diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/LICENSE b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/LICENSE new file mode 100644 index 0000000000..ca5fddfe0d --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/LICENSE @@ -0,0 +1,20 @@ + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu \ No newline at end of file diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/add_debug_postfix_on_mingw.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/add_debug_postfix_on_mingw.patch new file mode 100644 index 0000000000..22172ccfca --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/add_debug_postfix_on_mingw.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0fe939d..e4fc213 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -59,7 +59,7 @@ endif() + # + check_include_file(unistd.h Z_HAVE_UNISTD_H) + +-if(MSVC) ++if(WIN32) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/cmake_dont_build_more_than_needed.patch b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/cmake_dont_build_more_than_needed.patch new file mode 100644 index 0000000000..a374f76d62 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/cmake_dont_build_more_than_needed.patch @@ -0,0 +1,74 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0fe939d..a1291d5 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -7,6 +7,7 @@ set(VERSION "1.2.11") + + option(ASM686 "Enable building i686 assembly implementation") + option(AMD64 "Enable building amd64 assembly implementation") ++option(SKIP_BUILD_EXAMPLES "Skip build of the examples" OFF) + + set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") + set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +@@ -124,9 +125,11 @@ set(ZLIB_SRCS + ) + + if(NOT MINGW) +- set(ZLIB_DLL_SRCS +- win32/zlib1.rc # If present will override custom build rule below. +- ) ++ if(BUILD_SHARED_LIBS) ++ set(ZLIB_DLL_SRCS ++ win32/zlib1.rc # If present will override custom build rule below. ++ ) ++ endif() + endif() + + if(CMAKE_COMPILER_IS_GNUCC) +@@ -180,11 +183,12 @@ if(MINGW) + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) +- set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) ++ if(BUILD_SHARED_LIBS) ++ set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) ++ endif() + endif(MINGW) + +-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) ++add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) + set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) + set_target_properties(zlib PROPERTIES SOVERSION 1) + +@@ -201,7 +205,7 @@ endif() + + if(UNIX) + # On unix-like platforms the library is almost always called libz +- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) ++ set_target_properties(zlib PROPERTIES OUTPUT_NAME z) + if(NOT APPLE) + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") + endif() +@@ -211,7 +215,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32) + endif() + + if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) +- install(TARGETS zlib zlibstatic ++ install(TARGETS zlib + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) +@@ -230,6 +234,7 @@ endif() + # Example binaries + #============================================================================ + ++if (NOT SKIP_BUILD_EXAMPLES) + add_executable(example test/example.c) + target_link_libraries(example zlib) + add_test(example example) +@@ -247,3 +252,4 @@ if(HAVE_OFF64_T) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + endif() ++endif() diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/portfile.cmake b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/portfile.cmake new file mode 100644 index 0000000000..0d63291a28 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/portfile.cmake @@ -0,0 +1,54 @@ +set(VERSION 1.2.11) + +vcpkg_download_distfile(ARCHIVE_FILE + URLS "http://www.zlib.net/zlib-${VERSION}.tar.gz" "https://downloads.sourceforge.net/project/libpng/zlib/${VERSION}/zlib-${VERSION}.tar.gz" + FILENAME "zlib1211.tar.gz" + SHA512 73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE_FILE} + REF ${VERSION} + PATCHES + "cmake_dont_build_more_than_needed.patch" + "0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch" + "add_debug_postfix_on_mingw.patch" +) + +# This is generated during the cmake build +file(REMOVE ${SOURCE_PATH}/zconf.h) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + -DSKIP_INSTALL_FILES=ON + -DSKIP_BUILD_EXAMPLES=ON + OPTIONS_DEBUG + -DSKIP_INSTALL_HEADERS=ON +) + +vcpkg_install_cmake() + +# Install the pkgconfig file +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_replace_string(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/zlib.pc "-lz" "-lzlib") + endif() + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/zlib.pc DESTINATION ${CURRENT_PACKAGES_DIR}/lib/pkgconfig) +endif() +if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_replace_string(${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/zlib.pc "-lz" "-lzlibd") + endif() + file(COPY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/zlib.pc DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig) +endif() + +vcpkg_fixup_pkgconfig() + +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) + +vcpkg_copy_pdbs() + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) diff --git a/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/usage b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/usage new file mode 100644 index 0000000000..0dfed74930 --- /dev/null +++ b/azure-pipelines/e2e-ports/version-files/old-ports/zlib-1.2.11-9/usage @@ -0,0 +1,4 @@ +The package zlib is compatible with built-in CMake targets: + + find_package(ZLIB REQUIRED) + target_link_libraries(main PRIVATE ZLIB::ZLIB) diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/cat/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/cat/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/cat/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/cat/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/cat/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/cat/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/cat/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/cat/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/dog/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/dog/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/dog/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/dog/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/dog/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/dog/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/dog/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/dog/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/duck/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/duck/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/duck/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/duck/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/duck/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/duck/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/duck/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/duck/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/ferret/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/ferret/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/ferret/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/ferret/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/ferret/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/ferret/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/ferret/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/ferret/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/fish/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/fish/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/fish/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/fish/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/fish/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/fish/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/fish/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/fish/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/mouse/portfile.cmake b/azure-pipelines/e2e-ports/version-files/ports-incomplete/mouse/portfile.cmake similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/mouse/portfile.cmake rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/mouse/portfile.cmake diff --git a/azure-pipelines/e2e-ports/version-files/ports_incomplete/mouse/vcpkg.json b/azure-pipelines/e2e-ports/version-files/ports-incomplete/mouse/vcpkg.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/ports_incomplete/mouse/vcpkg.json rename to azure-pipelines/e2e-ports/version-files/ports-incomplete/mouse/vcpkg.json diff --git a/azure-pipelines/e2e-ports/version-files/versions_incomplete/baseline.json b/azure-pipelines/e2e-ports/version-files/versions-incomplete/baseline.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/versions_incomplete/baseline.json rename to azure-pipelines/e2e-ports/version-files/versions-incomplete/baseline.json diff --git a/azure-pipelines/e2e-ports/version-files/versions_incomplete/c-/cat.json b/azure-pipelines/e2e-ports/version-files/versions-incomplete/c-/cat.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/versions_incomplete/c-/cat.json rename to azure-pipelines/e2e-ports/version-files/versions-incomplete/c-/cat.json diff --git a/azure-pipelines/e2e-ports/version-files/versions_incomplete/d-/dog.json b/azure-pipelines/e2e-ports/version-files/versions-incomplete/d-/dog.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/versions_incomplete/d-/dog.json rename to azure-pipelines/e2e-ports/version-files/versions-incomplete/d-/dog.json diff --git a/azure-pipelines/e2e-ports/version-files/versions_incomplete/f-/fish.json b/azure-pipelines/e2e-ports/version-files/versions-incomplete/f-/fish.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/versions_incomplete/f-/fish.json rename to azure-pipelines/e2e-ports/version-files/versions-incomplete/f-/fish.json diff --git a/azure-pipelines/e2e-ports/version-files/versions_incomplete/m-/mouse.json b/azure-pipelines/e2e-ports/version-files/versions-incomplete/m-/mouse.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/versions_incomplete/m-/mouse.json rename to azure-pipelines/e2e-ports/version-files/versions-incomplete/m-/mouse.json diff --git a/azure-pipelines/e2e-ports/version-files/default-baseline-2/versions/z-/zlib.json b/azure-pipelines/e2e-ports/version-files/versions/z-/zlib.json similarity index 100% rename from azure-pipelines/e2e-ports/version-files/default-baseline-2/versions/z-/zlib.json rename to azure-pipelines/e2e-ports/version-files/versions/z-/zlib.json diff --git a/azure-pipelines/end-to-end-tests-dir/versions.ps1 b/azure-pipelines/end-to-end-tests-dir/versions.ps1 index 342fe8eae7..6f4ac057e0 100644 --- a/azure-pipelines/end-to-end-tests-dir/versions.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/versions.ps1 @@ -9,7 +9,6 @@ function Refresh-VersionFiles() { git -C $versionFilesPath @gitConfigOptions init git -C $versionFilesPath @gitConfigOptions add -A git -C $versionFilesPath @gitConfigOptions commit -m testing - git -C $versionFilesPath fetch https://github.com/vicroms/test-registries } Refresh-VersionFiles @@ -23,7 +22,7 @@ Throw-IfFailed # Test verify versions mkdir $VersionFilesRoot | Out-Null -Copy-Item -Recurse "$versionFilesPath/versions_incomplete" $VersionFilesRoot +Copy-Item -Recurse "$versionFilesPath/versions-incomplete" $VersionFilesRoot $portsRedirectArgsOK = @( "--feature-flags=versions", "--x-builtin-ports-root=$versionFilesPath/ports", @@ -31,8 +30,8 @@ $portsRedirectArgsOK = @( ) $portsRedirectArgsIncomplete = @( "--feature-flags=versions", - "--x-builtin-ports-root=$versionFilesPath/ports_incomplete", - "--x-builtin-registry-versions-dir=$VersionFilesRoot/versions_incomplete" + "--x-builtin-ports-root=$versionFilesPath/ports-incomplete", + "--x-builtin-registry-versions-dir=$VersionFilesRoot/versions-incomplete" ) $CurrentTest = "x-verify-ci-versions (All files OK)" Write-Host $CurrentTest @@ -75,10 +74,61 @@ $CurrentTest = "x-add-version mouse" # Missing baseline entry Run-Vcpkg @portsRedirectArgsIncomplete x-add-version mouse Throw-IfFailed + # Validate changes Run-Vcpkg @portsRedirectArgsIncomplete x-ci-verify-versions --verbose Throw-IfFailed +# Validate port-version +$CurrentTest = "x-add-version octopus" +Set-EmptyTestPort -Name octopus -Version 1.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports" +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1" +$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus +Throw-IfNotFailed +if ($output.Replace("`r`n", "`n") -notmatch @" +warning: In octopus, 1.0 is completely new version, so the "port-version" field should be removed. Remove "port-version", commit that change, and try again. To skip this check, rerun with --skip-version-format-check . +"@) { + throw "Expected detecting present port-version when a new version is added as bad" +} + +Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check +Throw-IfFailed +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1 to version database" + +Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports" +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1" +$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus +Throw-IfNotFailed +if ($output.Replace("`r`n", "`n") -notmatch @" +warning: In octopus, 2.0 is completely new version, so the "port-version" field should be removed. Remove "port-version", commit that change, and try again. To skip this check, rerun with --skip-version-format-check . +"@) { + throw "Expected detecting present port-version when a new version is added as bad" +} + +Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check +Throw-IfFailed +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1 to version database" + +Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "3" -PortsRoot "$versionFilesPath/ports" +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3" +$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus +Throw-IfNotFailed +if ($output.Replace("`r`n", "`n") -notmatch @" +warning: In octopus, the current "port-version" for 2.0 is 1, so the next added "port-version" should be 2, but the port declares "port-version" 3. Change "port-version" to 2, commit that change, and try again. To skip this check, rerun with --skip-version-format-check . +"@) { + throw "Expected detecting present port-version when a new version is added as bad" +} + +Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check +Throw-IfFailed +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3 to version database" + $CurrentTest = "default baseline" $out = Run-VcpkgAndCaptureOutput @commonArgs "--feature-flags=versions" install --x-manifest-root=$versionFilesPath/default-baseline-1 Throw-IfNotFailed @@ -97,31 +147,63 @@ if (($out -notmatch ".*error: Failed to load port because versions are inconsist throw "Expected to fail due to mismatched versions between portfile and the version database" } -foreach ($opt_registries in @("",",registries")) +Write-Trace "testing baselines" +Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-8" "$versionFilesPath/ports/zlib" +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-8" +Run-Vcpkg @portsRedirectArgsOK x-add-version zlib +Throw-IfFailed +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-8 to version database" +$baselineSha = git -C $versionFilesPath @gitConfigOptions rev-parse HEAD +Remove-Item -Recurse -Force -LiteralPath "$versionFilesPath/ports/zlib" +Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-9" "$versionFilesPath/ports/zlib" +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-9" +Run-Vcpkg @portsRedirectArgsOK x-add-version zlib +Throw-IfFailed +git -C $versionFilesPath @gitConfigOptions add -A +git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-9 to version database" + +$CurrentTest = "without default baseline 2 -- enabling versions should not change behavior" +Remove-Item -Recurse $buildtreesRoot/versioning_ -ErrorAction SilentlyContinue +Run-Vcpkg @commonArgs "--feature-flags=versions" install ` + "--dry-run" ` + "--x-manifest-root=$versionFilesPath/without-default-baseline-2" ` + "--x-builtin-registry-versions-dir=$versionFilesPath/versions" +Throw-IfFailed +Require-FileNotExists $buildtreesRoot/versioning_ + +$CurrentTest = "default baseline 2" +$baselinedVcpkgJson = @" { - Write-Trace "testing baselines: $opt_registries" - Refresh-VersionFiles - $CurrentTest = "without default baseline 2 -- enabling versions should not change behavior" - Remove-Item -Recurse $buildtreesRoot/versioning_ -ErrorAction SilentlyContinue - Run-Vcpkg @commonArgs "--feature-flags=versions$opt_registries" install ` - "--dry-run" ` - "--x-manifest-root=$versionFilesPath/without-default-baseline-2" ` - "--x-builtin-registry-versions-dir=$versionFilesPath/default-baseline-2/versions" - Throw-IfFailed - Require-FileNotExists $buildtreesRoot/versioning_ - - $CurrentTest = "default baseline 2" - Run-Vcpkg @commonArgs "--feature-flags=versions$opt_registries" install ` - "--dry-run" ` - "--x-manifest-root=$versionFilesPath/default-baseline-2" ` - "--x-builtin-registry-versions-dir=$versionFilesPath/default-baseline-2/versions" - Throw-IfFailed - Require-FileExists $buildtreesRoot/versioning_ - - $CurrentTest = "using version features fails without flag" - Run-Vcpkg @commonArgs "--feature-flags=-versions$opt_registries" install ` - "--dry-run" ` - "--x-manifest-root=$versionFilesPath/default-baseline-2" ` - "--x-builtin-registry-versions-dir=$versionFilesPath/default-baseline-2/versions" - Throw-IfNotFailed + "name": "default-baseline-test-2", + "version-string": "0", + "builtin-baseline": "$baselineSha", + "dependencies": [ + "zlib" + ] +} +"@ + +$defaultBaseline2 = "$TestingRoot/default-baseline-2" +if (Test-Path $defaultBaseline2) { + Remove-Item -Recurse -Force -LiteralPath $defaultBaseline2 | Out-Null } + +New-Item -ItemType Directory -Force $defaultBaseline2 | Out-Null +Set-Content -LiteralPath "$defaultBaseline2/vcpkg.json" -Value $baselinedVcpkgJson -NoNewline -Encoding Ascii + +Run-Vcpkg @commonArgs "--feature-flags=versions" install ` + "--dry-run" ` + "--x-manifest-root=$defaultBaseline2" ` + "--x-builtin-registry-versions-dir=$versionFilesPath/versions" +Throw-IfFailed +Require-FileExists $buildtreesRoot/versioning_ + +$CurrentTest = "using version features fails without flag" +Run-Vcpkg @commonArgs "--feature-flags=-versions" install ` + "--dry-run" ` + "--x-manifest-root=$defaultBaseline2" ` + "--x-builtin-registry-versions-dir=$versionFilesPath/versions" +Throw-IfNotFailed diff --git a/azure-pipelines/end-to-end-tests-prelude.ps1 b/azure-pipelines/end-to-end-tests-prelude.ps1 index 68c95949fb..ac968169d6 100644 --- a/azure-pipelines/end-to-end-tests-prelude.ps1 +++ b/azure-pipelines/end-to-end-tests-prelude.ps1 @@ -186,6 +186,7 @@ function Set-EmptyTestPort { [string]$Name, [Parameter(Mandatory)][ValidateNotNullOrWhitespace()] [string]$Version, + [string]$PortVersion, [Parameter(Mandatory)][ValidateNotNullOrWhitespace()] [string]$PortsRoot, [switch]$Malformed @@ -196,23 +197,25 @@ function Set-EmptyTestPort { New-Item -ItemType Directory -Force -Path $portDir | Out-Null Set-Content -Value "set(VCPKG_POLICY_EMPTY_PACKAGE enabled)" -LiteralPath (Join-Path $portDir 'portfile.cmake') -Encoding Ascii - if ($Malformed) { - # Add bad trailing comma - $json = @" -{ - "name": "$Name", - "version": "$Version", -} -"@ - } else { - $json = @" + $json = @" { "name": "$Name", "version": "$Version" -} "@ + + $json = $json.Replace("`r`n", "`n") + if (-not $null -eq $PortVersion) + { + $json += ",`n `"port-version`": $PortVersion" + } + + if ($Malformed) { + $json += ',' } - Set-Content -Value $json -LiteralPath (Join-Path $portDir 'vcpkg.json') -Encoding Ascii + + $json += "`n}`n" + + Set-Content -Value $json -LiteralPath (Join-Path $portDir 'vcpkg.json') -Encoding Ascii -NoNewline } Refresh-TestRoot diff --git a/include/vcpkg/base/json.h b/include/vcpkg/base/json.h index 29fc1d22d5..24cbceb80e 100644 --- a/include/vcpkg/base/json.h +++ b/include/vcpkg/base/json.h @@ -327,7 +327,6 @@ namespace vcpkg::Json JsonStyle style; }; - ExpectedL parse_file(const ReadOnlyFilesystem&, const Path&, std::error_code& ec); ExpectedL parse(StringView text, StringView origin); ParsedJson parse_file(LineInfo li, const ReadOnlyFilesystem&, const Path&); ExpectedL parse_object(StringView text, StringView origin); diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index effc1651ef..c4db50bea3 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -74,6 +74,19 @@ DECLARE_MESSAGE(AddVersionPortFilesShaUnchanged, "", "checked-in files for {package_name} are unchanged from version {version}") DECLARE_MESSAGE(AddVersionPortHasImproperFormat, (msg::package_name), "", "{package_name} is not properly formatted") +DECLARE_MESSAGE( + AddVersionPortVersionShouldBeGone, + (msg::package_name, msg::version), + "", + "In {package_name}, {version} is completely new version, so the \"port-version\" field should be removed. Remove " + "\"port-version\", commit that change, and try again. To skip this check, rerun with --skip-version-format-check .") +DECLARE_MESSAGE(AddVersionPortVersionShouldBeOneMore, + (msg::package_name, msg::version, msg::count, msg::expected_version, msg::actual_version), + "", + "In {package_name}, the current \"port-version\" for {version} is {count}, so the next added " + "\"port-version\" should be {expected_version}, but the port declares \"port-version\" " + "{actual_version}. Change \"port-version\" to {expected_version}, commit that change, and try again. " + "To skip this check, rerun with --skip-version-format-check .") DECLARE_MESSAGE(AddVersionSuggestVersionDate, (msg::package_name), "\"version-string\" and \"version-date\" are JSON keys, and --skip-version-format-check is a command " diff --git a/locales/messages.json b/locales/messages.json index afa5ba7e41..be4a9a9054 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -86,6 +86,10 @@ "_AddVersionPortFilesShaUnchanged.comment": "An example of {package_name} is zlib. An example of {version} is 1.3.8.", "AddVersionPortHasImproperFormat": "{package_name} is not properly formatted", "_AddVersionPortHasImproperFormat.comment": "An example of {package_name} is zlib.", + "AddVersionPortVersionShouldBeGone": "In {package_name}, {version} is completely new version, so the \"port-version\" field should be removed. Remove \"port-version\", commit that change, and try again. To skip this check, rerun with --skip-version-format-check .", + "_AddVersionPortVersionShouldBeGone.comment": "An example of {package_name} is zlib. An example of {version} is 1.3.8.", + "AddVersionPortVersionShouldBeOneMore": "In {package_name}, the current \"port-version\" for {version} is {count}, so the next added \"port-version\" should be {expected_version}, but the port declares \"port-version\" {actual_version}. Change \"port-version\" to {expected_version}, commit that change, and try again. To skip this check, rerun with --skip-version-format-check .", + "_AddVersionPortVersionShouldBeOneMore.comment": "An example of {package_name} is zlib. An example of {version} is 1.3.8. An example of {count} is 42. An example of {expected_version} is 1.3.8. An example of {actual_version} is 1.3.8.", "AddVersionSuggestVersionDate": "The version format of \"{package_name}\" uses \"version-string\", but the format is acceptable as a \"version-date\". If this format is actually intended to be an ISO 8601 date, change the format to \"version-date\", and rerun this command. Otherwise, disable this check by rerunning this command and adding --skip-version-format-check .", "_AddVersionSuggestVersionDate.comment": "\"version-string\" and \"version-date\" are JSON keys, and --skip-version-format-check is a command line switch. They should not be translated An example of {package_name} is zlib.", "AddVersionSuggestVersionRelaxed": "The version format of \"{package_name}\" uses \"version-string\", but the format is acceptable as a \"version\". If the versions for this port are orderable using relaxed-version rules, change the format to \"version\", and rerun this command. Relaxed-version rules order versions by each numeric component. Then, versions with dash suffixes are sorted lexcographically before. Plus'd build tags are ignored. Examples:\n1.0 < 1.1-alpha < 1.1-b < 1.1 < 1.1.1 < 1.2+build = 1.2 < 2.0\nNote in particular that dashed suffixes sort *before*, not after. 1.0-anything < 1.0\nNote that this sort order is the same as chosen in Semantic Versioning (see https://semver.org), even though the actually semantic parts do not apply.\nIf versions for this port are not ordered by these rules, disable this check by rerunning this command and adding --skip-version-format-check .", diff --git a/src/vcpkg/base/json.cpp b/src/vcpkg/base/json.cpp index 83c2d58ffd..e65c51e65a 100644 --- a/src/vcpkg/base/json.cpp +++ b/src/vcpkg/base/json.cpp @@ -1102,26 +1102,16 @@ namespace vcpkg::Json return true; } - ExpectedL parse_file(const ReadOnlyFilesystem& fs, const Path& json_file, std::error_code& ec) - { - auto res = fs.read_contents(json_file, ec); - if (ec) - { - return format_filesystem_call_error(ec, "read_contents", {json_file}); - } - - return parse(res, json_file); - } - ParsedJson parse_file(vcpkg::LineInfo li, const ReadOnlyFilesystem& fs, const Path& json_file) { std::error_code ec; - auto ret = parse_file(fs, json_file, ec); + auto disk_contents = fs.read_contents(json_file, ec); if (ec) { Checks::msg_exit_with_error(li, format_filesystem_call_error(ec, "read_contents", {json_file})); } - return std::move(ret).value_or_exit(VCPKG_LINE_INFO); + + return parse(disk_contents, json_file).value_or_exit(VCPKG_LINE_INFO); } ExpectedL parse(StringView json, StringView origin) { return Parser::parse(json, origin); } diff --git a/src/vcpkg/commands.add-version.cpp b/src/vcpkg/commands.add-version.cpp index 7c57ac2b97..72e0b8afd7 100644 --- a/src/vcpkg/commands.add-version.cpp +++ b/src/vcpkg/commands.add-version.cpp @@ -54,30 +54,32 @@ namespace { return insert_version_to_json_object(obj, version.version, JsonIdVersionString); } + Checks::unreachable(VCPKG_LINE_INFO); } - void check_used_version_scheme(const SchemedVersion& version, const std::string& port_name) + bool check_used_version_scheme(const SchemedVersion& version, const std::string& port_name) { if (version.scheme == VersionScheme::String) { if (DateVersion::try_parse(version.version.text)) { - Checks::msg_exit_with_message( - VCPKG_LINE_INFO, - msg::format(msgAddVersionSuggestVersionDate, msg::package_name = port_name) - .append_raw("\n") - .append(msgSeeURL, msg::url = docs::version_schemes)); + msg::println(msg::format(msgAddVersionSuggestVersionDate, msg::package_name = port_name) + .append_raw("\n") + .append(msgSeeURL, msg::url = docs::version_schemes)); + return true; } + if (DotVersion::try_parse_relaxed(version.version.text)) { - Checks::msg_exit_with_message( - VCPKG_LINE_INFO, - msg::format(msgAddVersionSuggestVersionRelaxed, msg::package_name = port_name) - .append_raw("\n") - .append(msgSeeURL, msg::url = docs::version_schemes)); + msg::println(msg::format(msgAddVersionSuggestVersionRelaxed, msg::package_name = port_name) + .append_raw("\n") + .append(msgSeeURL, msg::url = docs::version_schemes)); + return true; } } + + return false; } Json::Object serialize_baseline(const std::map>& baseline) @@ -111,24 +113,19 @@ namespace return output_object; } - void write_baseline_file(const Filesystem& fs, - const std::map>& baseline_map, - const Path& output_path) + static void write_json_file(const Filesystem& fs, const Json::Object& obj, const Path& output_path) { auto new_path = output_path + ".tmp"; fs.create_directories(output_path.parent_path(), VCPKG_LINE_INFO); - fs.write_contents(new_path, Json::stringify(serialize_baseline(baseline_map)), VCPKG_LINE_INFO); + fs.write_contents(new_path, Json::stringify(obj), VCPKG_LINE_INFO); fs.rename(new_path, output_path, VCPKG_LINE_INFO); } - void write_versions_file(const Filesystem& fs, - const std::vector& versions, - const Path& output_path) + static void write_versions_file(const Filesystem& fs, + const std::vector& versions, + const Path& output_path) { - auto new_path = output_path + ".tmp"; - fs.create_directories(output_path.parent_path(), VCPKG_LINE_INFO); - fs.write_contents(new_path, Json::stringify(serialize_versions(versions)), VCPKG_LINE_INFO); - fs.rename(new_path, output_path, VCPKG_LINE_INFO); + write_json_file(fs, serialize_versions(versions), output_path); } UpdateResult update_baseline_version(const VcpkgPaths& paths, @@ -153,8 +150,10 @@ namespace msg::version = version, msg::path = baseline_path); } + return UpdateResult::NotUpdated; } + baseline_version = version; } else @@ -162,12 +161,13 @@ namespace baseline_map.emplace(port_name, version); } - write_baseline_file(fs, baseline_map, baseline_path); + write_json_file(fs, serialize_baseline(baseline_map), baseline_path); if (print_success) { msg::println( Color::success, msgAddVersionAddedVersionToFile, msg::version = version, msg::path = baseline_path); } + return UpdateResult::Updated; } @@ -194,8 +194,30 @@ namespace { if (!skip_version_format_check) { - check_used_version_scheme(port_version, port_name); + if (check_used_version_scheme(port_version, port_name)) + { + if (!keep_going) + { + return UpdateResult::NotUpdated; + } + + Checks::exit_fail(VCPKG_LINE_INFO); + } + + if (port_version.version.port_version != 0) + { + msg::println_warning(msgAddVersionPortVersionShouldBeGone, + msg::package_name = port_name, + msg::version = port_version.version.text); + if (keep_going) + { + return UpdateResult::NotUpdated; + } + + Checks::exit_fail(VCPKG_LINE_INFO); + } } + std::vector new_entry{{port_version, git_tree}}; write_versions_file(fs, new_entry, maybe_maybe_versions.versions_file_path); if (print_success) @@ -207,15 +229,38 @@ namespace .append_raw(' ') .append(msgAddVersionNewFile)); } + return UpdateResult::Updated; } - const auto& versions_end = versions->end(); - auto found_same_sha = std::find_if( - versions->begin(), versions_end, [&](auto&& entry) -> bool { return entry.git_tree == git_tree; }); - if (found_same_sha != versions_end) + const GitVersionDbEntry* exactly_matching_sha_version_entry = nullptr; + GitVersionDbEntry* exactly_matching_version_entry = nullptr; + const GitVersionDbEntry* highest_matching_version_entry = nullptr; + for (auto&& version_entry : *versions) { - if (found_same_sha->version.version == port_version.version) + if (version_entry.version.version.text == port_version.version.text) + { + if (version_entry.version.version.port_version == port_version.version.port_version) + { + exactly_matching_version_entry = &version_entry; + } + + if (!highest_matching_version_entry || highest_matching_version_entry->version.version.port_version < + version_entry.version.version.port_version) + { + highest_matching_version_entry = &version_entry; + } + } + + if (version_entry.git_tree == git_tree) + { + exactly_matching_sha_version_entry = &version_entry; + } + } + + if (exactly_matching_sha_version_entry) + { + if (exactly_matching_version_entry == exactly_matching_sha_version_entry) { if (print_success) { @@ -224,11 +269,13 @@ namespace msg::version = port_version.version, msg::path = maybe_maybe_versions.versions_file_path); } + return UpdateResult::NotUpdated; } + msg::println_warning(msg::format(msgAddVersionPortFilesShaUnchanged, msg::package_name = port_name, - msg::version = found_same_sha->version.version) + msg::version = port_version.version) .append_raw("\n-- SHA: ") .append_raw(git_tree) .append_raw("\n-- ") @@ -238,15 +285,15 @@ namespace .append_raw("\n*** ") .append(msgSeeURL, msg::url = docs::add_version_command_url) .append_raw("\n***")); - if (keep_going) return UpdateResult::NotUpdated; + if (keep_going) + { + return UpdateResult::NotUpdated; + } + Checks::exit_fail(VCPKG_LINE_INFO); } - auto it = std::find_if(versions->begin(), versions_end, [&](const GitVersionDbEntry& entry) -> bool { - return entry.version.version == port_version.version; - }); - - if (it != versions_end) + if (exactly_matching_version_entry) { if (!overwrite_version) { @@ -255,7 +302,7 @@ namespace .append_raw('\n') .append(msgAddVersionVersionIs, msg::version = port_version.version) .append_raw('\n') - .append(msgAddVersionOldShaIs, msg::commit_sha = it->git_tree) + .append(msgAddVersionOldShaIs, msg::commit_sha = exactly_matching_version_entry->git_tree) .append_raw('\n') .append(msgAddVersionNewShaIs, msg::commit_sha = git_tree) .append_raw('\n') @@ -267,12 +314,46 @@ namespace .append_raw("\n***") .append(msgAddVersionNoFilesUpdated) .append_raw("***")); - if (keep_going) return UpdateResult::NotUpdated; + if (keep_going) + { + return UpdateResult::NotUpdated; + } + Checks::exit_fail(VCPKG_LINE_INFO); } - it->version = port_version; - it->git_tree = git_tree; + exactly_matching_version_entry->git_tree = git_tree; + } + else if (!skip_version_format_check && port_version.version.port_version != 0 && + !highest_matching_version_entry) + { + msg::println_warning(msgAddVersionPortVersionShouldBeGone, + msg::package_name = port_name, + msg::version = port_version.version.text); + if (keep_going) + { + return UpdateResult::NotUpdated; + } + + Checks::exit_fail(VCPKG_LINE_INFO); + } + else if (!skip_version_format_check && port_version.version.port_version != 0 && + highest_matching_version_entry->version.version.port_version != + (port_version.version.port_version - 1)) + { + msg::println_warning(msgAddVersionPortVersionShouldBeOneMore, + msg::package_name = port_name, + msg::version = port_version.version.text, + msg::count = highest_matching_version_entry->version.version.port_version, + msg::expected_version = + highest_matching_version_entry->version.version.port_version + 1, + msg::actual_version = port_version.version.port_version); + if (keep_going) + { + return UpdateResult::NotUpdated; + } + + Checks::exit_fail(VCPKG_LINE_INFO); } else { @@ -281,7 +362,15 @@ namespace if (!skip_version_format_check) { - check_used_version_scheme(port_version, port_name); + if (check_used_version_scheme(port_version, port_name)) + { + if (!keep_going) + { + return UpdateResult::NotUpdated; + } + + Checks::exit_fail(VCPKG_LINE_INFO); + } } write_versions_file(fs, *versions, maybe_maybe_versions.versions_file_path); @@ -292,6 +381,7 @@ namespace msg::version = port_version.version, msg::path = maybe_maybe_versions.versions_file_path); } + return UpdateResult::Updated; } @@ -313,7 +403,7 @@ namespace vcpkg Undocumented, AutocompletePriority::Public, 0, - 1, + SIZE_MAX, {AddVersionSwitches}, nullptr, }; @@ -335,15 +425,7 @@ namespace vcpkg } std::vector port_names; - if (!parsed_args.command_arguments.empty()) - { - if (add_all) - { - msg::println_warning(msgAddVersionIgnoringOptionAll, msg::option = SwitchAll); - } - port_names.emplace_back(parsed_args.command_arguments[0]); - } - else + if (parsed_args.command_arguments.empty()) { Checks::msg_check_exit( VCPKG_LINE_INFO, @@ -357,6 +439,15 @@ namespace vcpkg port_names.emplace_back(port_dir.stem().to_string()); } } + else + { + if (add_all) + { + msg::println_warning(msgAddVersionIgnoringOptionAll, msg::option = SwitchAll); + } + + port_names = std::move(parsed_args.command_arguments); + } auto baseline_map = [&]() -> std::map> { if (!fs.exists(baseline_path, IgnoreErrors{})) @@ -364,6 +455,7 @@ namespace vcpkg std::map> ret; return ret; } + auto maybe_baseline_map = vcpkg::get_builtin_baseline(paths); return maybe_baseline_map.value_or_exit(VCPKG_LINE_INFO); }(); @@ -388,15 +480,18 @@ namespace vcpkg for (auto&& port_name : port_names) { auto port_dir = paths.builtin_ports_directory() / port_name; - - auto maybe_scfl = Paragraphs::try_load_port_required( - fs, port_name, PortLocation{paths.builtin_ports_directory() / port_name}) - .maybe_scfl; + auto load_result = Paragraphs::try_load_port_required( + fs, port_name, PortLocation{paths.builtin_ports_directory() / port_name}); + auto& maybe_scfl = load_result.maybe_scfl; auto scfl = maybe_scfl.get(); if (!scfl) { msg::println(Color::error, maybe_scfl.error()); - Checks::check_exit(VCPKG_LINE_INFO, !add_all); + if (!add_all) + { + Checks::exit_fail(VCPKG_LINE_INFO); + } + continue; } @@ -406,10 +501,9 @@ namespace vcpkg if (scfl->control_path.filename() == FileVcpkgDotJson) { - const auto current_file_content = fs.read_contents(scfl->control_path, VCPKG_LINE_INFO); const auto json = serialize_manifest(*scfl->source_control_file); const auto formatted_content = Json::stringify(json); - if (current_file_content != formatted_content) + if (load_result.on_disk_contents != formatted_content) { std::string command_line = "vcpkg format-manifest "; append_shell_escaped(command_line, scfl->control_path); @@ -418,11 +512,12 @@ namespace vcpkg .append_raw('\n') .append(msgAddVersionFormatPortSuggestion, msg::command_line = command_line) .append_raw('\n') - .append(msgSeeURL, msg::url = docs::format_manifest_command_url) - .append(msgAddVersionCommitChangesReminder) - .append_raw('\n') - .append(msgSeeURL, msg::url = docs::add_version_command_url)); - Checks::check_exit(VCPKG_LINE_INFO, !add_all); + .append(msgSeeURL, msg::url = docs::format_manifest_command_url)); + if (!add_all) + { + Checks::exit_fail(VCPKG_LINE_INFO); + } + continue; } } @@ -449,6 +544,7 @@ namespace vcpkg if (add_all) continue; Checks::exit_fail(VCPKG_LINE_INFO); } + const auto& git_tree = git_tree_it->second; auto updated_versions_file = update_version_db_file(paths, port_name, @@ -466,6 +562,7 @@ namespace vcpkg msg::println(msgAddVersionNoFilesUpdatedForPort, msg::package_name = port_name); } } + Checks::exit_success(VCPKG_LINE_INFO); } } // namespace vcpkg diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 77e107f5ce..8635927c72 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -489,30 +489,22 @@ namespace { vcpkg::LockFile ret; std::error_code ec; - auto maybe_lock_contents = Json::parse_file(fs, p, ec); + auto lockfile_disk_contents = fs.read_contents(p, ec); if (ec) { Debug::print("Failed to load lockfile: ", ec.message(), "\n"); return ret; } - else if (auto lock_contents = maybe_lock_contents.get()) - { - auto& doc = lock_contents->value; - if (!doc.is_object()) - { - Debug::print("Lockfile was not an object\n"); - return ret; - } - - ret.lockdata = lockdata_from_json_object(doc.object(VCPKG_LINE_INFO)); - return ret; - } - else + auto maybe_lock_data = Json::parse_object(lockfile_disk_contents, p); + if (auto lock_data = maybe_lock_data.get()) { - Debug::print("Failed to load lockfile:\n", maybe_lock_contents.error()); + ret.lockdata = lockdata_from_json_object(*lock_data); return ret; } + + Debug::print("Failed to load lockfile:\n", maybe_lock_data.error()); + return ret; } } // unnamed namespace