diff options
Diffstat (limited to 'vcpkg/ports/sproto')
| -rw-r--r-- | vcpkg/ports/sproto/CMakeLists.txt | 56 | ||||
| -rw-r--r-- | vcpkg/ports/sproto/add-symbol-exports.patch | 74 | ||||
| -rw-r--r-- | vcpkg/ports/sproto/portfile.cmake | 28 | ||||
| -rw-r--r-- | vcpkg/ports/sproto/sproto-config.cmake.in | 8 | ||||
| -rw-r--r-- | vcpkg/ports/sproto/usage | 4 | ||||
| -rw-r--r-- | vcpkg/ports/sproto/vcpkg.json | 18 |
6 files changed, 188 insertions, 0 deletions
diff --git a/vcpkg/ports/sproto/CMakeLists.txt b/vcpkg/ports/sproto/CMakeLists.txt new file mode 100644 index 0000000..d5a1bae --- /dev/null +++ b/vcpkg/ports/sproto/CMakeLists.txt @@ -0,0 +1,56 @@ +cmake_minimum_required(VERSION 3.14) +project(sproto C) + +set(CMAKE_C_STANDARD 99) + +find_package(unofficial-lua CONFIG REQUIRED) + +add_library(sproto sproto.c lsproto.c) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(sproto PRIVATE SPROTO_BUILD_DLL) + # Set symbol visibility for GCC/Clang + if(NOT WIN32) + target_compile_options(sproto PRIVATE -fvisibility=hidden) + endif() +else() + target_compile_definitions(sproto PUBLIC SPROTO_STATIC) +endif() + +target_link_libraries(sproto PRIVATE lua) + +target_include_directories(sproto PRIVATE ${LUA_INCLUDE_DIR}) + +target_include_directories(sproto PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include> +) + +install(TARGETS sproto + EXPORT sproto-targets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) + +install(FILES sproto.h + DESTINATION include +) + +install(EXPORT sproto-targets + FILE sproto-targets.cmake + NAMESPACE unofficial::sproto:: + DESTINATION share/unofficial-sproto +) + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "${CMAKE_CURRENT_LIST_DIR}/sproto-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/unofficial-sproto-config.cmake" + INSTALL_DESTINATION share/unofficial-sproto +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/unofficial-sproto-config.cmake" + DESTINATION share/unofficial-sproto +) diff --git a/vcpkg/ports/sproto/add-symbol-exports.patch b/vcpkg/ports/sproto/add-symbol-exports.patch new file mode 100644 index 0000000..06f0e93 --- /dev/null +++ b/vcpkg/ports/sproto/add-symbol-exports.patch @@ -0,0 +1,74 @@ +diff --git a/sproto.h b/sproto.h +index 1234567..8901234 100644 +--- a/sproto.h ++++ b/sproto.h +@@ -6,6 +6,24 @@ + struct sproto; + struct sproto_type; + ++#if defined(_WIN32) ++ #if defined(SPROTO_BUILD_DLL) ++ #define SPROTO_API __declspec(dllexport) ++ #elif defined(SPROTO_STATIC) ++ #define SPROTO_API ++ #else ++ #define SPROTO_API __declspec(dllimport) ++ #endif ++#elif defined(__GNUC__) || defined(__clang__) ++ #if defined(SPROTO_BUILD_DLL) ++ #define SPROTO_API __attribute__((visibility("default"))) ++ #else ++ #define SPROTO_API ++ #endif ++#else ++ #define SPROTO_API ++#endif ++ + #define SPROTO_REQUEST 0 + #define SPROTO_RESPONSE 1 + +@@ -25,19 +43,19 @@ + #define SPROTO_CB_NIL -2 + #define SPROTO_CB_NOARRAY -3 + +-struct sproto * sproto_create(const void * proto, size_t sz); +-void sproto_release(struct sproto *); ++SPROTO_API struct sproto * sproto_create(const void * proto, size_t sz); ++SPROTO_API void sproto_release(struct sproto *); + +-int sproto_prototag(const struct sproto *, const char * name); +-const char * sproto_protoname(const struct sproto *, int proto); ++SPROTO_API int sproto_prototag(const struct sproto *, const char * name); ++SPROTO_API const char * sproto_protoname(const struct sproto *, int proto); + // SPROTO_REQUEST(0) : request, SPROTO_RESPONSE(1): response +-struct sproto_type * sproto_protoquery(const struct sproto *, int proto, int what); +-int sproto_protoresponse(const struct sproto *, int proto); ++SPROTO_API struct sproto_type * sproto_protoquery(const struct sproto *, int proto, int what); ++SPROTO_API int sproto_protoresponse(const struct sproto *, int proto); + +-struct sproto_type * sproto_type(const struct sproto *, const char * type_name); ++SPROTO_API struct sproto_type * sproto_type(const struct sproto *, const char * type_name); + +-int sproto_pack(const void * src, int srcsz, void * buffer, int bufsz); +-int sproto_unpack(const void * src, int srcsz, void * buffer, int bufsz); ++SPROTO_API int sproto_pack(const void * src, int srcsz, void * buffer, int bufsz); ++SPROTO_API int sproto_unpack(const void * src, int srcsz, void * buffer, int bufsz); + + struct sproto_arg { + void *ud; +@@ -58,11 +76,11 @@ struct sproto_arg { + + typedef int (*sproto_callback)(const struct sproto_arg *args); + +-int sproto_decode(const struct sproto_type *, const void * data, int size, sproto_callback cb, void *ud); +-int sproto_encode(const struct sproto_type *, void * buffer, int size, sproto_callback cb, void *ud); ++SPROTO_API int sproto_decode(const struct sproto_type *, const void * data, int size, sproto_callback cb, void *ud); ++SPROTO_API int sproto_encode(const struct sproto_type *, void * buffer, int size, sproto_callback cb, void *ud); + + // for debug use +-void sproto_dump(struct sproto *); +-const char * sproto_name(struct sproto_type *); ++SPROTO_API void sproto_dump(struct sproto *); ++SPROTO_API const char * sproto_name(struct sproto_type *); + + #endif diff --git a/vcpkg/ports/sproto/portfile.cmake b/vcpkg/ports/sproto/portfile.cmake new file mode 100644 index 0000000..10b02ae --- /dev/null +++ b/vcpkg/ports/sproto/portfile.cmake @@ -0,0 +1,28 @@ + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO cloudwu/sproto + REF 63df1ad8be4a7b295d389afaca7019e86f70d39c + SHA512 5613a04e6197b6fa00828f457aeee0270a7f4d300df609d62e405123f3623516c5761bd2c6b0b8e21be12aa30ca3288ae6307121bf8461535ad8c3efe9a750a2 + HEAD_REF master + PATCHES add-symbol-exports.patch +) + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/sproto-config.cmake.in" DESTINATION "${SOURCE_PATH}") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" +) + +vcpkg_cmake_build() + +vcpkg_cmake_install() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +vcpkg_cmake_config_fixup(CONFIG_PATH "share/unofficial-sproto" PACKAGE_NAME "unofficial-sproto") diff --git a/vcpkg/ports/sproto/sproto-config.cmake.in b/vcpkg/ports/sproto/sproto-config.cmake.in new file mode 100644 index 0000000..20db220 --- /dev/null +++ b/vcpkg/ports/sproto/sproto-config.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(unofficial-lua CONFIG)
+
+include("${CMAKE_CURRENT_LIST_DIR}/sproto-targets.cmake")
+
+check_required_components(sproto)
diff --git a/vcpkg/ports/sproto/usage b/vcpkg/ports/sproto/usage new file mode 100644 index 0000000..16a963e --- /dev/null +++ b/vcpkg/ports/sproto/usage @@ -0,0 +1,4 @@ +The package sproto provides CMake targets: + + find_package(unofficial-sproto CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::sproto::sproto) diff --git a/vcpkg/ports/sproto/vcpkg.json b/vcpkg/ports/sproto/vcpkg.json new file mode 100644 index 0000000..2ba8888 --- /dev/null +++ b/vcpkg/ports/sproto/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "sproto", + "version-date": "2024-07-08", + "description": "Yet another protocol library like google protocol buffers, but simple and fast", + "homepage": "https://github.com/cloudwu/sproto", + "license": "MIT", + "dependencies": [ + "lua", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} |