From 81671e99a4718a7e326171a2e8cd799cd1d7b3ff Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Mon, 16 Nov 2020 11:16:07 +0800 Subject: [PATCH] add package giflib and libwebp (#136) * add package giflib * add package libwebp * add require cgetopt * make autoconf configs consistent --- packages/g/giflib/xmake.lua | 63 ++++++++++++++++++++++++++++++++++++ packages/l/libwebp/xmake.lua | 42 ++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 packages/g/giflib/xmake.lua create mode 100644 packages/l/libwebp/xmake.lua diff --git a/packages/g/giflib/xmake.lua b/packages/g/giflib/xmake.lua new file mode 100644 index 000000000..66bfdbc7d --- /dev/null +++ b/packages/g/giflib/xmake.lua @@ -0,0 +1,63 @@ +package("giflib") + + set_homepage("https://sourceforge.net/projects/giflib/") + set_description("A library for reading and writing gif images.") + set_license("MIT") + + add_urls("https://jaist.dl.sourceforge.net/project/giflib/giflib-$(version).tar.gz") + add_versions("5.2.1", "31da5562f44c5f15d63340a09a4fd62b48c45620cd302f77a6d9acf0077879bd") + + add_configs("utils", {description = "Build utility binaries.", default = true, type = "boolean"}) + + if is_plat("windows") then + add_deps("cgetopt") + end + + on_install("linux", "macosx", "windows", "mingw", "android", "iphoneos", function (package) + local lib_sources = {"dgif_lib.c", "egif_lib.c", "gifalloc.c", "gif_err.c", "gif_font.c", "gif_hash.c", "openbsd-reallocarray.c"} + local kind = "static" + if package:config("shared") then + if package:is_plat("windows") then + cprint("${yellow}No support for dll on windows!${clear}") + else + kind = "shared" + end + end + if package:is_plat("windows") then + io.gsub("gif_hash.h", "\n#include \n", [[ + #ifndef _MSC_VER + #include + #endif + ]]) + io.gsub("gif_font.c", "\n#include \"gif_lib.h\"\n", "\n#include \"gif_lib.h\"\n#define strtok_r strtok_s\n") + end + local xmake_lua = string.format([[ + add_rules("mode.debug", "mode.release") + if is_plat("windows") then + add_requires("cgetopt") + end + target("gif") + set_kind("%s") + add_files("%s") + add_headerfiles("gif_lib.h") + ]], kind, table.concat(lib_sources, "\", \"")) + if package:config("utils") then + local util_table = {"gif2rgb", "gifbuild", "gifclrmp", "giffix", "giftext", "giftool"} + for _, util in ipairs(util_table) do + xmake_lua = xmake_lua .. string.format([[ + target("%s") + set_kind("binary") + if is_plat("windows") then + add_packages("cgetopt") + end + add_files("%s.c", "getarg.c", "qprintf.c", "quantize.c", "%s") + ]], util, util, table.concat(lib_sources, "\", \"")) + end + end + io.writefile("xmake.lua", xmake_lua) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:has_cfuncs("GifMakeMapObject", {includes = "gif_lib.h"})) + end) diff --git a/packages/l/libwebp/xmake.lua b/packages/l/libwebp/xmake.lua new file mode 100644 index 000000000..8d549ea52 --- /dev/null +++ b/packages/l/libwebp/xmake.lua @@ -0,0 +1,42 @@ +package("libwebp") + + set_homepage("https://chromium.googlesource.com/webm/libwebp/") + set_description("Library to encode and decode images in WebP format.") + set_license("BSD-3-Clause") + + local commits = {["1.1.0"] = "d7844e9762b61c9638c263657bd49e1690184832"} + add_urls("https://github.com/webmproject/libwebp/archive/v$(version).tar.gz", {alias = "github"}) + add_urls("https://chromium.googlesource.com/webm/libwebp/+archive/$(version).tar.gz", {alias = "google", version = function (version) return commits[version] end}) + add_versions("github:1.1.0", "424faab60a14cb92c2a062733b6977b4cc1e875a6398887c5911b3a1a6c56c51") + add_versions("google:1.1.0", "538fa4368f303251f7a672db5bf9970089493fab58c0d457e31a89703d9a786b") + + add_deps("libpng", "libjpeg", "libtiff", "giflib") + if is_plat("linux") then + add_syslinks("pthread") + elseif is_plat("macosx") then + add_deps("automake") + end + + on_install("linux", "macosx", function (package) + local configs = {} + table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) + table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) + import("package.tools.autoconf").install(package, configs) + end) + + on_install("windows", function (package) + local configs = {"-f", "Makefile.vc"} + local cfg = (package:debug() and "debug" or "release") .. "-" .. (package:config("shared") and "dynamic" or "static") + local arch = package:arch() + table.insert(configs, "CFG=" .. cfg) + table.insert(configs, "RTLIBCFG=" .. (package:config("vs_runtime"):startswith("MT") and "static" or "dynamic")) + table.insert(configs, "ARCH=" .. arch) + import("package.tools.nmake").build(package, configs) + local base = path.join("..", "obj", cfg, arch) + os.cp(path.join(base, "lib"), package:installdir()) + os.cp(path.join("src", "webp"), package:installdir("include")) + end) + + on_test(function (package) + assert(package:has_cfuncs("WebPGetEncoderVersion", {includes = "webp/encode.h"})) + end)