Platform-independent build systems

Ideally, the project and build system we choose could be used to build the target platform on any desktop platform. Usually, the main consideration here is the availability of the same toolchain and programmer for each development platform. Fortunately, for AVR- and ARM-based MCU platforms, the same GCC-based toolchain is available, so that we do not have to take different toolchains with different naming conventions, flags and settings into account.

The remaining challenge is simply to invoke the toolchain, and subsequently the programmer utility, in a way that doesn't require any knowledge of the underlying OS.

In Chapter 6, Testing OS-Based Applications, we looked at a multitarget build system, which could produce binaries for a wide variety of targets with minimal effort for each new target. For an MCU target, there would only be the following two targets:

  • The physical MCU target
  • The local OS target

Here, the first target is obviously fixed, as we picked out the MCU that we wanted to target. Barring any unpleasant surprises, we will be using this one target for the entire development process. In addition, we will want to preform local testing on our development PC. This is the second target.

Here it would be great if there is a version of the same or similar  C++ toolchain on each mainstream desktop OS. Fortunately, we find that GCC is available on just about any platform imaginable, with the Clang C++ frontend of the LLVM toolchain using regular GCC-style flags, providing us with broad compatibility.

Instead of requiring the complexity of a multitarget build system, as we saw in Chapter 6, Testing OS-Based Applications, we can simplify it so it that  just uses GCC, which would allow us to use that toolchain on Linux- and BSD-based OSes, along with Windows (MinGW via MSYS2 or equivalent) and macOS (after installing GCC).

For full compatibility on macOS, the use of GCC is recommended, due to small issues in the Clang implementation. One of these current issues is the __forceinline macro attribute being broken, for example, which would break a lot of code that assumes the GCC compiler.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9