mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 17:12:47 +08:00
[tree-sitter] add new port (#26058)
* [tree-sitter] add new port * ci: test support for uwp * fixup: address review comments * chore: update git-version * fixup: skip removing non-existent binaries * refactor: patch the upstream pkgconfig instead * fixup: remove unnecessary vcpkg-cmake-wrapper this is only used for overriding CMake's builtins * Bump cmake_minimum_required Co-authored-by: Robert Schumacher <roschuma@microsoft.com> * Fix version database Co-authored-by: Billy O'Neal <bion@microsoft.com> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
parent
5843d817ec
commit
00413b7537
51
ports/tree-sitter/CMakeLists.txt
Normal file
51
ports/tree-sitter/CMakeLists.txt
Normal file
@ -0,0 +1,51 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(
|
||||
tree-sitter
|
||||
LANGUAGES C
|
||||
VERSION 0.26.0
|
||||
)
|
||||
|
||||
set(TS_SOVERSION_MAJOR 0)
|
||||
set(TS_SOVERSION_MINOR 0)
|
||||
|
||||
file(GLOB TS_SRC_FILES "${PROJECT_SOURCE_DIR}/src/*.c")
|
||||
list(REMOVE_ITEM TS_SRC_FILES "${PROJECT_SOURCE_DIR}/src/lib.c") # skip amalgamation
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_library(tree-sitter ${TS_SRC_FILES})
|
||||
target_include_directories(
|
||||
tree-sitter
|
||||
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
set_target_properties(
|
||||
tree-sitter
|
||||
PROPERTIES C_STANDARD 99
|
||||
C_STANDARD_REQUIRED ON
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
SOVERSION ${TS_SOVERSION_MAJOR}.${TS_SOVERSION_MINOR})
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tree-sitter.pc.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter.pc" @ONLY)
|
||||
|
||||
install(
|
||||
TARGETS tree-sitter
|
||||
EXPORT unofficial-tree-sitter-config
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
install(FILES "${PROJECT_SOURCE_DIR}/include/tree_sitter/api.h"
|
||||
"${PROJECT_SOURCE_DIR}/include/tree_sitter/parser.h"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter")
|
||||
|
||||
install(
|
||||
EXPORT unofficial-tree-sitter-config
|
||||
NAMESPACE unofficial::tree-sitter::
|
||||
DESTINATION share/unofficial-tree-sitter)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
22
ports/tree-sitter/pkgconfig.patch
Normal file
22
ports/tree-sitter/pkgconfig.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/tree-sitter.pc.in b/lib/tree-sitter.pc.in
|
||||
similarity index 61%
|
||||
rename from tree-sitter.pc.in
|
||||
rename to lib/tree-sitter.pc.in
|
||||
index f98816cb..71a3b4f9 100644
|
||||
--- a/tree-sitter.pc.in
|
||||
+++ b/lib/tree-sitter.pc.in
|
||||
@@ -1,10 +1,10 @@
|
||||
-prefix=@PREFIX@
|
||||
-libdir=@LIBDIR@
|
||||
-includedir=@INCLUDEDIR@
|
||||
+prefix=@CMAKE_INSTALL_PREFIX@
|
||||
+libdir=${prefix}@/lib
|
||||
+includedir=${prefix}/include
|
||||
|
||||
Name: tree-sitter
|
||||
Description: An incremental parsing system for programming tools
|
||||
URL: https://tree-sitter.github.io/
|
||||
-Version: @VERSION@
|
||||
+Version: @PROJECT_VERSION@
|
||||
Libs: -L${libdir} -ltree-sitter
|
||||
Cflags: -I${includedir}
|
30
ports/tree-sitter/portfile.cmake
Normal file
30
ports/tree-sitter/portfile.cmake
Normal file
@ -0,0 +1,30 @@
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO tree-sitter/tree-sitter
|
||||
REF ccd6bf554d922596ce905730d98a77af368bba5c #v0.26.0
|
||||
SHA512 ab7eeecafc9d7d17093e25479903fa8c77a84ce4c3a41d737d49bcf9348ab6cc55cf3d6cce0229781292c2b05342fbf45641e40545ea3fde09e441e02f2cdb83
|
||||
HEAD_REF master
|
||||
PATCHES pkgconfig.patch
|
||||
)
|
||||
|
||||
# currently not supported upstream
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
|
||||
endif()
|
||||
|
||||
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}/lib")
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}/lib"
|
||||
)
|
||||
|
||||
vcpkg_cmake_install()
|
||||
|
||||
vcpkg_cmake_config_fixup(PACKAGE_NAME "unofficial-tree-sitter")
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
|
||||
|
||||
vcpkg_fixup_pkgconfig()
|
||||
|
||||
# Handle copyright
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
17
ports/tree-sitter/vcpkg.json
Normal file
17
ports/tree-sitter/vcpkg.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "tree-sitter",
|
||||
"version-semver": "0.26.0",
|
||||
"description": "An incremental parsing system for programming tools.",
|
||||
"homepage": "https://github.com/tree-sitter/tree-sitter",
|
||||
"license": "MIT",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
}
|
||||
]
|
||||
}
|
@ -7240,6 +7240,10 @@
|
||||
"baseline": "0.8.0",
|
||||
"port-version": 4
|
||||
},
|
||||
"tree-sitter": {
|
||||
"baseline": "0.26.0",
|
||||
"port-version": 0
|
||||
},
|
||||
"treehh": {
|
||||
"baseline": "3.16",
|
||||
"port-version": 0
|
||||
|
9
versions/t-/tree-sitter.json
Normal file
9
versions/t-/tree-sitter.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "a912cc848f08c05d9cbd87e24e47194b0ad43bd6",
|
||||
"version-semver": "0.26.0",
|
||||
"port-version": 0
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user