implements mblender-info command line option.

implmements patch discovery
This commit is contained in:
Jaume Bellet 2023-10-24 18:46:48 +02:00
parent 16071e49de
commit 260514cd54
8 changed files with 207 additions and 1 deletions

View File

@ -159,6 +159,7 @@ add_subdirectory(functions)
add_subdirectory(makesdna)
add_subdirectory(makesrna)
add_subdirectory(compositor)
add_subdirectory(mblender)
if(WITH_BLENDER_THUMBNAILER)
add_subdirectory(blendthumb)

View File

@ -0,0 +1,40 @@
#
#
#
set(INC
.
../blenlib
)
set(LIB
PRIVATE bf::blenlib
)
if(WITH_BOOST)
list(APPEND INC_SYS
${BOOST_INCLUDE_DIR}
)
else()
message (FATAL_ERROR "mblender requires WITH_BOOST")
endif()
# Auto fill source files, so patches will not touch that file
file(GLOB sources "MB_*")
foreach(source ${sources})
get_filename_component(name ${source} NAME)
list(APPEND SRC "${name}")
endforeach()
# Generate a Definition for each found patch
file(GLOB patches "patches/*.h")
foreach(patch ${patches})
get_filename_component(def ${patch} NAME_WE)
get_filename_component(name ${patch} NAME)
add_definitions(-D${def})
# list(APPEND SRC "patches/${name}")
endforeach()
blender_add_lib(mblender "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@ -0,0 +1,51 @@
/**
*
*/
#include "MB_patches.h"
#include <boost/preprocessor/if.hpp>
#include <stdio.h>
#include <string.h>
char patches[MAX_MB_PATCHES][8] = {0};
void MB_patches_discover()
{
int i = 0;
BOOST_PP_IF(MB_0001_APPLIED, strcpy(patches[i++], "MB_0001"), );
BOOST_PP_IF(MB_0002_APPLIED, strcpy(patches[i++], "MB_0002"), );
BOOST_PP_IF(MB_0003_APPLIED, strcpy(patches[i++], "MB_0003"), );
BOOST_PP_IF(MB_0004_APPLIED, strcpy(patches[i++], "MB_0004"), );
BOOST_PP_IF(MB_0005_APPLIED, strcpy(patches[i++], "MB_0005"), );
BOOST_PP_IF(MB_0006_APPLIED, strcpy(patches[i++], "MB_0006"), );
BOOST_PP_IF(MB_0007_APPLIED, strcpy(patches[i++], "MB_0007"), );
BOOST_PP_IF(MB_0008_APPLIED, strcpy(patches[i++], "MB_0008"), );
BOOST_PP_IF(MB_0009_APPLIED, strcpy(patches[i++], "MB_0009"), );
BOOST_PP_IF(MB_0010_APPLIED, strcpy(patches[i++], "MB_0010"), );
return;
}
void MB_init(void) {
MB_patches_discover();
}
char** MB_patches_get() {
return (char**) patches;
}
void MB_print_info()
{
printf("%s", "Mechanical Blender Info\n");
printf("%s", "---------------------\n");
for (int i = 0; i < MAX_MB_PATCHES; i++) {
if (*patches[i] != '\0') {
printf("Applied Patch %s\n", patches[i]);
}
}
printf("%s", "---------------------\n");
}

View File

@ -0,0 +1,15 @@
/**
*
*/
#ifndef MB_BLENDER_H
#define MB_BLENDER_H
void MB_init(void);
void MB_patches_discover(void);
void MB_patches_get(void);
void MB_print_info(void);
#endif

View File

@ -0,0 +1,79 @@
#ifndef MB_BLENDER_PATCHES_H
#define MB_BLENDER_PATCHES_H
#ifdef MB_0001
#include "patches/MB_0001.h"
#define MB_0001_APPLIED 1
#else
#define MB_0001_APPLIED 0
#endif
#ifdef MB_0002
#include "patches/MB_0002.h"
#define MB_0002_APPLIED 1
#else
#define MB_0002_APPLIED 0
#endif
#ifdef MB_0003
#include "patches/MB_0003.h"
#define MB_0003_APPLIED 1
#else
# define MB_0003_APPLIED 0
#endif
#ifdef MB_0004
# include "patches/MB_0004.h"
# define MB_0004_APPLIED 1
#else
# define MB_0004_APPLIED 0
#endif
#ifdef MB_0005
# include "patches/MB_0005.h"
# define MB_0005_APPLIED 1
#else
# define MB_0005_APPLIED 0
#endif
#ifdef MB_0006
# include "patches/MB_0005.h"
# define MB_0006_APPLIED 1
#else
# define MB_0006_APPLIED 0
#endif
#ifdef MB_0007
# include "patches/MB_0005.h"
# define MB_0007_APPLIED 1
#else
# define MB_0007_APPLIED 0
#endif
#ifdef MB_0008
# include "patches/MB_0005.h"
# define MB_0008_APPLIED 1
#else
# define MB_0008_APPLIED 0
#endif
#ifdef MB_0009
# include "patches/MB_0005.h"
# define MB_0009_APPLIED 1
#else
# define MB_0009_APPLIED 0
#endif
#ifdef MB_0010
# include "patches/MB_0010.h"
# define MB_0010_APPLIED 1
#else
# define MB_0010_APPLIED 0
#endif
#ifndef MB_0011
#define MAX_MB_PATCHES 12
#endif // !MB_0004
#endif // !MB_BLENDER_PATCHES_H

View File

@ -14,6 +14,7 @@ set(INC
../blender/makesrna
../blender/render
../blender/windowmanager
../blender/mblender
)
set(LIB
@ -21,6 +22,7 @@ set(LIB
PRIVATE bf::dna
PRIVATE bf::intern::guardedalloc
bf_windowmanager
mblender
)
if(HAVE_FEENABLEEXCEPT)

View File

@ -57,6 +57,8 @@
#include "BKE_vfont.h"
#include "BKE_volume.h"
#include "MB_blender.h"
#ifndef WITH_PYTHON_MODULE
# include "BLI_args.h"
#endif
@ -284,7 +286,7 @@ int main(int argc,
)
{
bContext *C;
#ifndef WITH_PYTHON_MODULE
bArgs *ba;
#endif
@ -489,6 +491,8 @@ int main(int argc,
/* Initialize sub-systems that use `BKE_appdir.h`. */
IMB_init();
MB_init();
#ifndef WITH_PYTHON_MODULE
/* First test for background-mode (#Global.background) */
BLI_args_parse(ba, ARG_PASS_SETTINGS, nullptr, nullptr);

View File

@ -47,6 +47,8 @@
# include "GPU_context.h"
# include "MB_blender.h"
# ifdef WITH_FFMPEG
# include "IMB_imbuf.h"
# endif
@ -1483,6 +1485,16 @@ static int arg_handle_start_with_console(int /*argc*/, const char ** /*argv*/, v
return 0;
}
static const char arg_handle_mblender_info_doc[] =
"\n\t"
"Shows Mechanical Blender info on loading.";
static int arg_handle_mblender_info(int /*argc*/, const char ** /*argv*/, void * /*data*/)
{
MB_print_info();
return 0;
}
static const char arg_handle_register_extension_doc[] =
"\n\t"
"Register blend-file extension for current user, then exit (Windows only).";
@ -2527,6 +2539,8 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
BLI_args_add(ba, nullptr, "--open-last", CB(arg_handle_load_last_file), C);
BLI_args_add(ba, nullptr, "--mblender-info", CB(arg_handle_mblender_info), nullptr);
# undef CB
# undef CB_EX
# undef CB_ALL