diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9d3457cf..860756db 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -30,6 +30,9 @@ jobs: - name: Setup Electrostatic-Sandbox Workstation run: chmod +rwx ./setup-environment/setup-sandbox.sh && ./setup-environment/setup-sandbox.sh + - name: User's Permissions Granting + run: cd ./electrostatic-sandbox-framework && chmod +rwx ./helper-scripts/project-impl/*.sh + - name: Compiling electrostatic-core Native Binaries run: cd ./electrostatic-sandbox-framework && ./helper-scripts/ci-cd/compile-electrostatic.sh @@ -37,7 +40,7 @@ jobs: run: cd ./electrostatic-sandbox-framework && ./helper-scripts/ci-cd/test-electrostatic.sh - name: Compiling electrostatic4j Java Binding API - run: cd ./electrostatic-sandbox-framework && ./helper-scripts/ci-cd/compile-e4j.sh "$(pwd)/electrostatic-core" + run: cd ./electrostatic-sandbox-framework && ./helper-scripts/ci-cd/compile-e4j.sh - name: Testing electrostatic4j Java Binding API run: cd ./electrostatic-sandbox-framework && ./helper-scripts/ci-cd/test-e4j.sh diff --git a/.gitignore b/.gitignore index b929490e..dd4c5326 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ # Ignore Gradle/CMake build output directory build cmake-build +dependencies +electrostatic4j-examples/libs .so .cache .idea diff --git a/electrostatic-sandbox-framework/electrostatic-core/CMakeLists.txt b/electrostatic-sandbox-framework/CMakeLists.txt similarity index 59% rename from electrostatic-sandbox-framework/electrostatic-core/CMakeLists.txt rename to electrostatic-sandbox-framework/CMakeLists.txt index f26c1b72..b9e0298e 100644 --- a/electrostatic-sandbox-framework/electrostatic-core/CMakeLists.txt +++ b/electrostatic-sandbox-framework/CMakeLists.txt @@ -7,38 +7,32 @@ project(electrostatic-sandbox VERSION 1.0) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) message(STATUS "Project: electrostatic-sandbox") +message(STATUS "Current Library in-comission: ${COMMISSION_LIB}") message(STATUS "GCC: ${GCC_BIN}") message(STATUS "GPP: ${GPP_BIN}") message(STATUS "Compiler Options: ${INPUT_COMPILER_OPTIONS}") message(STATUS "Target architecture: ${TARGET}") -message(STATUS "Toolchain Includes: ${TOOLCHAIN_INCLUDES}") - -# assign the target architecture arguments from the pre-determined directory -if("${TARGET}" STREQUAL "x86") - set(ARCH_OPTIONS "-m32") - message(STATUS "Compiling for 32-bit Intel Chipset") -elseif("${TARGET}" STREQUAL "x86-64") - set(ARCH_OPTIONS "-m64") - message(STATUS "Compiling for 64-bit Intel Chipset") -# elseif(${TARGET} STREQUAL "android-x86") -else() - set(${TARGET} "x86-64") - set(ARCH_OPTIONS "-m64") -endif() +message(STATUS "Toolchain Headers: ${TOOLCHAIN_HEADERS}") +message(STATUS "Source Directory: ${SOURCES_DIR}") +message(STATUS "Project sources: ${PROJECT_SOURCES}") +message(STATUS "Dependencies: ${DEPENDENCIES}") +message(STATUS "Building the binaries to: ${BUILD_DIR}") + +set(PROJECT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_DIR}") # Cmake variables -set(library_so "electrostatic") -set(library_a "electrostatic-a") +set(library_so "${COMMISSION_LIB}") +set(library_a "${COMMISSION_LIB}-a") set(CMAKE_C_COMPILER "${GCC_BIN}") set(CMAKE_CXX_COMPILER "${GPP_BIN}") -set(COMPILER_OPTIONS "${ARCH_OPTIONS} ${INPUT_COMPILER_OPTIONS}") - -set(toolchain_headers "${TOOLCHAIN_INCLUDES}") -set(libelectrostatic "${CMAKE_CURRENT_SOURCE_DIR}/src/libelectrostatic/comm/init_protocol.c") +set(COMPILER_OPTIONS "${TARGET} ${INPUT_COMPILER_OPTIONS}") -set(headers "${toolchain_headers}" - "${CMAKE_CURRENT_SOURCE_DIR}/src/include/") +set(headers "${TOOLCHAIN_HEADERS}" + "${PROJECT_SOURCE_DIR}/dependencies/include/" + "${PROJECT_SOURCE_DIR}/src/include/") + +set(libelectrostatic "${PROJECT_SOURCES}") # add a library target add_library(${library_a} STATIC ${libelectrostatic}) @@ -48,11 +42,13 @@ add_library(${library_so} SHARED ${libelectrostatic}) set_target_properties(${library_a} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}") set_target_properties(${library_so} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}") - # include headers for the target target_include_directories(${library_a} PUBLIC ${headers}) target_include_directories(${library_so} PUBLIC ${headers}) +target_link_libraries(${library_a} PUBLIC "${DEPENDENCIES}") +target_link_libraries(${library_so} PUBLIC "${DEPENDENCIES}") + # Start building the target target_sources(${library_a} PUBLIC ${libelectrostatic}) target_sources(${library_so} PUBLIC ${libelectrostatic}) \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/comm/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/comm/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/comm/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/comm/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/comm/init_protocol.c b/electrostatic-sandbox-framework/electrostatic-core/src/libs/comm/init_protocol.c similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/comm/init_protocol.c rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/comm/init_protocol.c diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrofs/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electrofs/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrofs/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electrofs/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrohid/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electrohid/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrohid/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electrohid/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electromemory/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electromemory/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electromemory/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electromemory/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electroparallel/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electroparallel/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electroparallel/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electroparallel/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electropci/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electropci/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electropci/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electropci/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electroserial/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electroserial/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electroserial/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electroserial/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrosockets/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electrosockets/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrosockets/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electrosockets/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrousbfs/info.txt b/electrostatic-sandbox-framework/electrostatic-core/src/libs/electrousbfs/info.txt similarity index 100% rename from electrostatic-sandbox-framework/electrostatic-core/src/libelectrostatic/electrousbfs/info.txt rename to electrostatic-sandbox-framework/electrostatic-core/src/libs/electrousbfs/info.txt diff --git a/electrostatic-sandbox-framework/electrostatic-examples/CMakeLists.txt b/electrostatic-sandbox-framework/electrostatic-examples/CMakeLists.txt index fb728d27..603a1a85 100644 --- a/electrostatic-sandbox-framework/electrostatic-examples/CMakeLists.txt +++ b/electrostatic-sandbox-framework/electrostatic-examples/CMakeLists.txt @@ -10,21 +10,8 @@ message(STATUS "GPP: ${GPP_BIN}") message(STATUS "Compiler Options: ${INPUT_COMPILER_OPTIONS}") message(STATUS "Target architecture: ${TARGET}") message(STATUS "Toolchain Includes: ${TOOLCHAIN_INCLUDES}") -message(STATUS "Included-library: ${ELECTROSTATIC_CORE}") message(STATUS "Runnable-example: ${EXAMPLE}") - -# assign the target architecture arguments from the pre-determined directory -if("${TARGET}" STREQUAL "x86") - set(ARCH_OPTIONS "-m32") - message(STATUS "Compiling for 32-bit Intel Chipset") -elseif("${TARGET}" STREQUAL "x86-64") - set(ARCH_OPTIONS "-m64") - message(STATUS "Compiling for 64-bit Intel Chipset") -# elseif(${TARGET} STREQUAL "android-x86") -else() - set(${TARGET} "x86-64") - set(ARCH_OPTIONS "-m64") -endif() +message(STATUS "Building the binaries to: ${BUILD_DIR}") # Cmake variables set(executable_a "${EXAMPLE}-a.elf") # target for archive-linked binary @@ -32,9 +19,9 @@ set(executable_so "${EXAMPLE}.elf") # target for shared-linked binary set(CMAKE_C_COMPILER "${GCC_BIN}") set(CMAKE_CXX_COMPILER "${GPP_BIN}") -set(COMPILER_OPTIONS "${ARCH_OPTIONS} ${INPUT_COMPILER_OPTIONS}") +set(COMPILER_OPTIONS "${TARGET} ${INPUT_COMPILER_OPTIONS}") -set(lib_headers "${ELECTROSTATIC_CORE}/src/include") +set(lib_headers "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/include") set(headers "${TOOLCHAIN_INCLUDES}") # C sources @@ -52,8 +39,8 @@ set_target_properties(${executable_so} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTI target_include_directories(${executable_a} PUBLIC ${lib_headers} ${headers}) target_include_directories(${executable_so} PUBLIC ${lib_headers} ${headers}) -target_link_libraries(${executable_a} "${ELECTROSTATIC_CORE}/build/${TARGET}/libelectrostatic-a.a") -target_link_libraries(${executable_so} "${ELECTROSTATIC_CORE}/build/${TARGET}/libelectrostatic.so") +target_link_libraries(${executable_a} "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libs/${BUILD_DIR}/libelectrostatic-a.a") +target_link_libraries(${executable_so} "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libs/${BUILD_DIR}/libelectrostatic.so") # Start building the target target_sources(${executable_a} PUBLIC ${sources}) diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build.gradle b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build.gradle deleted file mode 100755 index dba2465b..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -repositories { - mavenCentral() -} - -dependencies { - testImplementation 'junit:junit:4.13' -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/jme3/serial4j/actions/package-info.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/jme3/serial4j/actions/package-info.class deleted file mode 100644 index cbf02fb6..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/jme3/serial4j/actions/package-info.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/CompileX86.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/CompileX86.class deleted file mode 100644 index d2ed0804..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/CompileX86.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/UnixScriptRunner.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/UnixScriptRunner.class deleted file mode 100644 index a467b7a8..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/UnixScriptRunner.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/Permissioning.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/Permissioning.class deleted file mode 100644 index bac6e067..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/Permissioning.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/ScriptExecutor.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/ScriptExecutor.class deleted file mode 100644 index a1cb0a7e..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/actions/ScriptExecutor.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/package-info.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/package-info.class deleted file mode 100644 index fc3afcfb..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/package-info.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/ConsoleUtils.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/ConsoleUtils.class deleted file mode 100644 index 79889b76..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/ConsoleUtils.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/JarMetadata.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/JarMetadata.class deleted file mode 100644 index c5a28e33..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/JarMetadata.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/package-info.class b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/package-info.class deleted file mode 100644 index 4abb9a7b..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/classes/groovy/main/com/serial4j/build/util/package-info.class and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/libs/buildSrc.jar b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/libs/buildSrc.jar deleted file mode 100644 index 79d843b2..00000000 Binary files a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/libs/buildSrc.jar and /dev/null differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/source-roots/buildSrc/source-roots.txt b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/source-roots/buildSrc/source-roots.txt deleted file mode 100755 index b004ef4e..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/source-roots/buildSrc/source-roots.txt +++ /dev/null @@ -1,6 +0,0 @@ -src/main/resources -src/main/java -src/main/groovy -src/test/resources -src/test/java -src/test/groovy diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/tmp/jar/MANIFEST.MF b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/tmp/jar/MANIFEST.MF deleted file mode 100755 index 58630c02..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/build/tmp/jar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/CompileX86.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/CompileX86.groovy deleted file mode 100755 index 43b9a774..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/CompileX86.groovy +++ /dev/null @@ -1,67 +0,0 @@ -package com.serial4j.build; - -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.Input; - -/** - * Compiles a x86 binary to a specific system. - * - * @author pavl_g - */ -public class CompileX86 extends UnixScriptRunner { - - /** Placeholders for gradle properties */ - @Input - protected String compileWindowsX86 = ""; - - @Input - protected String compileMacX86 = ""; - - @Input - protected String compileLinuxX86 = ""; - - protected final boolean isWindows = System.getProperty("os.name").contains("Windows"); - protected final boolean isMacos = System.getProperty("os.name").contains("Mac"); - protected final boolean isLinux = System.getProperty("os.name").contains("Linux"); - - @Override - protected void scriptExecution() { - boolean isCompileWindowsX86 = getConditionFromValue(compileWindowsX86); - boolean isCompileMacX86 = getConditionFromValue(compileMacX86); - boolean isCompileLinuxX86 = getConditionFromValue(compileLinuxX86); - - if (isWindows && !isCompileWindowsX86) { - /* terminate when on windows if the compile flag is disabled */ - return; - } - - if (isMacos && !isCompileMacX86) { - /* terminate when on MacOS if the compile flag is disabled */ - return; - } - - if (isLinux && !isCompileLinuxX86) { - /* terminate when on linux if the compile flag is disabled */ - return; - } - - super.scriptExecution(); - } - - private boolean getConditionFromValue(final String value) { - return value.equals("true"); - } - - public String getCompileLinuxX86() { - return compileLinuxX86; - } - - public String getCompileWindowsX86() { - return compileWindowsX86; - } - - public String getCompileMacX86() { - return compileMacX86; - } - -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/UnixScriptRunner.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/UnixScriptRunner.groovy deleted file mode 100755 index f4a0cee1..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/UnixScriptRunner.groovy +++ /dev/null @@ -1,58 +0,0 @@ -package com.serial4j.build; - -import org.gradle.api.tasks.TaskAction; -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.Input; -import com.serial4j.build.actions.Permissioning; -import com.serial4j.build.actions.ScriptExecutor; - -/** - * The abstract entity for running unix scripts in bash shell environments. - * It consists of 2 sequential tasks: a [permissioning] task and a [script-executor] task. - * - * @author pavl_g - */ -public class UnixScriptRunner extends DefaultTask { - - /** - * The unix script to execute. - */ - @Input - protected String script = ""; - - @Input - protected String[] scriptArgs; - - @TaskAction - protected void scriptExecution() { - final ScriptExecutor executor = new ScriptExecutor(); - executor.execute(this); - } - - @TaskAction - protected void permissioning() { - final Permissioning permissioningTask = new Permissioning(); - permissioningTask.execute(this); - } - - /** - * Sets the unix-script to run. - * - * @param script a string representing the absolute path to the script ending with the script name and file extension - */ - public void setScript(final String script) { - this.script = script; - } - - public final String getScript() { - return script; - } - - public void setScriptArgs(final String[] scriptArgs) { - this.scriptArgs = scriptArgs; - } - - public String[] getScriptArgs() { - return scriptArgs; - } -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/Permissioning.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/Permissioning.groovy deleted file mode 100755 index 383c3e6d..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/Permissioning.groovy +++ /dev/null @@ -1,45 +0,0 @@ -package com.serial4j.build.actions; - -import org.gradle.api.resources.MissingResourceException; -import com.serial4j.build.util.ConsoleUtils; -import com.serial4j.build.UnixScriptRunner; -import java.lang.Process; -import org.gradle.api.Task; -import java.io.IOException; -import java.lang.InterruptedException; - -/** - * A task that gives a [+rwx] permission to a script. - * - * @author pavl_g - */ -public final class Permissioning { - - public void execute(Task task) { - final UnixScriptRunner runner = ((UnixScriptRunner) task); - if (runner.getScript() == null || runner.getScript().equals("")) { - throw new MissingResourceException("Cannot find a script to permissionize !"); - } - try { - permissionizeScript(runner.getScript()); - } catch(IOException | InterruptedException e) { - e.printStackTrace(); - } - } - - private void permissionizeScript(final String script) throws IOException, InterruptedException { - String[] chmod = new String[] { "chmod", "+rwx" }; - /* execute the shell script in a unix process that inheirt from the current environment */ - Process permissioning = Runtime.getRuntime().exec(new String[] { chmod[0], chmod[1], script }); - - permissioning.waitFor(); - - ConsoleUtils.printConsoleInput(permissioning); - ConsoleUtils.printConsoleError(permissioning); - - /* release resources */ - permissioning.destroy(); - permissioning = null; - chmod = null; - } -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/ScriptExecutor.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/ScriptExecutor.groovy deleted file mode 100755 index 7df29961..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/ScriptExecutor.groovy +++ /dev/null @@ -1,70 +0,0 @@ -package com.serial4j.build.actions; - -import org.gradle.api.resources.MissingResourceException; -import com.serial4j.build.util.ConsoleUtils; -import com.serial4j.build.UnixScriptRunner; -import java.util.Arrays; -import java.util.ArrayList; -import java.lang.Process; -import org.gradle.api.Task; -import java.io.IOException; -import java.lang.InterruptedException; - -/** - * A task that executes a script and print its stream. - * - * @author pavl_g - */ -public final class ScriptExecutor { - - public void execute(Task task) { - final UnixScriptRunner runner = ((UnixScriptRunner) task); - if (runner.getScript() == null || runner.getScript().equals("")) { - throw new MissingResourceException("Cannot find a script to execute !"); - } - try { - executeScript(runner.getScript(), (ArrayList) Arrays.asList(runner.getScriptArgs())); - } catch(IOException | InterruptedException e) { - e.printStackTrace(); - } - } - - private void executeScript(final String script, final ArrayList args) throws IOException, InterruptedException { - ArrayList command = new ArrayList<>(); - command.add(getBash()); - command.add(script); - - /* copy the args into the shell command */ - for (int i = 0; i < args.size(); i++) { - command.add(args.get(i)); - } - - Process run = Runtime.getRuntime().exec((String[]) command.toArray()); - - if (run.waitFor() == 1) { - System.out.println("Run Failed !"); - } - - ConsoleUtils.printConsoleInput(run); - ConsoleUtils.printConsoleError(run); - - /* release resources */ - run.destroy(); - run = null; - command.clear(); - command = null; - } - - /** - * Retrieves the system specific bash binary. - * - * @return a string representation of the bash (bourne-again-shell) - */ - private String getBash() { - if (!System.getProperty("os.name").contains("Windows")) { - return "bash"; - } - return "C:\\Program Files\\Git\\bin\\bash.exe"; - } - -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/package-info.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/package-info.groovy deleted file mode 100755 index 97fb36a3..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/actions/package-info.groovy +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Holds the task actions for the {@link com.jme3.build.UnixScriptRunner}. - */ -package com.jme3.serial4j.actions; \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/package-info.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/package-info.groovy deleted file mode 100755 index f7dac21b..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/package-info.groovy +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Holds the native build implementation for the jme3-alloc-native project. - */ -package com.serial4j.build; \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/ConsoleUtils.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/ConsoleUtils.groovy deleted file mode 100755 index 5e11edba..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/ConsoleUtils.groovy +++ /dev/null @@ -1,64 +0,0 @@ -package com.serial4j.build.util; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.InputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.lang.Process; - -/** - * Some useful console io utils to provide log errors and info. - * - * @author pavl_g - */ -public final class ConsoleUtils { - private ConsoleUtils() { - } - - /** - * Prints the process input-stream to the [stdout]. - * - * @param process a {@link java.lang.Process} process - */ - public static void printConsoleInput(final Process process) { - try { - printInputStream(process.getInputStream(), System.out); - } catch(IOException e) { - e.printStackTrace(); - } - } - - /** - * Prints the process input-stream to the [stderr]. - * - * @param process a {@link java.lang.Process} process - */ - public static void printConsoleError(final Process process) { - try { - printInputStream(process.getErrorStream(), System.err); - } catch(IOException e) { - e.printStackTrace(); - } - } - - /** - * Prints an input-stream content to a stream [e.g: stdout, stderr]. - * - * @param in an input-stream to print its content - * @param stream an output-stream to print on it - */ - public static int printInputStream(final InputStream in, final PrintStream stream) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - try { - for (String out = null; (out = reader.readLine()) != null;) { - stream.println(out); - } - } finally { - reader.close(); - in.close(); - reader = null; - } - return 0; - } -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/JarMetadata.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/JarMetadata.groovy deleted file mode 100755 index 2401d413..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/JarMetadata.groovy +++ /dev/null @@ -1,19 +0,0 @@ -package com.serial4j.build.util; - -public enum JarMetadata { - BASE_NAME("serial4j"), VERSION("0.1-A"), EXT(".jar"), TARGET("desktop"); - - String data; - - JarMetadata(final String data) { - this.data = data; - } - - public void setData(final String data) { - this.data = data; - } - - public String getData() { - return data; - } -} diff --git a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/package-info.groovy b/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/package-info.groovy deleted file mode 100755 index cfe6420e..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/buildSrc/src/main/groovy/com/serial4j/build/util/package-info.groovy +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Holds the utilities for the build api. - */ -package com.serial4j.build.util; \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-examples/libs/electrostatic4j-native-linux.jar b/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-examples/libs/electrostatic4j-native-linux.jar index 309b50e5..dcdd559e 100644 Binary files a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-examples/libs/electrostatic4j-native-linux.jar and b/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-examples/libs/electrostatic4j-native-linux.jar differ diff --git a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/CMakeLists.txt b/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/CMakeLists.txt deleted file mode 100644 index ffe4f3f7..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -cmake_minimum_required(VERSION 3.18.1) - -# define a project with a version -project(electrostatic4j-native VERSION 1.0) - -# print java_home -message(STATUS "GCC: ${GCC_BIN}") -message(STATUS "GPP: ${GPP_BIN}") -message(STATUS "Compiler Options: ${INPUT_COMPILER_OPTIONS}") -message(STATUS "Target architecture: ${TARGET}") -message(STATUS "Toolchain Includes: ${TOOLCHAIN_INCLUDES}") -message(STATUS "JAVA_HOME: ${JAVA_HOME}") -message(STATUS "Included-library: ${ELECTROSTATIC_CORE}") - -# assign the system dependent jni-headers identifier -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set(system "win32") -elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(system "darwin") -else() - set(system "linux") -endif() - -# assign the target architecture arguments from the pre-determined directory -if("${TARGET}" STREQUAL "x86") - set(ARCH_OPTIONS "-m32") - message(STATUS "Compiling for 32-bit Intel Chipset") -elseif("${TARGET}" STREQUAL "x86-64") - set(ARCH_OPTIONS "-m64") - message(STATUS "Compiling for 64-bit Intel Chipset") -# elseif(${TARGET} STREQUAL "android-x86") -else() - set(${TARGET} "x86-64") - set(ARCH_OPTIONS "-m64") -endif() - -# Cmake variables -set(library "electrostatic4j") -set(jni_headers "${JAVA_HOME}/include/" - "${JAVA_HOME}/include/${system}/") -set(electrostatic_headers "${ELECTROSTATIC_CORE}/src/include/") -set(headers - "${CMAKE_CURRENT_SOURCE_DIR}/src/include/" - "${CMAKE_CURRENT_SOURCE_DIR}/src/include/${system}/" - "${CMAKE_CURRENT_SOURCE_DIR}/src/include/jni/" - "${jni_headers}" - "${electrostatic_headers}") -set(jni_sources "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/jni/electrostatic4j_NativeLibrary.c") -set(sources "${jni_sources}" - "${CMAKE_CURRENT_SOURCE_DIR}/src/lib/linux/") - -# add a library target -add_library(${library} SHARED ${sources}) - -# setup compiler options -set(COMPILER_OPTIONS "${ARCH_OPTIONS} ${INPUT_COMPILER_OPTIONS}") -message(STATUS "Building binary for: ${CMAKE_SYSTEM_NAME}") -message(STATUS "Target Binary Instruction-set: ${TARGET}") - -# set both COMPILE_FLAGS and LINK_FLAGS to the specified binary architecture -set_target_properties(${library} PROPERTIES COMPILE_FLAGS "${COMPILER_OPTIONS}" LINK_FLAGS "${COMPILER_OPTIONS}") - -# include headers for the target -target_include_directories(${library} PUBLIC ${headers}) - -target_link_libraries(${library} PUBLIC "${ELECTROSTATIC_CORE}/build/${TARGET}/libelectrostatic-a.a") - -# Start building the target -target_sources(${library} PUBLIC ${sources}) \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/build.gradle b/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/build.gradle index 3d265bd2..5c64553d 100644 --- a/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/build.gradle +++ b/electrostatic-sandbox-framework/electrostatic4j/electrostatic4j-native/build.gradle @@ -1,6 +1,3 @@ -import com.serial4j.build.UnixScriptRunner; -import com.serial4j.build.util.JarMetadata - plugins { id 'java-library' } @@ -10,44 +7,23 @@ final String buildDirectory="${project.rootDir}/${rootProject.name}-native/build final String nativeObjects="${project.rootDir}/${rootProject.name}-native/build/lib" final String jarOutput="${project.rootDir}/${rootProject.name}-native/build/libs" final String examples="${project.rootDir}/${rootProject.name}-examples/libs" -final String compileX86_script = "./helper-scripts/compile.sh" -final String compileAndroid_script = "./helper-scripts/compile-android.sh" tasks.register("copyBinaries", Copy) { - mustRunAfter(compileX86_64, compileX86) - from "${nativeObjects}" into "${buildDirectory}" } tasks.register("copyToExamples", Copy) { - dependsOn(jar) - from "${jarOutput}" into "${examples}" } -tasks.register("compileX86_64", UnixScriptRunner) { - scriptArgs = new String[] { "${JAVA_HOME}", "x86-64", "${electrostaticHome}" } - script = "${compileX86_script}" -} - -tasks.register("compileX86", UnixScriptRunner) { - scriptArgs = new String[] { "${JAVA_HOME}", "x86", "${electrostaticHome}" } - script = "${compileX86_script}" -} - -tasks.register("compileAndroid", UnixScriptRunner) { - scriptArgs = new String[] { "${JAVA_HOME}" } - script = "${compileAndroid_script}" -} - jar { // assemble jar options [java -jar] archiveFileName = "${project.name}-${system}.jar" manifest { attributes 'Project': "${project.name}-${system}", - 'Implementation-Version': "${version}", - 'Automatic-Module-Name': "${project.name.replace("-", ".")}", - 'Created-by': JavaVersion.current() + 'Implementation-Version': "${version}", + 'Automatic-Module-Name': "${project.name.replace("-", ".")}", + 'Created-by': JavaVersion.current() } } \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/gradle.properties b/electrostatic-sandbox-framework/electrostatic4j/gradle.properties index 03d3b48c..dc352c70 100644 --- a/electrostatic-sandbox-framework/electrostatic4j/gradle.properties +++ b/electrostatic-sandbox-framework/electrostatic4j/gradle.properties @@ -1,17 +1,8 @@ -compileMacX86Property=false -compileWindowsX86Property=false -compileLinuxX86Property=true version=SNAPSHOT system=linux org.gradle.java.home=/opt/electrostatic-sandbox/jdk-20.0.2 -# assign from the command-line when running the -# gradle wrapper against this build -# utilized by the gradle build and cmake files to -# find the native library build files and headers -electrostaticHome=NULL - # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* diff --git a/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/compile.sh b/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/compile.sh deleted file mode 100755 index bb9e0759..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/compile.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# This must be called from the gradle wrapper directory entry -# That is why we use the return or back component [..] -source "../helper-scripts/abstract/abstract-compile-javabinding.sh" -source "../helper-scripts/abstract/abstract-util.sh" -source "./helper-scripts/variables.sh" - -java_home=${1} -arch=${2} -electrostatic_core_home=${3} - -compile "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \ - "${arch}" "${TOOLCHAIN_INCLUDES}" "${java_home}" \ - "${electrostatic_core_home}" "${e4j_source}" - -getCurrentSystem - -moveFile "${e4j_source}/cmake-build/${arch}/${library}.so" \ - "${e4j_source}/build/lib/${system}/${arch}/" \ No newline at end of file diff --git a/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/variables.sh b/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/variables.sh deleted file mode 100644 index 83459d59..00000000 --- a/electrostatic-sandbox-framework/electrostatic4j/helper-scripts/variables.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -project_root=$(pwd) -library="libelectrostatic4j" - -# home for toolchains and header files to link to sources -GCC_BIN="/usr/bin/gcc" -GPP_BIN="/usr/bin/g++" -TOOLCHAIN_INCLUDES="/usr/include/" -INPUT_COMPILER_OPTIONS="-fPIC -O2" - -# supported targets -x86="x86" -x86_64="x86-64" - -e4j_source="./electrostatic4j-native" diff --git a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-examples.sh b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-examples.sh index c58bd893..5fa52ea4 100644 --- a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-examples.sh +++ b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-examples.sh @@ -8,10 +8,11 @@ function compile() { local TOOLCHAIN_INCLUDES=${5} local ELECTROSTATIC_CORE=${6} local EXAMPLE=${7} - local source_dir=${8} + local BUILD_DIR=${8} + local SOURCE_DIR=${9} - local temp=$(pwd) - cd ${source_dir} + local TEMP=$(pwd) + cd ${SOURCE_DIR} cmake-3.19 "-DGCC_BIN=${GCC_BIN}" \ "-DGPP_BIN=${GPP_BIN}" \ @@ -20,9 +21,10 @@ function compile() { "-DTOOLCHAIN_INCLUDES=${TOOLCHAIN_INCLUDES}" \ "-DELECTROSTATIC_CORE=${ELECTROSTATIC_CORE}" \ "-DEXAMPLE=${EXAMPLE}" \ - -S . -B "./build/${TARGET}" + "-DBUILD_DIR=${BUILD_DIR}" \ + -S . -B "./build/${BUILD_DIR}" - cmake --build "./build/${TARGET}" - cd ${temp} + cmake --build "./build/${BUILD_DIR}" + cd ${TEMP} } diff --git a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-javabinding.sh b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-javabinding.sh index a747132e..591a7763 100644 --- a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-javabinding.sh +++ b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile-javabinding.sh @@ -8,10 +8,11 @@ function compile() { local TOOLCHAIN_INCLUDES=${5} local JAVA_HOME=${6} local ELECTROSTATIC_CORE=${7} - local source_dir=${8} + local BUILD_DIR=${8} + local SOURCE_DIR=${9} - local temp=$(pwd) - cd ${source_dir} + local TEMP=$(pwd) + cd ${SOURCE_DIR} cmake-3.19 "-DGCC_BIN=${GCC_BIN}" \ "-DGPP_BIN=${GPP_BIN}" \ @@ -20,9 +21,10 @@ function compile() { "-DTOOLCHAIN_INCLUDES=${TOOLCHAIN_INCLUDES}" \ "-DJAVA_HOME=${JAVA_HOME}" \ "-DELECTROSTATIC_CORE=${ELECTROSTATIC_CORE}" \ - -S . -B "./cmake-build/${TARGET}" + "-DBUILD_DIR=${BUILD_DIR}" \ + -S . -B "./cmake-build/${BUILD_DIR}" - cmake --build "./cmake-build/${TARGET}" - cd ${temp} + cmake --build "./cmake-build/${BUILD_DIR}" + cd ${TEMP} } diff --git a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile.sh b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile.sh index 074f5949..18005029 100644 --- a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile.sh +++ b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-compile.sh @@ -1,25 +1,35 @@ #!/bin/bash function compile() { - local GCC_BIN=${1} - local GPP_BIN=${2} - local INPUT_COMPILER_OPTIONS=${3} - local TOOLCHAIN_INCLUDES=${4} + local COMMISSION_LIB=${1} + local GCC_BIN=${2} + local GPP_BIN=${3} + local INPUT_COMPILER_OPTIONS=${4} local TARGET=${5} - local source_dir=${6} + local TOOLCHAIN_HEADERS=${6} + local BUILD_DIR=${7} + local CMAKE_DIR=${8} + local SOURCES_DIR=${9} + local PROJECT_SOURCES=${10} + local DEPENDENCIES=${11} - local temp=$(pwd) + local TEMP=$(pwd) - cd ${source_dir} + cd ${CMAKE_DIR} - cmake-3.19 "-DGCC_BIN=${GCC_BIN}" \ + cmake-3.19 "-DCOMMISSION_LIB=${COMMISSION_LIB}" \ + "-DGCC_BIN=${GCC_BIN}" \ "-DGPP_BIN=${GPP_BIN}" \ "-DINPUT_COMPILER_OPTIONS=${INPUT_COMPILER_OPTIONS}" \ - "-DTOOLCHAIN_INCLUDES=${TOOLCHAIN_INCLUDES}" \ "-DTARGET=${TARGET}" \ - -S . -B "./build/${TARGET}" + "-DTOOLCHAIN_HEADERS=${TOOLCHAIN_HEADERS}" \ + "-DBUILD_DIR=${BUILD_DIR}" \ + "-DSOURCES_DIR=${SOURCES_DIR}" \ + "-DPROJECT_SOURCES=${PROJECT_SOURCES}" \ + "-DDEPENDENCIES=${DEPENDENCIES}" \ + -S . -B "./${SOURCES_DIR}/cmake-build/${BUILD_DIR}" - cmake --build "./build/${TARGET}" - cd ${temp} + cmake --build "./${SOURCES_DIR}/cmake-build/${BUILD_DIR}" + cd ${TEMP} } diff --git a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-util.sh b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-util.sh index 81d56a0e..786df074 100644 --- a/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-util.sh +++ b/electrostatic-sandbox-framework/helper-scripts/abstract/abstract-util.sh @@ -3,6 +3,13 @@ system="NULL" ext="NULL" +function findFiles() { + local dir="${1}" + local args="${2}" + # args=(-name *.c -o -name *.cpp -o -name *.cxx) + return $(find "${dir}" "${args}") +} + function getCurrentSystem() { if [[ `uname` == "Darwin" ]]; then system="macos" diff --git a/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-e4j.sh b/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-e4j.sh index 1a31ad46..cd630e47 100755 --- a/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-e4j.sh +++ b/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-e4j.sh @@ -1,7 +1,6 @@ #!/bin/bash source "./common-variables.sh" - -electrostatic_core_home="${1}" +source "./helper-scripts/project-impl/variables.sh" cd ./electrostatic4j @@ -10,13 +9,22 @@ echo -e "${ORANGE_C} Compiling and Assembling e4j-core" :electrostatic4j-core:generateSourcesJar \ :electrostatic4j-core:generateJavadocJar +cd .. echo -e "${ORANGE_C} Compiling e4j-native" -./gradlew -PelectrostaticHome="${electrostatic_core_home}" \ - :electrostatic4j-native:compileX86 \ - :electrostatic4j-native:compileX86_64 && \ - ./gradlew :electrostatic4j-native:copyBinaries && \ - ./gradlew :electrostatic4j-native:build \ - :electrostatic4j-native:copyToExamples + +./helper-scripts/project-impl/compile-electrostatic4j.sh \ + "${GCC_BIN_x86}" "${GPP_BIN_x86}" "${TOOLCHAIN_INCLUDES_x86}" \ + "${JAVA_HOME}" "${TARGET_x86_64}" "linux" "${x86_64}" + +./helper-scripts/project-impl/compile-electrostatic4j.sh \ + "${GCC_BIN_x86}" "${GPP_BIN_x86}" "${TOOLCHAIN_INCLUDES_x86}" \ + "${JAVA_HOME}" "${TARGET_x86}" "linux" "${x86}" + +cd ./electrostatic4j +echo -e "${ORANGE_C} Bundling e4j-native" +./gradlew :electrostatic4j-native:copyBinaries && \ +./gradlew :electrostatic4j-native:build && \ +./gradlew :electrostatic4j-native:copyToExamples echo -e "${ORANGE_C} Building Examples" ./gradlew :electrostatic4j-examples:build diff --git a/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-electrostatic.sh b/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-electrostatic.sh index 0d13e868..e6e1721f 100755 --- a/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-electrostatic.sh +++ b/electrostatic-sandbox-framework/helper-scripts/ci-cd/compile-electrostatic.sh @@ -1,3 +1,4 @@ #!/bin/bash ./helper-scripts/project-impl/compile-all.sh +./helper-scripts/project-impl/compile-all-android.sh diff --git a/electrostatic-sandbox-framework/helper-scripts/ci-cd/test-electrostatic.sh b/electrostatic-sandbox-framework/helper-scripts/ci-cd/test-electrostatic.sh index f3a752cb..7279566d 100755 --- a/electrostatic-sandbox-framework/helper-scripts/ci-cd/test-electrostatic.sh +++ b/electrostatic-sandbox-framework/helper-scripts/ci-cd/test-electrostatic.sh @@ -1,6 +1,9 @@ #!/bin/bash -./helper-scripts/project-impl/compile-examples.sh "x86-64" "hello_comm.c" -./helper-scripts/project-impl/compile-examples.sh "x86" "hello_comm.c" -./electrostatic-examples/build/x86-64/hello_comm.c.elf -./electrostatic-examples/build/x86/hello_comm.c.elf \ No newline at end of file +source "./helper-scripts/project-impl/variables.sh" + +./helper-scripts/project-impl/compile-examples.sh "${TARGET_x86_64}" "hello_comm.c" "linux" "${x86_64}" +./helper-scripts/project-impl/compile-examples.sh "${TARGET_x86}" "hello_comm.c" "linux" "${x86}" + +./electrostatic-examples/build/linux/x86-64/hello_comm.c.elf +./electrostatic-examples/build/linux/x86/hello_comm.c.elf \ No newline at end of file diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all-android.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all-android.sh new file mode 100644 index 00000000..7c06f15e --- /dev/null +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all-android.sh @@ -0,0 +1,18 @@ +#!/bin/bash +source "./helper-scripts/project-impl/variables.sh" + +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${CLANG_BIN}" "${CLANGPP_BIN}" \ + "-target ${ARM_64}" "${NDK_TOOLCHAIN_INCLUDES}" "android" "${ARM_64}" + +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${CLANG_BIN}" "${CLANGPP_BIN}" \ + "-target ${ARM_32}" "${NDK_TOOLCHAIN_INCLUDES}" "android" "${ARM_32}" + +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${CLANG_BIN}" "${CLANGPP_BIN}" \ + "-target ${ANDROID_x86}" "${NDK_TOOLCHAIN_INCLUDES}" "android" "${ANDROID_x86}" + +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${CLANG_BIN}" "${CLANGPP_BIN}" \ + "-target ${ANDROID_x86_64}" "${NDK_TOOLCHAIN_INCLUDES}" "android" "${ANDROID_x86_64}" \ No newline at end of file diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all.sh index d06c7b2d..3d51e11c 100755 --- a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all.sh +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-all.sh @@ -2,5 +2,10 @@ source "./helper-scripts/project-impl/variables.sh" -./helper-scripts/project-impl/compile-x86.sh "${x86_64}" -./helper-scripts/project-impl/compile-x86.sh "${x86}" +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${GCC_BIN_x86}" "${GPP_BIN_x86}" \ + "${TARGET_x86_64}" "${TOOLCHAIN_INCLUDES}" "linux" "${x86_64}" + +./helper-scripts/project-impl/compile-electrostatic.sh \ + "${GCC_BIN_x86}" "${GPP_BIN_x86}" \ + "${TARGET_x86}" "${TOOLCHAIN_INCLUDES}" "linux" "${x86}" \ No newline at end of file diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic.sh new file mode 100755 index 00000000..84d9a6ee --- /dev/null +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +source "./helper-scripts/abstract/abstract-compile.sh" +source "./helper-scripts/abstract/abstract-util.sh" +source "./helper-scripts/project-impl/variables.sh" + +GCC_BIN="${1}" +GPP_BIN="${2}" +TARGET_MACHINE="${3}" +TOOLCHAIN_HEADERS="${4}" +SYSTEM_DIR="${5}" +BUILD_DIR="${6}" + +# precompile scripts +sources=$(find "$(pwd)/${source_dir}/src/" -name *.c -o -name *.cpp -o -name *.cxx | tr '\n' ';') +dependencies=$(find "$(pwd)/${source_dir}/dependencies/libs/" -name *.a -o -name *.so -o -name *.ar | tr '\n' ';') + +# compile scripts +compile "${COMMISSION_LIB}" "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \ + "${TARGET_MACHINE}" "${TOOLCHAIN_HEADERS}" \ + "${SYSTEM_DIR}/${BUILD_DIR}" "." "${source_dir}" "${sources}" "${dependencies}" + +# post compile scripts +mkdir -p "$(pwd)/${source_dir}/build/${SYSTEM_DIR}/${BUILD_DIR}" +mkdir -p "$(pwd)/${e4j_dir}/dependencies/" +mkdir -p "$(pwd)/${e4j_dir}/dependencies/libs/" + +mkdir -p "$(pwd)/${examples_dir}/dependencies/" +mkdir -p "$(pwd)/${examples_dir}/dependencies/libs/" + +cp -v "$(pwd)/${source_dir}/cmake-build/${SYSTEM_DIR}/${BUILD_DIR}/lib${COMMISSION_LIB}.so" \ + "$(pwd)/${source_dir}/build/${SYSTEM_DIR}/${BUILD_DIR}/" + +cp -v "$(pwd)/${source_dir}/cmake-build/${SYSTEM_DIR}/${BUILD_DIR}/lib${COMMISSION_LIB_AR}.a" \ + "$(pwd)/${source_dir}/build/${SYSTEM_DIR}/${BUILD_DIR}/" + +cp -rv "$(pwd)/${source_dir}/build/${SYSTEM_DIR}" \ + "$(pwd)/${e4j_dir}/dependencies/libs/" + +cp -rv "$(pwd)/${source_dir}/build/${SYSTEM_DIR}" \ + "$(pwd)/${examples_dir}/dependencies/libs/" + +cp -rv "$(pwd)/${source_dir}/src/include/" \ + "$(pwd)/${e4j_dir}/dependencies/" + +cp -rv "$(pwd)/${source_dir}/src/include/" \ + "$(pwd)/${examples_dir}/dependencies/" \ No newline at end of file diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic4j.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic4j.sh new file mode 100755 index 00000000..db1eb1ee --- /dev/null +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-electrostatic4j.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# This must be called from the gradle wrapper directory entry +# That is why we use the return or back component [..] +source "./helper-scripts/abstract/abstract-compile.sh" +source "./helper-scripts/abstract/abstract-util.sh" +source "./helper-scripts/project-impl/variables.sh" + +GCC_BIN="${1}" +GPP_BIN="${2}" +TOOLCHAIN_HEADERS="${3}" +java_home="${4}" +target="${5}" +system_dir="${6}" +build_dir="${7}" + +echo "${build_dir}" + +# precompile scripts +sources=$(find "$(pwd)/${e4j_dir}/src/" -name *.c -o -name *.cpp -o -name *.cxx | tr '\n' ';') +dependencies=$(find "$(pwd)/${e4j_dir}/dependencies/libs/${system_dir}/${build_dir}" -name *.a | tr '\n' ';') + +getCurrentSystem + +JNI_HEADERS_SYSTEM="${JNI_HEADERS}/${system}" + +compile "${COMMISSION_LIB_4j}" "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \ + "${target}" "${TOOLCHAIN_HEADERS};${JNI_HEADERS};${JNI_HEADERS_SYSTEM}" "${system_dir}/${build_dir}" \ + "." "${e4j_dir}" "${sources}" "${dependencies}" + +moveFile "${e4j_dir}/cmake-build/${system_dir}/${build_dir}/lib${COMMISSION_LIB_4j}.so" \ + "${e4j_dir}/build/lib/${system_dir}/${build_dir}/" \ No newline at end of file diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-examples.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-examples.sh index 0d9a5f36..eb729807 100755 --- a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-examples.sh +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-examples.sh @@ -4,8 +4,10 @@ source "./helper-scripts/abstract/abstract-compile-examples.sh" source "./helper-scripts/project-impl/variables.sh" TARGET_MACHINE="${1}" -example="${2}" +EXAMPLE="${2}" +SYSTEM_DIR="${3}" +BUILD_DIR="${4}" -compile "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \ - "${TARGET_MACHINE}" "${TOOLCHAIN_INCLUDES}" "${source_dir}" \ - "${example}" "${examples_dir}" +compile "${GCC_BIN_x86}" "${GPP_BIN_x86}" "${INPUT_COMPILER_OPTIONS}" \ + "${TARGET_MACHINE}" "${TOOLCHAIN_INCLUDES_x86}" "${source_dir}" \ + "${EXAMPLE}" "${SYSTEM_DIR}/${BUILD_DIR}" "${examples_dir}" diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-x86.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-x86.sh deleted file mode 100755 index cc22189e..00000000 --- a/electrostatic-sandbox-framework/helper-scripts/project-impl/compile-x86.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -source "./helper-scripts/abstract/abstract-compile.sh" -source "./helper-scripts/abstract/abstract-util.sh" -source "./helper-scripts/project-impl/variables.sh" - -TARGET_MACHINE="${1}" - -compile "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \ - "${TOOLCHAIN_INCLUDES}" "${TARGET_MACHINE}" "${source_dir}" diff --git a/electrostatic-sandbox-framework/helper-scripts/project-impl/variables.sh b/electrostatic-sandbox-framework/helper-scripts/project-impl/variables.sh index 538ec2b4..56ab7d34 100644 --- a/electrostatic-sandbox-framework/helper-scripts/project-impl/variables.sh +++ b/electrostatic-sandbox-framework/helper-scripts/project-impl/variables.sh @@ -1,23 +1,39 @@ #!/bin/bash project_root=$(pwd) + +sandbox_path="/opt/electrostatic-sandbox" +COMMISSION_LIB="electrostatic" +COMMISSION_LIB_AR="electrostatic-a" +COMMISSION_LIB_4j="${COMMISSION_LIB}4j" # home for toolchains and header files to link to sources -GCC_BIN="/usr/bin/gcc" -GPP_BIN="/usr/bin/g++" -TOOLCHAIN_INCLUDES="/usr/include/" +GCC_BIN_x86="gcc" +GPP_BIN_x86="g++" +TOOLCHAIN_INCLUDES_x86="/usr/local/include/posix-headers" +JAVA_HOME="/opt/electrostatic-sandbox/jdk-20.0.2" +JNI_HEADERS="${JAVA_HOME}/include" INPUT_COMPILER_OPTIONS="-fPIC -O2" -# specify home for android llvm -NDK_TOOLCHAIN_LLVM="" -NDK_TOOLCHAIN_INCLUDES="" -OPTIONS_X86="-target x86" +# specify android triples +minSDKVersion="21" +ARM_64="aarch64-linux-android${minSDKVersion}" +ARM_32="armv7a-linux-androideabi${minSDKVersion}" +ANDROID_x86="i686-linux-android${minSDKVersion}" +ANDROID_x86_64="x86_64-linux-android${minSDKVersion}" + +# specify symbolic binaries for android llvm +CLANG_BIN="android-clang" +CLANGPP_BIN="android-clang++" +NDK_TOOLCHAIN_INCLUDES="android-ndk-headers" -# supported targets +# supported targets for intel chipsets x86="x86" x86_64="x86-64" +TARGET_x86_64="-m64" +TARGET_x86="-m32" # cmake build caches -source_dir="$project_root/electrostatic-core/" -examples_dir="$project_root/electrostatic-examples" +source_dir="electrostatic-core" +examples_dir="electrostatic-examples" -e4j_dir="$project_root/electrostatic4j/electrostatic4j-native/" +e4j_dir="electrostatic4j/electrostatic4j-native" diff --git a/setup-environment/setup-sandbox.sh b/setup-environment/setup-sandbox.sh index cbc253ea..02399f42 100644 --- a/setup-environment/setup-sandbox.sh +++ b/setup-environment/setup-sandbox.sh @@ -8,64 +8,66 @@ source "${setup_gradle_script}" source "${setup_cmake_script}" source "${setup_avrdude_script}" source "${setup_arduinoide_script}" +source "${setup_android_ndk_script}" ## # Prepare the sandbox workspace ## prepare_sandbox "${sandbox_path}" "+rwx" "" - -## -# Setup JDK -## +### +## Setup JDK +### download_jdk extract_jdk cleanup_jdk create_java_symbol setup_java_home -## -# Setup Gradle -## + +### +## Setup Gradle +### download_gradle extract_gradle cleanup_gradle create_gradle_symbol -ls -l "${download_dir}" - - - -## -# Setup CMake -## +# +### +## Setup CMake +### download_cmake extract_cmake cleanup_cmake create_cmake_symbol +create_posix_headers_symbol install_gcc_multilib -ls -l "${download_dir}" -## -# Setup AVRDude -## +### +## Setup AVRDude +### download_avrdude extract_avrdude cleanup_avrdude create_avrdude_symbol -ls -l "${download_dir}" - -## -# Setup arduino-ide -## -download_arduinoide -extract_arduinoide -cleanup_arduinoide -create_arduinoide_symbol - -ls -l "${download_dir}" +### +## Setup arduino-ide +### +#download_arduinoide +#extract_arduinoide +#cleanup_arduinoide +#create_arduinoide_symbol +# +#ls -l "${download_dir}" + +download_ndk +extract_ndk +cleanup_ndk +create_clang_symbols +create_ndk_headers_symbol ## # Setup Jetbrains IDE @@ -82,6 +84,9 @@ all_symbols_manual="============================== \n ${jetbrains_ide_symbol} `${jetbrains_ide_symbol} --version` \n ${cmake_symbol} => `${cmake_symbol} --version` \n ${arduinoide_symbol} => `${arduinoide_symbol} --version` \n + $(`android-clang`) \n + $(`android-clang++`) \n + $(`android-ndk-headers`) \n ==============================" echo -e "${all_symbols_manual}" \ No newline at end of file diff --git a/setup-environment/setup-scripts/abstract/setup-utils.sh b/setup-environment/setup-scripts/abstract/setup-utils.sh index 87957bf3..60e7977b 100644 --- a/setup-environment/setup-scripts/abstract/setup-utils.sh +++ b/setup-environment/setup-scripts/abstract/setup-utils.sh @@ -21,7 +21,7 @@ function prepare_sandbox() { sandbox_path="${1}" user_permissions="${2}" more_options="${3}" - sudo mkdir --verbose --parents --mode="${user_permissions}" "${sandbox_path}" + sudo mkdir --parents --mode="${user_permissions}" "${sandbox_path}" error_handler "$?" "Preparing sandbox ${sandbox_path} has failed!" } @@ -34,7 +34,7 @@ function download_package() { package_url="${2}" more_options="${3}" - wget --https-only --continue --server-response --show-progress "${package_url}" -P "${download_dir}" + wget --https-only --continue --quiet --server-response "${package_url}" -P "${download_dir}" error_handler "$?" "Downloading package ${package_url} has failed!" } @@ -70,11 +70,15 @@ function zip_extract_package() { package_path="${1}" destination_path="${2}" - sudo unzip -v "${package_path}" + temp=$(pwd) - insert_package "${package_path}" "${destination_path}" + cd "${destination_path}" + + sudo unzip -q "${package_path}" error_handler "$?" "Extracting package ${package_path} has failed!" + + cd ${temp} } ## diff --git a/setup-environment/setup-scripts/tools/setup-android-ndk.sh b/setup-environment/setup-scripts/tools/setup-android-ndk.sh new file mode 100644 index 00000000..15d70ce0 --- /dev/null +++ b/setup-environment/setup-scripts/tools/setup-android-ndk.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +source "./setup-environment/setup-scripts/variables.sh" +source "${abstract_scripts}" + +function download_ndk() { + download_package "${download_dir}" "${ndk_url}" "" +} + +function extract_ndk() { + zip_extract_package "${ndk_provisional_path}" "${sandbox_path}" +} + +function cleanup_ndk() { + rm --verbose "${download_dir}/${ndk_zip_name}" +} + +function create_clang_symbols() { + create_sandbox_symbol "${sandbox_path}/${ndk_zip_content}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \ + "${clang_symbol}" + + create_sandbox_symbol "${sandbox_path}/${ndk_zip_content}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++" \ + "${clangpp_symbol}" +} + +function create_ndk_headers_symbol() { + create_sandbox_symbol "${sandbox_path}/${ndk_zip_content}/prebuilts/ndk/headers" \ + "${android_ndk_headers}" +} \ No newline at end of file diff --git a/setup-environment/setup-scripts/tools/setup-cmake.sh b/setup-environment/setup-scripts/tools/setup-cmake.sh index 5384b4be..9b2b6f32 100644 --- a/setup-environment/setup-scripts/tools/setup-cmake.sh +++ b/setup-environment/setup-scripts/tools/setup-cmake.sh @@ -19,6 +19,10 @@ function create_cmake_symbol() { create_sandbox_symbol "${sandbox_path}/${cmake_tar_content}/bin/cmake" "${cmake_symbol}" } +function create_posix_headers_symbol() { + create_sandbox_symbol "/usr/include" "${posix_headers_symbol}" +} + function install_gcc_multilib() { sudo apt-get install gcc-multilib sudo apt-get install g++-multilib diff --git a/setup-environment/setup-scripts/tools/setup-jdk.sh b/setup-environment/setup-scripts/tools/setup-jdk.sh index 37090aad..664c3e82 100644 --- a/setup-environment/setup-scripts/tools/setup-jdk.sh +++ b/setup-environment/setup-scripts/tools/setup-jdk.sh @@ -17,6 +17,7 @@ function cleanup_jdk() { function create_java_symbol() { create_sandbox_symbol "${sandbox_path}/${jdk_tar_content}/bin/java" "${java_symbol}" + create_sandbox_symbol "${sandbox_path}/${jdk_tar_content}/include" "${java_headers}" } function setup_java_home() { diff --git a/setup-environment/setup-scripts/variables.sh b/setup-environment/setup-scripts/variables.sh index 86c6406d..00038700 100644 --- a/setup-environment/setup-scripts/variables.sh +++ b/setup-environment/setup-scripts/variables.sh @@ -3,6 +3,7 @@ working_dir=$(pwd) root_path="${working_dir}" sandbox_path="/opt/electrostatic-sandbox" local_bin="/usr/local/bin" +local_include="/usr/local/include" unit_tests="${root_path}/setup-environment/setup-scripts/testing/testing.sh" abstract_scripts="${root_path}/setup-environment/setup-scripts/abstract/setup-utils.sh" @@ -12,6 +13,7 @@ setup_ide_script="${root_path}/setup-environment/setup-scripts/tools/setup-ide.s setup_gradle_script="${root_path}/setup-environment/setup-scripts/tools/setup-gradle.sh" setup_cmake_script="${root_path}/setup-environment/setup-scripts/tools/setup-cmake.sh" setup_avrdude_script="${root_path}/setup-environment/setup-scripts/tools/setup-avrdude.sh" +setup_android_ndk_script="${root_path}/setup-environment/setup-scripts/tools/setup-android-ndk.sh" download_dir="${HOME}/Downloads" ## @@ -30,6 +32,7 @@ jdk_url="https://download.oracle.com/java/20/archive/jdk-20.0.2_linux-x64_bin.ta jdk_tar_name="jdk-20.0.2_linux-x64_bin.tar.gz" jdk_tar_content="jdk-20.0.2" java_symbol="${local_bin}/java-20.0.2" +java_headers="${local_include}/java-20.0.2-headers" jdk_provisional_path="${download_dir}/${jdk_tar_name}" @@ -50,6 +53,18 @@ cmake_tar_name="cmake-3.19.6-Linux-x86_64.tar.gz" cmake_tar_content="cmake-3.19.6-Linux-x86_64" cmake_symbol="${local_bin}/cmake-3.19" cmake_provisional_path="${download_dir}/${cmake_tar_name}" +posix_headers_symbol="${local_include}/posix-headers" + +## +# Android NDK +## +ndk_url="https://dl.google.com/android/repository/android-ndk-r26d-linux.zip" +ndk_zip_name="android-ndk-r26d-linux.zip" +ndk_zip_content="android-ndk-r26d" +clang_symbol="${local_bin}/android-clang" +clangpp_symbol="${local_bin}/android-clang++" +android_ndk_headers="${local_include}/android-ndk-headers" +ndk_provisional_path="${download_dir}/${ndk_zip_name}" ## # AVRDude