From 0f70a3c9b35f7a3b9fdb96caf5332202b63ef90f Mon Sep 17 00:00:00 2001 From: Jim Jing Date: Fri, 20 Dec 2024 16:47:57 -0800 Subject: [PATCH] Add libmodbus (#3462) Co-authored-by: Fabian Meumertzheim --- modules/libmodbus/3.1.10/MODULE.bazel | 6 ++ .../3.1.10/patches/add_build_file.patch | 66 +++++++++++++++++++ .../add_modbus_versionscript_dot_lds.patch | 11 ++++ .../3.1.10/patches/module_dot_bazel.patch | 9 +++ modules/libmodbus/3.1.10/presubmit.yml | 15 +++++ modules/libmodbus/3.1.10/source.json | 11 ++++ modules/libmodbus/metadata.json | 22 +++++++ 7 files changed, 140 insertions(+) create mode 100644 modules/libmodbus/3.1.10/MODULE.bazel create mode 100644 modules/libmodbus/3.1.10/patches/add_build_file.patch create mode 100644 modules/libmodbus/3.1.10/patches/add_modbus_versionscript_dot_lds.patch create mode 100644 modules/libmodbus/3.1.10/patches/module_dot_bazel.patch create mode 100644 modules/libmodbus/3.1.10/presubmit.yml create mode 100644 modules/libmodbus/3.1.10/source.json create mode 100644 modules/libmodbus/metadata.json diff --git a/modules/libmodbus/3.1.10/MODULE.bazel b/modules/libmodbus/3.1.10/MODULE.bazel new file mode 100644 index 00000000000..1b6b6e907e1 --- /dev/null +++ b/modules/libmodbus/3.1.10/MODULE.bazel @@ -0,0 +1,6 @@ +module( + name = "libmodbus", + version = "3.1.10", + compatibility_level = 1, +) +bazel_dep(name = "bazel_skylib", version = "1.7.1") diff --git a/modules/libmodbus/3.1.10/patches/add_build_file.patch b/modules/libmodbus/3.1.10/patches/add_build_file.patch new file mode 100644 index 00000000000..754ad379968 --- /dev/null +++ b/modules/libmodbus/3.1.10/patches/add_build_file.patch @@ -0,0 +1,66 @@ +diff --git a/BUILD b/BUILD +new file mode 100644 +index 0000000..315d32e +--- /dev/null ++++ b/BUILD +@@ -0,0 +1,60 @@ ++load("@bazel_skylib//rules:expand_template.bzl", "expand_template") ++ ++cc_library( ++ name = "modbus", ++ srcs = glob(["src/*.c"]) + [ ++ ":generate_config_h", ++ ":generate_modbus_version_h", ++ ], ++ hdrs = glob(["src/*.h"]), ++ copts = ["-DHAVE_CONFIG_H"], ++ includes = ["src"], ++ include_prefix = "libmodbus", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "libmodbus", ++ actual = ":modbus", ++) ++ ++cc_shared_library( ++ name = "modbus_shared", ++ additional_linker_inputs = [ ++ ":modbus-versionscript.lds", ++ ], ++ user_link_flags = [ ++ # Linker script to hide non-modbus symbols. ++ "-Wl,--version-script", ++ "$(location modbus-versionscript.lds)", ++ ], ++ visibility = ["//visibility:public"], ++ deps = [ ++ ":modbus", ++ ], ++) ++ ++expand_template( ++ name = "generate_modbus_version_h", ++ out = "src/modbus-version.h", ++ substitutions = { ++ "@LIBMODBUS_VERSION_MAJOR@": "3", ++ "@LIBMODBUS_VERSION_MINOR@": "1", ++ "@LIBMODBUS_VERSION_MICRO@": "10", ++ "@LIBMODBUS_VERSION@": "3.1.10", ++ }, ++ template = "src/modbus-version.h.in", ++) ++ ++genrule( ++ name = "generate_config_h", ++ outs = ["src/config.h"], ++ cmd = """cat > $@ <