From 0a74fda5b80a4977069dbf8e579c1ae13a83c8b2 Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:30:19 +0800 Subject: [PATCH] improve opencv (#640) * update capnproto * improve opencv * fix opencv * restrict capnproto for mingw * fix opencv --- packages/c/capnproto/xmake.lua | 8 ++++---- packages/o/opencv/xmake.lua | 37 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/c/capnproto/xmake.lua b/packages/c/capnproto/xmake.lua index 7b2d08262..7ef45d774 100644 --- a/packages/c/capnproto/xmake.lua +++ b/packages/c/capnproto/xmake.lua @@ -2,8 +2,10 @@ package("capnproto") set_homepage("https://github.com/capnproto/capnproto") set_description("Cap'n Proto serialization/RPC system - core tools and C++ library.") + set_license("MIT") set_urls("https://github.com/capnproto/capnproto/archive/v$(version).zip") + add_versions("0.9.0", "18cf46aa4e05446a3d34bad8d56f9d0c73e72020a2b7548b6ec7cb7b1a828d5b") add_versions("0.8.0", "9a5e090b1f3ad39bb47fed5fd03672169493674ce273418b76c868393fced2e4") add_versions("0.7.0", "1054a879e174b8f797f1b506fedb14ecba5556c656e33ac51bd0a62bd90f925f") @@ -12,10 +14,8 @@ package("capnproto") end add_deps("cmake", "zlib") - - on_install("windows", "mingw", "linux", "macosx", "bsd", function (package) - local configs = {} - table.insert(configs, "-DBUILD_TESTING=OFF") + on_install("windows", "mingw@windows,msys", "linux", "macosx", "bsd", function (package) + local configs = {"-DBUILD_TESTING=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package: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) diff --git a/packages/o/opencv/xmake.lua b/packages/o/opencv/xmake.lua index ab4cbe47e..1f5635280 100644 --- a/packages/o/opencv/xmake.lua +++ b/packages/o/opencv/xmake.lua @@ -138,6 +138,16 @@ package("opencv") table.insert(configs, "-DOPENCV_EXTRA_MODULES_PATH=" .. path.absolute(path.join(modulesdir, "modules"))) end import("package.tools.cmake").install(package, configs, {buildir = "bd"}) + for _, link in ipairs({"opencv_datasets", "opencv_highgui", "opencv_phase_unwrapping", "opencv_features2d", "opencv_surface_matching", "opencv_stitching", "opencv_saliency", "opencv_wechat_qrcode", "opencv_mcc", "opencv_face", "opencv_img_hash", "opencv_videostab", "opencv_photo", "opencv_structured_light", "opencv_intensity_transform", "opencv_xobjdetect", "opencv_ccalib", "opencv_line_descriptor", "opencv_stereo", "opencv_dnn_objdetect", "opencv_dnn_superres", "opencv_dnn", "opencv_fuzzy", "opencv_hfs", "opencv_rapid", "opencv_quality", "opencv_bgsegm", "opencv_calib3d", "opencv_bioinspired", "opencv_xfeatures2d", "opencv_xphoto", "opencv_rgbd", "opencv_optflow", "opencv_dpm", "opencv_ml", "opencv_flann", "opencv_aruco", "opencv_plot", "opencv_reg", "opencv_shape", "opencv_objdetect", "opencv_tracking", "opencv_gapi", "opencv_barcode", "opencv_superres", "opencv_videoio", "opencv_video", "opencv_text", "opencv_ximgproc", "opencv_imgproc", "opencv_imgcodecs", "opencv_core"}) do + local reallink = link + if package:is_plat("windows", "mingw") then + reallink = reallink .. package:version():gsub("%.", "") + end + if xmake.version():le("2.5.7") and package:is_plat("mingw") and package:config("shared") then + reallink = reallink .. ".dll" + end + package:add("links", reallink) + end if package:is_plat("windows") then local arch = package:is_arch("x64") and "x64" or "x86" local linkdir = (package:config("shared") and "lib" or "staticlib") @@ -149,15 +159,9 @@ package("opencv") elseif vs == "2022" then vc_ver = "vc17" end - -- keep compatibility for old versions local installdir = package:installdir(arch, vc_ver) - if os.isdir(path.join(os.curdir(), "bd", "install")) then - os.trycp(path.join(os.curdir(), "bd", "install", arch, vc_ver), package:installdir(arch)) - end - - -- scanning for links for old xmake version - if xmake.version():le("2.5.6") then - for _, f in ipairs(os.files(path.join(installdir, linkdir, "*.lib"))) do + for _, f in ipairs(os.files(path.join(installdir, linkdir, "*.lib"))) do + if not f:match("opencv_.+") then package:add("links", path.basename(f)) end end @@ -165,18 +169,17 @@ package("opencv") elseif package:is_plat("mingw") then local arch = package:is_arch("x86_64") and "x64" or "x86" local linkdir = (package:config("shared") and "lib" or "staticlib") + for _, f in ipairs(os.files(path.join(arch, "mingw", linkdir, "lib*.a"))) do + if not f:match("libopencv_.+") then + package:add("links", path.basename(f):match("lib(.+)")) + end + end package:addenv("PATH", path.join(arch, "mingw", "bin")) else if package:version():ge("4.0") then - -- scanning for links for old xmake version - if xmake.version():le("2.5.6") then - for _, suffix in ipairs({"*.a", "*.so", "*.dylib"}) do - for _, f in ipairs(os.files(path.join(package:installdir("lib"), suffix))) do - package:add("links", path.basename(f):match("lib(.+)")) - end - for _, f in ipairs(os.files(path.join(package:installdir("lib/opencv4/3rdparty"), suffix))) do - package:add("links", path.basename(f):match("lib(.+)")) - end + for _, suffix in ipairs({"*.a", "*.so", "*.dylib"}) do + for _, f in ipairs(os.files(path.join(package:installdir("lib/opencv4/3rdparty"), suffix))) do + package:add("links", path.basename(f):match("lib(.+)")) end end end