AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

Allow cross platform code and components

Open bettio opened this issue 1 year ago • 1 comments

  1. Following directories will be created:
  • src/common
  • src/components
  1. src/common will contain common code, that can be shared across different platforms. A platform might require a "common module", but it is not mandatory to build and use all of them. E.g. src/libAtomVM/inet.(c,h) should be moved to src/common/inet/inet.(c,h), so it might be used from network enabled platforms, but STM32 platform will not build and use it.

  2. src/components will contain cross platform components. This will be useful for components that are the same across different platforms. Compared to src/common, src/components is focused on complete (and standalone) components, that are accessible from erlang as NIFs or port driver. E.g. src/libAtomVM/otp_socket.c should be moved to src/components/socket/otp_socket.c and ESP32 crypto functions should be moved to src/components/crypto/crypto.c.

bettio avatar Nov 06 '23 13:11 bettio

A reorganization of the code would be very welcome.

It's not clear how this would be articulated with CMake targets. The only platform with components is esp32 and they do define targets per component. Do we want an otp_socket component that could be included by various platforms? How would we configure them? Right now, we need otp_socket_platform.c for several platforms. This component also relies on inet.h and inet.c. Should it link an inet library?

Do we want a libatomvmcore and libatomvmsocket, libatomvmcrypto, libatomvminet?

pguyot avatar Nov 06 '23 17:11 pguyot