libgpiod: rework & fix C++ bindings (#2989)

* libgpiod: update test code

* libgpiod: create port file

* libgpiod: fix add_headerfiles

* libgpiod: add version defines

* libgpiod: print version

* libgpiod: fix version matching

* libgpiod: separate tools & fix program_invocation_name & version

* libgpiod: create on_load

* libgpiod: use before_build

* libgpiod: use add_defines

* libgpiod: use target:add

* libgpiod: add tools-common files

* libgpiod: ignore tools-common on its own

* libgpiod: add quotations around define program_invocation_name

* libgpiod: add configvar_check_csnippets

* libgpiod: make program_invocation_short_name same as program_invocation_name

* libgpiod: add quotations around GPIOD_VERSION_STR

* libgpiod: only get direct cxx files in bindings/cxx

* libgpiod: separate c and cxx bindings

* libgpiod: add options

* libgpiod: on_test use config

* libgpiod: test older version

* libgpiod: make `%[` & `%]` optional

* libgpiod: update test

* libgpiod: fix cxx test

* libgpiod: dont delete chip ptr

* libgpiod: set kind

* libgpiod: add patch for `v1.6.4`

* libgpiod: fix patch hash

* libgpiod: update patch

* libgpiod: set_languages("c89") & move deps

* libgpiod: use c99

* libgpiod: use C++11

* libgpiod: add io.replace

* libgpiod: update patch

* libgpiod: comment set_languages

* libgpiod: move add_includedirs

* libgpiod: set kind to shared if version under v1.6.4

* libgpiod: move includedirs

* libgpiod: remove `delete`

* libgpiod: add link

* libgpiod: use same methods for other deps

* libgpiod: remove libgpiod_cxx

* libgpiod: use add_deps

* libgpiod: add cxx17

* libgpiod: remove before_build

* libgpiod: readd addenv PATH

* libgpiod: test old version

* libgpiod: undo

* libgpiod: remove set config to shared for v1.6.4 static

* libgpiod: add target gpiodcxx

* libgpiod: remove duplicate before_build

* libgpiod: readd versions

* libgpiod: use c11

* libgpiod: use cxx11

* libgpiod: fix target name

* libgpiod: fix add_deps

* libgpiod: set target for tool's language to cxx11
pull/2991/head
Chi Huu Huynh 11 months ago committed by GitHub
parent 87dace2d3b
commit f152b68049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 52
      packages/l/libgpiod/port/xmake.lua
  2. 38
      packages/l/libgpiod/xmake.lua

@ -0,0 +1,52 @@
option("enable_bindings_cxx", {default = true, showmenu = true, description = "Enable C++ bindings"})
option("enable_tools", {default = true, showmenu = true, description = "Enable tools"})
target("gpiod")
set_kind("$(kind)")
set_languages("cxx11")
add_headerfiles("include/(gpiod.h)")
add_headerfiles("lib/uapi/*.h")
add_files("lib/*.c")
add_includedirs("include", {public = true})
before_build(function (target)
local configure = io.readfile("configure.ac")
local version = configure:match("AC_INIT%(%[libgpiod%], %[?([0-9%.]+)%]?%)")
target:add("defines", "GPIOD_VERSION_STR=\"" .. version .. "\"")
end)
if has_config("enable_bindings_cxx") then
target("gpiodcxx")
set_kind("$(kind)")
set_languages("cxx17")
add_headerfiles("bindings/cxx/(gpiod.hpp)")
add_headerfiles("bindings/cxx/(gpiodcxx/**.hpp)")
add_files("bindings/cxx/*.cpp")
add_includedirs("bindings/cxx", {public = true})
add_deps("gpiod")
end
if has_config("enable_tools") then
for _, tool_file in ipairs(os.files("tools/*.c")) do
local name = path.basename(tool_file)
if name ~= "tools-common" then
target(name)
set_kind("binary")
set_languages("cxx11")
add_files("tools/" .. name .. ".c")
add_headerfiles("tools/tools-common.h")
add_files("tools/tools-common.c")
add_defines("program_invocation_short_name=\"" .. name .. "\"")
add_defines("program_invocation_name=\"" .. name .. "\"")
add_deps("gpiod")
end
end
end

@ -7,18 +7,40 @@ package("libgpiod")
add_versions("v2.0.1", "cf0d4db1d94cc99281de142063d0e28f42760c4d918d6b8854e1b27811517c34") add_versions("v2.0.1", "cf0d4db1d94cc99281de142063d0e28f42760c4d918d6b8854e1b27811517c34")
add_versions("v2.0", "a0f835c4ca4a2a3ca021090b574235ba58bb9fd612d8a6051fb1350054e04fdd") add_versions("v2.0", "a0f835c4ca4a2a3ca021090b574235ba58bb9fd612d8a6051fb1350054e04fdd")
add_versions("v1.6.4", "9f920260c46b155f65cba8796dcf159e4ba56950b85742af357d75a1af709e68") add_versions("v1.6.4", "9f920260c46b155f65cba8796dcf159e4ba56950b85742af357d75a1af709e68")
add_deps("autoconf-archive", "automake", "libtool", "pkg-config") add_configs("enable_bindings_cxx", {description = "Enable C++ bindings", default = true, type = "boolean"})
add_configs("enable_tools", {description = "Enable tools", default = true, type = "boolean"})
on_install("linux", function (package) on_install("linux", function (package)
local configs = {"--enable-tools=yes", "--enable-bindings-cxx"} os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no")) local configs = {}
table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes")) if package:config("enable_bindings_cxx") then
import("package.tools.autoconf").install(package, configs) configs.enable_bindings_cxx = true
end
if package:config("enable_tools") then
configs.enable_tools = true
end
import("package.tools.xmake").install(package)
package:addenv("PATH", "bin") package:addenv("PATH", "bin")
end) end)
on_test(function (package) on_test(function (package)
os.runv("gpiodetect") assert(package:check_cxxsnippets({test = [[
assert(package:has_cfuncs("gpiod_api_version", {includes = "gpiod.h"})) #include <gpiod.h>
void test() {
struct gpiod_chip *chip;
chip = gpiod_chip_open("/dev/null");
}
]]}, {configs = {languages = "c++11"}}))
if package:config("enable_bindings_cxx") then
assert(package:check_cxxsnippets({test = [[
#include <gpiod.hpp>
void test() {
gpiod::chip chip("/dev/null");
}
]]}, {configs = {languages = "c++17"}}))
end
if package:config("enable_tools") then
os.runv("gpiodetect")
end
end) end)

Loading…
Cancel
Save