Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repo and dependencies for math #46

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions example/bazel.repos
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
repositories:
math:
type: git
url: https://github.com/gazebosim/gz-math
version: gz-math7
utils:
type: git
url: https://github.com/gazebosim/gz-utils
Expand Down
3 changes: 3 additions & 0 deletions workspace/default.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@gz//bazel/workspace:os.bzl", "os_repository")
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/gtest:repository.bzl", "gtest_repository") # noqa
load("@gz//bazel/workspace/pycodestyle:repository.bzl", "pycodestyle_repository") # noqa
load("@gz//bazel/workspace/rules_python:repository.bzl", "rules_python_repository") # noqa
Expand All @@ -26,6 +27,8 @@ def add_default_repositories(excludes = [], mirrors = DEFAULT_MIRRORS):
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 "pycodestyle" not in excludes:
pycodestyle_repository(name = "pycodestyle", mirrors = mirrors)
if "rules_python" not in excludes:
Expand Down
3 changes: 3 additions & 0 deletions workspace/eigen3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("@gz//bazel/lint:lint.bzl", "add_lint_tests")

add_lint_tests()
56 changes: 56 additions & 0 deletions workspace/eigen3/package.BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Description:
# Eigen is a C++ template library for linear algebra: vectors,
# matrices, and related algorithms.

licenses([
# Note: Eigen is an MPL2 library that includes GPL v3 and LGPL v2.1+ code.
# We've taken special care to not reference any restricted code.
"reciprocal", # MPL2
"notice", # Portions BSD
])

exports_files(["COPYING.MPL2"])

EIGEN_FILES = [
"include/eigen3/Eigen/**",
"include/eigen3/unsupported/Eigen/CXX11/**",
"include/eigen3/unsupported/Eigen/FFT",
"include/eigen3/unsupported/Eigen/KroneckerProduct",
"include/eigen3/unsupported/Eigen/src/FFT/**",
"include/eigen3/unsupported/Eigen/src/KroneckerProduct/**",
"include/eigen3/unsupported/Eigen/MatrixFunctions",
"include/eigen3/unsupported/Eigen/SpecialFunctions",
"include/eigen3/unsupported/Eigen/src/MatrixFunctions/**",
"include/eigen3/unsupported/Eigen/src/SpecialFunctions/**",
]

# List of files picked up by glob but actually part of another target.
EIGEN_EXCLUDE_FILES = [
"include/eigen3/Eigen/src/Core/arch/AVX/PacketMathGoogleTest.cc",
]

EIGEN_MPL2_HEADER_FILES = glob(
EIGEN_FILES,
exclude = EIGEN_EXCLUDE_FILES,
)

cc_library(
name = "eigen3",
hdrs = EIGEN_MPL2_HEADER_FILES,
includes = ["include/eigen3"],
visibility = ["//visibility:public"],
)
23 changes: 23 additions & 0 deletions workspace/eigen3/repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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:
repository_ctx.symlink("/usr/include/eigen3/Eigen", "include/eigen3/Eigen") # noqa
repository_ctx.symlink("/usr/include/eigen3/unsupported", "include/eigen3/unsupported") # noqa

# Add the BUILD file.
repository_ctx.symlink(
Label("@gz//bazel/workspace/eigen3:package.BUILD.bazel"),
"BUILD.bazel",
)

eigen3_repository = repository_rule(
local = True,
configure = True,
implementation = _impl,
)