From 0445abb8c4a81c62748b723b58dd6b60928a55b1 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 9 Feb 2023 21:43:55 -0600 Subject: [PATCH] Add repo and dependencies for common Signed-off-by: Michael Carroll --- .github/actions/bazel-ci-jammy/run.sh | 13 ++-- .github/workflows/ci.yml | 2 + example/bazel.repos | 4 ++ workspace/assimp/BUILD.bazel | 3 + workspace/assimp/package.BUILD.bazel | 21 +++++++ workspace/assimp/repository.bzl | 30 +++++++++ workspace/default.bzl | 28 ++++++++- workspace/ffmpeg/BUILD.bazel | 3 + workspace/ffmpeg/package.BUILD.bazel | 84 +++++++++++++++++++++++++ workspace/ffmpeg/repository.bzl | 36 +++++++++++ workspace/freeimage/BUILD.bazel | 3 + workspace/freeimage/package.BUILD.bazel | 17 +++++ workspace/freeimage/repository.bzl | 30 +++++++++ workspace/gdal/BUILD.bazel | 3 + workspace/gdal/package.BUILD.bazel | 15 +++++ workspace/gdal/repository.bzl | 30 +++++++++ workspace/glib/BUILD.bazel | 0 workspace/glib/package.BUILD.bazel | 25 ++++++++ workspace/glib/repository.bzl | 31 +++++++++ workspace/gts/BUILD.bazel | 3 + workspace/gts/package.BUILD.bazel | 21 +++++++ workspace/gts/repository.bzl | 31 +++++++++ workspace/tinyxml2/BUILD.bazel | 0 workspace/tinyxml2/package.BUILD.bazel | 17 +++++ workspace/tinyxml2/repository.bzl | 30 +++++++++ workspace/uuid/BUILD.bazel | 3 + workspace/uuid/package.BUILD.bazel | 14 +++++ workspace/uuid/repository.bzl | 33 ++++++++++ 28 files changed, 521 insertions(+), 9 deletions(-) create mode 100644 workspace/assimp/BUILD.bazel create mode 100644 workspace/assimp/package.BUILD.bazel create mode 100644 workspace/assimp/repository.bzl create mode 100644 workspace/ffmpeg/BUILD.bazel create mode 100644 workspace/ffmpeg/package.BUILD.bazel create mode 100644 workspace/ffmpeg/repository.bzl create mode 100644 workspace/freeimage/BUILD.bazel create mode 100644 workspace/freeimage/package.BUILD.bazel create mode 100644 workspace/freeimage/repository.bzl create mode 100644 workspace/gdal/BUILD.bazel create mode 100644 workspace/gdal/package.BUILD.bazel create mode 100644 workspace/gdal/repository.bzl create mode 100644 workspace/glib/BUILD.bazel create mode 100644 workspace/glib/package.BUILD.bazel create mode 100644 workspace/glib/repository.bzl create mode 100644 workspace/gts/BUILD.bazel create mode 100644 workspace/gts/package.BUILD.bazel create mode 100644 workspace/gts/repository.bzl create mode 100644 workspace/tinyxml2/BUILD.bazel create mode 100644 workspace/tinyxml2/package.BUILD.bazel create mode 100644 workspace/tinyxml2/repository.bzl create mode 100644 workspace/uuid/BUILD.bazel create mode 100644 workspace/uuid/package.BUILD.bazel create mode 100644 workspace/uuid/repository.bzl diff --git a/.github/actions/bazel-ci-jammy/run.sh b/.github/actions/bazel-ci-jammy/run.sh index a1fcd77..ecd0276 100755 --- a/.github/actions/bazel-ci-jammy/run.sh +++ b/.github/actions/bazel-ci-jammy/run.sh @@ -13,6 +13,7 @@ SOURCE_DEPENDENCIES="`pwd`/.github/ci/dependencies.yaml" SOURCE_DEPENDENCIES_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/dependencies.yaml" cd "$GITHUB_WORKSPACE" +mkdir -p ${GITHUB_WORKSPACE}/bazel-testlogs # Restore cache if [ ! -d "$BAZEL_CACHE" ]; then @@ -29,6 +30,7 @@ chmod +x ${BAZEL} # Import repos mkdir -p ${WORKSPACE}/bazel + cd ${WORKSPACE} shopt -s extglob # Copy relevant bazel files into the build space @@ -57,13 +59,10 @@ ${BAZEL} build $BAZEL_ARGS echo ::endgroup:: echo ::group::Bazel test -${BAZEL} test $BAZEL_ARGS +EXIT_CODE=0 +${BAZEL} test $BAZEL_ARGS || EXIT_CODE=$? echo ::endgroup:: -echo ::group::Bazel test -ls -la ${WORKSPACE} -ls -la ${WORKSPACE}/bazel-testlogs -ls -la ${BAZEL_CACHE} -echo ::endgroup:: +cp -RL ${WORKSPACE}/bazel-testlogs/* ${GITHUB_WORKSPACE}/bazel-testlogs/ -cp -RL ${WORKSPACE}/bazel-testlogs ${GITHUB_WORKSPACE}/bazel-testlogs +exit $EXIT_CODE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 210fa6c..6876971 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: ${{ github.workspace }}/bazel_cache key: cache-bazel-${{ hashFiles('example/bazel.repos') }} restore-keys: | + cache-bazel-${{ hashFiles('example/bazel.repos') }} cache-bazel- - name: Compile and test @@ -36,6 +37,7 @@ jobs: - name: 'Upload Test Logs' uses: actions/upload-artifact@v3 + if: success() || failure() with: name: bazel-testlogs path: ${{ github.workspace }}/bazel-testlogs diff --git a/example/bazel.repos b/example/bazel.repos index 89a197c..46e7487 100644 --- a/example/bazel.repos +++ b/example/bazel.repos @@ -1,4 +1,8 @@ repositories: + common: + type: git + url: https://github.com/gazebosim/gz-common + version: mjcarroll/garden_bazel math: type: git url: https://github.com/gazebosim/gz-math diff --git a/workspace/assimp/BUILD.bazel b/workspace/assimp/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/assimp/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/assimp/package.BUILD.bazel b/workspace/assimp/package.BUILD.bazel new file mode 100644 index 0000000..7518485 --- /dev/null +++ b/workspace/assimp/package.BUILD.bazel @@ -0,0 +1,21 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["notice"]) + +cc_library( + name = "assimp", + hdrs = glob([ + "include/assimp/*.h", + "include/assimp/Compiler/*.h", + "include/assimp/*.inl", + ]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lassimp", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/assimp/repository.bzl b/workspace/assimp/repository.bzl new file mode 100644 index 0000000..8a5895c --- /dev/null +++ b/workspace/assimp/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/assimp/", "include/assimp/") + + # 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/assimp:package.BUILD.bazel"), + "BUILD.bazel", + ) + +assimp_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/default.bzl b/workspace/default.bzl index 358850c..a396152 100644 --- a/workspace/default.bzl +++ b/workspace/default.bzl @@ -2,13 +2,21 @@ load("@gz//bazel/workspace:mirrors.bzl", "DEFAULT_MIRRORS") load("@gz//bazel/workspace:os.bzl", "os_repository") +load("@gz//bazel/workspace/assimp:repository.bzl", "assimp_repository") # noqa load("@gz//bazel/workspace/bazel_skylib:repository.bzl", "bazel_skylib_repository") # noqa load("@gz//bazel/workspace/buildifier:repository.bzl", "buildifier_repository") # noqa load("@gz//bazel/workspace/cli11:repository.bzl", "cli11_repository") # noqa load("@gz//bazel/workspace/eigen3:repository.bzl", "eigen3_repository") # noqa +load("@gz//bazel/workspace/ffmpeg:repository.bzl", "ffmpeg_repository") # noqa +load("@gz//bazel/workspace/freeimage:repository.bzl", "freeimage_repository") # noqa +load("@gz//bazel/workspace/gdal:repository.bzl", "gdal_repository") # noqa +load("@gz//bazel/workspace/glib:repository.bzl", "glib_repository") # noqa load("@gz//bazel/workspace/gtest:repository.bzl", "gtest_repository") # noqa +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_python:repository.bzl", "rules_python_repository") # noqa +load("@gz//bazel/workspace/tinyxml2:repository.bzl", "tinyxml2_repository") # noqa +load("@gz//bazel/workspace/uuid:repository.bzl", "uuid_repository") # noqa def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): """Declares workspace repositories for all externals needed by drake (other @@ -19,20 +27,36 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS): be useful if a WORKSPACE file has already supplied its own external of a given name. """ + if "assimp" not in excludes: + assimp_repository(name = "assimp") if "bazel_skylib" not in excludes: bazel_skylib_repository(name = "bazel_skylib", mirrors = mirrors) if "buildifier" not in excludes: buildifier_repository(name = "buildifier", mirrors = mirrors) if "cli11" not in excludes: cli11_repository(name = "cli11", mirrors = mirrors) - if "gtest" not in excludes: - gtest_repository(name = "gtest", mirrors = mirrors) if "eigen3" not in excludes: eigen3_repository(name = "eigen3") + if "ffmpeg" not in excludes: + ffmpeg_repository(name = "ffmpeg") + if "freeimage" not in excludes: + freeimage_repository(name = "freeimage") + if "gdal" not in excludes: + gdal_repository(name = "gdal") + if "glib" not in excludes: + glib_repository(name = "glib") + if "gtest" not in excludes: + gtest_repository(name = "gtest", mirrors = mirrors) + if "gts" not in excludes: + gts_repository(name = "gts") if "pycodestyle" not in excludes: pycodestyle_repository(name = "pycodestyle", mirrors = mirrors) if "rules_python" not in excludes: rules_python_repository(name = "rules_python", mirrors = mirrors) + if "tinyxml2" not in excludes: + tinyxml2_repository(name = "tinyxml2") + if "uuid" not in excludes: + uuid_repository(name = "uuid") def add_default_toolchains(excludes = []): """Register toolchains for each language (e.g., "py") not explicitly diff --git a/workspace/ffmpeg/BUILD.bazel b/workspace/ffmpeg/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/ffmpeg/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/ffmpeg/package.BUILD.bazel b/workspace/ffmpeg/package.BUILD.bazel new file mode 100644 index 0000000..0bb7deb --- /dev/null +++ b/workspace/ffmpeg/package.BUILD.bazel @@ -0,0 +1,84 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["restricted"]) # LGPL-2.0+ + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "libavcodec", + hdrs = glob(["include/libavcodec/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavcodec", + ], +) + +cc_library( + name = "libavdevice", + hdrs = glob(["include/libavdevice/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavdevice", + ], +) + +cc_library( + name = "libavfilter", + hdrs = glob(["include/libavfilter/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavfilter", + ], +) + +cc_library( + name = "libavformat", + hdrs = glob(["include/libavformat/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavformat", + ], +) + +cc_library( + name = "libavresample", + hdrs = glob(["include/libavresample/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavresample", + ], +) + +cc_library( + name = "libswscale", + hdrs = glob(["include/libswscale/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lswscale", + ], +) + +cc_library( + name = "libavutil", + hdrs = glob(["include/libavutil/*.h"]), + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lavutil", + ], +) diff --git a/workspace/ffmpeg/repository.bzl b/workspace/ffmpeg/repository.bzl new file mode 100644 index 0000000..7741e7f --- /dev/null +++ b/workspace/ffmpeg/repository.bzl @@ -0,0 +1,36 @@ +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/x86_64-linux-gnu/libavcodec", "include/libavcodec") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libavdevice", "include/libavdevice") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libavfilter", "include/libavfilter") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libavformat", "include/libavformat") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libswresample", "include/libswresample") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libavutil", "include/libavutil") # noqa + repository_ctx.symlink("/usr/include/x86_64-linux-gnu/libswscale", "include/libswscale") # 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/ffmpeg:package.BUILD.bazel"), + "BUILD.bazel", + ) + +ffmpeg_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/freeimage/BUILD.bazel b/workspace/freeimage/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/freeimage/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/freeimage/package.BUILD.bazel b/workspace/freeimage/package.BUILD.bazel new file mode 100644 index 0000000..a76868f --- /dev/null +++ b/workspace/freeimage/package.BUILD.bazel @@ -0,0 +1,17 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["restricted"]) # GPL-2.0+ + +cc_library( + name = "freeimage", + hdrs = ["include/FreeImage.h"], + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lfreeimage", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/freeimage/repository.bzl b/workspace/freeimage/repository.bzl new file mode 100644 index 0000000..b941302 --- /dev/null +++ b/workspace/freeimage/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/FreeImage.h", "include/FreeImage.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/freeimage:package.BUILD.bazel"), + "BUILD.bazel", + ) + +freeimage_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/gdal/BUILD.bazel b/workspace/gdal/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/gdal/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/gdal/package.BUILD.bazel b/workspace/gdal/package.BUILD.bazel new file mode 100644 index 0000000..b198bb6 --- /dev/null +++ b/workspace/gdal/package.BUILD.bazel @@ -0,0 +1,15 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +cc_library( + name = "gdal", + hdrs = glob(["include/gdal/*.h"]), + includes = ["include/gdal"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lgdal", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/gdal/repository.bzl b/workspace/gdal/repository.bzl new file mode 100644 index 0000000..be4d0dc --- /dev/null +++ b/workspace/gdal/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" + repository_ctx.symlink("/usr/include/gdal", "include/gdal") + + # 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/gdal:package.BUILD.bazel"), + "BUILD.bazel", + ) + +gdal_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/glib/BUILD.bazel b/workspace/glib/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/workspace/glib/package.BUILD.bazel b/workspace/glib/package.BUILD.bazel new file mode 100644 index 0000000..fdb3d57 --- /dev/null +++ b/workspace/glib/package.BUILD.bazel @@ -0,0 +1,25 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["restricted"]) # LGPL-2.0+ + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "glib", + hdrs = glob([ + "include/glibconfig.h", + "include/glib-2.0/*.h", + "include/glib-2.0/**/*.h", + ]), + includes = ["include", "include/glib-2.0"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lglib-2.0", + "-lgobject-2.0", + "-lgio-2.0", + "-lgthread-2.0", + ], +) diff --git a/workspace/glib/repository.bzl b/workspace/glib/repository.bzl new file mode 100644 index 0000000..c06995a --- /dev/null +++ b/workspace/glib/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/glib-2.0/", "include/glib-2.0/") + repository_ctx.symlink(libdir + "/glib-2.0/include/glibconfig.h", "include/glibconfig.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/glib:package.BUILD.bazel"), + "BUILD.bazel", + ) + +glib_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/gts/BUILD.bazel b/workspace/gts/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/gts/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/gts/package.BUILD.bazel b/workspace/gts/package.BUILD.bazel new file mode 100644 index 0000000..b3d9166 --- /dev/null +++ b/workspace/gts/package.BUILD.bazel @@ -0,0 +1,21 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["restricted"]) # LGPL-2.0+ + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "gts", + hdrs = ["include/gts.h", "include/gtsconfig.h"], + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-lgts", + ], + deps = [ + "@glib", + ], +) diff --git a/workspace/gts/repository.bzl b/workspace/gts/repository.bzl new file mode 100644 index 0000000..4fda171 --- /dev/null +++ b/workspace/gts/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/gts.h", "include/gts.h") + repository_ctx.symlink("/usr/include/gtsconfig.h", "include/gtsconfig.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/gts:package.BUILD.bazel"), + "BUILD.bazel", + ) + +gts_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/tinyxml2/BUILD.bazel b/workspace/tinyxml2/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/workspace/tinyxml2/package.BUILD.bazel b/workspace/tinyxml2/package.BUILD.bazel new file mode 100644 index 0000000..4f4ef87 --- /dev/null +++ b/workspace/tinyxml2/package.BUILD.bazel @@ -0,0 +1,17 @@ +# -*- python -*- + +load(":vars.bzl", "LIBDIR") + +licenses(["notice"]) # Zlib + +cc_library( + name = "tinyxml2", + hdrs = ["include/tinyxml2.h"], + includes = ["include"], + linkopts = [ + "-L" + LIBDIR, + "-Wl,-rpath," + LIBDIR, + "-ltinyxml2", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/tinyxml2/repository.bzl b/workspace/tinyxml2/repository.bzl new file mode 100644 index 0000000..422c20a --- /dev/null +++ b/workspace/tinyxml2/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/tinyxml2.h", "include/tinyxml2.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/tinyxml2:package.BUILD.bazel"), + "BUILD.bazel", + ) + +tinyxml2_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +) diff --git a/workspace/uuid/BUILD.bazel b/workspace/uuid/BUILD.bazel new file mode 100644 index 0000000..1f52546 --- /dev/null +++ b/workspace/uuid/BUILD.bazel @@ -0,0 +1,3 @@ +load("@gz//bazel/lint:lint.bzl", "add_lint_tests") + +add_lint_tests() diff --git a/workspace/uuid/package.BUILD.bazel b/workspace/uuid/package.BUILD.bazel new file mode 100644 index 0000000..d2107e6 --- /dev/null +++ b/workspace/uuid/package.BUILD.bazel @@ -0,0 +1,14 @@ +# -*- python -*- + +licenses(["notice"]) # SGI-B-2.0 + +cc_library( + name = "uuid", + hdrs = glob(["include/**/*.h"]), + includes = ["include"], + linkopts = [ + "-L/usr/lib/x86_64-linux-gnu", + "-luuid", + ], + visibility = ["//visibility:public"], +) diff --git a/workspace/uuid/repository.bzl b/workspace/uuid/repository.bzl new file mode 100644 index 0000000..001fda6 --- /dev/null +++ b/workspace/uuid/repository.bzl @@ -0,0 +1,33 @@ +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 or os_result.is_manylinux: + build_flavor = "ubuntu" + hdrs = [ + "uuid/uuid.h", + ] + for hdr in hdrs: + repository_ctx.symlink( + "/usr/include/{}".format(hdr), + "include/{}".format(hdr), + ) + else: + fail("Operating system is NOT supported {}".format(os_result)) + + repository_ctx.symlink( + Label( + "@gz//bazel/workspace/uuid:package.BUILD.bazel", + ), + "BUILD.bazel", + ) + +uuid_repository = repository_rule( + local = True, + configure = True, + implementation = _impl, +)