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 windows support #66

Merged
merged 3 commits into from
Sep 26, 2023
Merged

Conversation

jazi007
Copy link

@jazi007 jazi007 commented Sep 14, 2023

This PR is to have r2r works under windows, this also enable using cargo-ament for building with colcon

By default once cargo-ament is installed any package containing a package.xml and Cargo.toml is considered as cargo-ament, so using the custom r2r_cargo.cmake does not work anymore

@jazi007 jazi007 force-pushed the add-windows-support branch 3 times, most recently from d4c7295 to 9a40451 Compare September 16, 2023 09:35
@jazi007 jazi007 force-pushed the add-windows-support branch from 9a40451 to 9233af8 Compare September 16, 2023 09:53
@m-dahl
Copy link
Collaborator

m-dahl commented Sep 18, 2023

Hi. Thanks, this is really valuable. Is it ready for review/merge? I hope to be able to test it later this week, anything I should know when testing it on windows? (Haven't used windows in a long time).

Another question, since it sounds like you have experience with cargo-ament, is your feeling that cargo-ament makes r2r_cargo.cmake reduntant? If so I think we should try to drop it.

@jazi007
Copy link
Author

jazi007 commented Sep 18, 2023

Hi,
Yes it's ready for review
for windows you should know that you will get problems :-) what I installed is ros2-humble and python 3.8 at this location (C:\Python38)

regarding cargo-ament: https://github.com/colcon/colcon-ros-cargo#usage the problem is that if this is installed no way to make colcon understand that the project is cmake and not cargo. I think it's a bug. in the package.xml the build_type should be used.

anyway once colcon-ros-cargo and https://github.com/colcon/colcon-cargo are installed compilation works w/o the cmake file, so IMO you can drop the cmake work around

++

@m-dahl
Copy link
Collaborator

m-dahl commented Sep 22, 2023

I tried it yesterday evening, and as I suspected I couldn't get it to compile under windows. This is where I got stuck:

thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("c:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:84:1: error: unknown type name '_Check_return_'\nc:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:85:20: error: expected ';' after top level declarator\nc:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:107:1: error: unknown type name '_Check_return_'\nc:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:108:20: error: expected ';' after top level declarator\nc:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:117:1: error: unknown type name '_Check_return_'\nc:\\dev\\ros2_humble\\include\\rcutils\\rcutils/allocator.h:143:1: error: unknown type name '_Check_return_'\n")', r2r_rcl\build.rs:99:10

It looks like bindgen didn't like the _Check_return_ annotation. Have you seen this issue? I don't think its related to what you had to fix to make it run. Maybe related to clang? I used choco to install llvm to get libclang. Did you do something different?

@jazi007
Copy link
Author

jazi007 commented Sep 23, 2023

I didn't get this error, here's a step by step how I build/run the r2r_minimal_node

  1. Open a Developer Powershell for VS2019
$env:PATH = "C:\Python38;C:\Python38\Scripts;$env:PATH"
C:\ros2\ros2_humble\ros2-windows\setup.ps1
colcon build --event-handlers desktop_notification- --cargo-args --release --cmake-args -Wno-dev

colcon list outputs:

r2r_minimal_node        src\r2r_minimal_node\r2r_minimal_node   (ament_cargo)
r2r_minimal_node_msgs   src\r2r_minimal_node\r2r_minimal_node_msgs      (ros.ament_cmake)

build outputs:

Starting >>> r2r_minimal_node_msgs
Finished <<< r2r_minimal_node_msgs [14.6s]
Starting >>> r2r_minimal_node
[Processing: r2r_minimal_node]
Finished <<< r2r_minimal_node [57.9s]

Summary: 2 packages finished [1min 13s]

let me know if with those steps you still have issues, in this case I will start a fresh install of all my env and try to reproduce your issue

@m-dahl
Copy link
Collaborator

m-dahl commented Sep 24, 2023

I tried your steps (except I didn't have ament_cargo) but I got the same error as before.

My setup is roughly:

Are you able to build r2r without colcon? I.e. just cargo build in the r2r root after sourcing humble.

@jazi007
Copy link
Author

jazi007 commented Sep 25, 2023

Yes I'm able to compile r2r

python --version
Python 3.8.5

and sorry missed your question about clang

here's how I did the installation: clang, basicly what is related to ros2 I followed ros2 and what is related to rust/bindgen I followed rust ones.

@m-dahl
Copy link
Collaborator

m-dahl commented Sep 26, 2023

I updated clang and no change.

If I simply remove the _Check_return_ annotation from macros.h in rcutils everything builds fine (with your patch). While it works, I would like to be able to build against a clean source tree, will dig some more into this later.

@m-dahl
Copy link
Collaborator

m-dahl commented Sep 26, 2023

With the workaround I pushed I can build r2r against the stock humble install. Not very elegant but it works for now. I am ready to merge this if it still works for you.

@jazi007
Copy link
Author

jazi007 commented Sep 26, 2023

Nice WA :-) yes it's ok for me

@m-dahl m-dahl merged commit 0a6e0f5 into sequenceplanner:master Sep 26, 2023
@jazi007 jazi007 deleted the add-windows-support branch September 27, 2023 13:23
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 this pull request may close these issues.

2 participants