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

bzlmod support #1499

Merged
merged 9 commits into from
Nov 12, 2024
794 changes: 783 additions & 11 deletions BUILD.bazel

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions src/Actor_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "sdf/Actor.hh"
#include "sdf/Plugin.hh"

#include <filesystem>

/////////////////////////////////////////////////
sdf::Animation CreateDummyAnimation()
{
Expand Down Expand Up @@ -511,9 +509,6 @@ TEST(DOMActor, ToElement)
{
sdf::Actor actor;

// Output the current working directory
std::cout << std::filesystem::current_path() << std::endl;

actor.SetName("my-actor");
actor.SetRawPose(gz::math::Pose3d(1, 2, 3, 0.1, 0.2, 0.3));
actor.SetSkinFilename("my-skinfilename");
Expand Down
4 changes: 0 additions & 4 deletions src/SDF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,9 @@ const std::string &SDF::EmbeddedSpec(
const std::string &SDF::EmbeddedSpec(
sdf::Errors &_errors, const std::string &_filename)
{

try
{
const std::string pathname = SDF::Version() + "/" + _filename;

std::cout << "Reading: " << pathname << std::endl;

return GetEmbeddedSdf().at(pathname);
}
catch(const std::out_of_range &)
Expand Down
8 changes: 5 additions & 3 deletions src/SDF_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
#include <any>
#include <filesystem>

#include <gz/math.hh>
#include <gz/math/Color.hh>
#include <gz/math/Pose3.hh>
#include <gz/math/Vector2.hh>
#include <gz/math/Vector3.hh>
#include <gz/utils/Environment.hh>
#include <gz/utils/SuppressWarning.hh>

#include "sdf/parser.hh"
#include "test_config.hh"
#include "test_utils.hh"

#include "sdf/sdf.hh"

class SDFUpdateFixture
{
public: std::string GetName() const {return this->name;}
Expand Down
10 changes: 8 additions & 2 deletions src/Sensor_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
*/

#include <gtest/gtest.h>
#include "sdf/Noise.hh"
#include "sdf/AirPressure.hh"
#include "sdf/Altimeter.hh"
#include "sdf/Camera.hh"
#include "sdf/ForceTorque.hh"
#include "sdf/Imu.hh"
#include "sdf/Lidar.hh"
#include "sdf/Magnetometer.hh"
#include "sdf/sdf.hh"
#include "sdf/NavSat.hh"
#include "sdf/Noise.hh"
#include "sdf/Sensor.hh"

/////////////////////////////////////////////////
Expand Down
21 changes: 19 additions & 2 deletions src/bazel/InstallationDirectories.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
// Generate an installation directories file for bazel specifically
/*
* Copyright (C) 2024 Open Source Robotics Foundation
*
* 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.
*
*/

#include <sdf/InstallationDirectories.hh>

Expand All @@ -7,9 +22,11 @@ namespace sdf

inline namespace SDF_VERSION_NAMESPACE {

// Generate an install prefix specifically for bazel build.
std::string getInstallPrefix()
{
return ".";
}
} // namespace SDF_VERSION_NAMESPACE
} // namespace sdf
} // namespace sdf

1 change: 0 additions & 1 deletion src/parser_urdf_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <list>

#include "sdf/sdf.hh"
#include "parser_urdf.hh"
#include "test_utils.hh"

Expand Down
5 changes: 5 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ cc_library(
includes = ["."],
visibility = ["//:__subpackages__"],
)

exports_files([
"sdf",
"integration/model",
])
7 changes: 2 additions & 5 deletions test/test_config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ namespace sdf
/// \return True if directory is set correctly, false otherwise
bool ProjectSourcePath(std::string &_sourceDir)
{
std::string bazel_path;
// Bazel builds set TEST_SRCDIR
if(gz::utils::env("TEST_SRCDIR", _sourceDir) &&
gz::utils::env("GZ_BAZEL_PATH", bazel_path))
if(gz::utils::env("TEST_SRCDIR", _sourceDir))
{
_sourceDir = sdf::filesystem::append(
_sourceDir, "gz", bazel_path);
_sourceDir = sdf::filesystem::append(_sourceDir, "_main");
return true;
}
else
Expand Down
Loading