Skip to content

Electrostat-Lab/Electrostatic-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Electrostatic-application

An executable template utilizing the Electrostatic-Sandbox SDK

This is a template that builds a cross-platform native executable application for Linux variants, Android variants, and AVR MCU variants utilizing the Electrostatic-Sandbox SDK libraries.

System Requirements

  1. A GNU/Linux System or a WSL System.
  2. A minimum of 1GB RAM, and 4GB Disk Space.
  3. If planned Microcontroller development; ATMega32 and/or ATMega328p are the currently supported ones.
  4. If planned Android development; all Android variants are supported.

Setup the Electrostatic Environment

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.

chmod +rwx ./helper-scripts/setup-environment/setup-sandbox.sh && \
           ./helper-scripts/setup-environment/setup-sandbox.sh

Build the application binary (.elf)

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.

chmod +x ./helper-scripts/project-impl/compile-all.sh && \
         ./helper-scripts/project-impl/compile-all.sh 

Introducing other building routines using Bash

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.

Usually the build routines will look like that in general:

# pre-compilation automata
source "./helper-scripts/project-impl/variables.sh"
source_module="${app_src}/"
electrostatic_sdk="${app_libs}"
# compilation automata
./helper-scripts/project-impl/compile-electrostatic-app.sh \
"${COMMISSION_EXE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "-O3 -fPIC" \
"${TARGET_x86_64}" "${TOOLCHAIN_INCLUDES_x86};${app_headers}" "${source_module}" \
"${electrostatic_sdk}/linux/x86-64/" "m;pthread;dl" "." \
"linux" "${x86_64}"

They are dependent on that abstraction:

#!/bin/bash
function compile() {
local COMMISSION_OUTPUT=${1}
local GCC_BIN=${2}
local GPP_BIN=${3}
local INPUT_COMPILER_OPTIONS=${4}
local TARGET=${5}
local HEADERS=${6}
local SOURCES_DIR=${7}
local PROJECT_SOURCES=${8}
local DEPENDENCIES=${9}
local BUILD_DIR=${10}
local CMAKE_DIR=${11}
local TEMP=$(pwd)
cd "${CMAKE_DIR}" || exit $?
cmake-3.19 "-DCOMMISSION_OUTPUT=${COMMISSION_OUTPUT}" \
"-DGCC_BIN=${GCC_BIN}" \
"-DGPP_BIN=${GPP_BIN}" \
"-DINPUT_COMPILER_OPTIONS=${INPUT_COMPILER_OPTIONS}" \
"-DTARGET=${TARGET}" \
"-DHEADERS=${HEADERS}" \
"-DSOURCES_DIR=${SOURCES_DIR}" \
"-DPROJECT_SOURCES=${PROJECT_SOURCES}" \
"-DDEPENDENCIES=${DEPENDENCIES}" \
"-DBUILD_DIR=${BUILD_DIR}" \
-S . -B "$(pwd)/${SOURCES_DIR}/cmake-build/${BUILD_DIR}"
cmake-3.19 --build "$(pwd)/${SOURCES_DIR}/cmake-build/${BUILD_DIR}" || exit $?
cd "${TEMP}" || exit $?
}

Changing the project output name

This could be attained by changing the variable COMMISSION_EXE in the ./helper-scripts/project-impl/variables.sh:

Adding new dependencies

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:

if [ "${DEPENDENCIES_MODULES[*]}" != "${NULL}" ]; then
if [ "${DYNAMIC_LINKING}" == "true" ]; then
echo -e "--------- Deferring Linking to runtime ---------"
dependencies=$(find ${DEPENDENCIES_MODULES[*]} -name *.so | tr '\n' ';')
else
echo -e "--------- Performing Static Linking ---------"
dependencies=$(find ${DEPENDENCIES_MODULES[*]} -name *.a -o -name *.ar | tr '\n' ';')
fi
fi
# compile scripts
compile "${COMMISSION_OUTPUT}" "${GCC_BIN}" "${GPP_BIN}" \
"${COMPILER_OPTIONS}" \
"${TARGET_MACHINE}" "${HEADERS}" \
"${SOURCE_DIR}" "${sources}" "${dependencies};${BUILTIN_LIBS}" \
"${SYSTEM_DIR}/${BUILD_DIR}" "." "${SOURCE_DIR}"

Build front-end automata, CMake, and Toolchains

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.

The build of the Electrostatic-applications is much simpler than the SDK; it's literally a subset of it.

For more; refer to the build architecture of the Electrostatic-Sandbox SDK.

Releases

No releases published

Packages

No packages published

Languages