mirror of
https://github.com/wentasah/ros2nix.git
synced 2025-06-09 07:42:23 +03:00
Add ROS workspace that will be used by our planned test suite
This commit is contained in:
parent
a850550783
commit
b2de70cc66
9 changed files with 250 additions and 0 deletions
33
test/ws/flake.nix
Normal file
33
test/ws/flake.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
inputs = {
|
||||
nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master";
|
||||
nixpkgs.follows = "nix-ros-overlay/nixpkgs"; # IMPORTANT!!!
|
||||
};
|
||||
outputs = { self, nix-ros-overlay, nixpkgs }:
|
||||
nix-ros-overlay.inputs.flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ nix-ros-overlay.overlays.default ];
|
||||
};
|
||||
in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "Example project";
|
||||
packages = [
|
||||
pkgs.colcon
|
||||
# ... other non-ROS packages
|
||||
(with pkgs.rosPackages.humble; buildEnv {
|
||||
paths = [
|
||||
ros-core
|
||||
ament-cmake-core
|
||||
# ... other ROS packages
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
});
|
||||
nixConfig = {
|
||||
extra-substituters = [ "https://ros.cachix.org" ];
|
||||
extra-trusted-public-keys = [ "ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=" ];
|
||||
};
|
||||
}
|
60
test/ws/src/library/CMakeLists.txt
Normal file
60
test/ws/src/library/CMakeLists.txt
Normal file
|
@ -0,0 +1,60 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
project(library)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
# find dependencies
|
||||
find_package(ament_cmake REQUIRED)
|
||||
find_package(ament_cmake_ros REQUIRED)
|
||||
# uncomment the following section in order to fill in
|
||||
# further dependencies manually.
|
||||
# find_package(<dependency> REQUIRED)
|
||||
|
||||
add_library(library src/library.cpp)
|
||||
add_library(library::library ALIAS library)
|
||||
target_compile_features(library PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
|
||||
target_include_directories(library PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
|
||||
|
||||
# Causes the visibility macros to use dllexport rather than dllimport,
|
||||
# which is appropriate when building the dll but not consuming it.
|
||||
target_compile_definitions(library PRIVATE "LIBRARY_BUILDING_LIBRARY")
|
||||
|
||||
install(
|
||||
DIRECTORY include/
|
||||
DESTINATION include/${PROJECT_NAME}
|
||||
)
|
||||
install(
|
||||
TARGETS library
|
||||
EXPORT export_${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(ament_lint_auto REQUIRED)
|
||||
# the following line skips the linter which checks for copyrights
|
||||
# comment the line when a copyright and license is added to all source files
|
||||
set(ament_cmake_copyright_FOUND TRUE)
|
||||
# the following line skips cpplint (only works in a git repo)
|
||||
# comment the line when this package is in a git repo and when
|
||||
# a copyright and license is added to all source files
|
||||
set(ament_cmake_cpplint_FOUND TRUE)
|
||||
ament_lint_auto_find_test_dependencies()
|
||||
endif()
|
||||
|
||||
ament_export_include_directories(
|
||||
"include/${PROJECT_NAME}"
|
||||
)
|
||||
ament_export_libraries(
|
||||
library
|
||||
)
|
||||
ament_export_targets(
|
||||
export_${PROJECT_NAME}
|
||||
)
|
||||
|
||||
ament_package()
|
19
test/ws/src/library/include/library/library.hpp
Normal file
19
test/ws/src/library/include/library/library.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef LIBRARY__LIBRARY_HPP_
|
||||
#define LIBRARY__LIBRARY_HPP_
|
||||
|
||||
#include "library/visibility_control.h"
|
||||
|
||||
namespace library
|
||||
{
|
||||
|
||||
class Library
|
||||
{
|
||||
public:
|
||||
Library();
|
||||
|
||||
virtual ~Library();
|
||||
};
|
||||
|
||||
} // namespace library
|
||||
|
||||
#endif // LIBRARY__LIBRARY_HPP_
|
35
test/ws/src/library/include/library/visibility_control.h
Normal file
35
test/ws/src/library/include/library/visibility_control.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef LIBRARY__VISIBILITY_CONTROL_H_
|
||||
#define LIBRARY__VISIBILITY_CONTROL_H_
|
||||
|
||||
// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
|
||||
// https://gcc.gnu.org/wiki/Visibility
|
||||
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
#ifdef __GNUC__
|
||||
#define LIBRARY_EXPORT __attribute__ ((dllexport))
|
||||
#define LIBRARY_IMPORT __attribute__ ((dllimport))
|
||||
#else
|
||||
#define LIBRARY_EXPORT __declspec(dllexport)
|
||||
#define LIBRARY_IMPORT __declspec(dllimport)
|
||||
#endif
|
||||
#ifdef LIBRARY_BUILDING_LIBRARY
|
||||
#define LIBRARY_PUBLIC LIBRARY_EXPORT
|
||||
#else
|
||||
#define LIBRARY_PUBLIC LIBRARY_IMPORT
|
||||
#endif
|
||||
#define LIBRARY_PUBLIC_TYPE LIBRARY_PUBLIC
|
||||
#define LIBRARY_LOCAL
|
||||
#else
|
||||
#define LIBRARY_EXPORT __attribute__ ((visibility("default")))
|
||||
#define LIBRARY_IMPORT
|
||||
#if __GNUC__ >= 4
|
||||
#define LIBRARY_PUBLIC __attribute__ ((visibility("default")))
|
||||
#define LIBRARY_LOCAL __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define LIBRARY_PUBLIC
|
||||
#define LIBRARY_LOCAL
|
||||
#endif
|
||||
#define LIBRARY_PUBLIC_TYPE
|
||||
#endif
|
||||
|
||||
#endif // LIBRARY__VISIBILITY_CONTROL_H_
|
19
test/ws/src/library/package.xml
Normal file
19
test/ws/src/library/package.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>library</name>
|
||||
<version>0.0.0</version>
|
||||
<description>Library for testing ros2nix</description>
|
||||
<maintainer email="michal.sojka@cvut.cz">Michal Sojka</maintainer>
|
||||
<license>MIT</license>
|
||||
|
||||
<buildtool_depend>ament_cmake_ros</buildtool_depend>
|
||||
<build_depend>zlib</build_depend>
|
||||
|
||||
<test_depend>ament_lint_auto</test_depend>
|
||||
<test_depend>ament_lint_common</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
15
test/ws/src/library/src/library.cpp
Normal file
15
test/ws/src/library/src/library.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "library/library.hpp"
|
||||
#include "zlib.h"
|
||||
|
||||
namespace library
|
||||
{
|
||||
|
||||
Library::Library()
|
||||
{
|
||||
}
|
||||
|
||||
Library::~Library()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace library
|
37
test/ws/src/ros_node/CMakeLists.txt
Normal file
37
test/ws/src/ros_node/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
project(ros_node)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
# find dependencies
|
||||
find_package(ament_cmake REQUIRED)
|
||||
find_package(library REQUIRED)
|
||||
|
||||
add_executable(node src/node.cpp)
|
||||
target_include_directories(node PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
target_compile_features(node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
|
||||
ament_target_dependencies(
|
||||
node
|
||||
"library"
|
||||
)
|
||||
|
||||
install(TARGETS node
|
||||
DESTINATION lib/${PROJECT_NAME})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(ament_lint_auto REQUIRED)
|
||||
# the following line skips the linter which checks for copyrights
|
||||
# comment the line when a copyright and license is added to all source files
|
||||
set(ament_cmake_copyright_FOUND TRUE)
|
||||
# the following line skips cpplint (only works in a git repo)
|
||||
# comment the line when this package is in a git repo and when
|
||||
# a copyright and license is added to all source files
|
||||
set(ament_cmake_cpplint_FOUND TRUE)
|
||||
ament_lint_auto_find_test_dependencies()
|
||||
endif()
|
||||
|
||||
ament_package()
|
20
test/ws/src/ros_node/package.xml
Normal file
20
test/ws/src/ros_node/package.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>ros_node</name>
|
||||
<version>0.0.0</version>
|
||||
<description>ROS node for testing ros2nix</description>
|
||||
<maintainer email="michal.sojka@cvut.cz">Michal Sojka</maintainer>
|
||||
<license>MIT</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
<depend>library</depend>
|
||||
|
||||
<test_depend>ament_lint_auto</test_depend>
|
||||
<test_depend>ament_lint_common</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
12
test/ws/src/ros_node/src/node.cpp
Normal file
12
test/ws/src/ros_node/src/node.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <cstdio>
|
||||
#include <library/library.hpp>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
library::Library dummy;
|
||||
|
||||
printf("hello world package package\n");
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue