mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 11:19:00 +08:00
[jsonnet] Hook into existing cmake support (#6358)
Use jsonnet's cmake build system.
This commit is contained in:
parent
dc9761f7de
commit
5ae66b8074
78
ports/jsonnet/001-enable-msvc.patch
Normal file
78
ports/jsonnet/001-enable-msvc.patch
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 8682cc8..88b95c1 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -11,6 +11,8 @@ set(GLOBAL_OUTPUT_PATH_SUFFIX "" CACHE STRING
|
||||||
|
|
||||||
|
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
|
||||||
|
@@ -73,17 +75,6 @@ elseif (BUILD_TESTS AND USE_SYSTEM_GTEST)
|
||||||
|
add_subdirectory(/usr/src/googletest ${GLOBAL_OUTPUT_PATH}/googletest-build)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-# Compiler flags.
|
||||||
|
-if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR
|
||||||
|
- ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||||
|
- set(OPT "-O3")
|
||||||
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -std=c99 -O3 ${OPT}")
|
||||||
|
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC ${OPT}")
|
||||||
|
-else()
|
||||||
|
- # TODO: Windows support.
|
||||||
|
- message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} not supported")
|
||||||
|
-endif()
|
||||||
|
-
|
||||||
|
# Look for libraries in global output path.
|
||||||
|
link_directories(${GLOBAL_OUTPUT_PATH})
|
||||||
|
|
||||||
|
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
|
||||||
|
index f1c32b8..1a45a51 100644
|
||||||
|
--- 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)
|
||||||
|
|
||||||
|
@@ -36,13 +36,12 @@ target_link_libraries(libjsonnet md5)
|
||||||
|
# this step the output would be |liblibjsonnet|.
|
||||||
|
set_target_properties(libjsonnet PROPERTIES OUTPUT_NAME jsonnet
|
||||||
|
VERSION 0.12.1 SOVERSION 0)
|
||||||
|
-install(TARGETS libjsonnet DESTINATION lib)
|
||||||
|
+install(TARGETS libjsonnet DESTINATION lib RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
|
||||||
|
diff --git a/stdlib/CMakeLists.txt b/stdlib/CMakeLists.txt
|
||||||
|
index a481d9f..9fe768e 100644
|
||||||
|
--- a/stdlib/CMakeLists.txt
|
||||||
|
+++ b/stdlib/CMakeLists.txt
|
||||||
|
@@ -2,14 +2,6 @@
|
||||||
|
|
||||||
|
add_executable(to_c_array to_c_array.cpp)
|
||||||
|
|
||||||
|
-# Custom command that will only build stdlib when it changes.
|
||||||
|
-add_custom_command(
|
||||||
|
- OUTPUT ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h
|
||||||
|
- COMMAND ${GLOBAL_OUTPUT_PATH}/to_c_array
|
||||||
|
- ${PROJECT_SOURCE_DIR}/stdlib/std.jsonnet
|
||||||
|
- ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h
|
||||||
|
- DEPENDS to_c_array std.jsonnet)
|
||||||
|
-
|
||||||
|
# Standard library build target that libjsonnet can depend on.
|
||||||
|
add_custom_target(stdlib ALL
|
||||||
|
DEPENDS ${PROJECT_SOURCE_DIR}/core/std.jsonnet.h)
|
@ -1,49 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.5.1)
|
|
||||||
project(jsonnet)
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set( jsonnet_sources
|
|
||||||
core/desugarer.cpp
|
|
||||||
core/formatter.cpp
|
|
||||||
core/lexer.cpp
|
|
||||||
core/libjsonnet.cpp
|
|
||||||
core/parser.cpp
|
|
||||||
core/pass.cpp
|
|
||||||
core/static_analysis.cpp
|
|
||||||
core/string_utils.cpp
|
|
||||||
core/vm.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(third_party/md5 include cpp core stdlib)
|
|
||||||
|
|
||||||
add_library(md5 STATIC third_party/md5/md5.cpp)
|
|
||||||
|
|
||||||
add_library(libjsonnet ${jsonnet_sources})
|
|
||||||
target_link_libraries(libjsonnet md5)
|
|
||||||
|
|
||||||
add_library(libjsonnet++ cpp/libjsonnet++.cpp)
|
|
||||||
target_link_libraries(libjsonnet++ libjsonnet)
|
|
||||||
|
|
||||||
add_executable(jsonnet cmd/jsonnet.cpp)
|
|
||||||
target_link_libraries(jsonnet libjsonnet)
|
|
||||||
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS libjsonnet libjsonnet++
|
|
||||||
RUNTIME DESTINATION bin
|
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
ARCHIVE DESTINATION lib
|
|
||||||
)
|
|
||||||
if(NOT DISABLE_INSTALL_TOOLS)
|
|
||||||
install (
|
|
||||||
TARGETS jsonnet
|
|
||||||
RUNTIME DESTINATION tools/jsonnet
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT DISABLE_INSTALL_HEADERS)
|
|
||||||
install(FILES include/libjsonnet++.h include/libjsonnet.h DESTINATION include)
|
|
||||||
endif()
|
|
@ -1,3 +1,3 @@
|
|||||||
Source: jsonnet
|
Source: jsonnet
|
||||||
Version: 2018-11-01-3
|
Version: 2019-05-08
|
||||||
Description: Jsonnet - The data templating language
|
Description: Jsonnet - The data templating language
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
include(vcpkg_common_functions)
|
include(vcpkg_common_functions)
|
||||||
|
|
||||||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
|
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR NOT VCPKG_CMAKE_SYSTEM_NAME)
|
||||||
|
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
|
||||||
|
endif()
|
||||||
|
|
||||||
vcpkg_from_github(
|
vcpkg_from_github(
|
||||||
OUT_SOURCE_PATH SOURCE_PATH
|
OUT_SOURCE_PATH SOURCE_PATH
|
||||||
REPO google/jsonnet
|
REPO google/jsonnet
|
||||||
REF a0876b301daf8f45e16ac5f7bb814d0617772bb0
|
REF c323f5ce5b8aa663585d23dc0fb94d4b166c6f16
|
||||||
SHA512 a57380ecc578b11f3a763202abb7ab703f2cc3c098ca7602d0bd199594a9e8d1cebc6d51332658edb08bf088e565d6afae0cb2faaf127fa33542a406de1ac055
|
SHA512 d9f84c39929e9e80272e2b834f68a13b48c1cb4d64b70f5b6fa16e677555d947f7cf57372453e23066a330faa6a429b9aa750271b46f763581977a223d238785
|
||||||
HEAD_REF master
|
HEAD_REF master
|
||||||
|
PATCHES
|
||||||
|
001-enable-msvc.patch
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
@ -24,11 +28,10 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
|
||||||
|
|
||||||
vcpkg_configure_cmake(
|
vcpkg_configure_cmake(
|
||||||
SOURCE_PATH ${SOURCE_PATH}
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON -DDISABLE_INSTALL_TOOLS=ON
|
PREFER_NINJA
|
||||||
|
OPTIONS -DBUILD_JSONNET=OFF -DBUILD_TESTS=OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
vcpkg_install_cmake()
|
vcpkg_install_cmake()
|
||||||
@ -36,3 +39,4 @@ vcpkg_copy_pdbs()
|
|||||||
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/jsonnet)
|
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/jsonnet)
|
||||||
|
|
||||||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/jsonnet RENAME copyright)
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/jsonnet RENAME copyright)
|
||||||
|
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||||
|
Loading…
Reference in New Issue
Block a user