libmetalink: add package (#3929)

* libmetalink: add package

* limit plat

* disable windows

* Revert "disable windows"

This reverts commit 89e844526c.

* patch windows
pull/3480/head
star9029 7 months ago committed by GitHub
parent 68f44c2d04
commit b4c22cc451
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      packages/l/libmetalink/port/config.h.in
  2. 4
      packages/l/libmetalink/port/unistd.h
  3. 69
      packages/l/libmetalink/port/xmake.lua
  4. 23
      packages/l/libmetalink/xmake.lua

@ -0,0 +1,4 @@
${define HAVE_INTTYPES_H}
${define HAVE_MALLOC_H}
${define HAVE_ALLOCA_H}
${define HAVE_TIME64_H}

@ -0,0 +1,4 @@
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

@ -0,0 +1,69 @@
set_project("libmetalink")
option("version", {showmenu = true, default = "0.1.3"})
set_version(get_config("version"))
add_rules("mode.debug", "mode.release")
add_requires("expat")
add_packages("expat")
includes("@builtin/check")
configvar_check_cfuncs("HAVE_MALLOC_H", "malloc", {includes = "malloc.h"})
configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
configvar_check_cincludes("HAVE_ALLOCA_H", "alloca.h")
configvar_check_cincludes("HAVE_TIME64_H", "time64.h")
target("metalink")
set_kind("$(kind)")
add_files("lib/metalink_*.c", "lib/libexpat_metalink_parser.c")
add_includedirs("lib/includes")
add_headerfiles("lib/includes/(**.h)")
add_defines("HAVE_CONFIG_H")
add_includedirs(os.projectdir())
set_configdir(os.projectdir())
add_configfiles("config.h.in")
add_configfiles("lib/includes/metalink/metalinkver.h.in", {prefixdir = "metalink", pattern = "@(.-)@"})
add_headerfiles("(metalink/metalinkver.h)")
if is_plat("windows") then
add_defines("strncasecmp=_strnicmp")
add_defines("tzname=_tzname")
if is_kind("shared") then
add_rules("utils.symbols.export_all")
end
end
on_config(function (target)
import("core.base.semver")
local version = get_config("version")
if version then
version = semver.new(version)
local major = version:major()
local minor = version:minor()
local patch = version:patch()
target:set("configvar", "MAJOR_VERSION", major)
target:set("configvar", "MINOR_VERSION", minor)
target:set("configvar", "PATCH_VERSION", patch)
target:set("configvar", "PACKAGE_VERSION", get_config("version"))
target:set("configvar", "NUMBER_VERSION", format("0x%02x%02x%02x", tonumber(major), tonumber(minor), tonumber(patch)))
end
if target:has_cfuncs("timegm", {includes = "time.h"}) then
target:add("defines", "HAVE_TIMEGM")
else
target:add("files", path.join(os.projectdir(), "lib/timegm.c"))
end
if target:has_cfuncs("strptime", {includes = "time.h"}) then
target:add("defines", "HAVE_STRPTIME")
else
target:add("files", path.join(os.projectdir(), "lib/strptime.c"))
end
end)

@ -0,0 +1,23 @@
package("libmetalink")
set_homepage("https://github.com/metalink-dev/libmetalink")
set_description("C library to read Metalink XML download description format")
set_license("MIT")
add_urls("https://github.com/metalink-dev/libmetalink.git")
add_versions("2015.07.07", "5bcdfc0572fccc2b7bde32693f0dddb6ca040549")
add_deps("expat")
on_install("windows", "linux", "macosx", "android", "mingw", "cross", function (package)
if package:is_plat("windows") then
os.cp(path.join(package:scriptdir(), "port", "unistd.h"), "unistd.h")
end
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "config.h.in")
import("package.tools.xmake").install(package)
end)
on_test(function (package)
assert(package:has_cfuncs("metalink_get_version", {includes = "metalink/metalink.h"}))
end)
Loading…
Cancel
Save