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

rosrust_msg takes a lot of time on each cargo build while messages definitions have not changed #176

Open
romainreignier opened this issue Aug 23, 2022 · 1 comment · May be fixed by #201

Comments

@romainreignier
Copy link
Contributor

I have using rosrust in a catkin workspace and use catkin to build the nodes using these lines in the CMakeList.txt file, inspired from # 113

set(CARGO_OUTPUT "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}")

add_custom_command(
    OUTPUT ${CARGO_OUTPUT}
    DEPENDS src/main.rs
    COMMAND ${CMAKE_COMMAND} -E echo_append "Building Rust node..."
    COMMAND cargo build --release -p ${PROJECT_NAME} --target-dir ${CMAKE_BINARY_DIR}/cargo
    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/cargo/release/${PROJECT_NAME} ${CARGO_OUTPUT}
    COMMAND ${CMAKE_COMMAND} -E echo "Done."
)

add_custom_target(${PROJECT_NAME}_rust ALL DEPENDS ${CARGO_OUTPUT})

install(PROGRAMS
  ${CARGO_OUTPUT}
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

But after any change in the main.rs file, the rust target rosrust_msg takes a lot of time to build.
With the -vv flag of cargo build, I have noticed that the list of files printed with cargo:rerun-if-changed= includes literally all the files of my ROS workspace, including .git content for each package.

Commenting the following lines fixed the issue and only the .msg and .srv files are listed, which avoids the rosrust_msg rebuild after any change.

if let Some(name) = folder.to_str() {
rerun_if_file_changed(name);
}

I understand that using rosrust with catkin is not yet supported but maybe we can only add folders with names srv and msg in the list?

MichiBab added a commit to MichiBab/rosrust that referenced this issue Aug 28, 2022
@adnanademovic
Copy link
Owner

From all of my testing of how this trigger works, the rerun trigger needs to include the hierarchy of folders that we're looking at, otherwise adding a new .msg file won't be registered.

Overly eager rebuilds would be reduced by filtering out folders that we know won't contain message files, like .git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants