diff options
Diffstat (limited to 'vcpkg/ports/jsonnet')
| -rw-r--r-- | vcpkg/ports/jsonnet/0004-incorporate-md5.patch | 42 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/0005-use-upstream-rapidyaml.patch | 46 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/0006-use-cxx17.patch | 20 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/001-enable-msvc.patch | 80 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/002-fix-dependency-and-install.patch | 60 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/portfile.cmake | 56 | ||||
| -rw-r--r-- | vcpkg/ports/jsonnet/vcpkg.json | 16 |
7 files changed, 320 insertions, 0 deletions
diff --git a/vcpkg/ports/jsonnet/0004-incorporate-md5.patch b/vcpkg/ports/jsonnet/0004-incorporate-md5.patch new file mode 100644 index 0000000..2921368 --- /dev/null +++ b/vcpkg/ports/jsonnet/0004-incorporate-md5.patch @@ -0,0 +1,42 @@ +diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt +index 2eb28d2..8116ac3 100644 +--- a/core/CMakeLists.txt ++++ b/core/CMakeLists.txt +@@ -16,7 +16,8 @@ set(LIBJSONNET_HEADERS + static_error.h + string_utils.h + unicode.h +- vm.h) ++ vm.h ++ ../third_party/md5/md5.h) + + set(LIBJSONNET_SOURCE + desugarer.cpp +@@ -28,12 +29,13 @@ set(LIBJSONNET_SOURCE + path_utils.cpp + static_analysis.cpp + string_utils.cpp +- vm.cpp) ++ vm.cpp ++ ../third_party/md5/md5.cpp) + + if (BUILD_SHARED_BINARIES) + add_library(libjsonnet ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) +-add_dependencies(libjsonnet md5 stdlib) +-target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json ryml) ++add_dependencies(libjsonnet stdlib) ++target_link_libraries(libjsonnet nlohmann_json::nlohmann_json ryml) + + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../include/libjsonnet.h JSONNET_VERSION_DEF + REGEX "[#]define[ \t]+LIB_JSONNET_VERSION[ \t]+") +@@ -59,8 +61,8 @@ endif() + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet_static STATIC ${LIBJSONNET_SOURCE}) +- add_dependencies(libjsonnet_static md5 stdlib) +- target_link_libraries(libjsonnet_static md5 nlohmann_json::nlohmann_json ryml) ++ add_dependencies(libjsonnet_static stdlib) ++ target_link_libraries(libjsonnet_static nlohmann_json::nlohmann_json ryml) + set_target_properties(libjsonnet_static PROPERTIES OUTPUT_NAME jsonnet) + install(TARGETS libjsonnet_static DESTINATION "${CMAKE_INSTALL_LIBDIR}") + target_include_directories(libjsonnet_static INTERFACE diff --git a/vcpkg/ports/jsonnet/0005-use-upstream-rapidyaml.patch b/vcpkg/ports/jsonnet/0005-use-upstream-rapidyaml.patch new file mode 100644 index 0000000..b47a254 --- /dev/null +++ b/vcpkg/ports/jsonnet/0005-use-upstream-rapidyaml.patch @@ -0,0 +1,46 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3ebf359..8562715 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -13,6 +13,7 @@ option(BUILD_STATIC_LIBS "Build a static libjsonnet." ON) + option(BUILD_SHARED_BINARIES "Link binaries to the shared libjsonnet instead of the static one." OFF) + option(USE_SYSTEM_GTEST "Use system-provided gtest library" OFF) + option(USE_SYSTEM_JSON "Use the system-provided json library" OFF) ++option(USE_SYSTEM_RYML "Use the system-provided rapidyaml library" OFF) + # TODO: Support using a system Rapid YAML install. + set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING + "Output artifacts directory.") +@@ -104,6 +105,11 @@ if(USE_SYSTEM_JSON) + else() + add_subdirectory(third_party/json) + endif() ++if(USE_SYSTEM_RYML) ++ find_package(ryml CONFIG REQUIRED) ++else() ++ add_subdirectory(third_party/rapidyaml/rapidyaml ryml) ++endif() + + # Look for libraries in global output path. + link_directories(${GLOBAL_OUTPUT_PATH}) +@@ -125,7 +131,6 @@ endif() + add_subdirectory(include) + add_subdirectory(stdlib) + add_subdirectory(third_party/md5) +-add_subdirectory(third_party/rapidyaml) + add_subdirectory(core) + add_subdirectory(cpp) + add_subdirectory(cmd) +diff --git a/core/vm.cpp b/core/vm.cpp +index faf6d54..f14ddbe 100644 +--- a/core/vm.cpp ++++ b/core/vm.cpp +@@ -30,7 +30,8 @@ limitations under the License. + #include <nlohmann/json.hpp> + #include "md5.h" + #include "parser.h" +-#include "ryml_all.hpp" ++#include "ryml/ryml.hpp" ++#include "ryml/ryml_std.hpp" + #include "state.h" + #include "static_analysis.h" + #include "string_utils.h" diff --git a/vcpkg/ports/jsonnet/0006-use-cxx17.patch b/vcpkg/ports/jsonnet/0006-use-cxx17.patch new file mode 100644 index 0000000..84791ef --- /dev/null +++ b/vcpkg/ports/jsonnet/0006-use-cxx17.patch @@ -0,0 +1,20 @@ +diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt +index 8116ac3..25cebd0 100644 +--- a/core/CMakeLists.txt ++++ b/core/CMakeLists.txt +@@ -36,6 +36,7 @@ if (BUILD_SHARED_BINARIES) + add_library(libjsonnet ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet stdlib) + target_link_libraries(libjsonnet nlohmann_json::nlohmann_json ryml) ++target_compile_features(libjsonnet PRIVATE cxx_std_17) + + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../include/libjsonnet.h JSONNET_VERSION_DEF + REGEX "[#]define[ \t]+LIB_JSONNET_VERSION[ \t]+") +@@ -63,6 +64,7 @@ if (BUILD_STATIC_LIBS) + add_library(libjsonnet_static STATIC ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet_static stdlib) + target_link_libraries(libjsonnet_static nlohmann_json::nlohmann_json ryml) ++ target_compile_features(libjsonnet_static PRIVATE cxx_std_17) + set_target_properties(libjsonnet_static PROPERTIES OUTPUT_NAME jsonnet) + install(TARGETS libjsonnet_static DESTINATION "${CMAKE_INSTALL_LIBDIR}") + target_include_directories(libjsonnet_static INTERFACE diff --git a/vcpkg/ports/jsonnet/001-enable-msvc.patch b/vcpkg/ports/jsonnet/001-enable-msvc.patch new file mode 100644 index 0000000..1e51a0a --- /dev/null +++ b/vcpkg/ports/jsonnet/001-enable-msvc.patch @@ -0,0 +1,80 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dd17367..3ebf359 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,7 @@ + cmake_minimum_required(VERSION 2.8.7) + project(jsonnet C CXX) + ++add_definitions(-D_CRT_SECURE_NO_WARNINGS) + include(ExternalProject) + include(GNUInstallDirs) + +@@ -33,6 +34,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH}) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH}) + + # Compiler flags. ++if(0) + if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR + ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + set(OPT "-O3") +@@ -43,6 +45,7 @@ else() + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported") + endif() + ++endif() + set(CMAKE_CXX_STANDARD 17) + + +diff --git a/cmd/CMakeLists.txt b/cmd/CMakeLists.txt +index c032f02..d80d2a0 100644 +--- a/cmd/CMakeLists.txt ++++ b/cmd/CMakeLists.txt +@@ -13,5 +13,5 @@ if (BUILD_JSONNETFMT OR BUILD_TESTS) + add_dependencies(jsonnetfmt libjsonnet_for_binaries) + target_link_libraries(jsonnetfmt libjsonnet_for_binaries) + +- install(TARGETS jsonnetfmt DESTINATION "${CMAKE_INSTALL_BINDIR}") ++ install(TARGETS jsonnetfmt DESTINATION tools/jsonnet) + endif() +diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt +index 8ab3777..9e8ffe2 100644 +--- a/core/CMakeLists.txt ++++ b/core/CMakeLists.txt +@@ -30,7 +30,7 @@ set(LIBJSONNET_SOURCE + string_utils.cpp + vm.cpp) + +-add_library(libjsonnet SHARED ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) ++add_library(libjsonnet ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet md5 stdlib) + target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json ryml) + +@@ -49,7 +49,7 @@ set_target_properties(libjsonnet PROPERTIES OUTPUT_NAME jsonnet + install(TARGETS libjsonnet + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_BINDIR}" + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + target_include_directories(libjsonnet INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>) +diff --git a/stdlib/CMakeLists.txt b/stdlib/CMakeLists.txt +index a481d9f..002006f 100644 +--- a/stdlib/CMakeLists.txt ++++ b/stdlib/CMakeLists.txt +@@ -2,6 +2,7 @@ + + add_executable(to_c_array to_c_array.cpp) + ++if(0) + # Custom command that will only build stdlib when it changes. + add_custom_command( + OUTPUT ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h +@@ -13,3 +14,6 @@ add_custom_command( + # Standard library build target that libjsonnet can depend on. + add_custom_target(stdlib ALL + DEPENDS ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h) ++else() ++add_custom_target(stdlib) ++endif() diff --git a/vcpkg/ports/jsonnet/002-fix-dependency-and-install.patch b/vcpkg/ports/jsonnet/002-fix-dependency-and-install.patch new file mode 100644 index 0000000..7a97939 --- /dev/null +++ b/vcpkg/ports/jsonnet/002-fix-dependency-and-install.patch @@ -0,0 +1,60 @@ +diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt +index 9e8ffe2..2eb28d2 100644 +--- a/core/CMakeLists.txt ++++ b/core/CMakeLists.txt +@@ -30,6 +30,7 @@ set(LIBJSONNET_SOURCE + string_utils.cpp + vm.cpp) + ++if (BUILD_SHARED_BINARIES) + add_library(libjsonnet ${LIBJSONNET_HEADERS} ${LIBJSONNET_SOURCE}) + add_dependencies(libjsonnet md5 stdlib) + target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json ryml) +@@ -53,6 +54,7 @@ install(TARGETS libjsonnet + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + target_include_directories(libjsonnet INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>) ++endif() + + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. +@@ -112,3 +114,4 @@ if (BUILD_TESTS) + add_test(jsonnet_test_snippet + ${GLOBAL_OUTPUT_PATH}/jsonnet -e ${TEST_SNIPPET}) + endif() ++install(FILES ${LIB_HEADER} DESTINATION include) +diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +index 153a4a1..08bba4c 100644 +--- a/cpp/CMakeLists.txt ++++ b/cpp/CMakeLists.txt +@@ -8,8 +8,8 @@ set(LIBJSONNETPP_SOURCE + libjsonnet++.cpp + ) + ++if (BUILD_SHARED_BINARIES) + add_library(libjsonnet++ SHARED ${LIBJSONNETPP_HEADERS} ${LIBJSONNETPP_SOURCE}) +-add_dependencies(libjsonnet++ jsonnet) + target_link_libraries(libjsonnet++ libjsonnet) + + # CMake prepends CMAKE_SHARED_LIBRARY_PREFIX to shared libraries, so without +@@ -25,11 +25,11 @@ install(TARGETS libjsonnet++ + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + target_include_directories(libjsonnet++ INTERFACE + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>) ++endif() + + if (BUILD_STATIC_LIBS) + # Static library for jsonnet command-line tool. + add_library(libjsonnet++_static STATIC ${LIBJSONNETPP_SOURCE}) +- add_dependencies(libjsonnet++_static jsonnet) + target_link_libraries(libjsonnet++_static libjsonnet_static) + set_target_properties(libjsonnet++_static PROPERTIES OUTPUT_NAME jsonnet++) + install(TARGETS libjsonnet++_static DESTINATION "${CMAKE_INSTALL_LIBDIR}") +@@ -43,6 +43,7 @@ else() + add_library(libjsonnet++_for_binaries ALIAS libjsonnet++_static) + endif() + ++install(FILES ${LIBJSONNETPP_HEADERS} DESTINATION include) + # Tests + function(add_test_executablepp test_name) + if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/${test_name}.cpp) diff --git a/vcpkg/ports/jsonnet/portfile.cmake b/vcpkg/ports/jsonnet/portfile.cmake new file mode 100644 index 0000000..d975a30 --- /dev/null +++ b/vcpkg/ports/jsonnet/portfile.cmake @@ -0,0 +1,56 @@ +if (VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO google/jsonnet + REF "v${VERSION}" + SHA512 4fc39bd5e138623ba1ac7cf88594ea7957e9c3bcb952f0e9e346059a9de08eac3f60788376c31a70b34d6d522737a67ad4a122fadcd9621868722c23d9361d05 + HEAD_REF master + PATCHES + 001-enable-msvc.patch + 002-fix-dependency-and-install.patch + 0004-incorporate-md5.patch + 0005-use-upstream-rapidyaml.patch + 0006-use-cxx17.patch +) + +# see https://github.com/google/jsonnet/blob/v0.18.0/Makefile#L220 +if(VCPKG_TARGET_IS_WINDOWS) + find_program(PWSH_PATH pwsh) + vcpkg_execute_required_process( + COMMAND "${PWSH_PATH}" -Command "((Get-Content -AsByteStream \"${SOURCE_PATH}/stdlib/std.jsonnet\") -join ',') + ',0' | Out-File -Encoding Ascii \"${SOURCE_PATH}/core/std.jsonnet.h\"" + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME "std.jsonnet" + ) +else() + vcpkg_execute_required_process( + COMMAND bash -c "((od -v -Anone -t u1 \"${SOURCE_PATH}/stdlib/std.jsonnet\" | tr ' ' '\\n' | grep -v '^$' | tr '\\n' ',' ) && echo '0') > \"${SOURCE_PATH}/core/std.jsonnet.h\"" + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME "std.jsonnet" + ) +endif() + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_SHARED_BINARIES=${BUILD_SHARED} + -DBUILD_STATIC_LIBS=${BUILD_STATIC} + -DBUILD_JSONNET=OFF + -DBUILD_JSONNETFMT=OFF + -DBUILD_TESTS=OFF + -DUSE_SYSTEM_JSON=ON + -DUSE_SYSTEM_RYML=ON +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/jsonnet") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/vcpkg/ports/jsonnet/vcpkg.json b/vcpkg/ports/jsonnet/vcpkg.json new file mode 100644 index 0000000..faf795c --- /dev/null +++ b/vcpkg/ports/jsonnet/vcpkg.json @@ -0,0 +1,16 @@ +{ + "name": "jsonnet", + "version": "0.21.0", + "port-version": 1, + "description": "Jsonnet - The data templating language", + "homepage": "https://github.com/google/jsonnet", + "license": "Apache-2.0", + "dependencies": [ + "nlohmann-json", + "ryml", + { + "name": "vcpkg-cmake", + "host": true + } + ] +} |