diff --git a/.bazeliskrc b/.bazeliskrc new file mode 100644 index 0000000..69d6164 --- /dev/null +++ b/.bazeliskrc @@ -0,0 +1,2 @@ +# See https://github.com/bazelbuild/bazelisk +USE_BAZEL_VERSION=latest diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..694f59b --- /dev/null +++ b/.bazelrc @@ -0,0 +1,3 @@ +common --enable_bzlmod + +common --lockfile_mode=off diff --git a/.gitignore b/.gitignore index 62b9898..39555d6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,9 @@ build_* # OS generated files .DS_Store *.swp + +# Bazel generated files +bazel-bin/ +bazel-out/ +bazel-testlogs/ +bazel-* diff --git a/BUILD.bazel b/BUILD.bazel index cafd9c2..70932ca 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,18 +1,9 @@ -load( - "@gz//bazel/skylark:build_defs.bzl", - "GZ_FEATURES", - "GZ_ROOT", - "GZ_VISIBILITY", - "gz_configure_header", - "gz_export_header", - "gz_include_header", -) +load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test") +load("@rules_gz//gz:headers.bzl", "gz_configure_header", "gz_export_header", "gz_include_header") load("@rules_license//rules:license.bzl", "license") package( - default_applicable_licenses = [GZ_ROOT + "utils:license"], - default_visibility = GZ_VISIBILITY, - features = GZ_FEATURES, + default_applicable_licenses = [":license"], ) license( @@ -20,9 +11,10 @@ license( package_name = "gz-utils", ) -licenses(["notice"]) - -exports_files(["LICENSE"]) +exports_files([ + "LICENSE", + "MODULE.bazel", +]) gz_configure_header( name = "config", @@ -41,6 +33,7 @@ gz_export_header( public_headers_no_gen = glob([ "include/gz/utils/*.hh", "include/gz/utils/detail/*.hh", + "include/gz/utils/detail/*.h", ]) gz_include_header( @@ -59,11 +52,12 @@ public_headers = public_headers_no_gen + [ ] cc_library( - name = "utils", + name = "gz-utils", srcs = ["src/Environment.cc"], hdrs = public_headers, copts = ["-fexceptions"], includes = ["include"], + visibility = ["//visibility:public"], ) # Tests @@ -76,7 +70,7 @@ cc_library( "test/integration/implptr/implptr_test_classes.hh", ], includes = ["test/integration/implptr"], - deps = [":utils"], + deps = [":gz-utils"], ) cc_test( @@ -85,8 +79,7 @@ cc_test( srcs = ["test/integration/implptr/ImplPtr_TEST.cc"], deps = [ ":implptr_test_classes", - "@gtest", - "@gtest//:gtest_main", + "@googletest//:gtest_main", ], ) @@ -94,9 +87,8 @@ cc_test( name = "Environment_TEST", srcs = ["src/Environment_TEST.cc"], deps = [ - ":utils", - "@gtest", - "@gtest//:gtest_main", + ":gz-utils", + "@googletest//:gtest_main", ], ) @@ -105,8 +97,43 @@ cc_test( srcs = ["src/NeverDestroyed_TEST.cc"], copts = ["-fexceptions"], deps = [ - ":utils", - "@gtest", - "@gtest//:gtest_main", + ":gz-utils", + "@googletest//:gtest_main", + ], +) + +cc_binary( + name = "subprocess_main", + srcs = ["test/integration/subprocess/subprocess_main.cc"], + deps = [ + ":gz-utils", + "//cli", + ], +) + +cc_test( + name = "subprocess_TEST", + srcs = ["test/integration/subprocess_TEST.cc"], + local_defines = ['SUBPROCESS_EXECUTABLE_PATH=\\"subprocess_main\\"'], + deps = [ + ":gz-utils", + ":subprocess_main", + "@googletest//:gtest_main", ], ) + +buildifier( + name = "buildifier.fix", + exclude_patterns = ["./.git/*"], + lint_mode = "fix", + mode = "fix", +) + +buildifier_test( + name = "buildifier.test", + exclude_patterns = ["./.git/*"], + lint_mode = "warn", + mode = "diff", + no_sandbox = True, + workspace = "//:MODULE.bazel", +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..c6cec9f --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,14 @@ +## MODULE.bazel +module( + name = "gz-utils", + repo_name = "org_gazebosim_gz-utils", +) + +bazel_dep(name = "buildifier_prebuilt", version = "6.1.2") +bazel_dep(name = "googletest", version = "1.14.0") +bazel_dep(name = "rules_license", version = "0.0.8") +bazel_dep(name = "rules_gz") +local_path_override( + module_name = "rules_gz", + path = "/usr/local/google/home/mjcarroll/workspaces/gz_ionic_bazel/rules_gz", +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/cli/BUILD.bazel b/cli/BUILD.bazel index b97bc2d..b7d1260 100644 --- a/cli/BUILD.bazel +++ b/cli/BUILD.bazel @@ -1,12 +1,7 @@ -load( - "@gz//bazel/skylark:build_defs.bzl", - "GZ_ROOT", - "GZ_VISIBILITY", -) load("@rules_license//rules:license.bzl", "license") package( - default_applicable_licenses = [GZ_ROOT + "utils/cli:license"], + default_applicable_licenses = ["//cli:license"], ) license( @@ -17,7 +12,7 @@ license( public_headers = [ "include/gz/utils/cli/GzFormatter.hpp", ] + glob([ - "include/external-cli/gz/utils/cli/*.hpp", + "include/vendored-cli/gz/utils/cli/*.hpp", ]) cc_library( @@ -26,11 +21,19 @@ cc_library( copts = ["-fexceptions"], includes = [ "include", - "include/external-cli", + "include/vendored-cli", + ], + visibility = ["//visibility:public"], + deps = [ + "//:gz-utils", ], - visibility = GZ_VISIBILITY, +) + +cc_test( + name = "cli_TEST", + srcs = ["src/cli_TEST.cc"], deps = [ - GZ_ROOT + "utils:utils", - "@cli11" + ":cli", + "@googletest//:gtest_main", ], )