|
| 1 | +diff --git a/BUILD b/BUILD |
| 2 | +new file mode 100644 |
| 3 | +index 0000000..315d32e |
| 4 | +--- /dev/null |
| 5 | ++++ b/BUILD |
| 6 | +@@ -0,0 +1,60 @@ |
| 7 | ++load("@bazel_skylib//rules:expand_template.bzl", "expand_template") |
| 8 | ++ |
| 9 | ++cc_library( |
| 10 | ++ name = "modbus", |
| 11 | ++ srcs = glob(["src/*.c"]) + [ |
| 12 | ++ ":generate_config_h", |
| 13 | ++ ":generate_modbus_version_h", |
| 14 | ++ ], |
| 15 | ++ hdrs = glob(["src/*.h"]), |
| 16 | ++ copts = ["-DHAVE_CONFIG_H"], |
| 17 | ++ includes = ["src"], |
| 18 | ++ include_prefix = "libmodbus", |
| 19 | ++ visibility = ["//visibility:public"], |
| 20 | ++) |
| 21 | ++ |
| 22 | ++alias( |
| 23 | ++ name = "libmodbus", |
| 24 | ++ actual = ":modbus", |
| 25 | ++) |
| 26 | ++ |
| 27 | ++cc_shared_library( |
| 28 | ++ name = "modbus_shared", |
| 29 | ++ additional_linker_inputs = [ |
| 30 | ++ ":modbus-versionscript.lds", |
| 31 | ++ ], |
| 32 | ++ user_link_flags = [ |
| 33 | ++ # Linker script to hide non-modbus symbols. |
| 34 | ++ "-Wl,--version-script", |
| 35 | ++ "$(location modbus-versionscript.lds)", |
| 36 | ++ ], |
| 37 | ++ visibility = ["//visibility:public"], |
| 38 | ++ deps = [ |
| 39 | ++ ":modbus", |
| 40 | ++ ], |
| 41 | ++) |
| 42 | ++ |
| 43 | ++expand_template( |
| 44 | ++ name = "generate_modbus_version_h", |
| 45 | ++ out = "src/modbus-version.h", |
| 46 | ++ substitutions = { |
| 47 | ++ "@LIBMODBUS_VERSION_MAJOR@": "3", |
| 48 | ++ "@LIBMODBUS_VERSION_MINOR@": "1", |
| 49 | ++ "@LIBMODBUS_VERSION_MICRO@": "10", |
| 50 | ++ "@LIBMODBUS_VERSION@": "3.1.10", |
| 51 | ++ }, |
| 52 | ++ template = "src/modbus-version.h.in", |
| 53 | ++) |
| 54 | ++ |
| 55 | ++genrule( |
| 56 | ++ name = "generate_config_h", |
| 57 | ++ outs = ["src/config.h"], |
| 58 | ++ cmd = """cat > $@ <<EOF |
| 59 | ++#define HAVE_DECL_TIOCM_RTS 1 |
| 60 | ++#define HAVE_DECL_TIOCSRS485 1 |
| 61 | ++#undef HAVE_ACCEPT4 |
| 62 | ++#undef HAVE_GAI_STRERROR |
| 63 | ++#define HAVE_NETINET_IN_H 1 |
| 64 | ++#define HAVE_NETINET_IP_H 1 |
| 65 | ++""", |
| 66 | ++) |
0 commit comments