diff --git a/BUILD.bazel b/BUILD.bazel index e97f57bf6..33ac2dac8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,11 +1,11 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_FEATURES", "GZ_ROOT", "GZ_VISIBILITY", - "generate_include_header", - "gz_config_header", + "gz_configure_header", "gz_export_header", + "gz_include_header", ) package( @@ -13,25 +13,15 @@ package( features = GZ_FEATURES, ) -licenses(["notice"]) +licenses(["notice"]) # Apache-2.0 exports_files(["LICENSE"]) -PROJECT_NAME = "gz-common" - -PROJECT_MAJOR = 5 - -PROJECT_MINOR = 0 - -PROJECT_PATCH = 0 - -# Generates config.hh based on the version numbers in CMake code. -gz_config_header( +gz_configure_header( name = "config", src = "include/gz/common/config.hh.in", cmakelists = ["CMakeLists.txt"], - project_name = PROJECT_NAME, - project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), + package = "common", ) gz_export_header( @@ -44,19 +34,21 @@ gz_export_header( public_headers_no_gen = glob([ "include/gz/common/*.hh", "include/gz/common/detail/*.hh", + "include/gz/common/graph/*.hh", ]) -private_headers = [ - "src/PluginUtils.hh", - "src/PrintWindowsSystemWarning.hh", -] +private_headers = glob(["src/*.hh"]) sources = glob( ["src/*.cc"], - exclude = ["src/*_TEST.cc"], + exclude = [ + "src/Plugin.cc", + "src/PluginLoader.cc", + "src/*_TEST.cc", + ], ) -generate_include_header( +gz_include_header( name = "commonhh_genrule", out = "include/gz/common.hh", hdrs = public_headers_no_gen + [ @@ -72,39 +64,32 @@ public_headers = public_headers_no_gen + [ ] cc_library( - name = "gz_common", + name = "common", srcs = sources + private_headers, hdrs = public_headers, includes = ["include"], - linkopts = ["-ldl"], deps = [ + GZ_ROOT + "utils", + GZ_ROOT + "math", "@uuid", - GZ_ROOT + "gz_math", ], ) -cc_binary( - name = "libgz-common5.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5.so"], - linkshared = True, - deps = [":gz_common"], -) - -test_srcs = glob( - ["src/*_TEST.cc"], - exclude = ["src/PluginLoader_TEST.cc"], +test_sources = glob( + include = ["src/*_TEST.cc"], + exclude = [ + "src/PluginUtils_TEST.cc", + "src/PluginLoader_TEST.cc", + ], ) [cc_test( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], - data = [":libgz-common5.so"], deps = [ - ":gz_common", - GZ_ROOT + "gz_bazel:utilities", - GZ_ROOT + "gz_common/test:test_utils", + ":common", + GZ_ROOT + "common/testing", "@gtest", "@gtest//:gtest_main", ], -) for src in test_srcs] +) for src in test_sources] diff --git a/av/BUILD.bazel b/av/BUILD.bazel index a2d74f5f2..93fb8a6a6 100644 --- a/av/BUILD.bazel +++ b/av/BUILD.bazel @@ -1,17 +1,9 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_ROOT", "GZ_VISIBILITY", - "generate_include_header", "gz_export_header", -) - -package( - default_visibility = GZ_VISIBILITY, - features = [ - "-parse_headers", - "-layering_check", - ], + "gz_include_header", ) public_headers_no_gen = glob([ @@ -21,10 +13,7 @@ public_headers_no_gen = glob([ sources = glob( ["src/*.cc"], - exclude = [ - "src/*_TEST.cc", - "src/HWEncoder.cc", - ], + exclude = ["src/*_TEST.cc"], ) test_sources = glob(["src/*_TEST.cc"]) @@ -36,8 +25,8 @@ gz_export_header( visibility = ["//visibility:private"], ) -generate_include_header( - name = "eventshh_genrule", +gz_include_header( + name = "av_hh_genrule", out = "include/gz/common/av.hh", hdrs = public_headers_no_gen + [ "include/gz/common/av/Export.hh", @@ -54,35 +43,28 @@ cc_library( srcs = sources, hdrs = public_headers, includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ - GZ_ROOT + "gz_common", - "@ffmpeg//:avcodec", - "@ffmpeg//:avdevice", - "@ffmpeg//:avformat", - "@ffmpeg//:avutil", - "@ffmpeg//:swscale", + GZ_ROOT + "common", + GZ_ROOT + "utils", + "@ffmpeg//:libavcodec", + "@ffmpeg//:libavformat", + "@ffmpeg//:libavutil", + "@ffmpeg//:libswscale", ], ) -cc_binary( - name = "libgz-common5-av.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5-av.so"], - linkshared = True, - deps = [":av"], -) - [cc_test( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], - data = [ - GZ_ROOT + "gz_common/test:data", - ], + data = [GZ_ROOT + "common/test:data"], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, deps = [ ":av", - GZ_ROOT + "gz_common/test:test_utils", - GZ_ROOT + "gz_bazel:utilities", - "@gtest", + GZ_ROOT + "common/testing", "@gtest//:gtest_main", ], ) for src in test_sources] diff --git a/events/BUILD.bazel b/events/BUILD.bazel index 792ccd8a1..4d6936b99 100644 --- a/events/BUILD.bazel +++ b/events/BUILD.bazel @@ -1,22 +1,14 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_ROOT", "GZ_VISIBILITY", - "generate_include_header", "gz_export_header", -) - -package( - default_visibility = GZ_VISIBILITY, - features = [ - "-parse_headers", - "-layering_check", - ], + "gz_include_header", ) public_headers_no_gen = glob([ "include/gz/common/*.hh", - "include/gz/common/events/*.hh", + "include/gz/common/**/*.hh", ]) sources = glob( @@ -33,8 +25,8 @@ gz_export_header( visibility = ["//visibility:private"], ) -generate_include_header( - name = "eventshh_genrule", +gz_include_header( + name = "events_hh_genrule", out = "include/gz/common/events.hh", hdrs = public_headers_no_gen + [ "include/gz/common/events/Export.hh", @@ -51,26 +43,19 @@ cc_library( srcs = sources, hdrs = public_headers, includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ - GZ_ROOT + "gz_common", + GZ_ROOT + "common", + GZ_ROOT + "utils", ], ) -cc_binary( - name = "libgz-common5-events.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5-events.so"], - linkshared = True, - deps = [":events"], -) - [cc_test( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], deps = [ ":events", - GZ_ROOT + "gz_common/test:test_utils", - "@gtest", + GZ_ROOT + "common/testing", "@gtest//:gtest_main", ], ) for src in test_sources] diff --git a/geospatial/BUILD.bazel b/geospatial/BUILD.bazel new file mode 100644 index 000000000..b01923fa8 --- /dev/null +++ b/geospatial/BUILD.bazel @@ -0,0 +1,68 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_ROOT", + "GZ_VISIBILITY", + "gz_export_header", + "gz_include_header", +) + +public_headers_no_gen = glob([ + "include/gz/common/*.hh", + "include/gz/common/**/*.hh", +]) + +sources = glob( + ["src/*.cc"], + exclude = ["src/*_TEST.cc"], +) + +test_sources = glob(["src/*_TEST.cc"]) + +gz_export_header( + name = "include/gz/common/geospatial/Export.hh", + export_base = "GZ_COMMON_GEOSPATIAL", + lib_name = "gz-common-geospatial", + visibility = ["//visibility:private"], +) + +gz_include_header( + name = "geospatial_hh_genrule", + out = "include/gz/common/geospatial.hh", + hdrs = public_headers_no_gen + [ + "include/gz/common/geospatial/Export.hh", + ], +) + +public_headers = public_headers_no_gen + [ + "include/gz/common/geospatial/Export.hh", + "include/gz/common/geospatial.hh", +] + +cc_library( + name = "geospatial", + srcs = sources, + hdrs = public_headers, + includes = ["include"], + visibility = GZ_VISIBILITY, + deps = [ + GZ_ROOT + "common", + GZ_ROOT + "common/graphics", + GZ_ROOT + "utils", + "@gdal", + ], +) + +[cc_test( + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), + srcs = [src], + data = [GZ_ROOT + "common/test:data"], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, + deps = [ + ":geospatial", + GZ_ROOT + "common/testing", + "@gtest//:gtest_main", + ], +) for src in test_sources] diff --git a/graphics/BUILD.bazel b/graphics/BUILD.bazel index 4e41cff36..6d7b8822a 100644 --- a/graphics/BUILD.bazel +++ b/graphics/BUILD.bazel @@ -1,17 +1,9 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_ROOT", "GZ_VISIBILITY", - "generate_include_header", "gz_export_header", -) - -package( - default_visibility = GZ_VISIBILITY, - features = [ - "-parse_headers", - "-layering_check", - ], + "gz_include_header", ) public_headers_no_gen = glob([ @@ -33,7 +25,7 @@ gz_export_header( visibility = ["//visibility:private"], ) -generate_include_header( +gz_include_header( name = "graphics_hh_genrule", out = "include/gz/common/graphics.hh", hdrs = public_headers_no_gen + [ @@ -52,34 +44,29 @@ cc_library( srcs = sources, hdrs = public_headers, includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ + "@assimp", "@freeimage", "@glib", "@gts", "@tinyxml2", - GZ_ROOT + "gz_common", - GZ_ROOT + "gz_utils", + GZ_ROOT + "common", + GZ_ROOT + "utils", ], ) -cc_binary( - name = "libgz-common5-graphics.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5-graphics.so"], - linkshared = True, - deps = [":graphics"], -) - [cc_test( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], - data = [ - GZ_ROOT + "gz_common/test:data", - ], + data = [GZ_ROOT + "common/test:data"], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, deps = [ ":graphics", - GZ_ROOT + "gz_common/test:test_utils", - "@gtest", + GZ_ROOT + "common/testing", "@gtest//:gtest_main", ], ) for src in test_sources] diff --git a/io/BUILD.bazel b/io/BUILD.bazel index 89a00dbed..a3371a451 100644 --- a/io/BUILD.bazel +++ b/io/BUILD.bazel @@ -1,21 +1,14 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_ROOT", "GZ_VISIBILITY", - "generate_include_header", "gz_export_header", -) - -package( - default_visibility = GZ_VISIBILITY, - features = [ - "-parse_headers", - "-layering_check", - ], + "gz_include_header", ) public_headers_no_gen = glob([ "include/gz/common/*.hh", + "include/gz/common/**/*.hh", ]) sources = glob( @@ -32,8 +25,8 @@ gz_export_header( visibility = ["//visibility:private"], ) -generate_include_header( - name = "iohh_genrule", +gz_include_header( + name = "io_hh_genrule", out = "include/gz/common/io.hh", hdrs = public_headers_no_gen + [ "include/gz/common/io/Export.hh", @@ -50,27 +43,23 @@ cc_library( srcs = sources, hdrs = public_headers, includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ - GZ_ROOT + "gz_common", - GZ_ROOT + "gz_math", + GZ_ROOT + "common", + GZ_ROOT + "utils", ], ) -cc_binary( - name = "libgz-common5-io.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5-io.so"], - linkshared = True, - deps = [":events"], -) - [cc_test( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, deps = [ ":io", - GZ_ROOT + "gz_common/test:test_utils", - "@gtest", + GZ_ROOT + "common/testing", "@gtest//:gtest_main", ], ) for src in test_sources] diff --git a/profiler/BUILD.bazel b/profiler/BUILD.bazel index 6a39767d9..8d9a6dd21 100644 --- a/profiler/BUILD.bazel +++ b/profiler/BUILD.bazel @@ -1,29 +1,12 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_ROOT", "GZ_VISIBILITY", "cmake_configure_file", - "generate_include_header", "gz_export_header", + "gz_include_header", ) -package( - default_visibility = GZ_VISIBILITY, - features = [ - "-parse_headers", - "-layering_check", - ], -) - -public_headers_no_gen = [ - "include/gz/common/Profiler.hh", -] - -sources = [ - "src/Profiler.cc", - "src/RemoteryProfilerImpl.cc", -] - # Configuration for UNIX RMT_ENABLED = 1 @@ -53,6 +36,15 @@ cmake_configure_file( visibility = ["//visibility:private"], ) +public_headers_no_gen = [ + "include/gz/common/Profiler.hh", +] + +sources = [ + "src/Profiler.cc", + "src/RemoteryProfilerImpl.cc", +] + gz_export_header( name = "include/gz/common/profiler/Export.hh", export_base = "GZ_COMMON_PROFILER", @@ -60,18 +52,20 @@ gz_export_header( visibility = ["//visibility:private"], ) -generate_include_header( +gz_include_header( name = "profiler_hh_genrule", out = "include/gz/common/profiler.hh", hdrs = public_headers_no_gen + [ "include/gz/common/profiler/Export.hh", - "include/RemoteryConfig.h", ], ) public_headers = public_headers_no_gen + [ "include/gz/common/profiler/Export.hh", "include/gz/common/profiler.hh", +] + +private_headers = [ "src/ProfilerImpl.hh", "src/RemoteryProfilerImpl.hh", "include/RemoteryConfig.h", @@ -87,26 +81,19 @@ cc_library( cc_library( name = "profiler", srcs = sources, - hdrs = public_headers, + hdrs = public_headers + private_headers, defines = [ "GZ_PROFILER_ENABLE=1", "GZ_PROFILER_REMOTERY=1", ], includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ - GZ_ROOT + "gz_common", + GZ_ROOT + "common", ":remotery", ], ) -cc_binary( - name = "libgz-common5-profiler.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-common5-profiler.so"], - linkshared = True, - deps = [":profiler"], -) - cc_test( name = "Profiler_Disabled_TEST", srcs = ["src/Profiler_Disabled_TEST.cc"], diff --git a/test/BUILD.bazel b/test/BUILD.bazel index f499aa249..d62c70a6b 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,32 +1,42 @@ load( - "//gz_bazel:cmake_configure_file.bzl", - "cmake_configure_file", + "@gz//bazel/skylark:build_defs.bzl", + "GZ_ROOT", ) -BINARY_DIR = "./gz_common" - -SOURCE_DIR = "./gz_common" - -# Generates config.hh based on the version numbers in CMake code. -cmake_configure_file( - name = "test_config", - src = "test_config.h.in", - out = "test_config.h", - cmakelists = ["CMakeLists.txt"], - defines = [ - "PROJECT_BINARY_DIR=%s" % BINARY_DIR, - "PROJECT_SOURCE_DIR=%s" % SOURCE_DIR, +cc_test( + name = "INTEGRATION_console", + srcs = ["integration/console.cc"], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, + deps = [ + GZ_ROOT + "common", + GZ_ROOT + "common/testing", + "@gtest//:gtest_main", ], - visibility = ["//visibility:private"], ) -cc_library( - name = "test_utils", - srcs = [ - "test_config.h", +cc_test( + name = "INTEGRATION_mesh", + srcs = ["integration/mesh.cc"], + data = [ + "data/box.dae", + "data/box.fbx", + "data/box.glb", + "data/box.mtl", + "data/box.obj", + ], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, + deps = [ + GZ_ROOT + "common", + GZ_ROOT + "common/graphics", + GZ_ROOT + "common/testing", + "@gtest//:gtest_main", ], - includes = ["."], - visibility = ["//visibility:public"], ) exports_files(["data"]) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel new file mode 100644 index 000000000..ac9111cd3 --- /dev/null +++ b/testing/BUILD.bazel @@ -0,0 +1,69 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_ROOT", + "gz_export_header", +) + +gz_export_header( + name = "include/gz/common/testing/Export.hh", + export_base = "GZ_COMMON_TESTING", + lib_name = "gz-common-testing", + visibility = ["//visibility:private"], +) + +public_headers = glob([ + "include/gz/common/testing/*.hh", + "include/gz/common/testing/detail/*.hh", +]) + ["include/gz/common/testing/Export.hh"] + +cc_library( + name = "testing", + srcs = [ + "src/BazelTestPaths.cc", + "src/CMakeTestPaths.cc", + "src/TestPaths.cc", + "src/Utils.cc", + ], + hdrs = public_headers, + includes = ["include"], + visibility = ["//visibility:public"], + deps = [ + GZ_ROOT + "common", + ], +) + +cc_test( + name = "AutoLogFixture_TEST", + srcs = ["src/AutoLogFixture_TEST.cc"], + deps = [ + ":testing", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "BazelTestPaths_TEST", + srcs = ["src/BazelTestPaths_TEST.cc"], + data = glob(["test_files/**"]), + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, + deps = [ + ":testing", + "@gtest//:gtest_main", + ], +) + +cc_test( + name = "Utils_TEST", + srcs = ["src/Utils_TEST.cc"], + env = { + "GZ_BAZEL": "1", + "GZ_BAZEL_PATH": "common", + }, + deps = [ + ":testing", + "@gtest//:gtest_main", + ], +)