From abba176643a7a141bc6d3d81ce8f304363830af6 Mon Sep 17 00:00:00 2001 From: Nathaniel Brough Date: Tue, 11 Aug 2020 10:06:56 +0800 Subject: [PATCH] Adding support for the bazel build system This includes the libraries and examples. The correct implementation should automatically be configured depending on the platform. --- .gitignore | 2 ++ .travis.yml | 2 +- BUILD | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ WORKSPACE | 0 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 BUILD create mode 100644 WORKSPACE diff --git a/.gitignore b/.gitignore index 2634447..e7e369c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ doc/html ipch Debug Release + +bazel-* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index d626c6e..0f296b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ install: - source setup.bash script: - mkdir build && cd build && cmake .. -DPYTHON_EXECUTABLE=$(which python2) && make && make tests && make run_tests - - catkin_test_results . + - catkin_test_results . \ No newline at end of file diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..d43d395 --- /dev/null +++ b/BUILD @@ -0,0 +1,65 @@ +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary") + +cc_library( + name = "serial", + deps = [ + ":serial_facade", + ":common_impl", + ] + select({ + ":windows": [":windows_impl"], + ":linux": [":linux_impl"], + ":macos": [":unix_impl"], + }), + visibility = ["//visibility:public"], +) + +cc_library( + name = "serial_facade", + hdrs = glob(["**/*.h"]), + includes = ["include"], +) + +cc_library( + name = "windows_impl", + srcs = [ + "src/impl/list_ports/list_ports_win.cc", + "src/impl/win.cc", + ], + deps = [":serial_facade"], +) + +cc_library( + name = "linux_impl", + srcs = [ + "src/impl/list_ports/list_ports_linux.cc", + "src/impl/unix.cc", + ], + deps = [":serial_facade"], +) + +cc_library( + name = "common_impl", + srcs = ["src/serial.cc"], + deps = [":serial_facade"], +) + +cc_binary( + name = "example", + srcs = ["examples/serial_example.cc"], + deps = [":serial"], +) + +config_setting( + name = "windows", + constraint_values = ["@platforms//os:windows"], +) + +config_setting( + name = "linux", + constraint_values = ["@platforms//os:linux"], +) + +config_setting( + name = "macos", + constraint_values = ["@platforms//os:macos"], +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..e69de29