Skip to content

Commit 91a82f6

Browse files
committed
Electrostatic-Library: base template
1 parent e834e99 commit 91a82f6

30 files changed

+530
-125
lines changed
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
os: [ 'ubuntu-latest' ]
23-
name: Build Electrostatic App
23+
name: Build Electrostatic Library
2424

2525
# Steps represent a sequence of tasks that will be executed as part of the job
2626
steps:
@@ -33,8 +33,11 @@ jobs:
3333
- name: User's Permissions Granting
3434
run: chmod +rwx ./helper-scripts/project-impl/*.sh
3535

36-
- name: Building Electrostatic-application Executable Binaries
36+
- name: Building Electrostatic-Library Binaries
3737
run: sudo ./helper-scripts/project-impl/compile-all.sh
3838

39+
- name: Building Electrostatic-Library Examples
40+
run: ./helper-scripts/project-impl/compile-examples.sh "-m64" "main.cpp" "executable-example" "linux" "x86-64" "x86-64/exe"
41+
3942
- name: Testing Electrostatic-app ELF
40-
run: sudo ./build/linux/x86-64/electrostatic-app.elf
43+
run: ./cmake-build/linux/x86-64/exe/executable-example.elf

CMakeLists.txt

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
cmake_minimum_required(VERSION 3.18.1)
22

33
# define a project with a version
4-
project(electrostatic-application VERSION 1.0)
4+
project(electrostatic-library VERSION 1.0)
55

66
# To generate compile_commands.json for your project,
77
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
88

99
###################### CMake Predefined Variables ######################
1010
############################################################
1111

12-
message(STATUS "Project: electrostatic-application")
12+
message(STATUS "Project: electrostatic-library")
1313
message(STATUS "Current Output in-comission: ${COMMISSION_OUTPUT}")
1414
message(STATUS "GCC: ${GCC_BIN}")
1515
message(STATUS "GPP: ${GPP_BIN}")
16+
message(STATUS "Build Static Library: ${BUILD_STATIC}")
17+
message(STATUS "Build Shared Library: ${BUILD_SHARED}")
18+
message(STATUS "Build Executable binary: ${BUILD_EXE}")
1619
message(STATUS "Compiler Options: ${INPUT_COMPILER_OPTIONS}")
1720
message(STATUS "Target architecture: ${TARGET}")
1821
message(STATUS "Toolchain Headers: ${HEADERS}")
@@ -26,6 +29,8 @@ message(STATUS "Building the binaries to: ${BUILD_DIR}")
2629

2730
set(PROJECT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_DIR}")
2831

32+
set(commission_so "${COMMISSION_OUTPUT}")
33+
set(commission_a "${COMMISSION_OUTPUT}-a")
2934
set(commission_exe "${COMMISSION_OUTPUT}.elf")
3035

3136
set(CMAKE_C_COMPILER "${GCC_BIN}")
@@ -38,10 +43,34 @@ set(headers "${HEADERS}")
3843
############################################################
3944

4045
# build an executable
41-
add_executable(${commission_exe}) # executable based on the static archive
42-
set_target_properties(${commission_exe} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")
43-
# include headers for the target
44-
target_include_directories(${commission_exe} PUBLIC ${lib_headers} ${headers})
45-
target_link_libraries(${commission_exe} PUBLIC "${DEPENDENCIES}")
46-
# Start building the target
47-
target_sources(${commission_exe} PUBLIC "${PROJECT_SOURCES}")
46+
if (BUILD_EXE)
47+
# add a library target
48+
add_executable(${commission_exe}) # executable based on the static archive
49+
set_target_properties(${commission_exe} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")
50+
# include headers for the target
51+
target_include_directories(${commission_exe} PUBLIC ${lib_headers} ${headers})
52+
target_link_libraries(${commission_exe} PUBLIC "${DEPENDENCIES}")
53+
# Start building the target
54+
target_sources(${commission_exe} PUBLIC "${PROJECT_SOURCES}")
55+
endif ()
56+
57+
if (BUILD_STATIC)
58+
# add a library target
59+
add_library(${commission_a} STATIC)
60+
# set both COMPILE_FLAGS and LINK_FLAGS to the specified binary architecture
61+
set_target_properties(${commission_a} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")
62+
# include headers for the target
63+
target_include_directories(${commission_a} PUBLIC ${headers})
64+
target_link_libraries(${commission_a} PUBLIC "${DEPENDENCIES}")
65+
# Start building the target
66+
target_sources(${commission_a} PUBLIC "${PROJECT_SOURCES}")
67+
endif ()
68+
69+
# build a shared library version
70+
if (BUILD_SHARED)
71+
add_library(${commission_so} SHARED)
72+
set_target_properties(${commission_so} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}")
73+
target_include_directories(${commission_so} PUBLIC ${headers})
74+
target_link_libraries(${commission_so} PUBLIC "${DEPENDENCIES}")
75+
target_sources(${commission_so} PUBLIC "${PROJECT_SOURCES}")
76+
endif()

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Electrostatic-application
2-
> An executable template utilizing the Electrostatic-Sandbox SDK
1+
# Electrostatic-Library
2+
> A library template utilizing the Electrostatic-Sandbox SDK, acting as an extension pack.
33
4-
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.
4+
This is a template that builds a cross-platform native library for Linux variants, Android variants, and AVR MCU variants linking against the Electrostatic-Sandbox SDK libraries. The library is built into static archives, and
55

66
## System Requirements
77
1) A GNU/Linux System or a WSL System.
File renamed without changes.

helper-scripts/abstract/abstract-compile.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ function compile() {
44
local COMMISSION_OUTPUT=${1}
55
local GCC_BIN=${2}
66
local GPP_BIN=${3}
7-
local INPUT_COMPILER_OPTIONS=${4}
8-
local TARGET=${5}
9-
local HEADERS=${6}
10-
local SOURCES_DIR=${7}
11-
local PROJECT_SOURCES=${8}
12-
local DEPENDENCIES=${9}
13-
local BUILD_DIR=${10}
14-
local CMAKE_DIR=${11}
7+
local BUILD_STATIC=${4}
8+
local BUILD_SHARED=${5}
9+
local BUILD_EXE=${6}
10+
local INPUT_COMPILER_OPTIONS=${7}
11+
local TARGET=${8}
12+
local HEADERS=${9}
13+
local SOURCES_DIR=${10}
14+
local PROJECT_SOURCES=${11}
15+
local DEPENDENCIES=${12}
16+
local BUILD_DIR=${13}
17+
local CMAKE_DIR=${14}
1518

1619
local TEMP=$(pwd)
1720

@@ -20,6 +23,9 @@ function compile() {
2023
cmake-3.19 "-DCOMMISSION_OUTPUT=${COMMISSION_OUTPUT}" \
2124
"-DGCC_BIN=${GCC_BIN}" \
2225
"-DGPP_BIN=${GPP_BIN}" \
26+
"-DBUILD_STATIC=${BUILD_STATIC}" \
27+
"-DBUILD_SHARED=${BUILD_SHARED}" \
28+
"-DBUILD_EXE=${BUILD_EXE}" \
2329
"-DINPUT_COMPILER_OPTIONS=${INPUT_COMPILER_OPTIONS}" \
2430
"-DTARGET=${TARGET}" \
2531
"-DHEADERS=${HEADERS}" \
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
source "$(pwd)/helper-scripts/setup-environment/setup-scripts/variables.sh"
4+
source "${abstract_scripts}"
5+
source "${setup_doxygen_script}"
6+
7+
##
8+
# Prepare the sandbox workspace
9+
##
10+
prepare_sandbox "${sandbox_path}" "+rwx" ""
11+
12+
##
13+
# Doxygen
14+
##
15+
install_doxygen_dependencies
16+
download_doxygen
17+
extract_doxygen
18+
cleanup_doxygen
19+
20+
create_doxygen_symbol
21+
22+
doxygen-1.12.0 -v
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
source "./helper-scripts/common-variables.sh"
3+
source "./helper-scripts/project-impl/variables.sh"
4+
5+
arithmos4j_core=":electrostatic-sandbox-framework:electrostatic4j:arithmos4j:arithmos4j-core"
6+
arithmos4j_native=":electrostatic-sandbox-framework:electrostatic4j:arithmos4j:arithmos4j-native"
7+
arithmos4j_examples=":electrostatic-sandbox-framework:electrostatic4j:arithmos4j:arithmos4j-examples"
8+
9+
echo -e "${ORANGE_C} Compiling and Assembling serial4j-core"
10+
11+
./gradlew ${arithmos4j_core}:build \
12+
${arithmos4j_core}:generateSourcesJar
13+
# :serial4j:serial4j-core:generateJavadocJar
14+
15+
echo -e "${ORANGE_C} Compiling arithmos4j-native"
16+
17+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
18+
"electrostatic4j/arithmos4j/arithmos4j-native" "arithmos4j" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "${TOOLCHAIN_INCLUDES_x86}" \
19+
"${JAVA_HOME}" "${TARGET_x86_64}" "linux" "${x86_64}"
20+
21+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
22+
"electrostatic4j/arithmos4j/arithmos4j-native" "arithmos4j" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "${TOOLCHAIN_INCLUDES_x86}" \
23+
"${JAVA_HOME}" "${TARGET_x86}" "linux" "${x86}"
24+
25+
echo -e "${ORANGE_C} Bundling arithmos4j-native"
26+
27+
./gradlew ${arithmos4j_native}:copyBinaries && \
28+
./gradlew ${arithmos4j_native}:build && \
29+
./gradlew ${arithmos4j_native}:copyToExamples
30+
31+
echo -e "${ORANGE_C} Building Examples"
32+
./gradlew ${arithmos4j_native}:build
33+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
source "./helper-scripts/common-variables.sh"
3+
source "./helper-scripts/project-impl/variables.sh"
4+
5+
e4j_core=":electrostatic-sandbox-framework:electrostatic4j:electrostatic4j-core"
6+
e4j_native=":electrostatic-sandbox-framework:electrostatic4j:electrostatic4j-native"
7+
e4j_examples=":electrostatic-sandbox-framework:electrostatic4j:electrostatic4j-examples"
8+
9+
echo -e "${ORANGE_C} Compiling and Assembling e4j-core"
10+
11+
chmod +rwx ./gradlew
12+
13+
./gradlew ${e4j_core}:build \
14+
${e4j_core}:generateSourcesJar \
15+
${e4j_core}:generateJavadocJar
16+
17+
echo -e "${ORANGE_C} Compiling e4j-native"
18+
19+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
20+
"${e4j_dir}" "${COMMISSION_LIB_4j}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "${TOOLCHAIN_INCLUDES_x86}" \
21+
"${JAVA_HOME}" "${TARGET_x86_64}" "linux" "${x86_64}"
22+
23+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
24+
"${e4j_dir}" "${COMMISSION_LIB_4j}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "${TOOLCHAIN_INCLUDES_x86}" \
25+
"${JAVA_HOME}" "${TARGET_x86}" "linux" "${x86}"
26+
27+
echo -e "${ORANGE_C} Bundling e4j-native"
28+
29+
./gradlew ${e4j_native}:copyBinaries && \
30+
./gradlew ${e4j_native}:build && \
31+
./gradlew ${e4j_native}:copyToExamples
32+
33+
echo -e "${ORANGE_C} Building Examples"
34+
./gradlew ${e4j_examples}:build
35+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
PRIMER="${1}"
4+
5+
./helper-scripts/project-impl/compile-all.sh "${PRIMER}"
6+
./helper-scripts/project-impl/compile-all-android.sh "${PRIMER}"
7+
./helper-scripts/project-impl/compile-all-mcu.sh "${PRIMER}"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
source "./helper-scripts/common-variables.sh"
3+
source "./helper-scripts/project-impl/variables.sh"
4+
5+
serial4j_core=":electrostatic-sandbox-framework:electrostatic4j:serial4j:serial4j-core"
6+
serial4j_native=":electrostatic-sandbox-framework:electrostatic4j:serial4j:serial4j-native"
7+
serial4j_examples=":electrostatic-sandbox-framework:electrostatic4j:serial4j:serial4j-examples"
8+
9+
echo -e "${ORANGE_C} Compiling and Assembling serial4j-core"
10+
11+
chmod +rwx ./gradlew
12+
13+
./gradlew \
14+
"${serial4j_core}":build \
15+
"${serial4j_core}":generateSourcesJar
16+
#"${serial4j_core}":generateJavadocJar
17+
18+
echo -e "${ORANGE_C} Compiling serial4j-native"
19+
20+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
21+
"electrostatic4j/serial4j/serial4j-native" "serial4j" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "${TOOLCHAIN_INCLUDES_x86}" \
22+
"${JAVA_HOME}" "${TARGET_x86_64}" "linux" "${x86_64}"
23+
24+
./helper-scripts/project-impl/compile-electrostatic4j.sh \
25+
"electrostatic4j/serial4j/serial4j-native" "serial4j" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "ON" "${TOOLCHAIN_INCLUDES_x86}" \
26+
"${JAVA_HOME}" "${TARGET_x86}" "linux" "${x86}"
27+
28+
echo -e "${ORANGE_C} Bundling serial4j-native"
29+
30+
./gradlew "${serial4j_native}":copyBinaries && \
31+
./gradlew "${serial4j_native}":build && \
32+
./gradlew "${serial4j_native}":copyToExamples
33+
34+
#echo -e "${ORANGE_C} Building Examples"
35+
./gradlew "${serial4j_examples}":build
36+

0 commit comments

Comments
 (0)