cvra / robot-software

CVRA monorepo - All software running on our bots lives here
MIT License
43 stars 21 forks source link

[RFC, WIP] Cmake build infra #233

Closed antoinealb closed 4 years ago

antoinealb commented 5 years ago

This is the current status of my work on the CMake integration. It is not really ready to be used, but I wanted to get feedback as early as possible. For now only the UWB beacon is working, and I am expecting to fix the others pretty soon.

I encourage everyone to try it, and see if you like the CMake workflow.

@SyrianSpock, I think you are the most experienced with CMake, so I would be happy to have a review from you on the cmake infra itself.

Summary of the changes:

  1. The includes for modules now live in a include directory for each library. For example the includes for the PID filters live under lib/pid/include/pid. This avoids having accidental dependencies: it is not impossible to include a header from a non-linked library.
  2. Each module has its own test executable, and all the executables are built together. Before each platform had its own set of tests, and they all went in the same exec. It is now easier to have other tests, such as integration tests or tests from third party libraries running.

Things missing (probably not exhaustive):

Advantages of using cmake:

antoinealb commented 5 years ago

Friendly ping @SyrianSpock 👼

SyrianSpock commented 4 years ago

Do we plan to merge soon?

msplr commented 4 years ago

Nice, It builds! Does it run on hardware?

antoinealb commented 4 years ago

Nice, It builds! Does it run on hardware?

It does ! At least tested for the uwb-beacon. Bootloader integration is not yet ported over though.

SyrianSpock commented 4 years ago

So, what's the plan? Are we merging this?

antoinealb commented 4 years ago

Well CI is failing, and only one board is ported to the new build system, so I guess the answer is "not yet".

Current status:

SyrianSpock commented 4 years ago

Ok, so the project is still alive :+1:

antoinealb commented 4 years ago

Yes, it got rebased this weekend, and many commits are still in my home laptop.

msplr commented 4 years ago

I started with can-io in a branch (sould probably wok on this branch though). There I added bootloader config support (without touching the bootloader repo). I’m struggling with version.c generation and linker issues with some missing syscalls.

antoinealb commented 4 years ago

I can probably write version.c generation. I also had some issues with linker and syscalls but i don't remember how I fixed those. Fortunately, I will have to do it again for master-firmware.

antoinealb commented 4 years ago

@nuft I included version.c generation on this branch. Please push to another branch as I will often force push here.

antoinealb commented 4 years ago

@nuft you might want to link lib/chibios-syscall/newlib_syscalls.c in your build, helped a lot for me.

msplr commented 4 years ago

@antoinealb is it possible that you forgot to commit cmake/master.cmake? Or where do you define MCU, board name, compiler flags, etc for master-firmware?

antoinealb commented 4 years ago

@antoinealb is it possible that you forgot to commit cmake/master.cmake? Or where do you define MCU, board name, compiler flags, etc for master-firmware?

Yes its likely. You can use uwb-beacon.cmake as reference.

msplr commented 4 years ago

you might want to link lib/chibios-syscall/newlib_syscalls.c in your build, helped a lot for me.

yes, it helped. CAN-IO builds now but flash section is overflown. Need to investigate why the binary size blew up.

msplr commented 4 years ago

I managed to reduce the size, however I'm still 20k behind the previous build size.

I also observed that the chibios-syscalls library does not overwrite the default implementation (for example operator delete(), which ends up calling the newlib implementation.) This could have something to do with the library order during linking but I'm not sure. My temporary workaround was to build the sources directly without using the library archive.

antoinealb commented 4 years ago

Can you try playing with visibility settings ? https://stackoverflow.com/questions/17080869/what-is-the-cmake-equivalent-to-gcc-fvisibility-hidden-when-controlling-the-e

I also built the sources directly for chibios-syscalls, which sucks. Maybe we can use an INTERFACE library for that, will need to dig down in it.

SyrianSpock commented 4 years ago

Are we close to a mergeable state? I worry that soon, the code will change a lot and make you redo this PR work

msplr commented 4 years ago

Already part of #273