diff --git a/example/bazel.repos b/example/bazel.repos index 350eaab..bfae723 100644 --- a/example/bazel.repos +++ b/example/bazel.repos @@ -19,6 +19,10 @@ repositories: type: git url: https://github.com/gazebosim/sdformat version: mjcarroll/garden_bazel + transport: + type: git + url: https://github.com/gazebosim/gz-transport + version: mjcarroll/garden_bazel utils: type: git url: https://github.com/gazebosim/gz-utils diff --git a/workspace/default.bzl b/workspace/default.bzl index 71d79d8..b623028 100644 --- a/workspace/default.bzl +++ b/workspace/default.bzl @@ -16,8 +16,10 @@ load("@gz//bazel/workspace/gts:repository.bzl", "gts_repository") # noqa load("@gz//bazel/workspace/pycodestyle:repository.bzl", "pycodestyle_repository") # noqa load("@gz//bazel/workspace/rules_proto:repository.bzl", "rules_proto_repository") # noqa load("@gz//bazel/workspace/rules_python:repository.bzl", "rules_python_repository") # noqa +load("@gz//bazel/workspace/sqlite3:repository.bzl", "sqlite3_repository") # noqa load("@gz//bazel/workspace/tinyxml2:repository.bzl", "tinyxml2_repository") # noqa load("@gz//bazel/workspace/uuid:repository.bzl", "uuid_repository") # noqa +load("@gz//bazel/workspace/zmq:repository.bzl", "zmq_repository") # noqa def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): """Declares workspace repositories for all externals needed by drake (other @@ -56,10 +58,14 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): rules_proto_repository(name = "rules_proto", mirrors = mirrors) if "rules_python" not in excludes: rules_python_repository(name = "rules_python", mirrors = mirrors) + if "sqlite3" not in excludes: + sqlite3_repository(name = "sqlite3") if "tinyxml2" not in excludes: tinyxml2_repository(name = "tinyxml2") if "uuid" not in excludes: uuid_repository(name = "uuid") + if "zmq" not in excludes: + zmq_repository(name = "zmq") def add_default_toolchains(excludes = []): """Register toolchains for each language (e.g., "py") not explicitly diff --git a/workspace/sqlite3/BUILD.bazel b/workspace/sqlite3/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/workspace/sqlite3/package.BUILD.bazel b/workspace/sqlite3/package.BUILD.bazel new file mode 100644 index 0000000..5d2f875 --- /dev/null +++ b/workspace/sqlite3/package.BUILD.bazel @@ -0,0 +1,17 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +cc_library( + name = "sqlite3", + hdrs = glob([ + "include/sqlite3.h", + ]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lsqlite3", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/sqlite3/repository.bzl b/workspace/sqlite3/repository.bzl new file mode 100644 index 0000000..df0836f --- /dev/null +++ b/workspace/sqlite3/repository.bzl @@ -0,0 +1,30 @@ +load("@gz//bazel/workspace:os.bzl", "determine_os") + +def _impl(repository_ctx): + os_result = determine_os(repository_ctx) + + if os_result.error != None: + fail(os_result.error) + + if os_result.is_ubuntu: + libdir = "/usr/lib/x86_64-linux-gnu" + repository_ctx.symlink("/usr/include/sqlite3.h", "include/sqlite3.h") + + # Declare the libdir + repository_ctx.file( + "vars.bzl", + content = "LIBDIR = \"{}\"\n".format(libdir), + executable = False, + ) + + # Add the BUILD file. + repository_ctx.symlink( + Label("@gz//bazel/workspace/sqlite3:package.BUILD.bazel"), + "BUILD.bazel", + ) + +sqlite3_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/tinyxml2/BUILD.bazel b/workspace/tinyxml2/BUILD.bazel index e69de29..1f52546 100644 --- a/workspace/tinyxml2/BUILD.bazel +++ b/workspace/tinyxml2/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/zmq/BUILD.bazel b/workspace/zmq/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/zmq/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/zmq/package.BUILD.bazel b/workspace/zmq/package.BUILD.bazel new file mode 100644 index 0000000..3c01518 --- /dev/null +++ b/workspace/zmq/package.BUILD.bazel @@ -0,0 +1,17 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +cc_library( + name = "zmq", + hdrs = glob([ + "include/zmq.h", + ]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lzmq", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/zmq/repository.bzl b/workspace/zmq/repository.bzl new file mode 100644 index 0000000..2568cdf --- /dev/null +++ b/workspace/zmq/repository.bzl @@ -0,0 +1,31 @@ +load("@gz//bazel/workspace:os.bzl", "determine_os") + +def _impl(repository_ctx): + os_result = determine_os(repository_ctx) + + if os_result.error != None: + fail(os_result.error) + + if os_result.is_ubuntu: + libdir = "/usr/lib/x86_64-linux-gnu" + repository_ctx.symlink("/usr/include/zmq.h", "include/zmq.h") + repository_ctx.symlink("/usr/include/zmq_utils.h", "include/zmq_utils.h") # noqa + + # Declare the libdir + repository_ctx.file( + "vars.bzl", + content = "LIBDIR = \"{}\"\n".format(libdir), + executable = False, + ) + + # Add the BUILD file. + repository_ctx.symlink( + Label("@gz//bazel/workspace/zmq:package.BUILD.bazel"), + "BUILD.bazel", + ) + +zmq_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +)