diff --git a/packages/c/clip/xmake.lua b/packages/c/clip/xmake.lua index 2d9c6b11128..8f689b303d3 100644 --- a/packages/c/clip/xmake.lua +++ b/packages/c/clip/xmake.lua @@ -3,46 +3,66 @@ package("clip") set_description("Library to copy/retrieve content to/from the clipboard/pasteboard.") set_license("MIT") - set_urls("https://github.com/dacap/clip/archive/refs/tags/v$(version).zip") - add_versions("1.9", "905615eb1ceef15e96468891ad85b7aa6836bcda690006d61fa061ca029b2060") - add_versions("1.8", "9df8728c9ce7c3afcfc9a0c6718e064319f0cdffb927243ac1ca3be591578d00") - add_versions("1.5", "4ed7f54184c27c79a8f2382ba747dce11aeb4552017abf5588587369a6caeb6b") + add_urls("https://github.com/dacap/clip/archive/refs/tags/$(version).tar.gz", + "https://github.com/dacap/clip.git") - add_deps("cmake", "libpng") + add_versions("v1.11", "047d43f837adffcb3a26ce09fd321472615cf35a18e86418d789b70d742519dc") + + add_configs("image", {description = "Compile with support to copy/paste images", default = true, type = "boolean"}) + add_configs("list_format", {description = "Compile with support to list clipboard formats", default = false, type = "boolean"}) + add_configs("xp", {description = "Enable Windows XP support", default = false, type = "boolean"}) + add_configs("x11_png", {description = "Compile with libpng to support copy/paste image in png format", default = true, type = "boolean"}) + if is_plat("windows") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end + + add_deps("cmake") if is_plat("linux") then add_deps("libxcb") - elseif is_plat("windows") or is_plat("mingw") then - add_syslinks("Shlwapi", "Ole32", "User32") end - if is_plat("mingw") then - add_syslinks("Windowscodecs") + + if is_plat("windows", "mingw") then + add_syslinks("advapi32", "shlwapi", "ole32", "user32", "windowscodecs", "uuid") + elseif is_plat("macosx") then + add_frameworks("Foundation", "AppKit", "CoreGraphics") end - add_includedirs("include") + on_load(function(package) + if package:config("image") then + package:add("defines", "CLIP_ENABLE_IMAGE=1") + end + if package:config("list_format") then + package:add("defines", "CLIP_ENABLE_LIST_FORMATS=1") + end - on_install("linux", "windows", "mingw@windows,msys", "macos", function(package) - local configs = {} - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + if package:is_plat("linux") and package:config("image") and package:config("x11_png") then + package:add("deps", "libpng") + end + end) + + on_install("!android and !iphoneos and !bsd and !cross", function(package) + io.replace("CMakeLists.txt", "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}", "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}\nRUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}", {plain = true}) + io.replace("CMakeLists.txt", "if(CLIP_WINDOWSCODECS_LIBRARY)", "if(1)", {plain = true}) + io.replace("CMakeLists.txt", "target_link_libraries(clip ${CLIP_WINDOWSCODECS_LIBRARY})", "target_link_libraries(clip windowscodecs)", {plain = true}) + + local configs = {"-DCLIP_EXAMPLES=OFF", "-DCLIP_TESTS=OFF", "-DCMAKE_INSTALL_INCLUDEDIR=include/clip"} + 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")) - table.insert(configs, "-DCLIP_EXAMPLES=OFF") - table.insert(configs, "-DCLIP_TESTS=OFF") if package:config("shared") and package:is_plat("windows") then table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") end - import("package.tools.cmake").install(package, configs, { buildir="build" }) - os.cp("clip.h", package:installdir("include/clip")) - os.trycp("build/*.a", package:installdir("lib")) - os.trycp("build/*.dylib", package:installdir("lib")) - os.trycp("build/*.so", package:installdir("lib")) - os.trycp("build/*.lib", package:installdir("lib")) - os.trycp("build/*.dll", package:installdir("bin")) + + table.insert(configs, "-DCLIP_ENABLE_IMAGE=" .. (package:config("image") and "ON" or "OFF")) + table.insert(configs, "-DCLIP_ENABLE_LIST_FORMATS=" .. (package:config("list_format") and "ON" or "OFF")) + table.insert(configs, "-DCLIP_SUPPORT_WINXP=" .. (package:config("xp") and "ON" or "OFF")) + table.insert(configs, "-DCLIP_X11_WITH_PNG=" .. (package:config("x11_png") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) end) on_test(function(package) - assert(package:check_cxxsnippets({ test = [[ - #include - #include - void test() { clip::set_text("foo"); } - ]]} - )) + assert(package:check_cxxsnippets({test = [[ + void test() { + clip::set_text("foo"); + } + ]]}, {configs = {languages = "c++14"}, includes = {"clip/clip.h"}})) end)