diff options
Diffstat (limited to 'source/creator')
-rw-r--r-- | source/creator/CMakeLists.txt | 131 | ||||
-rw-r--r-- | source/creator/creator.c | 133 |
2 files changed, 182 insertions, 82 deletions
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 57e67a971d3..c6674e416d9 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -31,6 +31,7 @@ blender_include_dirs( ../blender/blenlib ../blender/blenkernel ../blender/blenloader + ../blender/depsgraph ../blender/editors/include ../blender/makesrna ../blender/imbuf @@ -239,28 +240,13 @@ if(WITH_BUILDINFO) add_dependencies(blender buildinfo) endif() -# Post build steps for bundling/packaging. - -function(install_text_files_patch path) - install( - CODE - " - set(DATA_FILE \"${path}/readme.html\") - file(READ \"\${DATA_FILE}\" DATA_SRC) - string(REGEX REPLACE \"BLENDER_VERSION\" \"${BLENDER_VERSION}\" DATA_DST \"\${DATA_SRC}\") - file(WRITE \"\${DATA_FILE}\" \"\${DATA_DST}\") - unset(DATA_FILE) - unset(DATA_SRC) - unset(DATA_DST) - " - ) -endfunction() set(BLENDER_TEXT_FILES ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt ${CMAKE_SOURCE_DIR}/release/text/copyright.txt - ${CMAKE_SOURCE_DIR}/release/text/readme.html + # generate this file + # ${CMAKE_SOURCE_DIR}/release/text/readme.html ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bfont.ttf.txt ) @@ -276,11 +262,15 @@ endif() # Platform Specific Var: TARGETDIR_VER if(UNIX AND NOT APPLE) - if(WITH_INSTALL_PORTABLE) - set(TARGETDIR_VER ${BLENDER_VERSION}) + if(WITH_PYTHON_MODULE) + if(WITH_INSTALL_PORTABLE) + set(TARGETDIR_VER ${BLENDER_VERSION}) + else() + set(TARGETDIR_VER ${PYTHON_SITE_PACKAGES}/${BLENDER_VERSION}) + endif() else() - if(WITH_PYTHON_MODULE) - set(TARGETDIR_VER ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${BLENDER_VERSION}) + if(WITH_INSTALL_PORTABLE) + set(TARGETDIR_VER ${BLENDER_VERSION}) else() set(TARGETDIR_VER share/blender/${BLENDER_VERSION}) endif() @@ -422,22 +412,31 @@ if(UNIX AND NOT APPLE) endif() # there are a few differences between portable and system install - if(WITH_INSTALL_PORTABLE) - if(WITH_PYTHON_MODULE) - # pass + if(WITH_PYTHON_MODULE) + if(WITH_INSTALL_PORTABLE) + install( + TARGETS blender + DESTINATION "." + ) else() - if(WITH_DOC_MANPAGE) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1 - DESTINATION "." - ) - endif() + install( + TARGETS blender + LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES} + ) endif() + # none of the other files are needed currently + elseif(WITH_INSTALL_PORTABLE) install( TARGETS blender DESTINATION "." ) + if(WITH_DOC_MANPAGE) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1 + DESTINATION "." + ) + endif() install( FILES ${CMAKE_SOURCE_DIR}/release/freedesktop/blender.desktop @@ -452,26 +451,18 @@ if(UNIX AND NOT APPLE) ) set(BLENDER_TEXT_FILES_DESTINATION ".") - else() # main blender binary - if(WITH_PYTHON_MODULE) - install( - TARGETS blender - LIBRARY DESTINATION ${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages - ) - else() + install( + TARGETS blender + DESTINATION bin + ) + if(WITH_DOC_MANPAGE) + # manpage only with 'blender' binary install( - TARGETS blender - DESTINATION bin + FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1 + DESTINATION share/man/man1 ) - if(WITH_DOC_MANPAGE) - # manpage only with 'blender' binary - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/blender.1 - DESTINATION share/man/man1 - ) - endif() endif() # misc files @@ -503,6 +494,12 @@ if(UNIX AND NOT APPLE) if(WITH_PYTHON) if(WITH_PYTHON_INSTALL) + + install( + FILES ${PYTHON_EXECUTABLE} + DESTINATION ${TARGETDIR_VER}/python/bin + ) + # on some platforms (like openSUSE) Python is linked # to be used from lib64 folder. # determine this from Python's libraries path @@ -653,9 +650,9 @@ elseif(WIN32) execute_process( COMMAND \${CMAKE_COMMAND} -E make_directory - \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python/lib\" + \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\" COMMAND \${CMAKE_COMMAND} -E - chdir \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python/lib\" + chdir \"\${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python\" \${CMAKE_COMMAND} -E tar xzfv \"\${PYTHON_ZIP}\" ) @@ -682,6 +679,19 @@ elseif(WIN32) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy DESTINATION ${BLENDER_VERSION}/python/lib/site-packages) endif() + + + # TODO(sergey): For unti we've got better way to deal with python binary + install( + FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll + DESTINATION ${BLENDER_VERSION}/python/bin + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + install( + FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll + DESTINATION ${BLENDER_VERSION}/python/bin + CONFIGURATIONS Debug + ) endif() unset(_PYTHON_VERSION_NO_DOTS) @@ -853,7 +863,7 @@ elseif(APPLE) ) # install release and app files - set(BLENDER_TEXT_FILES_DESTINATION blender.app/Contents) + set(BLENDER_TEXT_FILES_DESTINATION ".") install( FILES ${OSX_APP_SOURCEDIR}/Contents/PkgInfo @@ -870,6 +880,11 @@ elseif(APPLE) FILES ${LIBDIR}/openmp/lib/libiomp5.dylib DESTINATION blender.app/Contents/Resources/lib/ ) + install( + FILES ${LIBDIR}/openmp/LICENSE.txt + DESTINATION "." + RENAME LICENSE-libiomp5.txt + ) endif() if(WITH_LLVM AND NOT LLVM_STATIC) @@ -972,12 +987,25 @@ endif() # Generic Install, for all targets if(DEFINED BLENDER_TEXT_FILES_DESTINATION) + + install( + CODE + " + file(READ \"${CMAKE_SOURCE_DIR}/release/text/readme.html\" DATA_SRC) + string(REGEX REPLACE \"BLENDER_VERSION\" \"${BLENDER_VERSION}\" DATA_DST \"\${DATA_SRC}\") + file(WRITE \"\${CMAKE_BINARY_DIR}/release/text/readme.html\" \"\${DATA_DST}\") + unset(DATA_SRC) + unset(DATA_DST) + " + ) + list(APPEND BLENDER_TEXT_FILES + ${CMAKE_BINARY_DIR}/release/text/readme.html + ) + install( FILES ${BLENDER_TEXT_FILES} DESTINATION "${BLENDER_TEXT_FILES_DESTINATION}" ) - - install_text_files_patch("\${CMAKE_INSTALL_PREFIX}/${BLENDER_TEXT_FILES_DESTINATION}") endif() # install more files specified elsewhere @@ -993,7 +1021,6 @@ unset(BLENDER_TEXT_FILES_DESTINATION) add_dependencies(blender makesdna) setup_blender_sorted_libs() - target_link_libraries(blender ${BLENDER_SORTED_LIBS}) setup_liblinks(blender) diff --git a/source/creator/creator.c b/source/creator/creator.c index 0ca5fbeccac..a67dbd5a5c9 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -41,7 +41,7 @@ #endif #ifdef WIN32 -# if defined(_MSC_VER) && _MSC_VER >= 1800 && defined(_M_X64) +# if defined(_MSC_VER) && defined(_M_X64) # include <math.h> /* needed for _set_FMA3_enable */ # endif # include <windows.h> @@ -93,6 +93,8 @@ #include "BKE_image.h" #include "BKE_particle.h" +#include "DEG_depsgraph.h" + #include "IMB_imbuf.h" /* for IMB_init */ #ifdef WITH_PYTHON @@ -295,6 +297,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) BLI_argsPrintArgDoc(ba, "--python"); BLI_argsPrintArgDoc(ba, "--python-text"); + BLI_argsPrintArgDoc(ba, "--python-expr"); BLI_argsPrintArgDoc(ba, "--python-console"); BLI_argsPrintArgDoc(ba, "--addons"); @@ -320,6 +323,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) 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-wm"); BLI_argsPrintArgDoc(ba, "--debug-all"); @@ -357,6 +361,10 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) 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\t\"blender -ba test.blend\"\n"); @@ -671,7 +679,11 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo) /* If this is a stack overflow then we can't walk the stack, so just show * where the error happened */ if (EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode) { +#ifdef NDEBUG + TerminateProcess(GetCurrentProcess(), SIGSEGV); +#else blender_crash_handler(SIGSEGV); +#endif } return EXCEPTION_EXECUTE_HANDLER; @@ -811,7 +823,7 @@ static int no_glsl(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(dat static int no_audio(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { - sound_force_device(0); + BKE_sound_force_device(0); return 0; } @@ -822,7 +834,7 @@ static int set_audio(int argc, const char **argv, void *UNUSED(data)) exit(1); } - sound_force_device(sound_define_from_str(argv[1])); + BKE_sound_force_device(BKE_sound_define_from_str(argv[1])); return 1; } @@ -929,6 +941,13 @@ static int set_threads(int argc, const char **argv, void *UNUSED(data)) } } +static int depsgraph_use_new(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) +{ + printf("Using new dependency graph.\n"); + DEG_depsgraph_switch_to_new(); + return 0; +} + static int set_verbosity(int argc, const char **argv, void *UNUSED(data)) { if (argc > 1) { @@ -1024,6 +1043,7 @@ static int set_ge_parameters(int argc, const char **argv, void *data) } /* linearMipMap */ if (STREQ(argv[a], "linearmipmap")) { + GPU_set_mipmap(1); GPU_set_linear_mipmap(1); //linearMipMap = 1; } @@ -1185,19 +1205,24 @@ static int set_skip_frame(int argc, const char **argv, void *data) #define BPY_CTX_SETUP(_cmd) \ { \ wmWindowManager *wm = CTX_wm_manager(C); \ - wmWindow *prevwin = CTX_wm_window(C); \ - Scene *prevscene = CTX_data_scene(C); \ - if (wm->windows.first) { \ + Scene *scene_prev = CTX_data_scene(C); \ + wmWindow *win_prev; \ + const bool has_win = !BLI_listbase_is_empty(&wm->windows); \ + if (has_win) { \ + win_prev = CTX_wm_window(C); \ CTX_wm_window_set(C, wm->windows.first); \ - _cmd; \ - CTX_wm_window_set(C, prevwin); \ } \ else { \ fprintf(stderr, "Python script \"%s\" " \ "running with missing context data.\n", argv[1]); \ + } \ + { \ _cmd; \ } \ - CTX_data_scene_set(C, prevscene); \ + if (has_win) { \ + CTX_wm_window_set(C, win_prev); \ + } \ + CTX_data_scene_set(C, scene_prev); \ } (void)0 \ #endif /* WITH_PYTHON */ @@ -1259,6 +1284,27 @@ static int run_python_text(int argc, const char **argv, void *data) #endif /* WITH_PYTHON */ } +static int run_python_expr(int argc, const char **argv, void *data) +{ +#ifdef WITH_PYTHON + bContext *C = data; + + /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ + if (argc > 1) { + BPY_CTX_SETUP(BPY_string_exec_ex(C, argv[1], false)); + return 1; + } + else { + printf("\nError: you must specify a Python expression after '%s'.\n", argv[0]); + return 0; + } +#else + UNUSED_VARS(argc, argv, data); + printf("This blender was built without python support\n"); + return 0; +#endif /* WITH_PYTHON */ +} + static int run_python_console(int UNUSED(argc), const char **argv, void *data) { #ifdef WITH_PYTHON @@ -1279,11 +1325,18 @@ static int set_addons(int argc, const char **argv, void *data) /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */ if (argc > 1) { #ifdef WITH_PYTHON - const int slen = strlen(argv[1]) + 128; + const char script_str[] = + "from addon_utils import check, enable\n" + "for m in '%s'.split(','):\n" + " if check(m)[1] is False:\n" + " enable(m, persistent=True)"; + const int slen = strlen(argv[1]) + (sizeof(script_str) - 2); char *str = malloc(slen); bContext *C = data; - BLI_snprintf(str, slen, "[__import__('addon_utils').enable(i, default_set=False) for i in '%s'.split(',')]", argv[1]); - BPY_CTX_SETUP(BPY_string_exec(C, str)); + BLI_snprintf(str, slen, script_str, argv[1]); + + BLI_assert(strlen(str) + 1 == slen); + BPY_CTX_SETUP(BPY_string_exec_ex(C, str, false)); free(str); #else UNUSED_VARS(argv, data); @@ -1352,6 +1405,14 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) } else { /* failed to load file, stop processing arguments */ + if (G.background) { + /* Set is_break if running in the background mode so + * blender will return non-zero exit code which then + * could be used in automated script to control how + * good or bad things are. + */ + G.is_break = true; + } return -1; } @@ -1364,8 +1425,8 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); /* happens for the UI on file reading too (huh? (ton))*/ - // XXX BKE_reset_undo(); - // BKE_write_undo("original"); /* save current state */ + // XXX BKE_undo_reset(); + // BKE_undo_write("original"); /* save current state */ } else { /* we are not running in background mode here, but start blender in UI mode with @@ -1486,6 +1547,10 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, NULL, "--debug-value", "<value>\n\tSet debug value of <value> on startup\n", set_debug_value, NULL); BLI_argsAdd(ba, 1, NULL, "--debug-jobs", "\n\tEnable time profiling for background jobs.", debug_mode_generic, (void *)G_DEBUG_JOBS); BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph", "\n\tEnable debug messages from dependency graph", debug_mode_generic, (void *)G_DEBUG_DEPSGRAPH); + BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph-no-threads", "\n\tSwitch dependency graph to a single threaded evlauation", debug_mode_generic, (void *)G_DEBUG_DEPSGRAPH_NO_THREADS); + BLI_argsAdd(ba, 1, NULL, "--debug-gpumem", "\n\tEnable GPU memory stats in status bar", debug_mode_generic, (void *)G_DEBUG_GPU_MEM); + + BLI_argsAdd(ba, 1, NULL, "--enable-new-depsgraph", "\n\tUse new dependency graph", depsgraph_use_new, NULL); BLI_argsAdd(ba, 1, NULL, "--verbose", "<verbose>\n\tSet logging verbosity level.", set_verbosity, NULL); @@ -1521,6 +1586,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 4, "-j", "--frame-jump", "<frames>\n\tSet number of frames to step forward after each rendered frame", set_skip_frame, C); BLI_argsAdd(ba, 4, "-P", "--python", "<filename>\n\tRun the given Python script file", run_python_file, C); BLI_argsAdd(ba, 4, NULL, "--python-text", "<name>\n\tRun the given Python script text block", run_python_text, C); + BLI_argsAdd(ba, 4, NULL, "--python-expr", "<expression>\n\tRun the given expression as a Python script", run_python_expr, C); BLI_argsAdd(ba, 4, NULL, "--python-console", "\n\tRun blender with an interactive console", run_python_console, C); BLI_argsAdd(ba, 4, NULL, "--addons", "\n\tComma separated list of addons (no spaces)", set_addons, C); @@ -1554,13 +1620,13 @@ char **environ = NULL; * or exit when running in background mode. */ int main( - int argc, + int argc, #ifdef WIN32 const char **UNUSED(argv_c) #else const char **argv #endif - ) + ) { bContext *C; SYS_SystemHandle syshandle; @@ -1570,8 +1636,16 @@ int main( #endif #ifdef WIN32 + char **argv; + int argv_num; +#endif + + /* --- end declarations --- */ + + +#ifdef WIN32 /* FMA3 support in the 2013 CRT is broken on Vista and Windows 7 RTM (fixed in SP1). Just disable it. */ -# if defined(_MSC_VER) && _MSC_VER >= 1800 && defined(_M_X64) +# if defined(_MSC_VER) && defined(_M_X64) _set_FMA3_enable(0); # endif @@ -1579,16 +1653,15 @@ int main( /* NOTE: cannot use guardedalloc malloc here, as it's not yet initialized * (it depends on the args passed in, which is what we're getting here!) */ - wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); - char **argv = malloc(argc * sizeof(char *)); - int argci = 0; - - for (argci = 0; argci < argc; argci++) { - argv[argci] = alloc_utf_8_from_16(argv_16[argci], 0); + { + wchar_t **argv_16 = CommandLineToArgvW(GetCommandLineW(), &argc); + argv = malloc(argc * sizeof(char *)); + for (argv_num = 0; argv_num < argc; argv_num++) { + argv[argv_num] = alloc_utf_8_from_16(argv_16[argv_num], 0); + } + LocalFree(argv_16); } - - LocalFree(argv_16); -#endif +#endif /* WIN32 */ /* NOTE: Special exception for guarded allocator type switch: * we need to perform switch from lock-free to fully @@ -1656,7 +1729,7 @@ int main( setCallbacks(); #if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) -/* patch to ignore argument finder gives us (pid?) */ + /* patch to ignore argument finder gives us (pid?) */ if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) { extern int GHOST_HACK_getFirstFile(char buf[]); static char firstfilebuf[512]; @@ -1750,7 +1823,7 @@ int main( /* Initialize ffmpeg if built in, also needed for bg mode if videos are * rendered via ffmpeg */ - sound_init_once(); + BKE_sound_init_once(); init_def_material(); @@ -1814,8 +1887,8 @@ int main( #endif #ifdef WIN32 - while (argci) { - free(argv[--argci]); + while (argv_num) { + free(argv[--argv_num]); } free(argv); argv = NULL; |