Skip to content

Commit

Permalink
Build system refactor (#64)
Browse files Browse the repository at this point in the history
* Experimental change to build system.
Allows IDE to parse dependencies.
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Remove commented code
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Refactoring to workspace layout. Does not compile.
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Revert change to workspace, general CMake tweaks
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Initial re-make of build system
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Fixing warnings within rosidl_generator
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Make sure cargo builds within the correct directory
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Add in checks for ROS 2 version to change
the compilation syntax
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Properly query environment variable
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Only bind rcl, rmw, and rcutils
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Re-write to move most of `rclrs_common` to `rclrs`
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Updating/fixing package XML to comply with
format 3 schema
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Missed a schema update
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Missed another schema...
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>

* Remove manual crate paths in toml files
Distro A, OPSEC #4584. You may have additional rights; please see https://rosmilitary.org/faq/?category=ros-2-license

Signed-off-by: Jacob Hassold <jhassold@dcscorp.com>
  • Loading branch information
jhdcs authored Nov 22, 2021
1 parent 77ae3c1 commit 38ae32f
Show file tree
Hide file tree
Showing 31 changed files with 1,393 additions and 1,282 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,7 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

# Ignore generated .cargo/config.toml files
**/.cargo/config.toml

# End of https://www.toptal.com/developers/gitignore/api/cmake,rust,python,cpp,c
7 changes: 5 additions & 2 deletions ament_cmake_export_crates/package.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ament_cmake_export_crates</name>
<version>0.0.3</version>
<description>The ability to export Rust crates to downstream packages in the ament buildsystem in CMake.</description>
<author email="esteve@apache.org">Esteve Fernandez</author>
<maintainer email="esteve@apache.org">Esteve Fernandez</maintainer>
<license>Apache License 2.0</license>
<author email="esteve@apache.org">Esteve Fernandez</author>

<buildtool_depend>ament_cmake_core</buildtool_depend>

Expand Down
35 changes: 15 additions & 20 deletions rclrs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,25 @@ project(rclrs NONE)

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_export_crates REQUIRED)
find_package(rclrs_common REQUIRED)
find_package(rclrs_crate_config_generator REQUIRED)
find_package(rclrs_msg_utilities REQUIRED)

set(_crates_dependencies "")
set(_found_dependencies "")
foreach(_crate_dependency ${rclrs_common_CRATES})
if(NOT _crate_dependency IN_LIST _found_dependencies)
list(APPEND _found_dependencies ${_crate_dependency})
set(_crates_dependencies "${_crates_dependencies}\n[dependencies.rclrs_common]\npath = '${_crate_dependency}'\n")
endif()
endforeach()
ament_export_crates(${CMAKE_SOURCE_DIR})

file(COPY "${CMAKE_SOURCE_DIR}/Cargo.toml" DESTINATION "${CMAKE_BINARY_DIR}/")
file(APPEND "${CMAKE_BINARY_DIR}/Cargo.toml" "${_crates_dependencies}")
set(ROS_CRATES rclrs_msg_utilities)
rclrs_gen_crate_config(${ROS_CRATES})

install(
FILES ${CMAKE_BINARY_DIR}/Cargo.toml build.rs src/rcl_wrapper.h
DESTINATION share/${PROJECT_NAME}/rust/
# Build library
add_custom_target(
build_crate ALL
COMMAND cargo build $<$<NOT:$<CONFIG:Debug>>:--release>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

install(
DIRECTORY src/
DESTINATION share/${PROJECT_NAME}/rust/src
install(FILES
${CMAKE_SOURCE_DIR}/target/$<$<NOT:$<CONFIG:Debug>>:release>$<$<CONFIG:Debug>:debug>/librclrs.rlib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION lib/${PROJECT_NAME}
)

ament_export_crates("share/${PROJECT_NAME}/rust")

ament_package()
ament_package()
7 changes: 7 additions & 0 deletions rclrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
authors = ["Esteve Fernandez <esteve@apache.org>"]
edition = "2018"

[lib]
path = "src/lib.rs"

[dependencies]
libc = "0.2.43"
lock_api = "0.4.5"
Expand All @@ -12,6 +15,10 @@ cty = "0.2"
core-error = "0.0.0"
parking_lot = {version = "0.11.2", optional = true}
spin = "0.9.2"
downcast = "0.10.0"

[dependencies.rclrs_msg_utilities]
version = "*"

[build-dependencies]
bindgen = "0.59.1"
Expand Down
10 changes: 10 additions & 0 deletions rclrs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ fn main() {
.use_core()
.ctypes_prefix("cty")
.derive_copy(false)
.allowlist_recursively(true)
.allowlist_type("rcl_.*")
.allowlist_type("rmw_.*")
.allowlist_type("rcutils_.*")
.allowlist_function("rcl_.*")
.allowlist_function("rmw_.*")
.allowlist_function("rcutils_.*")
.allowlist_var("rcl_.*")
.allowlist_var("rcl_.*")
.allowlist_var("rcutils_.*")
.size_t_is_usize(true)
.default_enum_style(bindgen::EnumVariation::Rust {
non_exhaustive: false,
Expand Down
11 changes: 7 additions & 4 deletions rclrs/package.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<?xml version="1.0"?>
<package format="2">
<?xml-model
href="http://download.ros.org/schema/package_format3.xsd"
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rclrs</name>
<version>0.0.3</version>
<description>Package containing the Rust client.</description>
<author email="esteve@apache.org">Esteve Fernandez</author>
<maintainer email="esteve@apache.org">Esteve Fernandez</maintainer>
<license>Apache License 2.0</license>
<author email="esteve@apache.org">Esteve Fernandez</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_export_crates</buildtool_depend>
<buildtool_depend>rclrs_crate_config_generator</buildtool_depend>

<build_depend>builtin_interfaces</build_depend>
<build_depend>rclrs_msg_utilities</build_depend>
<build_depend>rcl</build_depend>
<build_depend>rcl_interfaces</build_depend>
<build_depend>rclrs_common</build_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
3 changes: 1 addition & 2 deletions rclrs/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::error::ToResult;
use crate::error::{RclReturnCode, ToResult};
use crate::rcl_bindings::*;
use crate::Node;
use alloc::sync::Arc;
use alloc::vec::Vec;
use cstr_core::{c_char, CString};
use rclrs_common::error::RclReturnCode;

#[cfg(not(feature = "std"))]
use spin::{Mutex, MutexGuard};
Expand Down
Loading

0 comments on commit 38ae32f

Please sign in to comment.