improve libbpf (#323)

pull/325/head
ruki 4 years ago committed by GitHub
parent e8665e224a
commit e4ac3586ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      packages/l/libbpf/xmake.lua
  2. 3
      packages/l/libelf/xmake.lua
  3. 29
      packages/m/memorymapping/xmake.lua
  4. 6
      scripts/test.lua

@ -11,23 +11,36 @@ package("libbpf")
add_includedirs("include", "include/uapi")
on_install("linux", function (package)
os.cd("src")
io.replace("Makefile", "PREFIX ?= /usr", "PREFIX ?= " .. package:installdir(), {plain = true})
if package:config("shared") then
io.replace("Makefile", "STATIC_LIBS := .-\n", "STATIC_LIBS :=\n")
else
io.replace("Makefile", "ifndef BUILD_STATIC_ONLY", "ifeq (1,0)")
on_load("android", function (package)
import("core.tool.toolchain")
local ndk_sdkver = toolchain.load("ndk"):config("ndk_sdkver")
if ndk_sdkver and tonumber(ndk_sdkver) < 23 then
package:add("deps", "memorymapping")
end
import("package.tools.make").install(package)
if package:is_plat("linux") and package:is_arch("x86_64") then
local lib64 = path.join(package:installdir(), "lib64")
if os.isdir(lib64) then
package:add("links", "bpf")
package:add("linkdirs", "lib64")
end)
on_install("linux", "android", function (package)
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
add_requires("libelf", "zlib")
target("bpf")
set_kind("$(kind)")
add_files("src/*.c")
add_includedirs("include", "include/uapi")
add_packages("libelf", "zlib")
add_headerfiles("src/(*.h)", {prefixdir = "bpf"})
add_headerfiles("include/(uapi/**.h)")
if is_plat("android") then
add_defines("__user=", "__force=", "__poll_t=uint32_t")
end
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
elseif package:config("pic") ~= false then
configs.cxflags = "-fPIC"
end
os.cp("../include/uapi", package:installdir("include"))
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)

@ -26,6 +26,7 @@ package("libelf")
io.replace("./configure", "#define off_t long", "")
io.replace("lib/private.h", "HAVE_MEMMOVE", "1")
io.replace("lib/private.h", "HAVE_MEMCPY", "1")
cxflags = (cxflags or "") .. " -D__LIBELF64=1 -D__LIBELF64_LINUX=1 -D__libelf_u64_t=uint64_t -D__libelf_i64_t=int64_t"
package:add("defines", "__LIBELF64=1")
package:add("defines", "__LIBELF64_LINUX=1")
package:add("defines", "__libelf_u64_t=uint64_t")
@ -35,6 +36,6 @@ package("libelf")
end)
on_test(function (package)
assert(package:has_cfuncs("elf_begin", {includes = "libelf/gelf.h"}))
assert(package:has_cfuncs("gelf_getsym", {includes = "libelf/gelf.h"}))
assert(package:has_cfuncs("elf_begin", {includes = "libelf/libelf.h"}))
end)

@ -0,0 +1,29 @@
package("memorymapping")
set_homepage("https://github.com/NimbusKit/memorymapping")
set_description("fmemopen port library")
set_urls("https://github.com/NimbusKit/memorymapping.git")
add_versions("2014.12.21", "79ce0ddd0de4b11e4944625eb866290368f867c0")
on_install("android", "macosx", "iphoneos", function (package)
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
target("fmemopen")
set_kind("$(kind)")
add_files("src/*.c")
add_headerfiles("src/*.h")
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
elseif package:config("pic") ~= false then
configs.cxflags = "-fPIC"
end
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("fmemopen", {includes = {"stdio.h", "fmemopen.h"}}))
end)

@ -17,7 +17,8 @@ local options =
, {nil, "cflags", "kv", nil, "Set the cflags." }
, {nil, "cxxflags", "kv", nil, "Set the cxxflags." }
, {nil, "ldflags", "kv", nil, "Set the ldflags." }
, {nil, "ndk", "kv", nil, "Set the android NDK directory." }
, {nil, "ndk", "kv", nil, "Set the Android NDK directory." }
, {nil, "ndk_sdkver", "kv", nil, "Set the Android NDK platform sdk version." }
, {nil, "sdk", "kv", nil, "Set the SDK directory of cross toolchain." }
, {nil, "vs_sdkver", "kv", nil, "Set the Windows SDK version." }
, {nil, "vs_runtime", "kv", nil, "Set the VS Runtime library." }
@ -51,6 +52,9 @@ function _require_packages(argv, packages)
if argv.sdk then
table.insert(config_argv, "--sdk=" .. argv.sdk)
end
if argv.ndk_sdkver then
table.insert(config_argv, "--ndk_sdkver=" .. argv.ndk_sdkver)
end
if argv.vs_sdkver then
table.insert(config_argv, "--vs_sdkver=" .. argv.vs_sdkver)
end

Loading…
Cancel
Save