|
| 1 | +# Electrostatic-Library |
| 2 | +> A library template utilizing the Electrostatic-Sandbox SDK, acting as an extension pack. |
| 3 | +
|
| 4 | +This is a template that builds a cross-platform native library for Linux variants, Android variants, and AVR MCU variants linking them against the Electrostatic-Sandbox SDK libraries. The library is built into static archives, and dynamic libraries. The template is also provided by `examples` module in which a single source file with a `main` function could be compiled and run on its respective system. |
| 5 | + |
| 6 | +<img width="1147" height="290" alt="image" src="https://github.com/user-attachments/assets/d2b9a685-a063-4bf1-b0ee-bf4ce5e1d4f4" /> |
| 7 | + |
| 8 | +## System Requirements |
| 9 | +1) A GNU/Linux System or a WSL System. |
| 10 | +2) A minimum of 1GB RAM, and 4GB Disk Space. |
| 11 | +3) If planned Microcontroller development; ATMega32 and/or ATMega328p are the currently supported ones. |
| 12 | +4) If planned Android development; all Android variants are supported. |
| 13 | + |
| 14 | +## Setup the Electrostatic Environment |
| 15 | +This will install missing dependencies (CLI tools and toolchains) in `/opt/electrostatic-sandbox` that shall be utilized by the SDK build front-end and CMake to build the applications. |
| 16 | + |
| 17 | +```bash |
| 18 | +chmod +rwx ./helper-scripts/setup-environment/setup-sandbox.sh && \ |
| 19 | + ./helper-scripts/setup-environment/setup-sandbox.sh |
| 20 | +``` |
| 21 | + |
| 22 | +## Build the application binary (.elf) |
| 23 | +This will build the application binary to all supported platforms; usually if a new build routine is to be built, it has to go here. |
| 24 | + |
| 25 | +```bash |
| 26 | +chmod +x ./helper-scripts/project-impl/compile-all.sh && \ |
| 27 | + ./helper-scripts/project-impl/compile-all.sh |
| 28 | +``` |
| 29 | + |
| 30 | +## Introducing other building routines using Bash |
| 31 | +Introducing other building routines is far easy. However, it's mostly dependent on whether the original SDK is supporting those platforms. If not yet, you will have to build a pre-compilation header that excludes the SDK for those unsupported systems or else you will get linking errors. |
| 32 | + |
| 33 | +Usually the build routines will look like that in general: |
| 34 | +https://github.com/Electrostat-Lab/Electrostatic-Library/blob/a6d9669dde096c02285e28c5657aa2438793b367/helper-scripts/project-impl/compile-all-linux.sh#L1-L17 |
| 35 | + |
| 36 | +They are dependent on that abstraction: |
| 37 | +https://github.com/Electrostat-Lab/Electrostatic-Library/blob/a6d9669dde096c02285e28c5657aa2438793b367/helper-scripts/abstract/abstract-compile.sh#L1-L41 |
| 38 | + |
| 39 | +## Changing the project output name |
| 40 | +This could be attained by changing the variable `COMMISSION_LIB` and `COMMISSION_LIB_AR` in the `./helper-scripts/project-impl/variables.sh`: |
| 41 | +https://github.com/Electrostat-Lab/Electrostatic-Library/blob/a6d9669dde096c02285e28c5657aa2438793b367/helper-scripts/project-impl/variables.sh#L8-L9 |
| 42 | + |
| 43 | +## Adding new dependencies |
| 44 | +Add your dependencies in the `libs` directory with the system directory of choice if required (in case of platform-dependent binaries); the build script finds all libraries listed under this directory through this code snippet: |
| 45 | +https://github.com/Electrostat-Lab/Electrostatic-Library/blob/a6d9669dde096c02285e28c5657aa2438793b367/helper-scripts/project-impl/compile-electrostatic.sh#L27-L38 |
| 46 | + |
| 47 | +## Adding new examples to test the introduced APIs |
| 48 | +* Adding new examples could be achieved by creating new source code (single source files) under the `examples` module, and using the following command to compile and run the example: |
| 49 | +```bash |
| 50 | +$ ./helper-scripts/project-impl/compile-examples.sh "-m64" "main.cpp" "executable-example" "linux" "x86-64" "x86-64/exe" |
| 51 | +$ ./cmake-build/linux/x86-64/exe/executable-example.elf |
| 52 | +``` |
| 53 | +> [!NOTE] |
| 54 | +> This command links the specified source example against the `Electrostatic-Sandbox SDK` libraries and the `Electroextension` library (your native library). |
| 55 | +
|
| 56 | +* Adding new examples for microcontroller programming is much the same, but will require uploading as a post-compilation script. |
| 57 | + |
| 58 | +## Excluding parts of the source code (dissociating the source code into modules) |
| 59 | +This could be attained through the build routines of the supported systems by decomposing the source directory into sub-directories and pass them as source modules to the compilation front-end (Ccoffee); the following shows the use of all the source code as a single module: |
| 60 | +https://github.com/Electrostat-Lab/Electrostatic-Library/blob/a6d9669dde096c02285e28c5657aa2438793b367/helper-scripts/project-impl/compile-all-android.sh#L4-L12 |
| 61 | + |
| 62 | +## Build front-end automata, CMake, and Toolchains |
| 63 | +Essentially, the build architecture of the Electrostatic-Sandbox SDK is based on the idea of creating a front-end scripted API that creates a building automata, which entails taking an input and passing into a chain of states, and eventually ending with a terminal state; thus the recognition of the machine to the building holds if the terminal state is being reached by the program counter. The initial input to the automata is mainly a building routine instruction and the outputs are proceeded and could be found at the filesystems cmake-build and build, where the terminal output is produced. |
| 64 | + |
| 65 | +The build of the Electrostatic-applications is much simpler than the SDK; it's literally a subset of it. |
| 66 | + |
| 67 | +For more; refer to the [build architecture of the Electrostatic-Sandbox SDK](https://github.com/Electrostat-Lab/Electrostatic-Sandbox/blob/master/electrostatic-sandbox-framework/docs/system-build/architecture.md). |
0 commit comments