crownstone / bluenet

Bluenet is the in-house firmware on Crownstone hardware. Functions: switching, dimming, energy monitoring, presence detection, indoor localization, switchcraft.
https://crownstone.rocks
91 stars 62 forks source link

Refactor build system #56

Closed mrquincle closed 5 years ago

mrquincle commented 6 years ago

Related to https://github.com/crownstone/bluenet/issues/55, but different.

CMake is a cross-platform meta build tool that generates files that can be used by build tools. It is possible to generate a Makefile, a Ninja file, or project files for Visual Studio, Xcode, Eclipse, Sublime, etc. It is important to realize that you should run cmake only once. Subsequently you can run e.g. make multiple times. Each time make should only rebuild the files of which the dependencies have changed. It is worthwhile to also use >3.0.0 features and do it right.

  1. One of the issues we have to cope with is the diversity of boards we want to build for. We would like to generate a Makefile (or other file) that is able to generate the binaries for each of these boards.

  2. Another issue is the bootloader. We would like to be able to build all relevant code in one sweep for a particular board. This means that the bootloader and the softdevice also should be built for that board. If we run make again, the dependencies should be tracked properly.

Instead of cmake it is also possible to use e.g. scons. An interesting option is to actually immediately integrate with platform.io.

We can then specify the following environments:

[platformio]
env_default = pca10040,acr01b7b

[env:pca10040]
platform = nrf52832
framework = crownstone
board = pca10040
build_flags = -D MESHING=1

[env:acr01b7b]
platform = nrf52832
framework = crownstone
board = acr01b7b
mrquincle commented 5 years ago

Now done through cmake. Platform.io should call cmake and make to compile properly.