New library structure prototype
This commit is contained in:
parent
5794e55e59
commit
8da3b4bd43
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "src/rlk"]
|
[submodule "RSEModel/rlk"]
|
||||||
path = src/rlk
|
path = RSEModel/rlk
|
||||||
url = https://github.com/rlk/obj.git
|
url = https://github.com/rlk/obj.git
|
||||||
|
@ -14,53 +14,26 @@ if(DEFINED ENV{MS_COMPATIBLE})
|
|||||||
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
|
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
include(CheckCSourceCompiles)
|
|
||||||
|
|
||||||
add_definitions(-DCONF_NO_GL) # Used for obj-lib to not compile GL part
|
|
||||||
|
|
||||||
|
|
||||||
# Project definition
|
# Project definition
|
||||||
if(DEFINED ENV{CI}) # Jenkins CI integration mode
|
if(DEFINED ENV{CI}) # Jenkins CI integration mode
|
||||||
project(rse-model VERSION $ENV{CI_VERSION}.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Model" LANGUAGES C)
|
project(rse-model VERSION $ENV{CI_VERSION}.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Model" LANGUAGES C)
|
||||||
set(RSE_MOD_NAME $ENV{CI_OUTPUT_NAME}-${PROJECT_VERSION})
|
|
||||||
|
set(RSE_MODEL_NAME $ENV{CI_OUTPUT_NAME}_${PROJECT_VERSION})
|
||||||
else() # Standalone project mode, should not be used for release.
|
else() # Standalone project mode, should not be used for release.
|
||||||
project(rse-model VERSION 1.0.0 DESCRIPTION "RogueSquadron Extractor - Model" LANGUAGES C)
|
project(rse-model VERSION 1.0.0 DESCRIPTION "RogueSquadron Extractor - Model" LANGUAGES C)
|
||||||
set(RSE_MOD_NAME RSE_Model-${PROJECT_VERSION})
|
set(RSE_MODEL_NAME RSEModel_${PROJECT_VERSION})
|
||||||
endif()
|
endif()
|
||||||
# Push compile infos to source
|
set(RSP_MODEL_LIB_NAME RSPModel${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR})
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
|
|
||||||
|
|
||||||
|
|
||||||
# Import needed packages and references their include path
|
# The project is divided in two parts:
|
||||||
#find_package(GLEW REQUIRED) # Enable when GL rendering is ready
|
# - RSPModelLib is the parser library for model type data, it's take HOB file as input and output extracted datas.
|
||||||
#include_directories(${GLEW_INCLUDE_DIR})
|
# It is intended to be used by others apps like rendering engine or others.
|
||||||
|
# - RSEModel is the standalone application of the library, take HOB file in argument and output OBJ/MTL file.
|
||||||
|
# Artists or users can directly use this program to retrieve data in common datas format.
|
||||||
# Define src/headers files
|
add_subdirectory(RSPModelLib)
|
||||||
FILE(GLOB_RECURSE RSE_MOD_SOURCES src/*.c)
|
add_subdirectory(RSEModel)
|
||||||
FILE(GLOB_RECURSE RSE_MOD_HEADERS src/*.h)
|
|
||||||
SOURCE_GROUP("Source Files" FILES ${RSE_MOD_SOURCES})
|
|
||||||
SOURCE_GROUP("Header Files" FILES ${RSE_MOD_HEADERS})
|
|
||||||
|
|
||||||
|
|
||||||
# Building instructions for RSE-Model
|
|
||||||
if(DEFINED ENV{RSE-WS})
|
|
||||||
set(CMAKE_BUILD_TYPE DEBUG)
|
|
||||||
endif()
|
|
||||||
#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
add_executable(rse-model ${RSE_MOD_SOURCES} ${RSE_MOD_HEADERS}) # Set the inputs for the compiler (srcs&hrds)
|
|
||||||
set_property(TARGET rse-model PROPERTY C_STANDARD 90)
|
|
||||||
set_target_properties(rse-model PROPERTIES OUTPUT_NAME ${RSE_MOD_NAME}) # Define the executable file name
|
|
||||||
# Link externals libraries to the linker
|
|
||||||
if(MSVC)
|
|
||||||
# msvc does not append 'lib' - do it here to have consistent name
|
|
||||||
#set_target_properties(rse-model PROPERTIES PREFIX "lib")
|
|
||||||
set_target_properties(rse-model PROPERTIES IMPORT_PREFIX "lib")
|
|
||||||
target_link_libraries(rse-model ${GLEW_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_link_libraries(rse-model ${GLEW_LIBRARIES} m)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# GPG signature custom command
|
# GPG signature custom command
|
||||||
|
43
RSEModel/CMakeLists.txt
Normal file
43
RSEModel/CMakeLists.txt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# CMakeLists.txt
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# Written by JackCarterSmith, 2022
|
||||||
|
# This code is released under the RSE license.
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
|
# General configuration
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
|
add_definitions(-DCONF_NO_GL) # Used for obj-lib to not compile GL part
|
||||||
|
|
||||||
|
# Import needed packages and references their include path
|
||||||
|
#find_package(GLEW REQUIRED) # Enable when GL rendering is ready
|
||||||
|
#include_directories(${GLEW_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# Push compile infos to source
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)
|
||||||
|
|
||||||
|
|
||||||
|
# Define src/headers files
|
||||||
|
FILE(GLOB_RECURSE RSE_MOD_SOURCES ./*.c)
|
||||||
|
SOURCE_GROUP("Source Files" FILES ${RSE_MOD_SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
# Building instructions for RSE-Model
|
||||||
|
if(DEFINED ENV{RSE-WS})
|
||||||
|
set(CMAKE_BUILD_TYPE DEBUG)
|
||||||
|
endif()
|
||||||
|
add_executable(rse-model ${RSE_MOD_SOURCES})
|
||||||
|
set_property(TARGET rse-model PROPERTY C_STANDARD 90)
|
||||||
|
target_include_directories(rse-model PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set_target_properties(rse-model PROPERTIES OUTPUT_NAME ${RSE_MODEL_NAME})
|
||||||
|
# Link externals libraries to the linker
|
||||||
|
if(MSVC)
|
||||||
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
|
set_target_properties(rse-model PROPERTIES IMPORT_PREFIX "lib")
|
||||||
|
target_link_libraries(rse-model PRIVATE ${GLEW_LIBRARIES} rsp-model-lib)
|
||||||
|
else()
|
||||||
|
target_link_libraries(rse-model PRIVATE ${GLEW_LIBRARIES} m rsp-model-lib)
|
||||||
|
endif()
|
@ -15,14 +15,15 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
#include "errors_types.h"
|
#include <errors_types.h>
|
||||||
|
#include <hob_struct.h>
|
||||||
|
#include <hob_parser.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "hob_struct.h"
|
|
||||||
#include "hob_parser.h"
|
|
||||||
#include "obj_exporter.h"
|
#include "obj_exporter.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal functions declarations
|
* Internal functions declarations
|
||||||
*/
|
*/
|
||||||
@ -75,7 +76,7 @@ static unsigned int mainProcess(int args_cnt, char* args_value[], T_PROG_OPTIONS
|
|||||||
printf("\n=============================================\n[INFO] - Parsing file: %s ...\n", args_value[file_index]);
|
printf("\n=============================================\n[INFO] - Parsing file: %s ...\n", args_value[file_index]);
|
||||||
hobStruct = calloc(1, sizeof(T_HOB));
|
hobStruct = calloc(1, sizeof(T_HOB));
|
||||||
// Parse data from HOB file and put in T_HOB structure.
|
// Parse data from HOB file and put in T_HOB structure.
|
||||||
if (parseHOBFile(args_value[file_index], hobStruct, p_opts) != NO_ERROR) {
|
if (RSP_ModelLib_ParseHOBFile(args_value[file_index], hobStruct, p_opts) != NO_ERROR) {
|
||||||
printf("[ERR] Failed to parse datas from %s\n", args_value[file_index]);
|
printf("[ERR] Failed to parse datas from %s\n", args_value[file_index]);
|
||||||
free(hobStruct);
|
free(hobStruct);
|
||||||
return ERROR_PROCESS;
|
return ERROR_PROCESS;
|
1
RSEModel/config.h
Normal file
1
RSEModel/config.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#define VERSION "1.0.0"
|
@ -9,9 +9,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "errors_types.h"
|
#include <errors_types.h>
|
||||||
|
#include <hob_struct.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "hob_struct.h"
|
|
||||||
#include "rlk/obj.h"
|
#include "rlk/obj.h"
|
||||||
#include "obj_exporter.h"
|
#include "obj_exporter.h"
|
||||||
|
|
38
RSPModelLib/CMakeLists.txt
Normal file
38
RSPModelLib/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# CMakeLists.txt
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# Written by JackCarterSmith, 2022
|
||||||
|
# This code is released under the RSE license.
|
||||||
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
|
# General library configuration
|
||||||
|
if(DEFINED ENV{MS_COMPATIBLE})
|
||||||
|
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
|
# Push compile infos to source
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)
|
||||||
|
|
||||||
|
|
||||||
|
# Define src/headers files
|
||||||
|
FILE(GLOB_RECURSE RSP_MOD_SOURCES ./*.c)
|
||||||
|
SOURCE_GROUP("Source Files" FILES ${RSP_MOD_SOURCES})
|
||||||
|
|
||||||
|
|
||||||
|
# Building instructions for RSE-Model
|
||||||
|
if(DEFINED ENV{RSE-WS})
|
||||||
|
set(CMAKE_BUILD_TYPE DEBUG)
|
||||||
|
endif()
|
||||||
|
add_library(rsp-model-lib ${RSP_MOD_SOURCES})
|
||||||
|
set_property(TARGET rsp-model-lib PROPERTY C_STANDARD 90)
|
||||||
|
target_include_directories(rsp-model-lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set_target_properties(rsp-model-lib PROPERTIES OUTPUT_NAME ${RSP_MODEL_LIB_NAME})
|
||||||
|
# Link externals libraries to the linker
|
||||||
|
if(MSVC)
|
||||||
|
# msvc does not append 'lib' - do it here to have consistent name
|
||||||
|
set_target_properties(rsp-model-lib PROPERTIES PREFIX "lib")
|
||||||
|
endif()
|
1
RSPModelLib/config.h
Normal file
1
RSPModelLib/config.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#define VERSION "1.0.0"
|
1
RSPModelLib/config.h.in
Normal file
1
RSPModelLib/config.h.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
#define VERSION "@PROJECT_VERSION@"
|
@ -15,7 +15,7 @@
|
|||||||
#include "hob_parser.h"
|
#include "hob_parser.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned char parseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts) {
|
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts) {
|
||||||
unsigned char err = NO_ERROR;
|
unsigned char err = NO_ERROR;
|
||||||
long fileSize;
|
long fileSize;
|
||||||
FILE* fStream = NULL;
|
FILE* fStream = NULL;
|
@ -6,10 +6,13 @@
|
|||||||
* \brief Decode HOB file structure.
|
* \brief Decode HOB file structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
#include "hob_struct.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef SRC_HOB_PARSER_H_
|
#ifndef SRC_HOB_PARSER_H_
|
||||||
#define SRC_HOB_PARSER_H_
|
#define SRC_HOB_PARSER_H_
|
||||||
|
|
||||||
unsigned char parseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts);
|
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts);
|
||||||
|
|
||||||
#endif /* SRC_HOB_PARSER_H_ */
|
#endif /* SRC_HOB_PARSER_H_ */
|
32
RSPModelLib/options.h
Normal file
32
RSPModelLib/options.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* \file options.h
|
||||||
|
* \date 29/07/2022
|
||||||
|
* \author JackCarterSmith
|
||||||
|
* \copyright GPL-v3.0
|
||||||
|
* \brief Shared options structure definition and declaration.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OPTIONS_H_
|
||||||
|
#define OPTIONS_H_
|
||||||
|
|
||||||
|
/// Options structure
|
||||||
|
typedef union u_prog_options {
|
||||||
|
struct {
|
||||||
|
unsigned char verbose_mode:1; //!< Output simple details about ID and other "light" things.
|
||||||
|
|
||||||
|
unsigned char output_dir:1; //!< Export extracted datas to a sub-directory.
|
||||||
|
unsigned char export_mtl:1; //!< Export materials datas with object.
|
||||||
|
|
||||||
|
unsigned char reserved0:5; //!< For future use.
|
||||||
|
|
||||||
|
unsigned char debug_mode:1; //!< Output all values of faces, indices and vertices and others "heavy" things.
|
||||||
|
unsigned char god_mode:1; //!< Dev only. Output experimental values.
|
||||||
|
|
||||||
|
unsigned char reserved1:6; //!< For future use.
|
||||||
|
|
||||||
|
unsigned short input_files_cnt; //!< Internal files counters.
|
||||||
|
};
|
||||||
|
unsigned int raw; //!< Raw options access for bit-masking or memory copy/compare.
|
||||||
|
} T_PROG_OPTIONS ;
|
||||||
|
|
||||||
|
#endif /* OPTIONS_H_ */
|
Loading…
x
Reference in New Issue
Block a user