Skip to content

Commit 52837f6

Browse files
authored
Merge pull request #1 from Electrostat-Lab/build-script
Build: cross-platform building scripts and github workflow
2 parents 5fed0a8 + d46619f commit 52837f6

File tree

7 files changed

+130
-83
lines changed

7 files changed

+130
-83
lines changed

.github/workflows/build-app.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Build Electrostatic-Application
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the "master" branch
8+
push:
9+
branches: [ "master" ]
10+
pull_request:
11+
branches: [ "master" ]
12+
13+
# Allows you to run this workflow manually from the Actions tab
14+
workflow_dispatch:
15+
16+
jobs:
17+
build-electrostatic-app:
18+
# runner images with architectures (variants)
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ 'ubuntu-latest' ]
23+
name: Build Electrostatic App
24+
25+
# Steps represent a sequence of tasks that will be executed as part of the job
26+
steps:
27+
- name: Checkout Job
28+
uses: actions/checkout@v3
29+
30+
- name: Setup Electrostatic-Sandbox Workstation
31+
run: chmod +rwx ./helper-scripts/setup-environment/setup-sandbox.sh && ./helper-scripts/setup-environment/setup-sandbox.sh
32+
33+
- name: User's Permissions Granting
34+
run: chmod +rwx ./helper-scripts/project-impl/*.sh
35+
36+
- name: Building Electrostatic-application Executable Binaries
37+
run: sudo ./helper-scripts/project-impl/compile-all.sh
38+
39+
- name: Testing Electrostatic-app ELF
40+
run: sudo ./build/linux/x86-64/electrostatic-app.elf
Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
11
#!/bin/bash
2+
3+
# pre-compilation automata
24
source "./helper-scripts/project-impl/variables.sh"
35

4-
PRIMER_SUFFIX="${1}"
5-
6-
##
7-
# define source modules
8-
# The suffix 'primer' swaps binaries with
9-
# the original project for testing purposes!
10-
##
11-
electronetsoft="$(pwd)/electrostatic-sandbox-framework/${source_dir}/src/libs/electrostatic${PRIMER_SUFFIX}/electronetsoft"
12-
13-
platform_module="${electronetsoft}/platform/linux/"
14-
comm_module="${electronetsoft}/comm/"
15-
algorithm_module="${electronetsoft}/algorithm/"
16-
util_module="${electronetsoft}/util/"
17-
18-
./helper-scripts/project-impl/compile-electrostatic.sh \
19-
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
20-
"--target=${ARM_64}" \
21-
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
22-
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ARM_64}" "${POST_COMPILE_TRUE}"
23-
24-
./helper-scripts/project-impl/compile-electrostatic.sh \
25-
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
26-
"--target=${ARM_32}" \
27-
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
28-
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ARM_32}" "${POST_COMPILE_TRUE}"
29-
30-
./helper-scripts/project-impl/compile-electrostatic.sh \
31-
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
32-
"--target=${ANDROID_x86}" \
33-
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
34-
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ANDROID_x86}" "${POST_COMPILE_TRUE}"
35-
36-
./helper-scripts/project-impl/compile-electrostatic.sh \
37-
"${COMMISSION_LIB}" "${CLANG_BIN}" "${CLANGPP_BIN}" "ON" "ON" "OFF" "-O3 -fPIC" \
38-
"--target=${ANDROID_x86_64}" \
39-
"${electrostatic_core_headers}" "${platform_module} ${comm_module} \
40-
${algorithm_module} ${util_module}" "${NULL}" "m;c;dl" "${source_dir}" "android" "${ANDROID_x86_64}" "${POST_COMPILE_TRUE}"
6+
source_module="${app_src}/"
7+
electrostatic_sdk="${app_libs}"
8+
9+
# compilation automata
10+
11+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
12+
"${COMMISSION_EXE}" "${CLANG_BIN}" "${CLANGPP_BIN}" "-O3 -fPIC" \
13+
"--target=${ARM_64}" "${NDK_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
14+
"${electrostatic_sdk}/android/${ARM_64}" "m;c;dl" "." \
15+
"android" "${ARM_64}" "false" "true"
16+
17+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
18+
"${COMMISSION_EXE}" "${CLANG_BIN}" "${CLANGPP_BIN}" "-O3 -fPIC" \
19+
"--target=${ARM_32}" "${NDK_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
20+
"${electrostatic_sdk}/android/${ARM_32}" "m;c;dl" "." \
21+
"android" "${ARM_32}" "false" "true"
22+
23+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
24+
"${COMMISSION_EXE}" "${CLANG_BIN}" "${CLANGPP_BIN}" "-O3 -fPIC" \
25+
"--target=${ANDROID_x86}" "${NDK_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
26+
"${electrostatic_sdk}/android/${ANDROID_x86}" "m;c;dl" "." \
27+
"android" "${ANDROID_x86}" "false" "true"
28+
29+
30+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
31+
"${COMMISSION_EXE}" "${CLANG_BIN}" "${CLANGPP_BIN}" "-O3 -fPIC" \
32+
"--target=${ANDROID_x86_64}" "${NDK_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
33+
"${electrostatic_sdk}/android/${ANDROID_x86_64}" "m;c;dl" "." \
34+
"android" "${ANDROID_x86_64}" "false" "true"

helper-scripts/project-impl/compile-all-mcu.sh

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,18 @@
22

33
source "./helper-scripts/project-impl/variables.sh"
44

5-
PRIMER_SUFFIX="${1}"
5+
source_module="${app_src}/"
6+
electrostatic_sdk="${app_libs}"
67

7-
##
8-
# define source modules
9-
# The suffix 'primer' swaps binaries with
10-
# the original project for testing purposes!
11-
##
12-
electronetsoft="$(pwd)/electrostatic-sandbox-framework/${source_dir}/src/libs/electrostatic${PRIMER_SUFFIX}/electronetsoft"
13-
electroio="$(pwd)/electrostatic-sandbox-framework/${source_dir}/src/libs/electrostatic${PRIMER_SUFFIX}/electroio"
8+
# compilation automata
9+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
10+
"${COMMISSION_EXE}" "${AVR_GCC_BIN}" "${AVR_GPP_BIN}" "-O2" \
11+
"-mmcu=atmega32 -D_ELECTRO_MIO" "${AVR_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
12+
"${electrostatic_sdk}/avr-mcu/atmega32/" "m" "." \
13+
"avr-mcu" "atmega32" "false" "true"
1414

15-
platform_module="${electronetsoft}/platform/linux/"
16-
comm_module="${electronetsoft}/comm/"
17-
algorithm_module="${electronetsoft}/algorithm/"
18-
util_module="${electronetsoft}/util/"
19-
electromio_module="${electroio}/electromio/"
20-
21-
./helper-scripts/project-impl/compile-electrostatic.sh \
22-
"${COMMISSION_LIB}" "${AVR_GCC_BIN}" "${AVR_GPP_BIN}" "ON" "OFF" "OFF" "-O2" \
23-
"-mmcu=atmega32 -D_ELECTRO_MIO" "${AVR_TOOLCHAIN_INCLUDES};${electrostatic_core_headers}" "${platform_module} \
24-
${comm_module} ${algorithm_module} ${util_module} ${electromio_module}" "${NULL}" "m" "${source_dir}" "avr-mcu" "atmega32" "${POST_COMPILE_TRUE}"
25-
26-
./helper-scripts/project-impl/compile-electrostatic.sh \
27-
"${COMMISSION_LIB}" "${AVR_GCC_BIN}" "${AVR_GPP_BIN}" "ON" "OFF" "OFF" "-O2" \
28-
"-mmcu=atmega328p -D_ELECTRO_MIO" "${AVR_TOOLCHAIN_INCLUDES};${electrostatic_core_headers}" "${platform_module} \
29-
${comm_module} ${algorithm_module} ${util_module} ${electromio_module}" "${NULL}" "m" "${source_dir}" "avr-mcu" "atmega328p" "${POST_COMPILE_TRUE}"
15+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
16+
"${COMMISSION_EXE}" "${AVR_GCC_BIN}" "${AVR_GPP_BIN}" "-O2" \
17+
"-mmcu=atmega328p -D_ELECTRO_MIO" "${AVR_TOOLCHAIN_INCLUDES};${app_headers}" "${source_module}" \
18+
"${electrostatic_sdk}/avr-mcu/atmega328p/" "m" "." \
19+
"avr-mcu" "atmega328p" "false" "true"

helper-scripts/project-impl/compile-all.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,5 @@
33
# pre-compilation automata
44
source "./helper-scripts/project-impl/variables.sh"
55

6-
source_module="${app_src}/"
7-
electrostatic_sdk="${app_libs}"
8-
9-
# compilation automata
10-
./helper-scripts/project-impl/compile-electrostatic-app.sh \
11-
"${COMMISSION_EXE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "-O3 -fPIC" \
12-
"${TARGET_x86_64}" "${TOOLCHAIN_INCLUDES_x86};${app_headers}" "${source_module}" \
13-
"${electrostatic_sdk}/linux/x86-64/" "m;pthread;dl" "." \
14-
"linux" "${x86_64}"
15-
16-
17-
./helper-scripts/project-impl/compile-electrostatic-app.sh \
18-
"${COMMISSION_EXE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "-O3 -fPIC" \
19-
"${TARGET_x86}" "${TOOLCHAIN_INCLUDES_x86};${app_headers}" "${source_module}" \
20-
"${electrostatic_sdk}/linux/x86/" "m;pthread;dl" "." \
21-
"linux" "${x86}"
22-
23-
# post-compilation automata
24-
mkdir --parents "$(pwd)/build/linux/x86"
25-
mkdir --parents "$(pwd)/build/linux/x86-64"
26-
27-
mv --update "$(pwd)/cmake-build/linux/x86/${COMMISSION_EXE}.elf" "$(pwd)/build/linux/x86"
28-
mv --update "$(pwd)/cmake-build/linux/x86-64/${COMMISSION_EXE}.elf" "$(pwd)/build/linux/x86-64"
6+
./helper-scripts/project-impl/compile-desktop-linux.sh
7+
./helper-scripts/project-impl/compile-all-android.sh
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# pre-compilation automata
4+
source "./helper-scripts/project-impl/variables.sh"
5+
6+
source_module="${app_src}/"
7+
electrostatic_sdk="${app_libs}"
8+
9+
# compilation automata
10+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
11+
"${COMMISSION_EXE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "-O3 -fPIC" \
12+
"${TARGET_x86_64}" "${TOOLCHAIN_INCLUDES_x86};${app_headers}" "${source_module}" \
13+
"${electrostatic_sdk}/linux/x86-64/" "m;pthread;dl" "." \
14+
"linux" "${x86_64}" "false" "true"
15+
16+
17+
./helper-scripts/project-impl/compile-electrostatic-app.sh \
18+
"${COMMISSION_EXE}" "${GCC_BIN_x86}" "${GPP_BIN_x86}" "-O3 -fPIC" \
19+
"${TARGET_x86}" "${TOOLCHAIN_INCLUDES_x86};${app_headers}" "${source_module}" \
20+
"${electrostatic_sdk}/linux/x86/" "m;pthread;dl" "." \
21+
"linux" "${x86}" "false" "true"
22+
23+
# post-compilation automata
24+
# true, See, the compile-electrostatic-app.sh

helper-scripts/project-impl/compile-electrostatic-app.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ BUILTIN_LIBS="${9}"
1818
SOURCE_DIR="${10}"
1919
SYSTEM_DIR="${11}"
2020
BUILD_DIR="${12}"
21+
DYNAMIC_LINKING="${13}"
22+
POST_PROCESSING="${14}"
2123

2224
# precompile scripts
2325
sources=$(find ${CODEBASE_MODULES[*]} -name *.c -o -name *.cpp -o -name *.cxx | tr '\n' ';')
2426

2527
if [ "${DEPENDENCIES_MODULES[*]}" != "${NULL}" ]; then
28+
if [ "${DYNAMIC_LINKING}" == "true" ]; then
29+
echo -e "--------- Deferring Linking to runtime ---------"
30+
dependencies=$(find ${DEPENDENCIES_MODULES[*]} -name *.so | tr '\n' ';')
31+
else
32+
echo -e "--------- Performing Static Linking ---------"
2633
dependencies=$(find ${DEPENDENCIES_MODULES[*]} -name *.a -o -name *.ar | tr '\n' ';')
34+
fi
2735
fi
2836

2937
# compile scripts
@@ -32,3 +40,15 @@ compile "${COMMISSION_OUTPUT}" "${GCC_BIN}" "${GPP_BIN}" \
3240
"${TARGET_MACHINE}" "${HEADERS}" \
3341
"${SOURCE_DIR}" "${sources}" "${dependencies};${BUILTIN_LIBS}" \
3442
"${SYSTEM_DIR}/${BUILD_DIR}" "." "${SOURCE_DIR}"
43+
44+
# post-compilation automata
45+
if [ "${POST_PROCESSING}" == "true" ]; then
46+
mkdir --parents "$(pwd)/build/${SYSTEM_DIR}/${BUILD_DIR}"
47+
mkdir --parents "$(pwd)/build/${SYSTEM_DIR}/${BUILD_DIR}"
48+
49+
mv --update "$(pwd)/cmake-build/${SYSTEM_DIR}/${BUILD_DIR}/${COMMISSION_EXE}.elf" \
50+
"$(pwd)/build/${SYSTEM_DIR}/${BUILD_DIR}"
51+
52+
mv --update "$(pwd)/cmake-build/${SYSTEM_DIR}/${BUILD_DIR}/${COMMISSION_EXE}.elf" \
53+
"$(pwd)/build/${SYSTEM_DIR}/${BUILD_DIR}"
54+
fi
-46.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)