From 411929e664f7736b4b52113cd48b7560a4e4842b Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Wed, 6 May 2020 14:01:30 -0400 Subject: [discord-game-sdk] new port (#10763) * [discord-game-sdk] new port * [discord-game-sdk] Invert Supports field * [discord-game-sdk] Fix Supports field * [discord-game-sdk] Fix Supports field again * [discord-game-sdk] Update find_library * [discord-game-sdk] Rename LICENSE.md, remove include(vcpkg_common_functions) * [discord-game-sdk] Fix Linux build, add usage file * [discord-game-sdk] Add missing file(INSTALL) * [discord-game-sdk] Update baseline and fix macOS build * [discord-game-sdk] Specify C++ standard version * [discord-game-sdk] Remove vcpkg_copy_pdbs * [discord-game-sdk] Replace ToS text by link to online version --- ports/discord-game-sdk/CMakeLists.txt | 19 +++++++++++++ ports/discord-game-sdk/CONTROL | 5 ++++ ports/discord-game-sdk/copyright | 1 + ports/discord-game-sdk/portfile.cmake | 51 +++++++++++++++++++++++++++++++++++ ports/discord-game-sdk/usage | 12 +++++++++ scripts/ci.baseline.txt | 1 + 6 files changed, 89 insertions(+) create mode 100644 ports/discord-game-sdk/CMakeLists.txt create mode 100644 ports/discord-game-sdk/CONTROL create mode 100644 ports/discord-game-sdk/copyright create mode 100644 ports/discord-game-sdk/portfile.cmake create mode 100644 ports/discord-game-sdk/usage diff --git a/ports/discord-game-sdk/CMakeLists.txt b/ports/discord-game-sdk/CMakeLists.txt new file mode 100644 index 000000000..f5a1d5136 --- /dev/null +++ b/ports/discord-game-sdk/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.5) + +project(discord_game_sdk_cpp) + +find_library(SDK_LIB + "discord_game_sdk" + PATHS "${SDK_LIB_FOLDER}" + NO_DEFAULT_PATH +) + +file(GLOB SRC_FILES "${PROJECT_SOURCE_DIR}/cpp/*.cpp") +file(GLOB_RECURSE HDR_FILES "${PROJECT_SOURCE_DIR}/*.h") + +add_library(discord_game_sdk_cpp STATIC ${SRC_FILES}) +target_link_libraries(discord_game_sdk_cpp PUBLIC ${SDK_LIB}) +set_property(TARGET discord_game_sdk_cpp PROPERTY CXX_STANDARD 11) + +install(TARGETS discord_game_sdk_cpp ARCHIVE) +install(FILES ${HDR_FILES} DESTINATION "include/discord-game-sdk") \ No newline at end of file diff --git a/ports/discord-game-sdk/CONTROL b/ports/discord-game-sdk/CONTROL new file mode 100644 index 000000000..7110110de --- /dev/null +++ b/ports/discord-game-sdk/CONTROL @@ -0,0 +1,5 @@ +Source: discord-game-sdk +Version: 2.5.6 +Homepage: https://discordapp.com/developers/docs/game-sdk/sdk-starter-guide +Description: The Discord GameSDK is an easy drop-in SDK to help you manage all the hard things that come with making a game. +Supports: ((x64 && (windows || osx || linux)) || (x86 && windows)) && !uwp && !static \ No newline at end of file diff --git a/ports/discord-game-sdk/copyright b/ports/discord-game-sdk/copyright new file mode 100644 index 000000000..6e0e2e914 --- /dev/null +++ b/ports/discord-game-sdk/copyright @@ -0,0 +1 @@ +Your use of the GameSDK is bound by the Discord Developer Terms of Service, whose text is available online at https://discordapp.com/developers/docs/legal. diff --git a/ports/discord-game-sdk/portfile.cmake b/ports/discord-game-sdk/portfile.cmake new file mode 100644 index 000000000..fbd82dee0 --- /dev/null +++ b/ports/discord-game-sdk/portfile.cmake @@ -0,0 +1,51 @@ +vcpkg_fail_port_install(ON_ARCH "arm" "arm64" ON_TARGET "android" "uwp") +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND NOT VCPKG_TARGET_IS_WINDOWS) + vcpkg_fail_port_install(MESSAGE "The GameSDK only supports x86 on Windows." ALWAYS) +endif() + +vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY) + +vcpkg_download_distfile(ARCHIVE + URLS https://dl-game-sdk.discordapp.net/2.5.6/discord_game_sdk.zip + FILENAME discord_game_sdk.zip + SHA512 4c8f72c7bdf92bc969fb86b96ea0d835e01b9bab1a2cc27ae00bdac1b9733a1303ceadfe138c24a7609b76d61d49999a335dd596cf3f335d894702e2aa23406f +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + NO_REMOVE_ONE_LEVEL +) + +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION ${SOURCE_PATH}) + +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(ARCH_FOLDER "x86") +else(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(ARCH_FOLDER "x86_64") +endif() + +if(VCPKG_TARGET_IS_WINDOWS) + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/bin") + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dll" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin") + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "discord_game_sdk.lib") + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dll.lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "discord_game_sdk.lib") +elseif(VCPKG_TARGET_IS_OSX) + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dylib" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "libdiscord_game_sdk.dylib") + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.dylib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "libdiscord_game_sdk.dylib") +elseif(VCPKG_TARGET_IS_LINUX) + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.so" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "libdiscord_game_sdk.so") + file(INSTALL "${SOURCE_PATH}/lib/${ARCH_FOLDER}/discord_game_sdk.so" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "libdiscord_game_sdk.so") +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + "-DSDK_LIB_FOLDER=${CURRENT_PACKAGES_DIR}/lib" +) +vcpkg_install_cmake() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") \ No newline at end of file diff --git a/ports/discord-game-sdk/usage b/ports/discord-game-sdk/usage new file mode 100644 index 000000000..11faa0c98 --- /dev/null +++ b/ports/discord-game-sdk/usage @@ -0,0 +1,12 @@ +The package discord-game-sdk does not provides CMake integration: + + find_library(GAME_SDK discord_game_sdk) + target_link_libraries( PRIVATE ${GAME_SDK}) + + find_path(GAME_SDK_INCLUDE discord-game-sdk/discord.h) + target_include_directories( PRIVATE ${GAME_SDK_INCLUDE}) + +The C++ SDK source code is compiled in a static library: + + find_library(CPP_GAME_SDK discord_game_sdk_cpp) + target_link_libraries( PRIVATE ${CPP_GAME_SDK}) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 1cda26b25..b473ec050 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -329,6 +329,7 @@ directxtk:x64-windows-static=fail directxtk12:x64-linux=fail directxtk12:x64-osx=fail directxtk12:x64-windows-static=fail +discord-game-sdk:x64-windows-static=fail discord-rpc:arm-uwp=fail discord-rpc:x64-uwp=fail dlfcn-win32:arm-uwp=fail -- cgit v1.2.3