moving native code around
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-03 12:38:40 -05:00
parent 7e6b0a1703
commit a9c7118ac5
29 changed files with 47 additions and 116 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "src/fluid/lib/stb"] [submodule "src/fluid/lib/stb"]
path = src/fluid/lib/stb path = src/main/c/lib/stb
url = https://github.com/nothings/stb.git url = https://github.com/nothings/stb.git

View File

@ -21,6 +21,7 @@
"electrosphere_server_fluid_manager_serverfluidchunk.h": "c", "electrosphere_server_fluid_manager_serverfluidchunk.h": "c",
"stdio.h": "c", "stdio.h": "c",
"cstdlib": "c", "cstdlib": "c",
"pool.h": "c" "pool.h": "c",
"mainfunctions.h": "c"
} }
} }

View File

@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.20.0)
project(StormEngine VERSION 0.1.0 LANGUAGES C) project(StormEngine VERSION 0.1.0 LANGUAGES C)
# Find sources # Find sources
file(GLOB_RECURSE SOURCES src/fluid/src/**.c) file(GLOB_RECURSE SOURCES src/main/c/src/**.c)
# include header files # include header files
include_directories(src/fluid/includes) include_directories(src/main/c/includes)
# include jni # include jni
set(JAVA_AWT_LIBRARY NotNeeded) set(JAVA_AWT_LIBRARY NotNeeded)
@ -22,17 +22,16 @@ add_library(StormEngine SHARED ${SOURCES})
# set props for the lib # set props for the lib
target_compile_options(StormEngine PRIVATE -m64 -mavx -mavx2) target_compile_options(StormEngine PRIVATE -m64 -mavx -mavx2)
# set shared library output dir
set_target_properties(StormEngine PROPERTIES set_target_properties(StormEngine PROPERTIES
CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/shared-folder CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/shared-folder
) )
# include and enable testing # include and enable testing
include(CTest) include(CTest)
enable_testing() enable_testing()
# emit test driver to outdir
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/build)
# Grab test files # Grab test files
file(GLOB_RECURSE TEST_FILES ${CMAKE_SOURCE_DIR}/test/c/**.c) file(GLOB_RECURSE TEST_FILES ${CMAKE_SOURCE_DIR}/test/c/**.c)
set(TEST_DRIVER test_driver.c) set(TEST_DRIVER test_driver.c)
@ -51,6 +50,11 @@ create_test_sourcelist(TEST_SOURCE_LIST ${TEST_DRIVER} ${TEST_SOURCES})
# Create test executable # Create test executable
add_executable(test_runner ${TEST_SOURCE_LIST}) add_executable(test_runner ${TEST_SOURCE_LIST})
# emit test driver to outdir
set_target_properties(test_runner PROPERTIES
CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/build
)
# link the library to the test executable # link the library to the test executable
target_link_libraries(test_runner StormEngine) target_link_libraries(test_runner StormEngine)

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Tue Dec 03 11:43:16 EST 2024 #Tue Dec 03 12:29:34 EST 2024
buildNumber=513 buildNumber=516

View File

@ -1224,6 +1224,9 @@ Integrate CMake + Ninja
Add testing to native code side Add testing to native code side
Add native testing step to jenkins pipeline Add native testing step to jenkins pipeline
(12/03/2024)
Native code building correctly in jenkins pipeline
# TODO # TODO

View File

@ -520,7 +520,7 @@
<configuration> <configuration>
<compilerArgs> <compilerArgs>
<arg>-h</arg> <arg>-h</arg>
<arg>src/main/c/includes</arg> <arg>src/main/c/includes/native</arg>
</compilerArgs> </compilerArgs>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -1,101 +0,0 @@
cd ./src/fluid
echo "[Fluid Lib] SAVE STEPS $SAVE_STEPS"
LIB_ENDING=".so"
BASE_INCLUDE_DIR=""
OS_INCLUDE_DIR=""
#determine os
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
#linux
LIB_ENDING=".so"
BASE_INCLUDE_DIR="${JAVA_HOME}/include"
OS_INCLUDE_DIR="${JAVA_HOME}/include/linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
LIB_ENDING=".so"
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
LIB_ENDING=".dll"
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
LIB_ENDING=".dll"
BASE_INCLUDE_DIR="${JAVA_HOME}/include"
OS_INCLUDE_DIR="${JAVA_HOME}/include/win32"
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
LIB_ENDING=".dll"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
# ...
LIB_ENDING=".so"
else
# Unknown.
LIB_ENDING=".so"
fi
# echo $PWD
#clean compile dir
rm -f ./*.o
rm -f ./*.so
rm -f ./*.dll
#compile object files
# COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -msse -msse2 -msse3 -mmmx -m3dnow"
# INPUT_FILES="./src/densitystep.c"
# OUTPUT_FILE="./densitystep.o"
# gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
# COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -msse -msse2 -msse3 -mmmx -m3dnow"
# INPUT_FILES="./src/velocitystep.c"
# OUTPUT_FILE="./velocitystep.o"
# gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
# COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -msse -msse2 -msse3 -mmmx -m3dnow"
# INPUT_FILES="./src/chunkmask.c"
# OUTPUT_FILE="./chunkmask.o"
# gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
INPUT_FILES="./src/javainterface.c"
OUTPUT_FILE="./javainterface.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
INPUT_FILES="./src/fluidsim.c"
OUTPUT_FILE="./fluidsim.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
INPUT_FILES="./src/metadata/metadatacalc.c"
OUTPUT_FILE="./metadatacalc.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
INPUT_FILES="./src/mem/fluidmem.c"
OUTPUT_FILE="./fluidmem.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
COMPILE_FLAGS="-c -fPIC -m64 -mavx -mavx2 -march=native -Ofast -DSAVE_STEPS=$SAVE_STEPS"
INPUT_FILES="./src/mem/pool.c"
OUTPUT_FILE="./pool.o"
gcc $COMPILE_FLAGS -I"$BASE_INCLUDE_DIR" -I"$OS_INCLUDE_DIR" $INPUT_FILES -o $OUTPUT_FILE
#compile shared object file
OUTPUT_FILE="libfluidsim$LIB_ENDING"
COMPILE_FLAGS="-shared"
INPUT_FILES="fluidsim.o javainterface.o metadatacalc.o fluidmem.o pool.o"
gcc $COMPILE_FLAGS $INPUT_FILES -o $OUTPUT_FILE
#move to resources
mkdir -p ../../shared-folder
mv "./libfluidsim$LIB_ENDING" "../../shared-folder/"
#clean compile dir
rm -f ./*.o
rm -f ./*.so
rm -f ./*.dll

View File

@ -1,3 +1,25 @@
# determine environment variables
LIB_ENDING=".so"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
#linux
LIB_ENDING=".so"
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
LIB_ENDING=".dll"
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
LIB_ENDING=".dll"
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
LIB_ENDING=".dll"
fi
# Builds the native code # Builds the native code
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE= -D CMAKE_INSTALL_PREFIX=${PWD}/out/install -S ${PWD} -B ${PWD}/out/build -G Ninja cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE= -D CMAKE_INSTALL_PREFIX=${PWD}/out/install -S ${PWD} -B ${PWD}/out/build -G Ninja
cmake --build ${PWD}/out/build cmake --build ${PWD}/out/build
#copy to expected folder
mkdir ${PWD}/shared-folder
cp ${PWD}/out/build/libStormEngine${LIB_ENDING} ${PWD}/shared-folder/

View File

@ -1,3 +1,5 @@
#include <jni.h>
#ifndef ENVIRONMENT_H #ifndef ENVIRONMENT_H
#define ENVIRONMENT_H #define ENVIRONMENT_H

View File

@ -1,7 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include "../includes/utilities.h" #include "../includes/utilities.h"
#include "../includes/chunkmask.h" #include "../includes/chunkmask.h"
#include "../../main/c/includes/electrosphere_server_fluid_simulator_FluidAcceleratedSimulator.h" #include "..//includes/native/electrosphere_server_fluid_simulator_FluidAcceleratedSimulator.h"
#include "../includes/mainFunctions.h" #include "../includes/mainFunctions.h"
#include "../includes/chunk.h" #include "../includes/chunk.h"
#include "../includes/simulation.h" #include "../includes/simulation.h"

View File

@ -1,8 +1,8 @@
#include <jni.h> #include <jni.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../../main/c/includes/electrosphere_server_fluid_manager_ServerFluidChunk.h" #include "../..//includes/native/electrosphere_server_fluid_manager_ServerFluidChunk.h"
#include "../../../main/c/includes/electrosphere_client_fluid_cache_FluidChunkData.h" #include "../..//includes/native/electrosphere_client_fluid_cache_FluidChunkData.h"
#include "../../includes/mem/pool.h" #include "../../includes/mem/pool.h"