Keeping track of source code variants

后端 未结 6 1756
眼角桃花
眼角桃花 2021-02-06 02:03

I am soon starting to maintain a line of products containing variants of the same embedded software. Since I\'ve been playing with git for one year and appreciate it very much,

6条回答
  •  情深已故
    2021-02-06 02:52

    I am not sure if that's "best practice", but the Scintilla project uses something for years that is still quite manageable. It has only one branch common to all platforms (mostly Windows/GTK+/Mac, but with variants for VMS, Fox, etc.).

    Somehow, it uses the first option which is quite common: it uses defines to manage little platform specific portions inside the sources, where it is impractical or impossible to put common code.
    Note that this option is not possible with some languages (eg. Java).

    But the main mechanism for portability is using OO: it abstracts some operations (drawing, showing context menu, etc.) and uses a Platform file (or several) per target, providing the concrete implementation.
    The makefile compiles only the proper file(s) and uses linking to get the proper code.

提交回复
热议问题