Bladeren bron

lsp-framework: new package (#7251)

* lsp-framework: new package

* fixup

* fixup
Saikari 3 maanden geleden
bovenliggende
commit
023039188c

+ 41 - 0
packages/l/lsp-framework/patches/1.0.1/fix-install.diff

@@ -0,0 +1,41 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ef7bbda..a8ef219 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.12)
+ project(lsp)
+ 
+ option(LSP_USE_SANITIZERS "Use address and undefined behavior sanitizers" ON)
++option(BUILD_SHARED_LIBS "Build shared library" OFF)
+ 
+ set(CMAKE_CXX_STANDARD 20)
+ 
+@@ -91,6 +92,28 @@ add_custom_command(
+ 	COMMENT "Generating lsp types from meta model..."
+ )
+ 
++if(BUILD_SHARED_LIBS)
++if(WIN32)
++set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
++endif()
++add_library(lsp SHARED)
++else()
+ add_library(lsp STATIC)
++endif()
+ target_include_directories(lsp PUBLIC . ${LSP_GENERATED_FILES_DIR})
+ target_sources(lsp PRIVATE ${LSP_HEADERS} ${LSP_SOURCES} ${LSP_GENERATED_HEADERS} ${LSP_GENERATED_SOURCES})
++install(TARGETS lsp
++	ARCHIVE DESTINATION lib
++	LIBRARY DESTINATION lib
++	RUNTIME DESTINATION bin
++)
++
++install(DIRECTORY ${LSP_SRC_DIR}/
++    DESTINATION include/lsp
++    FILES_MATCHING PATTERN "*.h" PATTERN "*.inl"
++)
++
++install(DIRECTORY ${LSP_GENERATED_FILES_DIR}/lsp/
++    DESTINATION include/lsp
++    FILES_MATCHING PATTERN "*.h" PATTERN "*.inl"
++)

+ 12 - 0
packages/l/lsp-framework/patches/1.0.1/fix-missing-ios.diff

@@ -0,0 +1,12 @@
+diff --git a/lsp/connection.cpp b/lsp/connection.cpp
+index e7368c3..0515fe1 100644
+--- a/lsp/connection.cpp
++++ b/lsp/connection.cpp
+@@ -5,6 +5,7 @@
+ #include <lsp/connection.h>
+ #include <lsp/json/json.h>
+ #include <lsp/io/stream.h>
++#include <ios>
+ 
+ #ifndef LSP_MESSAGE_DEBUG_LOG
+ 	#ifdef NDEBUG

+ 50 - 0
packages/l/lsp-framework/xmake.lua

@@ -0,0 +1,50 @@
+package("lsp-framework")
+    set_homepage("https://github.com/leon-bckl/lsp-framework")
+    set_description("Language Server Protocol implementation in C++")
+    set_license("MIT")
+
+    add_urls("https://github.com/leon-bckl/lsp-framework/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/leon-bckl/lsp-framework.git")
+
+    add_versions("1.0.1", "07f924d851896a2d424d554d20820483f8458aa1ff907bb68657b0d2d0bd0d13")
+
+    add_patches("1.0.1", "patches/1.0.1/fix-install.diff", "bb5e4436091ba1846144ffa80fb8afd4d0213760bce45dd6fd31662905cb4bc3")
+    add_patches("1.0.1", "patches/1.0.1/fix-missing-ios.diff", "8447605c2ed14cfbf394b29ffe2348e2179424504100aa01cd88b3d054e5ceb1")
+
+    add_deps("cmake")
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("pthread")
+    elseif is_plat("windows", "mingw") then
+        add_syslinks("ws2_32")
+    end
+
+    if on_check then
+        on_check("windows|arm64", function (package)
+            import("core.base.semver")
+            local vs = package:toolchain("msvc"):config("vs")
+            assert(tonumber(vs) >= 2022, "lsp-framework requires Visual Studio 2022 and later for arm64 targets")
+            assert(os.arch() == "arm64", "package(lsp-framework): requires host arch to be arm64.")
+        end)
+    end
+
+    on_install("windows", "linux", "macosx", "mingw@windows", "bsd", function (package)
+        local configs = {}
+        table.insert(configs, "-DLSP_USE_SANITIZERS=" .. (package:config("asan") and "ON" or "OFF"))
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <lsp/messages.h>
+            #include <lsp/connection.h>
+            #include <lsp/io/standardio.h>
+            #include <lsp/messagehandler.h>
+            void test() {
+                auto connection     = lsp::Connection(lsp::io::standardIO());
+                auto messageHandler = lsp::MessageHandler(connection);
+            }
+        ]]}, {configs = {languages = "c++20"}}))
+    end)