How to deal with hardware interfaces optional

Most IoT devices have subtypes devices on the same CPU platform. For example, I have two devices, they are identical except the counts of serial-ports. One has two serial-ports, the other has only one serial-port. Or one provides a serial-port, the other provides a can-bus port. Due to hardware slots were defined in gadget snap, and gadget snap needs to pre-build with image. So I have to build two gadget snap and two images.

Would anyone can give me any suggestions? Thank you.