Skip to content

modules

Lars de Smit edited this page Nov 8, 2024 · 1 revision

2. Modules

This document will explain, in more depth, the way modules are supposed to work.

2.1 Folder structure

The basic folder structure including configuration files, at the time of writing should be as follows for a module called "my-module".

  • my-module\ (module root)
    • interface\
    • implementations\
    • tests\
    • my-module.fmod

However, this specific folder structure is for a module that contains both an interface and implementation. There is one other case that must be covered, which is when a user wants to create their own implementation of a module. This folder should be placed in the implementations folder of the project.

We will now take a closer look into each separate folder and configuration file and what they should be used for.

2.2 \interface\

As the previous paragraph suggest, this folder should only exist in the folder where the module is declared, meaning the location of the .fmod file.
This folder will contain all header files, or interfaces that are exposed to other modules.

2.3 \implementations\

This is where the interfaces are implemented, and thus the implementations are located. The following is how the folder structure should look for an implementation called "default-implementation".

  • default-implementation\
    • bin\ (generated by the build process)
    • lib\ (generated by the build process)
    • intermediate\ (generated by project generation)
    • src\
    • tests\
    • default.fimpl

As described above, the first three folders (bin, lib and intermediate) are automatically generated and don't have to be created. For now, the rest of the files and folders will have to be manually created. This will most likely be different in the future, when there's an application that will help with the generation of applications.

The src and tests folder are fairly straight forward, they contain the source files and test files for this module respectively.

Finally the default.fimpl file is probably the most important of the bunch, this is the configuration for our implementation. In here we can configure module dependencies, but most importantly this is where we configure which module we are implementing. A more in-depth explanation for this file can be found here.

2.4 \tests\

This is where the interface tests should be placed.

2.5 \my-module.fmod

The configuration file for this module, in here we can configure the metadata of this module as well as potential hard dependencies for this module that will always be there no matter which implementation is chosen. A more in-depth explanation for this file can be found here.

<< 1. Introduction | 3. Project >>

Clone this wiki locally