[jsonnet]Upgrade to 0.14.0. (#8848)

This commit is contained in:
JackBoosY 2019-11-02 07:51:08 +08:00 committed by Robert Schumacher
parent bba74913da
commit b6f6619408
4 changed files with 106 additions and 40 deletions

View File

@ -1,17 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cdd5367..e982ee5 100644
index 0418d4a..ac8f0f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,8 @@ set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING
@@ -2,6 +2,8 @@
cmake_minimum_required(VERSION 2.8.7)
project(jsonnet C CXX)
+add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+
# Discourage in-source builds because they overwrite the hand-written Makefile.
# Use `cmake . -B<dir>` or the CMake GUI to do an out-of-source build.
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} AND
@@ -76,6 +78,7 @@ elseif (BUILD_TESTS AND USE_SYSTEM_GTEST)
include(ExternalProject)
include(GNUInstallDirs)
@@ -89,6 +91,7 @@ else()
endif()
# Compiler flags.
@ -19,7 +19,7 @@ index cdd5367..e982ee5 100644
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(OPT "-O3")
@@ -85,6 +88,7 @@ else()
@@ -98,6 +101,7 @@ else()
# TODO: Windows support.
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported")
endif()
@ -28,18 +28,18 @@ index cdd5367..e982ee5 100644
# Look for libraries in global output path.
link_directories(${GLOBAL_OUTPUT_PATH})
diff --git a/cmd/CMakeLists.txt b/cmd/CMakeLists.txt
index 66e6aa0..aedc87e 100644
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_static)
target_link_libraries(jsonnetfmt libjsonnet_static)
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 e877015..5ec328b 100644
index 60fdcb1..82fb7c2 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -28,7 +28,7 @@ set(LIBJSONNET_SOURCE
@ -49,25 +49,19 @@ index e877015..5ec328b 100644
-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)
target_link_libraries(libjsonnet md5 nlohmann_json::nlohmann_json)
@@ -41,13 +41,13 @@ set_target_properties(libjsonnet PROPERTIES OUTPUT_NAME jsonnet
@@ -46,7 +46,7 @@ set_target_properties(libjsonnet PROPERTIES OUTPUT_NAME jsonnet
PUBLIC_HEADER "${LIB_HEADER}")
install(TARGETS libjsonnet
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_BINDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# 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)
-set_target_properties(libjsonnet_static PROPERTIES OUTPUT_NAME jsonnet)
install(TARGETS libjsonnet_static DESTINATION "${CMAKE_INSTALL_LIBDIR}")
# Tests
if (BUILD_STATIC_LIBS)
diff --git a/stdlib/CMakeLists.txt b/stdlib/CMakeLists.txt
index a481d9f..bb8e418 100644
index a481d9f..0dc3ab6 100644
--- a/stdlib/CMakeLists.txt
+++ b/stdlib/CMakeLists.txt
@@ -2,6 +2,7 @@
@ -78,11 +72,9 @@ index a481d9f..bb8e418 100644
# Custom command that will only build stdlib when it changes.
add_custom_command(
OUTPUT ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h
@@ -9,6 +10,7 @@ add_custom_command(
${PROJECT_SOURCE_DIR}/stdlib/std.jsonnet
${PROJECT_SOURCE_DIR}/core/std.jsonnet.h
DEPENDS to_c_array std.jsonnet)
+endif()
@@ -13,3 +14,4 @@ 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)
+endif()
\ No newline at end of file

View File

@ -0,0 +1,61 @@
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 82fb7c2..a94b4ff 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -28,6 +28,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)
@@ -48,6 +49,7 @@ install(TARGETS libjsonnet
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_BINDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
if (BUILD_STATIC_LIBS)
# Static library for jsonnet command-line tool.
@@ -102,3 +104,6 @@ if (BUILD_TESTS)
add_test(jsonnet_test_snippet
${GLOBAL_OUTPUT_PATH}/jsonnet -e ${TEST_SNIPPET})
endif()
+
+
+install(FILES ${LIBJSONNET_HEADERS} DESTINATION include)
\ No newline at end of file
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index bf349df..6ed1442 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -8,9 +8,9 @@ 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)
+target_link_libraries(libjsonnet++ libjsonnet)
# CMake prepends CMAKE_SHARED_LIBRARY_PREFIX to shared libraries, so without
# this step the output would be |liblibjsonnet|.
@@ -22,6 +22,7 @@ install(TARGETS libjsonnet++
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
if (BUILD_STATIC_LIBS)
# Static library for jsonnet command-line tool.
@@ -38,6 +39,8 @@ 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)

View File

@ -1,4 +1,4 @@
Source: jsonnet
Version: 0.13.0
Version: 0.14.0
Homepage: https://github.com/google/jsonnet
Description: Jsonnet - The data templating language

View File

@ -1,17 +1,16 @@
include(vcpkg_common_functions)
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME)
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/jsonnet
REF v0.13.0
SHA512 d19e5398763e37b79b0ef02368f6bd6215d2df234b5ff7a6d98e2306a0d47290600061c9f868c0c262570b4f0ee9eee6c309bcc93937b12f6c14f8d12339a7d5
REF 552d8ec6f6b973a6357b83eb9bacd707366d28f0 # v0.14.0
SHA512 a4a9c6285155addbc5b7ef1a0c02b99b4d941bfc8e6536eaf029bff77c9c303a5c36f654ca8ab6b9757d2710c100c3e4a05f310269d82b0385ae55ea6ead14ef
HEAD_REF master
PATCHES
001-enable-msvc.patch
001-enable-msvc.patch
002-fix-dependency-and-install.patch
)
if (VCPKG_TARGET_IS_WINDOWS)
@ -28,15 +27,29 @@ else()
)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(BUILD_SHARED ON)
set(BUILD_STATIC OFF)
else()
set(BUILD_SHARED OFF)
set(BUILD_STATIC ON)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS -DBUILD_JSONNET=OFF -DBUILD_JSONNETFMT=OFF -DBUILD_TESTS=OFF
OPTIONS
-DBUILD_SHARED_BINARIES=${BUILD_SHARED}
-DBUILD_STATIC_LIBS=${BUILD_STATIC}
-DBUILD_JSONNET=OFF
-DBUILD_JSONNETFMT=OFF
-DBUILD_TESTS=OFF
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/jsonnet)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/jsonnet RENAME copyright)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)