Skip to content

fix up warnings and use definition to specialize _rclpy.c - #2

Merged
esteve merged 9 commits into
rclpy-conversion-functionsfrom
rclpy-conversion-functions-wjwwood
Feb 16, 2016
Merged

esteve merged 9 commits into
rclpy-conversion-functionsfrom
rclpy-conversion-functions-wjwwood

Conversation

@wjwwood

@wjwwood wjwwood commented Feb 14, 2016

Copy link
Copy Markdown
Member

The big change here is that I renamed _rclpy.c.in to _rclpy.c and changed to using a preprocessor definition instead of the CMake template that was being used before. I thought this was better so that editors could more easily detect and color the file, and for me it allowed me to add a definition to my C++ checker and then it could parse and check for warnings/errors in my editor, which is obviously harder when it's a CMake template.

I also addressed the style stuff in _rclpy.c according to uncrusfity and cpplint, added a copyright header, and changed it so that rcl errors are propagated up to Python as RuntimeError's.

@esteve I made this as a pull request so you could consider the changes before merging it into your pull request.

@wjwwood wjwwood added the in progress Actively being worked on (Kanban column) label Feb 14, 2016
Comment thread CMakeLists.txt
include_directories(include)

if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this package doesn't do any C++ stuff project(...) should explicitly list only C to avoid searching for a C++ compiler.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread CMakeLists.txt
file(
COPY "${PROJECT_NAME}"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't see why this should be done. Copying files like this should be avoided at all cost. Can someone argue why this is absolutely necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying files like this should be avoided at all cost.

Why? That seems to be an absolute assertion without an obvious reason (as if it should be clear to everyone that this is always implicitly true).

Can someone argue why this is absolutely necessary?

It is necessary because in order to import rclpy you need a folder which contains both the Python code (which starts in the source space) and the generated C extensions (.so's) which are generated into the build space. So this copies the Python source into the build space so that there can be a folder in the build space which contains both the Python source and the C extensions. This is needed so that the tests can import rclpy as if it were installed, and the tests do so by importing rclpy from the build space.

I'd suggest you look into why it is that way by trying to change it (as I did), if you don't believe me. Maybe you can come up with an improvement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying files like this should be avoided at all cost.

Why? That seems to be an absolute assertion without an obvious reason (as if it should be clear to everyone that this is always implicitly true).

Updated: The reasons are:

  • when files get copied the developer might unintentionally change the wrong file
  • changes to the source files won't have any effect on future builds since the files are only copied once at configure time
  • either CMake needs to be reinvoked every time (which is time consuming during the development) or the developer edits the copied files in the build space for faster iteration and then has to copy back his changes (always potentially overwriting them accidentally when reconfiguring)

Can someone argue why this is absolutely necessary?

It is necessary because in order to import rclpy you need a folder which contains both the Python code (which starts in the source space) and the generated C extensions (.so's) which are generated into the build space. So this copies the Python source into the build space so that there can be a folder in the build space which contains both the Python source and the C extensions. This is needed so that the tests can import rclpy as if it were installed, and the tests do so by importing rclpy from the build space.

I'd suggest you look into why it is that way by trying to change it (as I did), if you don't believe me. Maybe you can come up with an improvement.

See PR #3 which achieves the described goal.

@esteve

esteve commented Feb 16, 2016

Copy link
Copy Markdown
Member

@wjwwood thanks for the improvements! Yeah, the explanation you added as a comment is why I copied the files from the source tree to the build tree so that a single call to ament_python_install_package would install both the Python files and the native extensions. Sorry if the code wasn't very clear, I was in a bit of a rush to get this running ASAP and didn't add many comments.

esteve added a commit that referenced this pull request Feb 16, 2016
fix up warnings and use definition to specialize _rclpy.c
@esteve
esteve merged commit 0297caf into rclpy-conversion-functions Feb 16, 2016
@esteve esteve removed the in progress Actively being worked on (Kanban column) label Feb 16, 2016
@mikaelarguedas
mikaelarguedas deleted the rclpy-conversion-functions-wjwwood branch October 30, 2016 17:25
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.

3 participants