Skip to content

Commit

Permalink
Incorporate feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Oct 23, 2020
1 parent 60420bd commit b4b3550
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 53 deletions.
84 changes: 40 additions & 44 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
load(
"//ign_bazel:cmake_configure_file.bzl",
"//ign_bazel:build_defs.bzl",
"IGNITION_ROOT",
"IGNITION_VISIBILITY",
"cmake_configure_file",
)
load(
"//ign_bazel:generate_include_header.bzl",
"generate_include_header",
)
load(
"//ign_bazel:ign_export_header.bzl",
"ign_config_header",
"ign_export_header",
)

load(
":ign_msg_gen.bzl",
"get_proto_headers",
"ign_msg_gen",
)

package(default_visibility = ["//visibility:public"])
package(
default_visibility = IGNITION_VISIBILITY,
features = [
"-parse_headers",
"-layering_check",
],
)

licenses(["notice"])

exports_files(["LICENSE"])

PROJECT_NAME = "ignition-msgs"

Expand All @@ -27,23 +35,12 @@ PROJECT_MINOR = 0
PROJECT_PATCH = 0

# Generates config.hh based on the version numbers in CMake code.
cmake_configure_file(
ign_config_header(
name = "config",
src = "include/ignition/msgs/config.hh.in",
out = "include/ignition/msgs/config.hh",
cmakelists = ["CMakeLists.txt"],
defines = [
"PROJECT_VERSION_MAJOR=%d" % PROJECT_MAJOR,
"PROJECT_VERSION_MINOR=%d" % PROJECT_MINOR,
"PROJECT_VERSION_PATCH=%d" % PROJECT_PATCH,
"PROJECT_MAJOR_VERSION=%d" % PROJECT_MAJOR,
"PROJECT_MINOR_VERSION=%d" % PROJECT_MINOR,
"PROJECT_PATCH_VERSION=%d" % PROJECT_PATCH,
"PROJECT_VERSION=%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR),
"PROJECT_VERSION_FULL=%d.%d.%d" % (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), # noqa
"PROJECT_NAME_NO_VERSION=%s" % PROJECT_NAME,
],
visibility = ["//visibility:public"],
project_name = PROJECT_NAME,
project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH),
)

ign_export_header(
Expand All @@ -67,6 +64,7 @@ generate_include_header(
name = "messagetypeshh_genrule",
out = "include/ignition/msgs/MessageTypes.hh",
hdrs = get_proto_headers(protos),
strip_prefix = ["ign_msgs"],
)

generate_include_header(
Expand Down Expand Up @@ -120,50 +118,46 @@ ign_msg_gen(
deps = [":ignmsgs_proto"],
)

cc_binary(
name = "libignition-msgs6.so",
cc_library(
name = "ign_msgs",
srcs = [
":ignmsgs_proto_cc",
"src/Factory.cc",
"src/Filesystem.cc",
"src/Utility.cc",
] + public_headers,
includes = ["include"],
linkopts = [
"-Wl,-soname,libignition-msgs6.so",
"-ltinyxml2",
],
linkshared = True,
linkstatic = True,
visibility = [],
hdrs = public_headers,
includes = ["include"],
deps = [
":ignmsgs_proto_cc",
"//ign_math",
IGNITION_ROOT + "ign_math",
"@tinyxml2",
"@com_google_protobuf//:protobuf",
],
)

cc_library(
name = "ign_msgs",
srcs = ["libignition-msgs6.so"],
hdrs = public_headers + [":ignmsgs_proto_cc"],
# use shared library only when absolutely needd
cc_binary(
name = "libignition-msgs6.so",
includes = ["include"],
visibility = ["//visibility:public"],
linkopts = [
"-Wl,-soname,libignition-msgs6.so",
],
linkshared = True,
linkstatic = True,
deps = [
":ignmsgs_proto_cc",
"//ign_math",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//:protoc_lib",
":ign_msgs",
],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
data = ["//ign_msgs/test:desc/stringmsg.desc"],
data = [IGNITION_ROOT + "ign_msgs/test:desc/stringmsg.desc"],
deps = [
":ign_msgs",
"//ign_msgs/test:test_utils",
IGNITION_ROOT + "ign_math",
IGNITION_ROOT + "ign_msgs/test:test_utils",
"@gtest",
"@gtest//:gtest_main",
],
Expand All @@ -174,3 +168,5 @@ cc_library(
)]

exports_files(["src/cmd/cmdmsgs.rb.in"])

exports_files(["CMakeLists.txt"])
29 changes: 20 additions & 9 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
load(
"//ign_bazel:cmake_configure_file.bzl",
"//ign_bazel:build_defs.bzl",
"IGNITION_ROOT",
"IGNITION_VISIBILITY",
"cmake_configure_file",
)

BINARY_DIR = "./ign_msgs/"
package(
default_visibility = IGNITION_VISIBILITY,
features = [
"-layering_check",
],
)

licenses(["notice"])

exports_files(["LICENSE"])

SOURCE_DIR = "./ign_msgs/"
MSGS_DIR = "./ign_msgs/"

# Generates config.hh based on the version numbers in CMake code.
cmake_configure_file(
Expand All @@ -14,9 +25,9 @@ cmake_configure_file(
out = "test_config.h",
cmakelists = ["CMakeLists.txt"],
defines = [
"CMAKE_BINARY_DIR=%s" % BINARY_DIR,
"PROJECT_BINARY_DIR=%s" % BINARY_DIR,
"PROJECT_SOURCE_DIR=%s" % SOURCE_DIR,
"CMAKE_BINARY_DIR=%s" % (MSGS_DIR),
"PROJECT_BINARY_DIR=%s" % (MSGS_DIR),
"PROJECT_SOURCE_DIR=%s" % (MSGS_DIR),
],
visibility = ["//visibility:private"],
)
Expand All @@ -25,10 +36,8 @@ cc_library(
name = "test_utils",
srcs = ["test_config.h"],
includes = ["."],
visibility = ["//visibility:public"],
)

exports_files(["desc/stringmsg.desc"])

[
cc_test(
Expand All @@ -40,10 +49,12 @@ exports_files(["desc/stringmsg.desc"])
],
deps = [
":test_utils",
"//ign_msgs",
IGNITION_ROOT + "ign_msgs",
"@gtest",
"@gtest//:gtest_main",
],
)
for test in glob(["integration/*.cc"])
]

exports_files(["desc/stringmsg.desc"])

0 comments on commit b4b3550

Please sign in to comment.