From 6960eca3a94f8ca1a6ce5917e292b60da8a4693a Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 16 Apr 2020 22:35:06 +0800 Subject: [PATCH] improve libraw --- packages/l/libraw/xmake.lua | 50 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/l/libraw/xmake.lua b/packages/l/libraw/xmake.lua index e95d95076..f30f2d799 100644 --- a/packages/l/libraw/xmake.lua +++ b/packages/l/libraw/xmake.lua @@ -7,37 +7,43 @@ package("libraw") add_versions("0.19.5", "9a2a40418e4fb0ab908f6d384ff6f9075f4431f8e3d79a0e44e5a6ea9e75abdc") - on_install(function(package) - io.writefile("xmake.lua", format([[ + if is_plat("windows", "mingw") then + add_syslinks("ws2_32") + end + + on_load(function (package) + if package:is_plat("windows") then + package:add("defines", "WIN32") + end + if not package:config("shared") then + package:add("defines", "LIBRAW_NODLL") + end + end) + + on_install("macosx", "linux", "windows", "mingw", "iphoneos", function(package) + io.writefile("xmake.lua", [[ target("libraw") - if %s then - set_kind("shared") + set_kind("$(kind)") + if is_kind("shared") then add_defines("LIBRAW_BUILDLIB") else - set_kind("static") add_defines("LIBRAW_NODLL") end - - if %s then + if is_plat("windows") then add_defines("WIN32") end - add_headerfiles("(libraw/*.h)") add_includedirs(".") - add_files("src/libraw_cxx.cpp", - "src/libraw_datastream.cpp", - "src/libraw_c_api.cpp") - add_files("internal/dcraw_common.cpp", - "internal/dcraw_fileio.cpp", - "internal/demosaic_packs.cpp") - ]], package:config("shared") and "true" or "false", package:is_plat("windows") and "true" or "false")) - import("package.tools.xmake").install(package) + add_files("src/libraw_cxx.cpp", "src/libraw_datastream.cpp", "src/libraw_c_api.cpp") + add_files("internal/dcraw_common.cpp", "internal/dcraw_fileio.cpp", "internal/demosaic_packs.cpp") + ]]) + local configs = {} + if package:config("shared") then + table.insert(configs, "--kind=shared") + end + import("package.tools.xmake").install(package, configs) end) on_test(function(package) - local defines = package:is_plat("windows") and {"WIN32"} or {} - if not package:config("shared") then - table.insert(defines, "LIBRAW_NODLL") - end - assert(package:has_cfuncs("libraw_version", {configs = {defines = defines}, includes = {"libraw/libraw.h"}, })) - end) \ No newline at end of file + assert(package:has_cfuncs("libraw_version", {includes = "libraw/libraw.h"})) + end)