[Bf-blender-cvs] [6e66ffb] master: Cleanup split creator.c

Campbell Barton noreply at git.blender.org
Sat Feb 27 19:32:21 CET 2016


Commit: 6e66ffb61abf0952f3ec8d820e58da9df7f6db6f
Author: Campbell Barton
Date:   Sun Feb 28 05:10:00 2016 +1100
Branches: master
https://developer.blender.org/rB6e66ffb61abf0952f3ec8d820e58da9df7f6db6f

Cleanup split creator.c

creator.c was getting hard to follow.

- Split off argument and signal handling into own files.
- Move docstrings next to functions (to keep docs grouped with code).

===================================================================

M	source/creator/CMakeLists.txt
M	source/creator/creator.c
A	source/creator/creator_args.c
A	source/creator/creator_intern.h
A	source/creator/creator_signals.c

===================================================================

diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 74b26d1..765f98b 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -102,6 +102,10 @@ endif()
 # Setup the exe sources and buildinfo
 set(SRC
 	creator.c
+	creator_args.c
+	creator_signals.c
+
+	creator_intern.h
 )
 
 # MSVC 2010 gives linking errors with the manifest
diff --git a/source/creator/creator.c b/source/creator/creator.c
index b2bfe7f..2c2af7c 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -29,1748 +29,137 @@
  *  \ingroup creator
  */
 
+#include <stdlib.h>
+#include <string.h>
 
-#if defined(__linux__) && defined(__GNUC__)
-#  define _GNU_SOURCE
-#  include <fenv.h>
-#endif
-
-#if (defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
-#  define OSX_SSE_FPE
-#  include <xmmintrin.h>
-#endif
-
-#ifdef WIN32
-#  if defined(_MSC_VER) && defined(_M_X64)
-#    include <math.h> /* needed for _set_FMA3_enable */
-#  endif
-#  include <windows.h>
-#  include "utfconv.h"
-#endif
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-
-/* This little block needed for linking to Blender... */
-
-#include "MEM_guardedalloc.h"
-
-#ifdef WIN32
-#  include "BLI_winstuff.h"
-#endif
-
-#include "BLI_args.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-#include "BLI_callbacks.h"
-#include "BLI_blenlib.h"
-#include "BLI_mempool.h"
-#include "BLI_system.h"
-#include BLI_SYSTEM_PID_H
-
-#include "DNA_ID.h"
-#include "DNA_scene_types.h"
-#include "DNA_userdef_types.h"
-
-#include "BKE_appdir.h"
-#include "BKE_blender.h"
-#include "BKE_brush.h"
-#include "BKE_context.h"
-#include "BKE_depsgraph.h" /* for DAG_on_visible_update */
-#include "BKE_font.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_material.h"
-#include "BKE_modifier.h"
-#include "BKE_scene.h"
-#include "BKE_node.h"
-#include "BKE_report.h"
-#include "BKE_sound.h"
-#include "BKE_image.h"
-#include "BKE_particle.h"
-
-#include "DEG_depsgraph.h"
-
-#include "IMB_imbuf.h"  /* for IMB_init */
-
-#ifdef WITH_PYTHON
-#include "BPY_extern.h"
-#endif
-
-#include "RE_engine.h"
-#include "RE_pipeline.h"
-#include "RE_render_ext.h"
-
-#include "ED_datafiles.h"
-#include "ED_util.h"
-
-#include "WM_api.h"
-
-#include "RNA_define.h"
-
-#include "GPU_draw.h"
-#include "GPU_extensions.h"
-
-#ifdef WITH_FREESTYLE
-#  include "FRS_freestyle.h"
-#endif
-
-#ifdef WITH_BUILDINFO_HEADER
-#  define BUILD_DATE
-#endif
-
-/* for passing information between creator and gameengine */
-#ifdef WITH_GAMEENGINE
-#  include "BL_System.h"
-#else /* dummy */
-#  define SYS_SystemHandle int
-#endif
-
-#include <signal.h>
-
-#ifdef __FreeBSD__
-#  include <sys/types.h>
-#  include <floatingpoint.h>
-#  include <sys/rtprio.h>
-#endif
-
-#ifdef WITH_BINRELOC
-#  include "binreloc.h"
-#endif
-
-#ifdef WITH_LIBMV
-#  include "libmv-capi.h"
-#endif
-
-#ifdef WITH_CYCLES_LOGGING
-#  include "CCL_api.h"
-#endif
-
-#ifdef WITH_SDL_DYNLOAD
-#  include "sdlew.h"
-#endif
-
-/* from buildinfo.c */
-#ifdef BUILD_DATE
-extern char build_date[];
-extern char build_time[];
-extern char build_hash[];
-extern unsigned long build_commit_timestamp;
-
-/* TODO(sergey): ideally size need to be in sync with buildinfo.c */
-extern char build_commit_date[16];
-extern char build_commit_time[16];
-
-extern char build_branch[];
-extern char build_platform[];
-extern char build_type[];
-extern char build_cflags[];
-extern char build_cxxflags[];
-extern char build_linkflags[];
-extern char build_system[];
-#endif
-
-/*	Local Function prototypes */
-#ifdef WITH_PYTHON_MODULE
-int  main_python_enter(int argc, const char **argv);
-void main_python_exit(void);
-#else
-static int print_help(int argc, const char **argv, void *data);
-static int print_version(int argc, const char **argv, void *data);
-#endif
-
-/* for the callbacks: */
-#ifndef WITH_PYTHON_MODULE
-#define BLEND_VERSION_FMT         "Blender %d.%02d (sub %d)"
-#define BLEND_VERSION_ARG         BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION
-/* pass directly to printf */
-#define BLEND_VERSION_STRING_FMT  BLEND_VERSION_FMT "\n", BLEND_VERSION_ARG
-#endif
-
-/* Initialize callbacks for the modules that need them */
-static void setCallbacks(void); 
-
-static unsigned char python_exit_code_on_error = 0;
-
-#ifndef WITH_PYTHON_MODULE
-
-static bool use_crash_handler = true;
-static bool use_abort_handler = true;
-
-/* set breakpoints here when running in debug mode, useful to catch floating point errors */
-#if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE)
-static void fpe_handler(int UNUSED(sig))
-{
-	fprintf(stderr, "debug: SIGFPE trapped\n");
-}
-#endif
-
-/* handling ctrl-c event in console */
-#if !(defined(WITH_PYTHON_MODULE) || defined(WITH_HEADLESS))
-static void blender_esc(int sig)
-{
-	static int count = 0;
-	
-	G.is_break = true;  /* forces render loop to read queue, not sure if its needed */
-	
-	if (sig == 2) {
-		if (count) {
-			printf("\nBlender killed\n");
-			exit(2);
-		}
-		printf("\nSent an internal break event. Press ^C again to kill Blender\n");
-		count++;
-	}
-}
-#endif
-
-static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
-{
-	printf(BLEND_VERSION_STRING_FMT);
-#ifdef BUILD_DATE
-	printf("\tbuild date: %s\n", build_date);
-	printf("\tbuild time: %s\n", build_time);
-	printf("\tbuild commit date: %s\n", build_commit_date);
-	printf("\tbuild commit time: %s\n", build_commit_time);
-	printf("\tbuild hash: %s\n", build_hash);
-	printf("\tbuild platform: %s\n", build_platform);
-	printf("\tbuild type: %s\n", build_type);
-	printf("\tbuild c flags: %s\n", build_cflags);
-	printf("\tbuild c++ flags: %s\n", build_cxxflags);
-	printf("\tbuild link flags: %s\n", build_linkflags);
-	printf("\tbuild system: %s\n", build_system);
-#endif
-	exit(0);
-
-	return 0;
-}
-
-static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
-{
-	bArgs *ba = (bArgs *)data;
-
-	printf(BLEND_VERSION_STRING_FMT);
-	printf("Usage: blender [args ...] [file] [args ...]\n\n");
-
-	printf("Render Options:\n");
-	BLI_argsPrintArgDoc(ba, "--background");
-	BLI_argsPrintArgDoc(ba, "--render-anim");
-	BLI_argsPrintArgDoc(ba, "--scene");
-	BLI_argsPrintArgDoc(ba, "--render-frame");
-	BLI_argsPrintArgDoc(ba, "--frame-start");
-	BLI_argsPrintArgDoc(ba, "--frame-end");
-	BLI_argsPrintArgDoc(ba, "--frame-jump");
-	BLI_argsPrintArgDoc(ba, "--render-output");
-	BLI_argsPrintArgDoc(ba, "--engine");
-	BLI_argsPrintArgDoc(ba, "--threads");
-	
-	printf("\n");
-	printf("Format Options:\n");
-	BLI_argsPrintArgDoc(ba, "--render-format");
-	BLI_argsPrintArgDoc(ba, "--use-extension");
-
-	printf("\n");
-	printf("Animation Playback Options:\n");
-	BLI_argsPrintArgDoc(ba, "-a");
-				
-	printf("\n");
-	printf("Window Options:\n");
-	BLI_argsPrintArgDoc(ba, "--window-border");
-	BLI_argsPrintArgDoc(ba, "--window-borderless");
-	BLI_argsPrintArgDoc(ba, "--window-geometry");
-	BLI_argsPrintArgDoc(ba, "--start-console");
-	BLI_argsPrintArgDoc(ba, "--no-native-pixels");
-
-
-	printf("\n");
-	printf("Game Engine Specific Options:\n");
-	BLI_argsPrintArgDoc(ba, "-g");
-
-	printf("\n");
-	printf("Python Options:\n");
-	BLI_argsPrintArgDoc(ba, "--enable-autoexec");
-	BLI_argsPrintArgDoc(ba, "--disable-autoexec");
-
-	printf("\n");
-
-	BLI_argsPrintArgDoc(ba, "--python");
-	BLI_argsPrintArgDoc(ba, "--python-text");
-	BLI_argsPrintArgDoc(ba, "--python-expr");
-	BLI_argsPrintArgDoc(ba, "--python-console");
-	BLI_argsPrintArgDoc(ba, "--python-exit-code");
-	BLI_argsPrintArgDoc(ba, "--addons");
-
-
-	printf("\n");
-	printf("Debug Options:\n");
-	BLI_argsPrintArgDoc(ba, "--debug");
-	BLI_argsPrintArgDoc(ba, "--debug-value");
-
-	printf("\n");
-	BLI_argsPrintArgDoc(ba, "--debug-events");
-#ifdef WITH_FFMPEG
-	BLI_argsPrintArgDoc(ba, "--debug-ffmpeg");
-#endif
-	BLI_argsPrintArgDoc(ba, "--debug-handlers");
-#ifdef WITH_LIBMV
-	BLI_argsPrintArgDoc(ba, "--debug-libmv");
-#endif
-#ifdef WITH_CYCLES_LOGGING
-	BLI_argsPrintArgDoc(ba, "--debug-cycles");
-#endif
-	BLI_argsPrintArgDoc(ba, "--debug-memory");
-	BLI_argsPrintArgDoc(ba, "--debug-jobs");
-	BLI_argsPrintArgDoc(ba, "--debug-python");
-	BLI_argsPrintArgDoc(ba, "--debug-depsgraph");
-	BLI_argsPrintArgDoc(ba, "--debug-depsgraph-no-threads");
-
-	BLI_argsPrintArgDoc(ba, "--debug-gpumem");
-	BLI_argsPrintArgDoc(ba, "--debug-wm");
-	BLI_argsPrintArgDoc(ba, "--debug-all");
-
-	printf("\n");
-	BLI_argsPrintArgDoc(ba, "--debug-fpe");
-	BLI_argsPrintArgDoc(ba, "--disable-crash-handler");
-
-	printf("\n");
-	printf("Misc Options:\n");
-	BLI_argsPrintArgDoc(ba, "--factory-startup");
-	printf("\n");
-	BLI_argsPrintArgDoc(ba, "--env-system-datafiles");
-	BLI_argsPrintArgDoc(ba, "--env-system-scripts");
-	BLI_argsPrintArgDoc(ba, "--env-system-python");
-	printf("\n");
-	BLI_argsPrintArgDoc(ba, "-nojoystick");
-	BLI_argsPrintArgDoc(ba, "-noglsl");
-	BLI_argsPrintArgDoc(ba, "-noaudio");
-	BLI_argsPrintArgDoc(ba, "-setaudio");
-
-	printf("\n");
-
-	BLI_argsPrintArgDoc(ba, "--help");
-
-#ifdef WIN32
-	BLI_argsPrintArgDoc(ba, "-R");
-	BLI_argsPrintArgDoc(ba, "-r");
-#endif
-	BLI_argsPrintArgDoc(ba, "--version");
-
-	BLI_argsPrintArgDoc(ba, "--");
-
-	printf("Other Options:\n");
-	BLI_argsPrintOtherDoc(ba);
-
-	printf("\n");
-	printf("Experimental features:\n");
-	BLI_argsPrintArgDoc(ba, "--enable-new-depsgraph");
-
-	printf("Argument Parsing:\n");
-	printf("\tArguments must be separated by white space, eg:\n");
-	printf("\t# blender -ba test.blend\n");
-	printf("\t...will ignore the 'a'\n");
-	printf("\t# blender -b test.blend -f8\n");
-	printf("\t...will ignore '8' because there is no space between the '-f' and the frame value\n\n");
-
-	printf("Argument Order:\n");
-	printf("\tArguments are executed in the order they are given. eg:\n");
-	printf("\t# blender --background test.blend --render-frame 1 --render-output '/tmp'\n");
-	printf("\t...will not render to '/tmp' because '--render-frame 1' renders before the output path is set\n");
-	printf("\t# blender --background --render-output /tmp test.blend --render-frame 1\n");
-	printf("\t...will not render to '/tmp' because lo

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list