early-access version 2853

This commit is contained in:
pineappleEA
2022-07-23 03:01:36 +02:00
parent 1f2b5081b5
commit 1f111bb69c
8955 changed files with 418777 additions and 999 deletions

View File

@@ -0,0 +1,13 @@
diff --git a/core/vm.cpp b/core/vm.cpp
index 0cf06fa..d65a6d7 100644
--- a/core/vm.cpp
+++ b/core/vm.cpp
@@ -23,7 +23,7 @@ limitations under the License.
#include "desugarer.h"
#include "json.h"
-#include "json.hpp"
+#include "nlohmann/json.hpp"
#include "md5.h"
#include "parser.h"
#include "state.h"

View File

@@ -0,0 +1,41 @@
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -15,7 +15,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
@@ -26,12 +27,13 @@ set(LIBJSONNET_SOURCE
pass.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)
+add_dependencies(libjsonnet stdlib)
+target_link_libraries(libjsonnet nlohmann_json::nlohmann_json)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/../include/libjsonnet.h JSONNET_VERSION_DEF
REGEX "[#]define[ \t]+LIB_JSONNET_VERSION[ \t]+")
@@ -54,8 +56,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)
+ add_dependencies(libjsonnet_static stdlib)
+ target_link_libraries(libjsonnet_static nlohmann_json::nlohmann_json)
set_target_properties(libjsonnet_static PROPERTIES OUTPUT_NAME jsonnet)
install(TARGETS libjsonnet_static DESTINATION "${CMAKE_INSTALL_LIBDIR}")
target_include_directories(libjsonnet_static INTERFACE

View File

@@ -0,0 +1,80 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 385ea82..ebd12b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,8 @@
cmake_minimum_required(VERSION 2.8.7)
project(jsonnet C CXX)
+add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+
include(ExternalProject)
include(GNUInstallDirs)
@@ -33,6 +35,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")
@@ -42,7 +45,7 @@ else()
# TODO: Windows support.
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported")
endif()
-
+endif()
set(CMAKE_CXX_STANDARD 11)
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
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -28,7 +28,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)
@@ -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}"
+ 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..2f58d2f 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,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,56 @@
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
--- 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
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.
@@ -102,3 +104,5 @@ 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
--- 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|.
@@ -24,6 +24,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.
@@ -38,6 +39,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)

59
externals/vcpkg/ports/jsonnet/portfile.cmake vendored Executable file
View File

@@ -0,0 +1,59 @@
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.17.0
SHA512 D3EE6947163D8ABCED504FF37ECF365C0311164CBF243D4C635D34944F0831CA9FCE2470ACF00EB9A218F82A2E553B3F885DB9BD21BB9DCEFBD707FA0202925D
HEAD_REF master
PATCHES
001-enable-msvc.patch
002-fix-dependency-and-install.patch
0003-use-upstream-nlohmann-json.patch
0004-incorporate-md5.patch
)
# see https://github.com/google/jsonnet/blob/v0.17.0/Makefile#L214
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()
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_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
)
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)

14
externals/vcpkg/ports/jsonnet/vcpkg.json vendored Executable file
View File

@@ -0,0 +1,14 @@
{
"name": "jsonnet",
"version": "0.17.0",
"description": "Jsonnet - The data templating language",
"homepage": "https://github.com/google/jsonnet",
"supports": "!(windows & !static)",
"dependencies": [
"nlohmann-json",
{
"name": "vcpkg-cmake",
"host": true
}
]
}