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 cxx11pull/2991/head
parent
87dace2d3b
commit
f152b68049
2 changed files with 82 additions and 8 deletions
@ -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 |
Loading…
Reference in new issue