Blender V5.3
creator_args.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#ifndef WITH_PYTHON_MODULE
10
11# include <cerrno>
12# include <cstdint>
13# include <cstdlib>
14# include <cstring>
15# include <limits>
16
17# include "MEM_guardedalloc.h"
18
19# include "CLG_log.h"
20
21# ifdef WIN32
22# include "BLI_winstuff.hh"
23# endif
24
25# include "BLI_args.hh"
26# include "BLI_dynstr.hh"
27# include "BLI_fileops.hh"
28# include "BLI_listbase.hh"
29# include "BLI_path_utils.hh"
30# include "BLI_string.hh"
31# include "BLI_string_utf8.hh"
32# include "BLI_system.hh"
33# include "BLI_threads.hh"
34# include "BLI_utildefines.hh"
35# ifndef NDEBUG
36# include "BLI_mempool.hh"
37# endif
38
39# include "BKE_appdir.hh"
40# include "BKE_blender.hh"
42# include "BKE_blender_version.h"
43# include "BKE_blendfile.hh"
44# include "BKE_context.hh"
45
46# include "BKE_global.hh"
47# include "BKE_image_format.hh"
48# include "BKE_lib_id.hh"
49# include "BKE_main.hh"
50# include "BKE_report.hh"
51# include "BKE_scene.hh"
52# include "BKE_sound.hh"
53
54# include "GPU_context.hh"
55# ifdef WITH_OPENGL_BACKEND
56# include "GPU_capabilities.hh"
58# endif
59
60# ifdef WITH_PYTHON
61# include "BPY_extern_python.hh"
62# include "BPY_extern_run.hh"
63# endif
64
65# include "RE_engine.h"
66# include "RE_pipeline.h"
67
68# include "WM_api.hh"
69
70# ifdef WITH_LIBMV
71# include "libmv-capi.h"
72# endif
73
74# include "DEG_depsgraph.hh"
75
76# include "WM_types.hh"
77
78# include "creator_intern.h" /* Own include. */
79
80namespace blender {
81
82/* -------------------------------------------------------------------- */
85
109
110static void build_defs_init(BuildDefs *build_defs, bool force_all)
111{
112 if (force_all) {
113 bool *var_end = reinterpret_cast<bool *>(build_defs + 1);
114 for (bool *var = reinterpret_cast<bool *>(build_defs); var < var_end; var++) {
115 *var = true;
116 }
117 return;
118 }
119
120 memset(build_defs, 0x0, sizeof(*build_defs));
121
122# ifdef __APPLE__
123 build_defs->apple = true;
124# endif
125# ifdef WIN32
126 build_defs->win32 = true;
127# endif
128# ifdef WITH_CYCLES
129 build_defs->with_cycles = true;
130# endif
131# ifdef WITH_FFMPEG
132 build_defs->with_ffmpeg = true;
133# endif
134# ifdef WITH_FREESTYLE
135 build_defs->with_freestyle = true;
136# endif
137# ifdef WITH_LIBMV
138 build_defs->with_libmv = true;
139# endif
140# ifdef WITH_OPENGL_BACKEND
141 build_defs->with_opengl_backend = true;
142# endif
143# ifdef WITH_RENDERDOC
144 build_defs->with_renderdoc = true;
145# endif
146# ifdef WITH_INPUT_NDOF
147 build_defs->with_input_ndof = true;
148# endif
149# ifdef WITH_VULKAN_BACKEND
150 build_defs->with_vulkan_backend = true;
151# endif
152# ifdef WITH_XR_OPENXR
153 build_defs->with_xr_openxr = true;
154# endif
155}
156
158
159/* -------------------------------------------------------------------- */
162
163static bool parse_int_relative(const char *str,
164 const char *str_end_test,
165 int pos,
166 int neg,
167 int *r_value,
168 const char **r_err_msg)
169{
170 char *str_end = nullptr;
171 long value;
172
173 errno = 0;
174
175 switch (*str) {
176 case '+':
177 value = pos + strtol(str + 1, &str_end, 10);
178 break;
179 case '-':
180 value = (neg - strtol(str + 1, &str_end, 10)) + 1;
181 break;
182 default:
183 value = strtol(str, &str_end, 10);
184 break;
185 }
186
187 if (*str_end != '\0' && (str_end != str_end_test)) {
188 static const char *msg = "not a number";
189 *r_err_msg = msg;
190 return false;
191 }
192 if ((errno == ERANGE) || ((value < INT_MIN) || (value > INT_MAX))) {
193 static const char *msg = "exceeds range";
194 *r_err_msg = msg;
195 return false;
196 }
197 *r_value = int(value);
198 return true;
199}
200
201static const char *parse_int_range_sep_search(const char *str, const char *str_end_test)
202{
203 const char *str_end_range = nullptr;
204 if (str_end_test) {
205 str_end_range = static_cast<const char *>(memchr(str, '.', (str_end_test - str) - 1));
206 if (str_end_range && (str_end_range[1] != '.')) {
207 str_end_range = nullptr;
208 }
209 }
210 else {
211 str_end_range = strstr(str, "..");
212 if (str_end_range && (str_end_range[2] == '\0')) {
213 str_end_range = nullptr;
214 }
215 }
216 return str_end_range;
217}
218
224static bool parse_int_range_relative(const char *str,
225 const char *str_end_range,
226 const char *str_end_test,
227 int pos,
228 int neg,
229 int r_value_range[2],
230 const char **r_err_msg)
231{
232 if (parse_int_relative(str, str_end_range, pos, neg, &r_value_range[0], r_err_msg) &&
233 parse_int_relative(str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg))
234 {
235 return true;
236 }
237 return false;
238}
239
240static bool parse_int_relative_clamp(const char *str,
241 const char *str_end_test,
242 int pos,
243 int neg,
244 int min,
245 int max,
246 int *r_value,
247 const char **r_err_msg)
248{
249 if (parse_int_relative(str, str_end_test, pos, neg, r_value, r_err_msg)) {
250 CLAMP(*r_value, min, max);
251 return true;
252 }
253 return false;
254}
255
256static bool parse_int_range_relative_clamp(const char *str,
257 const char *str_end_range,
258 const char *str_end_test,
259 int pos,
260 int neg,
261 int min,
262 int max,
263 int r_value_range[2],
264 const char **r_err_msg)
265{
267 str, str_end_range, str_end_test, pos, neg, r_value_range, r_err_msg))
268 {
269 CLAMP(r_value_range[0], min, max);
270 CLAMP(r_value_range[1], min, max);
271 return true;
272 }
273 return false;
274}
275
279static bool parse_int_strict_range(const char *str,
280 const char *str_end_test,
281 const int min,
282 const int max,
283 int *r_value,
284 const char **r_err_msg)
285{
286 char *str_end = nullptr;
287 long value;
288
289 errno = 0;
290 value = strtol(str, &str_end, 10);
291
292 if (*str_end != '\0' && (str_end != str_end_test)) {
293 static const char *msg = "not a number";
294 *r_err_msg = msg;
295 return false;
296 }
297 if ((errno == ERANGE) || ((value < min) || (value > max))) {
298 static const char *msg = "exceeds range";
299 *r_err_msg = msg;
300 return false;
301 }
302 *r_value = int(value);
303 return true;
304}
305
306static bool parse_int(const char *str,
307 const char *str_end_test,
308 int *r_value,
309 const char **r_err_msg)
310{
311 return parse_int_strict_range(str, str_end_test, INT_MIN, INT_MAX, r_value, r_err_msg);
312}
313
314static bool parse_int_clamp(const char *str,
315 const char *str_end_test,
316 int min,
317 int max,
318 int *r_value,
319 const char **r_err_msg)
320{
321 if (parse_int(str, str_end_test, r_value, r_err_msg)) {
322 CLAMP(*r_value, min, max);
323 return true;
324 }
325 return false;
326}
327
328# if 0
333static int *parse_int_relative_clamp_n(
334 const char *str, int pos, int neg, int min, int max, int *r_value_len, const char **r_err_msg)
335{
336 const char sep = ',';
337 int len = 1;
338 for (int i = 0; str[i]; i++) {
339 if (str[i] == sep) {
340 len++;
341 }
342 }
343
344 int *values = MEM_new_array_uninitialized<int>(size_t(len), __func__);
345 int i = 0;
346 while (true) {
347 const char *str_end = strchr(str, sep);
348 if (ELEM(*str, sep, '\0')) {
349 static const char *msg = "incorrect comma use";
350 *r_err_msg = msg;
351 goto fail;
352 }
353 else if (parse_int_relative_clamp(str, str_end, pos, neg, min, max, &values[i], r_err_msg)) {
354 i++;
355 }
356 else {
357 goto fail; /* Error message already set. */
358 }
359
360 if (str_end) { /* Next. */
361 str = str_end + 1;
362 }
363 else { /* Finished. */
364 break;
365 }
366 }
367
368 *r_value_len = i;
369 return values;
370
371fail:
372 MEM_delete(values);
373 return nullptr;
374}
375
376# endif
377
384static int (*parse_int_range_relative_clamp_n(const char *str,
385 int pos,
386 int neg,
387 int min,
388 int max,
389 int *r_value_len,
390 const char **r_err_msg))[2]
391{
392 const char sep = ',';
393 int len = 1;
394 for (int i = 0; str[i]; i++) {
395 if (str[i] == sep) {
396 len++;
397 }
398 }
399
400 int (*values)[2] = MEM_new_array_uninitialized<int[2]>(size_t(len), __func__);
401 int i = 0;
402 while (true) {
403 const char *str_end_range;
404 const char *str_end = strchr(str, sep);
405 if (ELEM(*str, sep, '\0')) {
406 static const char *msg = "incorrect comma use";
407 *r_err_msg = msg;
408 goto fail;
409 }
410 else if ((str_end_range = parse_int_range_sep_search(str, str_end)) ?
412 str, str_end_range, str_end, pos, neg, min, max, values[i], r_err_msg) :
414 str, str_end, pos, neg, min, max, &values[i][0], r_err_msg))
415 {
416 if (str_end_range == nullptr) {
417 values[i][1] = values[i][0];
418 }
419 i++;
420 }
421 else {
422 goto fail; /* Error message already set. */
423 }
424
425 if (str_end) { /* Next. */
426 str = str_end + 1;
427 }
428 else { /* Finished. */
429 break;
430 }
431 }
432
433 *r_value_len = i;
434 return values;
435
436fail:
437 MEM_delete(values);
438 return nullptr;
439}
440
442
443/* -------------------------------------------------------------------- */
450
451/* When the deferred argument is handled on Windows the `argv` will have been freed,
452 * see `USE_WIN32_UNICODE_ARGS` in `creator.cc`. */
453
454# ifdef WIN32
455static char **argv_duplicate(const char **argv, int argc)
456{
457 char **argv_copy = MEM_new_array_uninitialized<char *>(size_t(argc), __func__);
458 for (int i = 0; i < argc; i++) {
459 argv_copy[i] = BLI_strdup(argv[i]);
460 }
461 return argv_copy;
462}
463
464static void argv_free(char **argv, int argc)
465{
466 for (int i = 0; i < argc; i++) {
467 MEM_delete(argv[i]);
468 }
469 MEM_delete(argv);
470}
471# endif /* !WIN32 */
472
481
483{
484 return app_state.main_arg_deferred != nullptr;
485}
486
487static void main_arg_deferred_setup(BA_ArgCallback func, int argc, const char **argv, void *data)
488{
491 d->func = func;
492 d->argc = argc;
493 d->argv = argv;
494 d->data = data;
495 d->exit_code = 0;
496# ifdef WIN32
497 d->argv = const_cast<const char **>(argv_duplicate(d->argv, d->argc));
498# endif
500}
501
503{
506# ifdef WIN32
507 argv_free(const_cast<char **>(d->argv), d->argc);
508# endif
509 MEM_delete(d);
510}
511
512static void main_arg_deferred_exit_code_set(int exit_code)
513{
515 BLI_assert(d != nullptr);
516 d->exit_code = exit_code;
517}
518
520{
522 d->func(d->argc, d->argv, d->data);
523 return d->exit_code;
524}
525
527
528/* -------------------------------------------------------------------- */
531
532# ifdef WITH_PYTHON
533
534struct BlendePyContextStore {
535 wmWindowManager *wm;
536 Scene *scene;
537 wmWindow *win;
538 bool has_win;
539};
540
541static void arg_py_context_backup(bContext *C, BlendePyContextStore *c_py)
542{
543 c_py->wm = CTX_wm_manager(C);
544 c_py->scene = CTX_data_scene(C);
545 c_py->has_win = c_py->wm && !c_py->wm->windows.is_empty();
546 if (c_py->has_win) {
547 c_py->win = CTX_wm_window(C);
548 CTX_wm_window_set(C, c_py->wm->windows.first());
549 }
550 else {
551 /* NOTE: this should never happen, although it may be possible when loading
552 * `.blend` files without windowing data. Whatever the case, it shouldn't crash,
553 * although typical scripts that accesses the context is not expected to work usefully. */
554 c_py->win = nullptr;
555 fprintf(stderr, "Python script running with missing context data.\n");
556 }
557}
558
559static void arg_py_context_restore(bContext *C, BlendePyContextStore *c_py)
560{
561 /* Script may load a file, check old data is valid before using. */
562 if (c_py->has_win) {
563 if ((c_py->win == nullptr) || ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) &&
564 (BLI_findindex(&c_py->wm->windows, c_py->win) != -1)))
565 {
566 CTX_wm_window_set(C, c_py->win);
567 }
568 }
569
570 if ((c_py->scene == nullptr) || BLI_findindex(&G_MAIN->scenes, c_py->scene) != -1) {
571 CTX_data_scene_set(C, c_py->scene);
572 }
573}
574
575/* Macro for context setup/reset. */
576# define BPY_CTX_SETUP(_cmd) \
577 { \
578 BlendePyContextStore py_c; \
579 arg_py_context_backup(C, &py_c); \
580 { \
581 _cmd; \
582 } \
583 arg_py_context_restore(C, &py_c); \
584 } \
585 ((void)0)
586
587# endif /* WITH_PYTHON */
588
590
591/* -------------------------------------------------------------------- */
604
606{
607 printf("Blender %s\n", BKE_blender_version_string());
608# ifdef BUILD_DATE
609 printf("\tbuild date: %s\n", build_date);
610 printf("\tbuild time: %s\n", build_time);
611 printf("\tbuild commit date: %s\n", build_commit_date);
612 printf("\tbuild commit time: %s\n", build_commit_time);
613 printf("\tbuild hash: %s\n", build_hash);
614 printf("\tbuild branch: %s\n", build_branch);
615 printf("\tbuild platform: %s\n", build_platform);
616 printf("\tbuild type: %s\n", build_type);
617 printf("\tbuild c flags: %s\n", build_cflags);
618 printf("\tbuild c++ flags: %s\n", build_cxxflags);
619 printf("\tbuild link flags: %s\n", build_linkflags);
620 printf("\tbuild system: %s\n", build_system);
621# endif
622}
623
625{
626# ifdef BUILD_DATE
627 /* NOTE: We include built time since sometimes we need to tell broken from
628 * working built of the same hash. */
629 printf("Blender %s (hash %s built %s %s)\n",
633 build_time);
634# else
635 printf("Blender %s\n", BKE_blender_version_string());
636# endif
637}
638
639static const char arg_handle_print_version_doc[] =
640 "\n\t"
641 "Print Blender version and exit.";
642static int arg_handle_print_version(int /*argc*/, const char ** /*argv*/, void * /*data*/)
643{
645
646 /* Handles cleanup before exit. */
648
649 exit(EXIT_SUCCESS);
651 return 0;
652}
653
654static void print_help(bArgs *ba, bool all)
655{
656 BuildDefs defs;
657 build_defs_init(&defs, all);
658
659/* All printing must go via `PRINT` macro. */
660# define printf __ERROR__
661
662# define PRINT(...) BLI_args_printf(ba, __VA_ARGS__)
663
664 PRINT("Blender %s\n", BKE_blender_version_string());
665 PRINT("Usage: blender [args ...] [file] [args ...]\n");
666 PRINT("\n");
667
668 PRINT("Render Options:\n");
669 BLI_args_print_arg_doc(ba, "--background");
670 BLI_args_print_arg_doc(ba, "--render-anim");
671 BLI_args_print_arg_doc(ba, "--scene");
672 BLI_args_print_arg_doc(ba, "--render-frame");
673 BLI_args_print_arg_doc(ba, "--frame-start");
674 BLI_args_print_arg_doc(ba, "--frame-end");
675 BLI_args_print_arg_doc(ba, "--frame-jump");
676 BLI_args_print_arg_doc(ba, "--render-output");
677 BLI_args_print_arg_doc(ba, "--engine");
678 BLI_args_print_arg_doc(ba, "--threads");
679
680 if (defs.with_cycles) {
681 PRINT("Cycles Render Options:\n");
682 PRINT("\tCycles add-on options must be specified following a double dash.\n");
683 PRINT("\n");
684 PRINT("--cycles-device <device>\n");
685 PRINT("\tSet the device used for rendering.\n");
686 PRINT("\tValid options are: 'CPU' 'CUDA' 'OPTIX' 'HIP' 'ONEAPI' 'METAL'.\n");
687 PRINT("\n");
688 PRINT("\tAppend +CPU to a GPU device to render on both CPU and GPU.\n");
689 PRINT("\n");
690 PRINT("\tExample:\n");
691 PRINT("\t# blender -b file.blend -f 20 -- --cycles-device OPTIX\n");
692 PRINT("--cycles-print-stats\n");
693 PRINT("\tLog statistics about render memory and time usage.\n");
694 }
695
696 PRINT("\n");
697 PRINT("Format Options:\n");
698 BLI_args_print_arg_doc(ba, "--render-format");
699 BLI_args_print_arg_doc(ba, "--use-extension");
700
701 PRINT("\n");
702 PRINT("Animation Playback Options:\n");
703 BLI_args_print_arg_doc(ba, "-a");
704
705 PRINT("\n");
706 PRINT("Window Options:\n");
707 BLI_args_print_arg_doc(ba, "--window-border");
708 BLI_args_print_arg_doc(ba, "--window-maximized");
709 BLI_args_print_arg_doc(ba, "--window-fullscreen");
710 BLI_args_print_arg_doc(ba, "--window-geometry");
711 BLI_args_print_arg_doc(ba, "--start-console");
712 BLI_args_print_arg_doc(ba, "--no-native-pixels");
713 BLI_args_print_arg_doc(ba, "--no-window-frame");
714 BLI_args_print_arg_doc(ba, "--no-window-focus");
715
716 PRINT("\n");
717 PRINT("Python Options:\n");
718 BLI_args_print_arg_doc(ba, "--enable-autoexec");
719 BLI_args_print_arg_doc(ba, "--disable-autoexec");
720
721 PRINT("\n");
722
723 BLI_args_print_arg_doc(ba, "--python");
724 BLI_args_print_arg_doc(ba, "--python-text");
725 BLI_args_print_arg_doc(ba, "--python-expr");
726 BLI_args_print_arg_doc(ba, "--python-console");
727 BLI_args_print_arg_doc(ba, "--python-exit-code");
728 BLI_args_print_arg_doc(ba, "--python-use-system-env");
729 BLI_args_print_arg_doc(ba, "--python-use-user-env");
730 BLI_args_print_arg_doc(ba, "--addons");
731
732 PRINT("\n");
733 PRINT("Network Options:\n");
734 BLI_args_print_arg_doc(ba, "--online-mode");
735 BLI_args_print_arg_doc(ba, "--offline-mode");
736
737 PRINT("\n");
738 PRINT("Logging Options:\n");
739 BLI_args_print_arg_doc(ba, "--log");
740 BLI_args_print_arg_doc(ba, "--log-level");
741 BLI_args_print_arg_doc(ba, "--log-show-memory");
742 BLI_args_print_arg_doc(ba, "--log-show-source");
743 BLI_args_print_arg_doc(ba, "--log-show-backtrace");
744 BLI_args_print_arg_doc(ba, "--log-file");
745 BLI_args_print_arg_doc(ba, "--log-list-categories");
746
747 PRINT("\n");
748 PRINT("Debug Options:\n");
749 BLI_args_print_arg_doc(ba, "--debug");
750 BLI_args_print_arg_doc(ba, "--debug-value");
751
752 PRINT("\n");
753 BLI_args_print_arg_doc(ba, "--debug-events");
754 BLI_args_print_arg_doc(ba, "--debug-handlers");
755 if (defs.with_libmv) {
756 BLI_args_print_arg_doc(ba, "--debug-libmv");
757 }
758 BLI_args_print_arg_doc(ba, "--debug-memory");
759 BLI_args_print_arg_doc(ba, "--debug-jobs");
760 BLI_args_print_arg_doc(ba, "--debug-python");
761 BLI_args_print_arg_doc(ba, "--debug-depsgraph");
762 BLI_args_print_arg_doc(ba, "--debug-depsgraph-eval");
763 BLI_args_print_arg_doc(ba, "--debug-depsgraph-build");
764 BLI_args_print_arg_doc(ba, "--debug-depsgraph-tag");
765 BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
766 BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
767 BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
768 BLI_args_print_arg_doc(ba, "--debug-depsgraph-uid");
769 BLI_args_print_arg_doc(ba, "--debug-ghost");
770 BLI_args_print_arg_doc(ba, "--debug-wintab");
771 BLI_args_print_arg_doc(ba, "--debug-gpu");
772 BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
773 BLI_args_print_arg_doc(ba, "--debug-gpu-compile-shaders");
774 BLI_args_print_arg_doc(ba, "--debug-gpu-shader-debug-info");
775 BLI_args_print_arg_doc(ba, "--debug-gpu-scope-capture");
776 BLI_args_print_arg_doc(ba, "--debug-gpu-shader-source");
777 BLI_args_print_arg_doc(ba, "--debug-gpu-shader-no-preprocessor");
778 BLI_args_print_arg_doc(ba, "--debug-gpu-shader-no-dce");
779 BLI_args_print_arg_doc(ba, "--debug-gpu-no-texture-pool");
780 BLI_args_print_arg_doc(ba, "--debug-gpu-backend-no-fallback");
781 if (defs.with_renderdoc) {
782 BLI_args_print_arg_doc(ba, "--debug-gpu-renderdoc");
783 }
784 if (defs.with_vulkan_backend) {
785 BLI_args_print_arg_doc(ba, "--debug-gpu-vulkan-local-read");
786 }
787 BLI_args_print_arg_doc(ba, "--debug-gpu-no-hw-raytracing");
788 BLI_args_print_arg_doc(ba, "--debug-wm");
789 if (defs.with_xr_openxr) {
790 BLI_args_print_arg_doc(ba, "--debug-xr");
791 BLI_args_print_arg_doc(ba, "--debug-xr-time");
792 }
793 BLI_args_print_arg_doc(ba, "--debug-all");
794 BLI_args_print_arg_doc(ba, "--debug-io");
795
796 PRINT("\n");
797 BLI_args_print_arg_doc(ba, "--debug-fpe");
798 BLI_args_print_arg_doc(ba, "--debug-exit-on-error");
799 if (defs.with_freestyle) {
800 BLI_args_print_arg_doc(ba, "--debug-freestyle");
801 }
802 BLI_args_print_arg_doc(ba, "--console-crash-handler");
803 BLI_args_print_arg_doc(ba, "--disable-crash-handler");
804 BLI_args_print_arg_doc(ba, "--disable-abort-handler");
805
806 BLI_args_print_arg_doc(ba, "--verbose");
807 BLI_args_print_arg_doc(ba, "--quiet");
808
809 PRINT("\n");
810 PRINT("GPU Options:\n");
811 BLI_args_print_arg_doc(ba, "--gpu-backend");
812 BLI_args_print_arg_doc(ba, "--gpu-device");
813 BLI_args_print_arg_doc(ba, "--gpu-device-no-fallback");
814 BLI_args_print_arg_doc(ba, "--gpu-vsync");
815 if (defs.with_opengl_backend) {
816 BLI_args_print_arg_doc(ba, "--gpu-compilation-subprocesses");
817 }
818 BLI_args_print_arg_doc(ba, "--profile-gpu");
819
820 PRINT("\n");
821 PRINT("Misc Options:\n");
822 BLI_args_print_arg_doc(ba, "--open-last");
823 BLI_args_print_arg_doc(ba, "--app-template");
824 BLI_args_print_arg_doc(ba, "--factory-startup");
825 BLI_args_print_arg_doc(ba, "--enable-event-simulate");
826 PRINT("\n");
827 BLI_args_print_arg_doc(ba, "--env-system-datafiles");
828 BLI_args_print_arg_doc(ba, "--env-system-scripts");
829 BLI_args_print_arg_doc(ba, "--env-system-extensions");
830 BLI_args_print_arg_doc(ba, "--env-system-python");
831 PRINT("\n");
832 BLI_args_print_arg_doc(ba, "-noaudio");
833 BLI_args_print_arg_doc(ba, "-setaudio");
834 PRINT("\n");
835 BLI_args_print_arg_doc(ba, "--command");
836
837 PRINT("\n");
838
839 BLI_args_print_arg_doc(ba, "--help");
840 BLI_args_print_arg_doc(ba, "/?");
841
842 /* File type registration (Windows & Linux only). */
843 BLI_args_print_arg_doc(ba, "--register");
844 BLI_args_print_arg_doc(ba, "--register-allusers");
845 BLI_args_print_arg_doc(ba, "--unregister");
846 BLI_args_print_arg_doc(ba, "--unregister-allusers");
847 /* Windows only. */
848 BLI_args_print_arg_doc(ba, "--qos");
849
850 BLI_args_print_arg_doc(ba, "--version");
851
852 BLI_args_print_arg_doc(ba, "--");
853
854 // PRINT("\n");
855 // PRINT("Experimental Features:\n");
856
857 /* Other options _must_ be last (anything not handled will show here).
858 *
859 * Note that it's good practice for this to remain empty,
860 * nevertheless print if any exist. */
861 if (BLI_args_has_other_doc(ba)) {
862 PRINT("\n");
863 PRINT("Other Options:\n");
865 }
866
867 PRINT("\n");
868 PRINT("Argument Parsing:\n");
869 PRINT("\tArguments must be separated by white space, eg:\n");
870 PRINT("\t# blender -ba test.blend\n");
871 PRINT("\t...will exit since '-ba' is an unknown argument.\n");
872 PRINT("\n");
873
874 PRINT("Argument Order:\n");
875 PRINT("\tArguments are executed in the order they are given. eg:\n");
876 PRINT("\t# blender --background test.blend --render-frame 1 --render-output \"/tmp\"\n");
877 PRINT(
878 "\t...will not render to '/tmp' because '--render-frame 1' renders before the output path "
879 "is set.\n");
880 PRINT("\t# blender --background --render-output /tmp test.blend --render-frame 1\n");
881 PRINT(
882 "\t...will not render to '/tmp' because loading the blend-file overwrites the render output "
883 "that was set.\n");
884 PRINT("\t# blender --background test.blend --render-output /tmp --render-frame 1\n");
885 PRINT("\t...works as expected.\n");
886 PRINT("\n");
887
888 PRINT("Environment Variables:\n");
889 PRINT(" $BLENDER_USER_RESOURCES Replace default directory of all user files.\n");
890 PRINT(" Other 'BLENDER_USER_*' variables override when set.\n");
891 PRINT(" $BLENDER_USER_CONFIG Directory for user configuration files.\n");
892 PRINT(" $BLENDER_USER_SCRIPTS Directory for user scripts.\n");
893 PRINT(" $BLENDER_USER_EXTENSIONS Directory for user extensions.\n");
894 PRINT(" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n");
895 PRINT("\n");
896 PRINT(" $BLENDER_SYSTEM_RESOURCES Replace default directory of all bundled resource files.\n");
897 PRINT(" $BLENDER_SYSTEM_SCRIPTS Directories to add extra scripts.\n");
898 PRINT(" $BLENDER_SYSTEM_EXTENSIONS Directory for system extensions repository.\n");
899 PRINT(" $BLENDER_SYSTEM_DATAFILES Directory to replace bundled datafiles.\n");
900 PRINT(" $BLENDER_SYSTEM_PYTHON Directory to replace bundled Python libraries.\n");
901 PRINT(" $BLENDER_CUSTOM_SPLASH Full path to an image that replaces the splash screen.\n");
902 PRINT(
903 " $BLENDER_CUSTOM_SPLASH_BANNER Full path to an image to overlay on the splash screen.\n");
904
905 PRINT(
906 " $BLENDER_OCIO Path to override the OpenColorIO configuration file.\n"
907 " If not set, the 'OCIO' environment variable is used.\n");
908
909 /* Non `BLENDER_` prefixed, conventions from 3rd party libraries or the operating system. */
910
911 if ((!defs.win32 && !defs.apple && defs.with_input_ndof) || all) {
912 PRINT(
913 " $SPNAV_SOCKET The socket path to connect to the 3D-mouse daemon "
914 "(Unix only).\n");
915 }
916
917 if (defs.win32 || all) {
918 PRINT(" $TEMP Store temporary files here (MS-Windows).\n");
919 }
920 if (!defs.win32 || all) {
921 PRINT(" $TMPDIR Store temporary files here (UNIX Systems).\n");
922 }
923 PRINT(
924 " The path must reference an existing directory "
925 "or it will be ignored.\n");
926
927# undef printf
928# undef PRINT
929}
930
932static void help_print_ds_fn(void *ds_v, const char *format, va_list args)
933{
934 DynStr *ds = static_cast<DynStr *>(ds_v);
935 BLI_dynstr_vappendf(ds, format, args);
936}
937
939{
940 DynStr *ds = BLI_dynstr_new();
941 {
942 bArgs *ba = BLI_args_create(0, nullptr);
943 main_args_setup(nullptr, ba, all);
945 print_help(ba, all);
947 }
948 char *buf = BLI_dynstr_get_cstring(ds);
949 BLI_dynstr_free(ds);
950 return buf;
951}
952
953static const char arg_handle_print_help_doc[] =
954 "\n\t"
955 "Print this help text and exit.";
957 "\n\t"
958 "Print this help text and exit (Windows only).";
959static int arg_handle_print_help(int /*argc*/, const char ** /*argv*/, void *data)
960{
961 bArgs *ba = static_cast<bArgs *>(data);
962
963 print_help(ba, false);
964
965 /* Handles cleanup before exit. */
967
968 exit(EXIT_SUCCESS);
970
971 return 0;
972}
973
974static const char arg_handle_arguments_end_doc[] =
975 "\n\t"
976 "End option processing, following arguments passed unchanged. Access via Python's "
977 "'sys.argv'.";
978static int arg_handle_arguments_end(int /*argc*/, const char ** /*argv*/, void * /*data*/)
979{
980 return -1;
981}
982
983/* Only to give help message. */
984# ifdef WITH_PYTHON_SECURITY /* Default. */
985# define PY_ENABLE_AUTO ""
986# define PY_DISABLE_AUTO ", (default)"
987# else
988# define PY_ENABLE_AUTO ", (default, non-standard compilation option)"
989# define PY_DISABLE_AUTO ""
990# endif
991
993 "\n\t"
994 "Enable automatic Python script execution" PY_ENABLE_AUTO ".";
996 "\n\t"
997 "Disable automatic Python script execution "
998 "(Python-drivers & startup scripts)" PY_DISABLE_AUTO ".";
999# undef PY_ENABLE_AUTO
1000# undef PY_DISABLE_AUTO
1001
1002static int arg_handle_python_set(int /*argc*/, const char ** /*argv*/, void *data)
1003{
1004 const bool use_autoexec = bool(data);
1005 if (use_autoexec) {
1007 }
1008 else {
1010 }
1011 G.autoexec_override = use_autoexec;
1012 return 0;
1013}
1014
1016 "\n\t"
1017 "Allow internet access, overriding the preference.";
1019 "\n\t"
1020 "Disallow internet access, overriding the preference.";
1021
1022static int arg_handle_internet_allow_set(int /*argc*/, const char ** /*argv*/, void *data)
1023{
1025 if (bool(data)) {
1028 }
1029 else {
1032 }
1033 return 0;
1034}
1035
1037 "\n\t"
1038 "Use the console to report crashes.";
1039static int arg_handle_crash_handler_console(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1040{
1041 app_state.signal.use_console_crash_handler = true;
1042 return 0;
1043}
1044
1046 "\n\t"
1047 "Disable the crash handler.";
1048static int arg_handle_crash_handler_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1049{
1050 app_state.signal.use_crash_handler = false;
1051 return 0;
1052}
1053
1055 "\n\t"
1056 "Disable the abort handler.";
1057static int arg_handle_abort_handler_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1058{
1059 app_state.signal.use_abort_handler = false;
1060 return 0;
1061}
1062
1063static void clog_abort_on_error_callback(void *fp)
1064{
1065 BLI_system_backtrace(static_cast<FILE *>(fp));
1066 fflush(static_cast<FILE *>(fp));
1067 abort();
1068}
1069
1071 "\n\t"
1072 "Immediately exit when internal errors are detected.";
1073static int arg_handle_debug_exit_on_error(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1074{
1077 return 0;
1078}
1079
1080static const char arg_handle_quiet_set_doc[] =
1081 "\n\t"
1082 "Suppress status printing (warnings & errors are still printed).";
1083static int arg_handle_quiet_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1084{
1085 CLG_quiet_set(true);
1086 return 0;
1087}
1088
1091{
1092 G.background = true;
1093
1094 /* Background Mode Defaults:
1095 *
1096 * In general background mode should strive to match the behavior of running
1097 * Blender inside a graphical session, any exception to this should have a well
1098 * justified reason and be noted in the docstring. */
1099
1100 /* NOTE(@ideasman42): While there is no requirement for sound to be disabled in background-mode,
1101 * the use case for playing audio in background mode is enough of a special-case
1102 * that users who wish to do this can explicitly enable audio in background mode.
1103 * While the down sides for connecting to an audio device aren't terrible they include:
1104 * - Listing Blender as an active application which may output audio.
1105 * - Unnecessary overhead running an operation in background mode or ...
1106 * - Having to remember to include `-noaudio` with batch operations.
1107 * - A quiet but audible click when Blender starts & configures its audio device.
1108 */
1109 BKE_sound_force_device("None");
1110}
1111
1113 "\n"
1114 "\tRun in background (often used for UI-less rendering).\n"
1115 "\n"
1116 "\tThe audio device is disabled in background-mode by default\n"
1117 "\tand can be re-enabled by passing in '-setaudio Default' afterwards.";
1118static int arg_handle_background_mode_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1119{
1120 if (!CLG_quiet_get()) {
1122 }
1124 return 0;
1125}
1126
1127static const char arg_handle_command_set_doc[] =
1128 "<command>\n"
1129 "\tRun a command which consumes all remaining arguments.\n"
1130 "\tUse '-c help' to list all other commands.\n"
1131 "\tPass '--help' after the command to see its help text.\n"
1132 "\n"
1133 "\tThis implies '--background' mode.";
1134static int arg_handle_command_set(int argc, const char **argv, void *data)
1135{
1136 if (!main_arg_deferred_is_set()) {
1137 if (argc < 2) {
1138 fprintf(
1139 stderr, "%s requires at least one argument, see 'help' for all commands.\n", argv[0]);
1140 exit(EXIT_FAILURE);
1142 }
1143 /* Application "info" messages get in the way of command line output, suppress them. */
1144 CLG_quiet_set(true);
1145
1147
1149 }
1150 else {
1151 bContext *C = static_cast<bContext *>(data);
1152 const char *id = argv[1];
1153 int exit_code;
1154 if (STREQ(id, "help")) {
1156 exit_code = EXIT_SUCCESS;
1157 }
1158 else {
1159 exit_code = BKE_blender_cli_command_exec(C, id, argc - 2, argv + 2);
1160 }
1162 }
1163
1164 /* Consume remaining arguments. */
1165 return argc - 1;
1166}
1167
1169 "\n"
1170 "\tBackground mode: Do not systematically build and evaluate ViewLayers' dependency graphs\n"
1171 "\twhen loading a blend-file in background mode ('-b' or '-c' options).\n"
1172 "\n"
1173 "\tScripts requiring evaluated data then need to explicitly ensure that\n"
1174 "\tan evaluated depsgraph is available\n"
1175 "\t(e.g. by calling 'depsgraph = context.evaluated_depsgraph_get()').\n"
1176 "\n"
1177 "\tNOTE: this is a temporary option, in the future depsgraph will never be\n"
1178 "\tautomatically generated on file load in background mode.";
1180 const char ** /*argv*/,
1181 void * /*data*/)
1182{
1183 G.fileflags |= G_BACKGROUND_NO_DEPSGRAPH;
1184 return 0;
1185}
1186
1188 "\n"
1189 "\tDo not perform library override automatic resync when loading a new blend-file.\n"
1190 "\n"
1191 "\tNOTE: this is an alternative way to get the same effect as when setting the\n"
1192 "\t'No Override Auto Resync' User Preferences Debug option.";
1194 const char ** /*argv*/,
1195 void * /*data*/)
1196{
1197 G.fileflags |= G_LIBOVERRIDE_NO_AUTO_RESYNC;
1198 return 0;
1199}
1200
1201static const char arg_handle_log_level_set_doc[] =
1202 "<level>\n"
1203 "\tSet the logging verbosity level.\n"
1204 "\n"
1205 "\tfatal: Fatal errors only\n"
1206 "\terror: Errors only\n"
1207 "\twarning: Warnings\n"
1208 "\tinfo: Information about devices, files, configuration, operations\n"
1209 "\tdebug: Verbose messages for developers\n"
1210 "\ttrace: Very verbose code execution tracing";
1211static int arg_handle_log_level_set(int argc, const char **argv, void * /*data*/)
1212{
1213 const char *arg_id = "--log-level";
1214 if (argc > 1) {
1215 const char *err_msg = nullptr;
1216
1217 if (STRCASEEQ(argv[1], "fatal")) {
1218 G.log.level = CLG_LEVEL_FATAL;
1219 }
1220 else if (STRCASEEQ(argv[1], "error")) {
1221 G.log.level = CLG_LEVEL_ERROR;
1222 }
1223 else if (STRCASEEQ(argv[1], "warning")) {
1224 G.log.level = CLG_LEVEL_WARN;
1225 }
1226 else if (STRCASEEQ(argv[1], "info")) {
1227 G.log.level = CLG_LEVEL_INFO;
1228 }
1229 else if (STRCASEEQ(argv[1], "debug")) {
1230 G.log.level = CLG_LEVEL_DEBUG;
1231 }
1232 else if (STRCASEEQ(argv[1], "trace")) {
1233 G.log.level = CLG_LEVEL_TRACE;
1234 }
1235 else if (parse_int_clamp(argv[1], nullptr, -1, INT_MAX, &G.log.level, &err_msg)) {
1236 /* Numeric level for backwards compatibility. */
1237 if (G.log.level < 0) {
1238 G.log.level = CLG_LEVEL_LEN - 1;
1239 }
1240 else {
1241 G.log.level = std::min(CLG_LEVEL_INFO + G.log.level, CLG_LEVEL_LEN - 1);
1242 }
1243 }
1244 else {
1245 fprintf(stderr, "\nError: Invalid log level '%s %s'.\n", arg_id, argv[1]);
1246 return 1;
1247 }
1248
1249 CLG_level_set(CLG_Level(G.log.level));
1250 return 1;
1251 }
1252 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1253 return 0;
1254}
1255
1257 "\n\t"
1258 "Show source file and function name in output.";
1259static int arg_handle_log_show_source_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1260{
1262 return 0;
1263}
1264
1266 "\n\t"
1267 "Show a back trace for each log message (debug builds only).";
1268static int arg_handle_log_show_backtrace_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1269{
1270 /* Ensure types don't become incompatible. */
1271 void (*fn)(FILE *fp) = BLI_system_backtrace;
1272 CLG_backtrace_fn_set(reinterpret_cast<void (*)(void *)>(fn));
1273 return 0;
1274}
1275
1277 "\n\t"
1278 "Show memory usage for each log message.";
1279static int arg_handle_log_show_memory_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1280{
1282 return 0;
1283}
1284
1285static const char arg_handle_log_file_set_doc[] =
1286 "<filepath>\n"
1287 "\tSet a file to output the log to.";
1288static int arg_handle_log_file_set(int argc, const char **argv, void * /*data*/)
1289{
1290 const char *arg_id = "--log-file";
1291 if (argc > 1) {
1292 errno = 0;
1293 FILE *fp = BLI_fopen(argv[1], "w");
1294 if (fp == nullptr) {
1295 const char *err_msg = errno ? strerror(errno) : "unknown";
1296 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1297 }
1298 else {
1299 if (G.log.file != nullptr) [[unlikely]] {
1300 fclose(static_cast<FILE *>(G.log.file));
1301 }
1302 G.log.file = fp;
1303 CLG_output_set(G.log.file);
1304 }
1305 return 1;
1306 }
1307 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1308 return 0;
1309}
1310
1311static const char arg_handle_log_set_doc[] =
1312 "<match>\n"
1313 "\tEnable logging categories, taking a single comma separated argument.\n"
1314 "\n"
1315 "\t--log \"*\": log everything\n"
1316 "\t--log \"event\": logs every category starting with 'event'.\n"
1317 "\t--log \"render,cycles\": log both render and cycles messages.\n"
1318 "\t--log \"*mesh*\": log every category containing 'mesh' sub-string.\n"
1319 "\t--log \"*,^operator\": log everything except operators, with '^prefix' to exclude.";
1320static int arg_handle_log_set(int argc, const char **argv, void * /*data*/)
1321{
1322 const char *arg_id = "--log";
1323 if (argc > 1) {
1324 const char *str_step = argv[1];
1325 while (*str_step) {
1326 const char *str_step_end = strchr(str_step, ',');
1327 int str_step_len = str_step_end ? (str_step_end - str_step) : strlen(str_step);
1328
1329 if (str_step[0] == '^') {
1330 CLG_type_filter_exclude(str_step + 1, str_step_len - 1);
1331 }
1332 else {
1333 CLG_type_filter_include(str_step, str_step_len);
1334 }
1335
1336 if (str_step_end) {
1337 /* Typically only be one, but don't fail on multiple. */
1338 while (*str_step_end == ',') {
1339 str_step_end++;
1340 }
1341 str_step = str_step_end;
1342 }
1343 else {
1344 break;
1345 }
1346 }
1347 return 1;
1348 }
1349 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1350 return 0;
1351}
1352
1354 "\n"
1355 "\tList all available logging categories for '--log', and exit.\n";
1356
1357static int arg_handle_list_clog_cats(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1358{
1359 auto print_identifier = [](const char *identifier, void *) { printf("%s\n", identifier); };
1360 CLG_logref_list_all(print_identifier, nullptr);
1362 exit(EXIT_SUCCESS);
1363 return 0;
1364}
1365
1367 "\n"
1368 "\tTurn debugging on.\n"
1369 "\n"
1370 "\t* Enables memory error detection\n"
1371 "\t* Disables mouse grab (to interact with a debugger in some cases)\n"
1372 "\t* Keeps Python's 'sys.stdin' rather than setting it to None";
1373static int arg_handle_debug_mode_set(int /*argc*/, const char ** /*argv*/, void *data)
1374{
1375 G.debug |= G_DEBUG;
1376 printf("Blender %s\n", BKE_blender_version_string());
1378# ifndef NDEBUG
1380# endif
1381
1382# ifdef WITH_BUILDINFO
1383 printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
1384# endif
1385
1386 BLI_args_print(static_cast<bArgs *>(data));
1387 return 0;
1388}
1389
1391 "\n\t"
1392 "Enable debug messages for Freestyle.";
1394 "\n\t"
1395 "Enable debug messages for Python.";
1397 "\n\t"
1398 "Enable debug messages for the event system.";
1400 "\n\t"
1401 "Enable debug messages for event handling.";
1403 "\n\t"
1404 "Enable debug messages for the window manager, shows all operators in search, shows "
1405 "keymap errors.";
1407 "\n\t"
1408 "Enable debug messages for Ghost (Linux only).";
1410 "\n\t"
1411 "Enable debug messages for Wintab.";
1413 "\n\t"
1414 "Enable debug messages for virtual reality contexts.\n"
1415 "\tEnables the OpenXR API validation layer, (OpenXR) debug messages and general information "
1416 "prints.";
1418 "\n\t"
1419 "Enable debug messages for virtual reality frame rendering times.";
1421 "\n\t"
1422 "Enable time profiling for background jobs.";
1424 "\n\t"
1425 "Enable all debug messages from dependency graph.";
1427 "\n\t"
1428 "Enable debug messages from dependency graph related on graph construction.";
1430 "\n\t"
1431 "Enable debug messages from dependency graph related on tagging.";
1433 "\n\t"
1434 "Enable debug messages from dependency graph related on timing.";
1436 "\n\t"
1437 "Enable debug messages from dependency graph related on evaluation.";
1439 "\n\t"
1440 "Switch dependency graph to a single threaded evaluation.";
1442 "\n\t"
1443 "Enable colors for dependency graph debug messages.";
1445 "\n\t"
1446 "Verify validity of session-wide identifiers assigned to ID data-blocks.";
1448 "\n\t"
1449 "Enable workarounds for typical GPU issues and disable all GPU extensions.";
1451 "\n\t"
1452 "Force Vulkan dynamic rendering local read when supported by device.";
1454 "\n\t"
1455 "Fail instead of falling back when '--gpu-device' does not match a usable Vulkan device.";
1457 "\n\t"
1458 "Fail instead of falling back to another GPU backend when the selected one is not supported.\n"
1459 "\tSkips the GPU backend support check.";
1461 "\n\t"
1462 "Force disable hardware raytracing support (Vulkan only).";
1463
1464static int arg_handle_debug_mode_generic_set(int /*argc*/, const char ** /*argv*/, void *data)
1465{
1466 G.debug |= reinterpret_cast<uint64_t>(data);
1467 return 0;
1468}
1469
1470static const char arg_handle_debug_mode_io_doc[] =
1471 "\n\t"
1472 "Enable debug messages for I/O.";
1473static int arg_handle_debug_mode_io(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1474{
1475 G.debug |= G_DEBUG_IO;
1476 return 0;
1477}
1478
1480 "\n\t"
1481 "Enable all debug messages.";
1482static int arg_handle_debug_mode_all(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1483{
1484 G.debug |= G_DEBUG_ALL;
1485# ifdef WITH_LIBMV
1487# endif
1488 return 0;
1489}
1490
1492 "\n\t"
1493 "Enable debug messages from libmv library.";
1494static int arg_handle_debug_mode_libmv(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1495{
1496# ifdef WITH_LIBMV
1498# endif
1499 return 0;
1500}
1501
1503 "\n\t"
1504 "Enable debug messages from Cycles.";
1505static int arg_handle_debug_mode_cycles(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1506{
1507 const char *cycles_filter = "cycles.*";
1508 CLG_type_filter_include(cycles_filter, strlen(cycles_filter));
1509 return 0;
1510}
1511
1513 "\n\t"
1514 "Enable debug messages from FFmpeg video input and output.";
1515static int arg_handle_debug_mode_ffmpeg(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1516{
1517 const char *video_filter = "video.*";
1518 CLG_type_filter_include(video_filter, strlen(video_filter));
1519 return 0;
1520}
1521
1523 "\n\t"
1524 "Enable fully guarded memory allocation and debugging.";
1525static int arg_handle_debug_mode_memory_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1526{
1528 return 0;
1529}
1530
1532 "<value>\n"
1533 "\tSet debug value of <value> on startup.";
1534static int arg_handle_debug_value_set(int argc, const char **argv, void * /*data*/)
1535{
1536 const char *arg_id = "--debug-value";
1537 if (argc > 1) {
1538 const char *err_msg = nullptr;
1539 int value;
1540 if (!parse_int(argv[1], nullptr, &value, &err_msg)) {
1541 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1542 return 1;
1543 }
1544
1545 G.debug_value = value;
1546
1547 return 1;
1548 }
1549 fprintf(stderr, "\nError: you must specify debug value to set.\n");
1550 return 0;
1551}
1552
1553static const char arg_handle_debug_gpu_set_doc[] =
1554 "\n"
1555 "\tEnable GPU debug context and information for OpenGL 4.3+.";
1556static int arg_handle_debug_gpu_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1557{
1558 /* Also enable logging because that how gl errors are reported. */
1559 const char *gpu_filter = "gpu.*";
1560 CLG_type_filter_include(gpu_filter, strlen(gpu_filter));
1561 G.debug |= G_DEBUG_GPU;
1562 return 0;
1563}
1564
1566 "\n"
1567 "\tCompile all statically defined shaders to test platform compatibility.";
1569 const char ** /*argv*/,
1570 void * /*data*/)
1571{
1573 return 0;
1574}
1575
1577 "\n"
1578 "\tCapture the GPU commands issued inside the given scope name.";
1579static int arg_handle_debug_gpu_scope_capture_set(int argc, const char **argv, void * /*data*/)
1580{
1581 if (argc > 1) {
1582 STRNCPY(G.gpu_debug_scope_name, argv[1]);
1583 return 1;
1584 }
1585 fprintf(stderr, "\nError: you must specify a scope name to capture.\n");
1586 return 0;
1587}
1588
1590 "\n"
1591 "\tSave the compiled GPU shader source code for the given shader name.\n"
1592 "\tThe given name can contain leading or trailing wildcard \"*\" to match multiple shaders.\n"
1593 "\tFiles are saved in the current working directory inside a directory named \"Shaders\".";
1594static int arg_handle_debug_gpu_shader_source(int argc, const char **argv, void * /*data*/)
1595{
1596 if (argc > 1) {
1597 STRNCPY(G.gpu_debug_shader_source_name, argv[1]);
1598 return 1;
1599 }
1600 fprintf(stderr, "\nError: you must specify a shader name to capture.\n");
1601 return 0;
1602}
1603
1605 "\n"
1606 "\tSkip preprocessor pass and rely on driver or shader compiler preprocessor instead.\n"
1607 "\tAlso disable dead code elimination.";
1609 const char ** /*argv*/,
1610 void * /*data*/)
1611{
1613 return 0;
1614}
1615
1617 "\n"
1618 "\tSkip dead code elimination pass.";
1620 const char ** /*argv*/,
1621 void * /*data*/)
1622{
1624 return 0;
1625}
1626
1628 "\n"
1629 "\tDisable memory aliasing optimizations in the GPU texture pool.";
1631 const char ** /* argv */,
1632 void * /*data*/)
1633{
1635 return 0;
1636}
1637
1639 "\n"
1640 "\tEnable RenderDoc integration for GPU frame grabbing and debugging.";
1642 const char ** /*argv*/,
1643 void * /*data*/)
1644{
1645# ifdef WITH_RENDERDOC
1647# else
1649# endif
1650 return 0;
1651}
1652
1654 "\n"
1655 "\tEnable shader debug info generation (Vulkan only).";
1657 const char ** /*argv*/,
1658 void * /*data*/)
1659{
1661 return 0;
1662}
1663
1665 "\n"
1666 "\tForce to use a specific GPU backend. Valid options: "
1667 "'vulkan', "
1668 "'metal', "
1669 "'opengl'.";
1671 "\n"
1672 "\tForce to use a specific GPU backend. Valid options: "
1673# ifdef WITH_OPENGL_BACKEND
1674 "'opengl'"
1675# endif
1676# ifdef WITH_METAL_BACKEND
1677 "'metal'"
1678# endif
1679# ifdef WITH_VULKAN_BACKEND
1680# if defined(WITH_OPENGL_BACKEND) || defined(WITH_METAL_BACKEND)
1681 " or "
1682# endif
1683 "'vulkan'"
1684# endif
1685 ".";
1686static int arg_handle_gpu_backend_set(int argc, const char **argv, void * /*data*/)
1687{
1688 if (argc < 2) {
1689 fprintf(stderr, "\nError: GPU backend must follow '--gpu-backend'.\n");
1690 return 0;
1691 }
1692 const char *backends_supported[3] = {nullptr};
1693 int backends_supported_num = 0;
1694
1695 GPUBackendType gpu_backend = GPU_BACKEND_NONE;
1696
1697 /* NOLINTBEGIN: bugprone-assignment-in-if-condition */
1698 if (false) {
1699 /* Use a dummy block to make the following `ifdef` blocks work. */
1700 }
1701# ifdef WITH_OPENGL_BACKEND
1702 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "opengl"))) {
1703 gpu_backend = GPU_BACKEND_OPENGL;
1704 }
1705# endif
1706# ifdef WITH_VULKAN_BACKEND
1707 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "vulkan"))) {
1708 gpu_backend = GPU_BACKEND_VULKAN;
1709 }
1710# endif
1711# ifdef WITH_METAL_BACKEND
1712 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "metal"))) {
1713 gpu_backend = GPU_BACKEND_METAL;
1714 }
1715# endif
1716 else {
1717 fprintf(stderr, "\nError: Unrecognized GPU backend for '--gpu-backend', expected one of [");
1718 for (int i = 0; i < backends_supported_num; i++) {
1719 fprintf(stderr, (i + 1 != backends_supported_num) ? "%s, " : "%s", backends_supported[i]);
1720 }
1721 fprintf(stderr, "].\n");
1722 return 1;
1723 }
1724 /* NOLINTEND: bugprone-assignment-in-if-condition */
1725
1727
1728 return 1;
1729}
1730
1731static void arg_handle_gpu_device_exit(const int exit_code)
1732{
1733 /* `BKE_blender_atexit` expects `BKE_appdir_init` to have been called.
1734 * `--gpu-device` is parsed in the environment pass, before the usual appdir initialization. */
1737 exit(exit_code);
1739}
1740
1742 "<device>\n"
1743 "\tSelect a specific GPU device, overriding the GPU device from user preferences for this\n"
1744 "\trun only. Accepted forms:\n"
1745 "\n"
1746 "\t* '<vendor-hex>/<device-hex>/<index-hex>' (matches the identifier used in user\n"
1747 "\t preferences, with vendor PCI ID, device PCI ID and enumeration index all hex-encoded).\n"
1748 "\t* '<index>' (no slashes) picks the Nth supported device by enumeration order, decimal.\n"
1749 "\t* 'help' prints supported Vulkan devices and exits.\n"
1750 "\n"
1751 "\tOnly used with the Vulkan backend. Other backends print a warning and ignore this option.\n"
1752 "\tIf the requested Vulkan device is unavailable, Blender falls back to the saved GPU\n"
1753 "\tpreference unless '--gpu-device-no-fallback' is also set.";
1754static int arg_handle_gpu_device_set(int argc, const char **argv, void * /*data*/)
1755{
1756 const char *arg_id = "--gpu-device";
1757 if (argc < 2) {
1758 fprintf(stderr, "\nError: GPU device specifier must follow '%s'.\n", arg_id);
1759 arg_handle_gpu_device_exit(EXIT_FAILURE);
1760 }
1761
1762 const char *spec = argv[1];
1763 if (STREQ(spec, "help")) {
1764 printf("Blender GPU Device Listing (Vulkan):\n");
1765 printf("Pass an Index or Device-ID to '--gpu-device'.\n");
1766# ifdef WITH_VULKAN_BACKEND
1767 GPU_vulkan_supported_devices_print(stdout);
1768# else
1769 printf(" (Vulkan backend not built)\n");
1770# endif
1771 arg_handle_gpu_device_exit(EXIT_SUCCESS);
1772 }
1773
1774 int device_index = 0;
1775 uint32_t device_vendor_id = 0;
1776 uint32_t device_device_id = 0;
1777
1778 if (strchr(spec, '/') == nullptr) {
1779 const char *err_msg = nullptr;
1780 if (!parse_int_strict_range(spec, nullptr, 0, INT_MAX, &device_index, &err_msg)) {
1781 fprintf(stderr,
1782 "\nError: %s '%s %s', expected '<index>' (a non-negative integer) "
1783 "or '<vendor-hex>/<device-hex>/<index-hex>'.\n",
1784 err_msg,
1785 arg_id,
1786 spec);
1787 arg_handle_gpu_device_exit(EXIT_FAILURE);
1788 }
1789 device_vendor_id = uint32_t(-1);
1790 device_device_id = uint32_t(-1);
1791 }
1792 else {
1793 const char *p1 = strchr(spec, '/');
1794 const char *p2 = strchr(p1 + 1, '/');
1795 if (p2 == nullptr) {
1796 fprintf(stderr,
1797 "\nError: unrecognized '%s %s', expected "
1798 "'<vendor-hex>/<device-hex>/<index-hex>', '<index>' or 'help'.\n",
1799 arg_id,
1800 spec);
1801 arg_handle_gpu_device_exit(EXIT_FAILURE);
1802 }
1803
1804 char *end = nullptr;
1805 errno = 0;
1806 const ulong vendor_id = strtoul(spec, &end, 16);
1807 const bool vendor_ok = (errno == 0) && (end == p1) && (end != spec) &&
1808 (vendor_id <= std::numeric_limits<uint32_t>::max());
1809 errno = 0;
1810 const ulong device_id = strtoul(p1 + 1, &end, 16);
1811 const bool device_ok = (errno == 0) && (end == p2) && (end != p1 + 1) &&
1812 (device_id <= std::numeric_limits<uint32_t>::max());
1813 errno = 0;
1814 const ulong index = strtoul(p2 + 1, &end, 16);
1815 const bool index_ok = (errno == 0) && (*end == '\0') && (end != p2 + 1) && (index <= INT_MAX);
1816
1817 if (!vendor_ok || !device_ok || !index_ok) {
1818 fprintf(stderr,
1819 "\nError: failed to parse '%s %s', "
1820 "expected '<vendor-hex>/<device-hex>/<index-hex>'.\n",
1821 arg_id,
1822 spec);
1823 arg_handle_gpu_device_exit(EXIT_FAILURE);
1824 }
1825
1826 device_vendor_id = uint32_t(vendor_id);
1827 device_device_id = uint32_t(device_id);
1828 device_index = int(index);
1829 }
1830
1831 GPU_backend_preferred_device_set_override(device_index, device_vendor_id, device_device_id);
1832 return 1;
1833}
1834
1835static const char arg_handle_gpu_vsync_set_doc[] =
1836 "\n"
1837 "\tSet the VSync.\n"
1838 "\tValid options are: 'on', 'off' & 'auto' for adaptive sync.\n"
1839 "\n"
1840 "\t* The default settings depend on the GPU driver.\n"
1841 "\t* Disabling VSync can be useful for testing performance.\n"
1842 "\t* 'auto' is only supported by the OpenGL backend.";
1843static int arg_handle_gpu_vsync_set(int argc, const char **argv, void * /*data*/)
1844{
1845 const char *arg_id = "--gpu-vsync";
1846
1847 if (argc < 2) {
1848 fprintf(stderr, "\nError: VSync value must follow '%s'.\n", arg_id);
1849 return 0;
1850 }
1851
1852 /* Must be compatible with #GHOST_TVSyncModes. */
1853 int vsync;
1854 if (STREQ(argv[1], "on")) {
1855 vsync = 1;
1856 }
1857 else if (STREQ(argv[1], "off")) {
1858 vsync = 0;
1859 }
1860 else if (STREQ(argv[1], "auto")) {
1861 vsync = -1;
1862 }
1863 else {
1864 fprintf(stderr, "\nError: expected a value in [on, off, auto] '%s %s'.\n", arg_id, argv[1]);
1865 return 1;
1866 }
1867
1869
1870 return 1;
1871}
1872
1874 "\n"
1875 "\tOverride the Max Compilation Subprocesses setting (OpenGL only).";
1877 const char **argv,
1878 void * /*data*/)
1879{
1880 const char *arg_id = "--gpu-compilation-subprocesses";
1881 const int min = 0, max = BLI_system_thread_count();
1882 if (argc > 1) {
1883 const char *err_msg = nullptr;
1884 int subprocesses;
1885 if (!parse_int_strict_range(argv[1], nullptr, min, max, &subprocesses, &err_msg)) {
1886 fprintf(stderr,
1887 "\nError: %s '%s %s', expected number in [%d..%d].\n",
1888 err_msg,
1889 arg_id,
1890 argv[1],
1891 min,
1892 max);
1893 return 1;
1894 }
1895
1896# ifdef WITH_OPENGL_BACKEND
1898# else
1899 UNUSED_VARS(subprocesses);
1901# endif
1902 return 1;
1903 }
1904 fprintf(stderr,
1905 "\nError: you must specify a number of subprocesses in [%d..%d] '%s'.\n",
1906 min,
1907 max,
1908 arg_id);
1909 return 0;
1910}
1911
1912static const char arg_handle_debug_fpe_set_doc[] =
1913 "\n\t"
1914 "Enable floating-point exceptions.";
1915static int arg_handle_debug_fpe_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1916{
1918 return 0;
1919}
1920
1921static const char arg_handle_app_template_doc[] =
1922 "<template>\n"
1923 "\tSet the application template (matching the directory name), use 'default' for none.";
1924static int arg_handle_app_template(int argc, const char **argv, void * /*data*/)
1925{
1926 if (argc > 1) {
1927 const char *app_template = STREQ(argv[1], "default") ? "" : argv[1];
1928 WM_init_state_app_template_set(app_template);
1929 return 1;
1930 }
1931 fprintf(stderr, "\nError: App template must follow '--app-template'.\n");
1932 return 0;
1933}
1934
1936 "\n\t"
1937 "Skip reading the '" BLENDER_STARTUP_FILE "' in the user's home directory.";
1938static int arg_handle_factory_startup_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1939{
1940 G.factory_startup = true;
1942 return 0;
1943}
1944
1946 "\n\t"
1947 "Enable event simulation testing feature 'bpy.types.Window.event_simulate'.";
1948static int arg_handle_enable_event_simulate(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1949{
1951 return 0;
1952}
1953
1955 "\n\t"
1956 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES) " environment variable.";
1958 "\n\t"
1959 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS) " environment variable.";
1961 "\n\t"
1962 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON) " environment variable.";
1964 "\n\t"
1965 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_EXTENSIONS) " environment variable.";
1966
1967static int arg_handle_env_system_set(int argc, const char **argv, void * /*data*/)
1968{
1969 /* `--env-system-scripts` -> `BLENDER_SYSTEM_SCRIPTS` */
1970
1971 char env[64] = "BLENDER";
1972 char *ch_dst = env + 7; /* Skip `BLENDER`. */
1973 const char *ch_src = argv[0] + 5; /* Skip `--env`. */
1974
1975 if (argc < 2) {
1976 fprintf(stderr, "%s requires one argument\n", argv[0]);
1977 exit(EXIT_FAILURE);
1979 }
1980
1981 for (; *ch_src; ch_src++, ch_dst++) {
1982 *ch_dst = (*ch_src == '-') ? '_' : (*ch_src) - 32; /* Inline #toupper(). */
1983 }
1984
1985 *ch_dst = '\0';
1986 BLI_setenv(env, argv[1]);
1987 return 1;
1988}
1989
1990static const char arg_handle_playback_mode_doc[] =
1991 "<options> <file(s)>\n"
1992 "\tInstead of showing Blender's user interface, this runs Blender as an animation player,\n"
1993 "\tto view movies and image sequences rendered in Blender (ignored if '-b' is set).\n"
1994 "\n"
1995 "\tPlayback Arguments:\n"
1996 "\n"
1997 "\t-p <sx> <sy>\n"
1998 "\t\tOpen with lower left corner at <sx>, <sy>.\n"
1999 "\t-m\n"
2000 "\t\tRead from disk (Do not buffer).\n"
2001 "\t-f <fps> <fps_base>\n"
2002 "\t\tSpecify FPS to start with.\n"
2003 "\t-j <frame>\n"
2004 "\t\tSet frame step to <frame>.\n"
2005 "\t-s <frame>\n"
2006 "\t\tPlay from <frame>.\n"
2007 "\t-e <frame>\n"
2008 "\t\tPlay until <frame>.\n"
2009 "\t-c <cache_memory>\n"
2010 "\t\tAmount of memory in megabytes to allow for caching images during playback.\n"
2011 "\t\tZero disables (clamping to a fixed number of frames instead).";
2012static int arg_handle_playback_mode(int argc, const char **argv, void * /*data*/)
2013{
2014 /* Ignore the animation player if `-b` was given first. */
2015 if (G.background == 0) {
2016 /* Skip this argument (`-a`). */
2017 const int exit_code = WM_main_playanim(argc - 1, argv + 1);
2018
2019 exit(exit_code);
2020 }
2021
2022 return -2;
2023}
2024
2026 "<sx> <sy> <w> <h>\n"
2027 "\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>.";
2028static int arg_handle_window_geometry(int argc, const char **argv, void * /*data*/)
2029{
2030 const char *arg_id = "-p / --window-geometry";
2031 int params[4], i;
2032
2033 if (argc < 5) {
2034 fprintf(stderr, "Error: requires four arguments '%s'\n", arg_id);
2035 exit(1);
2036 }
2037
2038 for (i = 0; i < 4; i++) {
2039 const char *err_msg = nullptr;
2040 if (!parse_int(argv[i + 1], nullptr, &params[i], &err_msg)) {
2041 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2042 exit(1);
2043 }
2044 }
2045
2047
2048 return 4;
2049}
2050
2052 "\n\t"
2053 "Do not use native pixel size, for high resolution displays (MacBook 'Retina').";
2054static int arg_handle_native_pixels_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2055{
2056 WM_init_native_pixels(false);
2057 return 0;
2058}
2059
2060static const char arg_handle_window_border_doc[] =
2061 "\n\t"
2062 "Force opening with borders, in a normal (non maximized) state.";
2063static int arg_handle_window_border(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2064{
2066 return 0;
2067}
2068
2070 "\n\t"
2071 "Force opening full-screen.";
2072static int arg_handle_window_fullscreen(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2073{
2075 return 0;
2076}
2077
2079 "\n\t"
2080 "Force opening maximized.";
2081static int arg_handle_window_maximized(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2082{
2084 return 0;
2085}
2086
2088 "\n\t"
2089 "Disable all window decorations (Linux only).";
2090static int arg_handle_no_window_frame(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2091{
2093 return 0;
2094}
2095
2097 "\n\t"
2098 "Open behind other windows and without taking focus.";
2099static int arg_handle_no_window_focus(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2100{
2102 return 0;
2103}
2104
2106 "\n\t"
2107 "Start with the console window open (ignored if '-b' is set), (Windows only).";
2108static int arg_handle_start_with_console(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2109{
2111 return 0;
2112}
2113
2114static bool arg_handle_extension_registration(const bool do_register, const bool all_users)
2115{
2116 /* Logic runs in #main_args_handle_registration. */
2117# ifdef WIN32
2118 /* This process has been launched with the permissions needed
2119 * to register or unregister, so just do it now and then exit. */
2120 if (do_register) {
2122 }
2123 else {
2125 }
2126 TerminateProcess(GetCurrentProcess(), 0);
2127 return true;
2128# else
2129 char *error_msg = nullptr;
2130 bool result = WM_platform_associate_set(do_register, all_users, &error_msg);
2131 if (error_msg) {
2132 fprintf(stderr, "Error: %s\n", error_msg);
2133 MEM_delete(error_msg);
2134 }
2135 return result;
2136# endif
2137}
2138
2140 "\n\t"
2141 "Register blend-file extension for current user, then exit (Windows & Linux only).";
2142static int arg_handle_register_extension(int argc, const char **argv, void *data)
2143{
2144 CLG_quiet_set(true);
2146
2147# if !(defined(WIN32) || defined(__APPLE__))
2148 if (!main_arg_deferred_is_set()) {
2150 return argc - 1;
2151 }
2152# else
2153 UNUSED_VARS(argv, data);
2154# endif
2156 return argc - 1;
2157}
2158
2160 "\n\t"
2161 "Register blend-file extension for all users, then exit (Windows & Linux only).";
2162static int arg_handle_register_extension_all(int argc, const char **argv, void *data)
2163{
2164 CLG_quiet_set(true);
2166
2167# if !(defined(WIN32) || defined(__APPLE__))
2168 if (!main_arg_deferred_is_set()) {
2170 return argc - 1;
2171 }
2172# else
2173 UNUSED_VARS(argv, data);
2174# endif
2176 return argc - 1;
2177}
2178
2180 "\n\t"
2181 "Unregister blend-file extension for current user, then exit (Windows & Linux only).";
2182static int arg_handle_unregister_extension(int argc, const char **argv, void *data)
2183{
2184 CLG_quiet_set(true);
2186
2187# if !(defined(WIN32) || defined(__APPLE__))
2188 if (!main_arg_deferred_is_set()) {
2190 return argc - 1;
2191 }
2192# else
2193 UNUSED_VARS(argc, argv, data);
2194# endif
2196 return 0;
2197}
2198
2200 "\n\t"
2201 "Unregister blend-file extension for all users, then exit (Windows & Linux only).";
2202static int arg_handle_unregister_extension_all(int argc, const char **argv, void *data)
2203{
2204 CLG_quiet_set(true);
2206
2207# if !(defined(WIN32) || defined(__APPLE__))
2208 if (!main_arg_deferred_is_set()) {
2210 return argc - 1;
2211 }
2212# else
2213 UNUSED_VARS(argc, argv, data);
2214# endif
2216 return 0;
2217}
2218
2219static const char arg_handle_qos_set_doc[] =
2220 "<level>\n"
2221 "\tSet the Quality of Service (QoS) mode for hybrid CPU architectures (Windows only).\n"
2222 "\n"
2223 "\tdefault: Uses the default behavior of the OS.\n"
2224 "\thigh: Always makes use of performance cores.\n"
2225 "\teco: Schedules Blender threads exclusively to efficiency cores.";
2226static int arg_handle_qos_set(int argc, const char **argv, void * /*data*/)
2227{
2228 const char *arg_id = "--qos";
2229 if (argc > 1) {
2230# ifdef _WIN32
2231 QoSMode qos_mode;
2232 if (STRCASEEQ(argv[1], "default")) {
2233 qos_mode = QoSMode::DEFAULT;
2234 }
2235 else if (STRCASEEQ(argv[1], "high")) {
2236 qos_mode = QoSMode::HIGH;
2237 }
2238 else if (STRCASEEQ(argv[1], "eco")) {
2239 qos_mode = QoSMode::ECO;
2240 }
2241 else {
2242 fprintf(stderr, "\nError: Invalid QoS level '%s %s'.\n", arg_id, argv[1]);
2243 return 1;
2244 }
2246# else
2247 UNUSED_VARS(argv);
2248 fprintf(stderr, "\nError: '%s' is Windows only.\n", arg_id);
2249# endif
2250 return 1;
2251 }
2252 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
2253 return 0;
2254}
2255
2256static const char arg_handle_audio_disable_doc[] =
2257 "\n\t"
2258 "Force sound system to None.";
2259static int arg_handle_audio_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2260{
2261 BKE_sound_force_device("None");
2262 return 0;
2263}
2264
2265static const char arg_handle_audio_set_doc[] =
2266 "\n\t"
2267 "Force sound system to a specific device.\n"
2268 "\t'None' 'Default' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'.";
2269static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/)
2270{
2271 if (argc < 1) {
2272 fprintf(stderr, "-setaudio requires one argument\n");
2273 exit(1);
2274 }
2275
2276 const char *device = argv[1];
2277 if (STREQ(device, "Default")) {
2278 /* Unset any forced device. */
2279 device = nullptr;
2280 }
2281
2282 BKE_sound_force_device(device);
2283 return 1;
2284}
2285
2286static const char arg_handle_output_set_doc[] =
2287 "<path>\n"
2288 "\tSet the render path and file name.\n"
2289 "\tUse '//' at the start of the path to render relative to the blend-file.\n"
2290 "\n"
2291 "\tYou can use path templating features such as '{blend_name}' in the path.\n"
2292 "\tSee Blender's documentation on path templates for more details.\n"
2293 "\n"
2294 "\tThe '#' characters are replaced by the frame number, and used to define zero padding.\n"
2295 "\n"
2296 "\t* 'animation_##_test.png' becomes 'animation_01_test.png'\n"
2297 "\t* 'test-######.png' becomes 'test-000001.png'\n"
2298 "\n"
2299 "\tWhen the filename does not contain '#', the suffix '####' is added to the filename.\n"
2300 "\n"
2301 "\tThe frame number will be added at the end of the filename, eg:\n"
2302 "\t# blender -b animation.blend -o //render_ -F PNG -x 1 -a\n"
2303 "\t'//render_' becomes '//render_####', writing frames as '//render_0001.png'";
2304static int arg_handle_output_set(int argc, const char **argv, void *data)
2305{
2306 bContext *C = static_cast<bContext *>(data);
2307 if (argc > 1) {
2308 Scene *scene = CTX_data_scene(C);
2309 if (scene) {
2310 STRNCPY(scene->r.pic, argv[1]);
2312 }
2313 else {
2314 fprintf(stderr, "\nError: no blend loaded. cannot use '-o / --render-output'.\n");
2315 }
2316 return 1;
2317 }
2318 fprintf(stderr, "\nError: you must specify a path after '-o / --render-output'.\n");
2319 return 0;
2320}
2321
2322static const char arg_handle_engine_set_doc[] =
2323 "<engine>\n"
2324 "\tSpecify the render engine.\n"
2325 "\tUse '-E help' to list available engines.";
2326static int arg_handle_engine_set(int argc, const char **argv, void *data)
2327{
2328 bContext *C = static_cast<bContext *>(data);
2329 if (argc >= 2) {
2330 const char *engine_name = argv[1];
2331
2332 if (STREQ(engine_name, "help")) {
2333 printf("Blender Engine Listing:\n");
2334 for (RenderEngineType &type : R_engines) {
2335 printf("\t%s\n", type.idname);
2336 }
2337 WM_exit_ex(C, false, false);
2338 exit(0);
2339 }
2340 else {
2341 Scene *scene = CTX_data_scene(C);
2342 if (scene) {
2343 /* Backwards compatibility. */
2344 if (STREQ(engine_name, "BLENDER_EEVEE_NEXT")) {
2345 engine_name = "BLENDER_EEVEE";
2346 }
2347
2348 if (BLI_findstring(&R_engines, engine_name, offsetof(RenderEngineType, idname))) {
2349 STRNCPY_UTF8(scene->r.engine, engine_name);
2351 }
2352 else {
2353 fprintf(stderr, "\nError: engine not found '%s'\n", engine_name);
2354 WM_exit_ex(C, false, false);
2355 exit(1);
2356 }
2357 }
2358 else {
2359 fprintf(stderr,
2360 "\nError: no blend loaded. "
2361 "order the arguments so '-E / --engine' is after a blend is loaded.\n");
2362 }
2363 }
2364
2365 return 1;
2366 }
2367 fprintf(stderr, "\nEngine not specified, give 'help' for a list of available engines.\n");
2368 return 0;
2369}
2370
2372 "<format>\n"
2373 "\tSet the render format.\n"
2374 "\tValid options are:\n"
2375 "\t'TGA' 'RAWTGA' 'JPEG' 'IRIS' 'PNG' 'BMP' 'HDR' 'TIFF'.\n"
2376 "\n"
2377 "\tFormats that can be compiled into Blender, not available on all systems:\n"
2378 "\t'OPEN_EXR' 'OPEN_EXR_MULTILAYER' 'FFMPEG' 'CINEON' 'DPX' 'JP2' 'WEBP'.";
2379static int arg_handle_image_type_set(int argc, const char **argv, void *data)
2380{
2381 bContext *C = static_cast<bContext *>(data);
2382 if (argc > 1) {
2383 const char *imtype = argv[1];
2384 Scene *scene = CTX_data_scene(C);
2385 if (scene) {
2386 const char imtype_new = BKE_imtype_from_arg(imtype);
2387
2388 if (imtype_new == R_IMF_IMTYPE_INVALID) {
2389 fprintf(stderr,
2390 "\nError: Format from '-F / --render-format' not known or not compiled in this "
2391 "release.\n");
2392 }
2393 else {
2394 BKE_image_format_set(&scene->r.im_format, &scene->id, imtype_new);
2396 }
2397 }
2398 else {
2399 fprintf(stderr,
2400 "\nError: no blend loaded. "
2401 "order the arguments so '-F / --render-format' is after the blend is loaded.\n");
2402 }
2403 return 1;
2404 }
2405 fprintf(stderr, "\nError: you must specify a format after '-F / --render-format'.\n");
2406 return 0;
2407}
2408
2409static const char arg_handle_threads_set_doc[] =
2410 "<threads>\n"
2411 "\tUse amount of <threads> for rendering and other operations\n"
2412 "\t[1-" STRINGIFY(BLENDER_MAX_THREADS) "], 0 to use the system's processor count.";
2413static int arg_handle_threads_set(int argc, const char **argv, void * /*data*/)
2414{
2415 const char *arg_id = "-t / --threads";
2416 const int min = 0, max = BLENDER_MAX_THREADS;
2417 if (argc > 1) {
2418 const char *err_msg = nullptr;
2419 int threads;
2420 if (!parse_int_strict_range(argv[1], nullptr, min, max, &threads, &err_msg)) {
2421 fprintf(stderr,
2422 "\nError: %s '%s %s', expected number in [%d..%d].\n",
2423 err_msg,
2424 arg_id,
2425 argv[1],
2426 min,
2427 max);
2428 return 1;
2429 }
2430
2432 return 1;
2433 }
2434 fprintf(stderr,
2435 "\nError: you must specify a number of threads in [%d..%d] '%s'.\n",
2436 min,
2437 max,
2438 arg_id);
2439 return 0;
2440}
2441
2442static const char arg_handle_verbosity_set_doc[] =
2443 "<verbose>\n"
2444 "\tSet the logging verbosity level for debug messages that support it.";
2445static int arg_handle_verbosity_set(int argc, const char **argv, void * /*data*/)
2446{
2447 const char *arg_id = "--verbose";
2448 if (argc > 1) {
2449 const char *err_msg = nullptr;
2450 int level;
2451 if (!parse_int(argv[1], nullptr, &level, &err_msg)) {
2452 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2453 }
2454
2455# ifdef WITH_LIBMV
2457# endif
2458
2459 return 1;
2460 }
2461 fprintf(stderr, "\nError: you must specify a verbosity level.\n");
2462 return 0;
2463}
2464
2465static const char arg_handle_extension_set_doc[] =
2466 "<bool>\n"
2467 "\tSet option to add the file extension to the end of the file.";
2468static int arg_handle_extension_set(int argc, const char **argv, void *data)
2469{
2470 bContext *C = static_cast<bContext *>(data);
2471 if (argc > 1) {
2472 Scene *scene = CTX_data_scene(C);
2473 if (scene) {
2474 if (argv[1][0] == '0') {
2475 scene->r.scemode &= ~R_EXTENSION;
2477 }
2478 else if (argv[1][0] == '1') {
2479 scene->r.scemode |= R_EXTENSION;
2481 }
2482 else {
2483 fprintf(stderr,
2484 "\nError: Use '-x 1 / -x 0' To set the extension option or '--use-extension'\n");
2485 }
2486 }
2487 else {
2488 fprintf(stderr,
2489 "\nError: no blend loaded. "
2490 "order the arguments so '-o ' is after '-x '.\n");
2491 }
2492 return 1;
2493 }
2494 fprintf(stderr, "\nError: you must specify a path after '- '.\n");
2495 return 0;
2496}
2497
2499{
2500 const char *render_filter = "render.*";
2501 CLG_type_filter_include(render_filter, strlen(render_filter));
2502}
2503
2504static const char arg_handle_render_frame_doc[] =
2505 "<frame>\n"
2506 "\tRender frame <frame> and save it.\n"
2507 "\n"
2508 "\t* +<frame> start frame relative, -<frame> end frame relative.\n"
2509 "\t* A comma separated list of frames can also be used (no spaces).\n"
2510 "\t* A range of frames can be expressed using '..' separator between the first and last "
2511 "frames (inclusive).\n";
2512static int arg_handle_render_frame(int argc, const char **argv, void *data)
2513{
2514 const char *arg_id = "-f / --render-frame";
2515 bContext *C = static_cast<bContext *>(data);
2516 Scene *scene = CTX_data_scene(C);
2517 if (scene) {
2519
2520 Main *bmain = CTX_data_main(C);
2521
2522 if (argc > 1) {
2523 const char *err_msg = nullptr;
2524 Render *re;
2525 ReportList reports;
2526
2527 int (*frame_range_arr)[2], frames_range_len;
2528 if ((frame_range_arr = parse_int_range_relative_clamp_n(argv[1],
2529 scene->r.sfra,
2530 scene->r.efra,
2531 MINAFRAME,
2532 MAXFRAME,
2533 &frames_range_len,
2534 &err_msg)) == nullptr)
2535 {
2536 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2537 return 1;
2538 }
2539
2540 BKE_reports_init(&reports, RPT_STORE);
2541
2542 if (!RE_disable_save_output_allowed(true, *scene, &reports)) {
2543 BKE_reports_free(&reports);
2544 MEM_delete(frame_range_arr);
2545 return 1;
2546 }
2547
2548 if (!RE_is_rendering_allowed(*bmain, scene, nullptr, nullptr, &reports)) {
2549 BKE_reports_free(&reports);
2550 MEM_delete(frame_range_arr);
2551 return 1;
2552 }
2553
2554 re = RE_NewSceneRender(scene);
2555 RE_SetReports(re, &reports);
2556
2557 for (int i = 0; i < frames_range_len; i++) {
2558 /* We could pass in frame ranges,
2559 * but prefer having exact behavior as passing in multiple frames. */
2560 if ((frame_range_arr[i][0] <= frame_range_arr[i][1]) == 0) {
2561 fprintf(stderr, "\nWarning: negative range ignored '%s %s'.\n", arg_id, argv[1]);
2562 }
2563
2564 for (int frame = frame_range_arr[i][0]; frame <= frame_range_arr[i][1]; frame++) {
2565 RE_RenderAnim(re, bmain, scene, nullptr, nullptr, frame, frame, scene->r.frame_step);
2566 }
2567 }
2568 RE_SetReports(re, nullptr);
2569 BKE_reports_free(&reports);
2570 MEM_delete(frame_range_arr);
2571 return 1;
2572 }
2573 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2574 return 0;
2575 }
2576 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2577 return 0;
2578}
2579
2581 "\n\t"
2582 "Render frames from start to end (inclusive).";
2583static int arg_handle_render_animation(int /*argc*/, const char ** /*argv*/, void *data)
2584{
2585 bContext *C = static_cast<bContext *>(data);
2586 Scene *scene = CTX_data_scene(C);
2587 if (scene) {
2589
2590 Main *bmain = CTX_data_main(C);
2591
2592 ReportList reports;
2593 BKE_reports_init(&reports, RPT_STORE);
2594
2595 if (!RE_disable_save_output_allowed(true, *scene, &reports)) {
2596 BKE_reports_free(&reports);
2597 return 0;
2598 }
2599
2600 if (!RE_is_rendering_allowed(*bmain, scene, nullptr, nullptr, &reports)) {
2601 BKE_reports_free(&reports);
2602 return 0;
2603 }
2604
2605 Render *re = RE_NewSceneRender(scene);
2606 RE_SetReports(re, &reports);
2607
2609 re, bmain, scene, nullptr, nullptr, scene->r.sfra, scene->r.efra, scene->r.frame_step);
2610 RE_SetReports(re, nullptr);
2611 BKE_reports_free(&reports);
2612 }
2613 else {
2614 fprintf(stderr, "\nError: no blend loaded. cannot use '-a'.\n");
2615 }
2616 return 0;
2617}
2618
2619static const char arg_handle_scene_set_doc[] =
2620 "<name>\n"
2621 "\tSet the active scene <name> for rendering.";
2622static int arg_handle_scene_set(int argc, const char **argv, void *data)
2623{
2624 if (argc > 1) {
2625 bContext *C = static_cast<bContext *>(data);
2626 Scene *scene = BKE_scene_set_name(CTX_data_main(C), argv[1]);
2627 if (scene) {
2628 CTX_data_scene_set(C, scene);
2629
2630 /* Set the scene of the first window, see: #55991,
2631 * otherwise scripts that run later won't get this scene back from the context. */
2632 wmWindow *win = CTX_wm_window(C);
2633 if (win == nullptr) {
2634 win = CTX_wm_manager(C)->windows.first();
2635 }
2636 if (win != nullptr) {
2638 }
2639 }
2640 return 1;
2641 }
2642 fprintf(stderr, "\nError: Scene name must follow '-S / --scene'.\n");
2643 return 0;
2644}
2645
2647 "<frame>\n"
2648 "\tSet start to frame <frame>, supports +/- for relative frames too.";
2649static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
2650{
2651 const char *arg_id = "-s / --frame-start";
2652 bContext *C = static_cast<bContext *>(data);
2653 Scene *scene = CTX_data_scene(C);
2654 if (scene) {
2655 if (argc > 1) {
2656 const char *err_msg = nullptr;
2657 if (!parse_int_relative_clamp(argv[1],
2658 nullptr,
2659 scene->r.sfra,
2660 scene->r.sfra - 1,
2661 MINAFRAME,
2662 MAXFRAME,
2663 &scene->r.sfra,
2664 &err_msg))
2665 {
2666 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2667 }
2668 else {
2670 }
2671 return 1;
2672 }
2673 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2674 return 0;
2675 }
2676 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2677 return 0;
2678}
2679
2680static const char arg_handle_frame_end_set_doc[] =
2681 "<frame>\n"
2682 "\tSet end to frame <frame>, supports +/- for relative frames too.";
2683static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
2684{
2685 const char *arg_id = "-e / --frame-end";
2686 bContext *C = static_cast<bContext *>(data);
2687 Scene *scene = CTX_data_scene(C);
2688 if (scene) {
2689 if (argc > 1) {
2690 const char *err_msg = nullptr;
2691 if (!parse_int_relative_clamp(argv[1],
2692 nullptr,
2693 scene->r.efra,
2694 scene->r.efra - 1,
2695 MINAFRAME,
2696 MAXFRAME,
2697 &scene->r.efra,
2698 &err_msg))
2699 {
2700 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2701 }
2702 else {
2704 }
2705 return 1;
2706 }
2707 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2708 return 0;
2709 }
2710 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2711 return 0;
2712}
2713
2715 "<frames>\n"
2716 "\tSet number of frames to step forward after each rendered frame.";
2717static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
2718{
2719 const char *arg_id = "-j / --frame-jump";
2720 bContext *C = static_cast<bContext *>(data);
2721 Scene *scene = CTX_data_scene(C);
2722 if (scene) {
2723 if (argc > 1) {
2724 const char *err_msg = nullptr;
2725 if (!parse_int_clamp(argv[1], nullptr, 1, MAXFRAME, &scene->r.frame_step, &err_msg)) {
2726 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2727 }
2728 else {
2730 }
2731 return 1;
2732 }
2733 fprintf(stderr, "\nError: number of frames to step must follow '%s'.\n", arg_id);
2734 return 0;
2735 }
2736 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2737 return 0;
2738}
2739
2741 "<filepath>\n"
2742 "\tRun the given Python script file.";
2743static int arg_handle_python_file_run(int argc, const char **argv, void *data)
2744{
2745 bContext *C = static_cast<bContext *>(data);
2746
2747 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2748 if (argc > 1) {
2749# ifdef WITH_PYTHON
2750 /* Make the path absolute because its needed for relative linked blends to be found. */
2751 char filepath[FILE_MAX];
2752 STRNCPY(filepath, argv[1]);
2753 BLI_path_canonicalize_native(filepath, sizeof(filepath));
2754
2755 bool ok;
2756 BPY_CTX_SETUP(ok = BPY_run_filepath(C, filepath, nullptr));
2757 if (!ok && app_state.exit_code_on_error.python) {
2758 fprintf(stderr, "\nError: script failed, file: '%s', exiting.\n", argv[1]);
2760 }
2761# else
2762 UNUSED_VARS(C);
2763 fprintf(stderr, "This Blender was built without Python support\n");
2764# endif /* WITH_PYTHON */
2765
2766 return 1;
2767 }
2768 fprintf(stderr, "\nError: you must specify a filepath after '%s'.\n", argv[0]);
2769 return 0;
2770}
2771
2773 "<name>\n"
2774 "\tRun the given Python script text block.";
2775static int arg_handle_python_text_run(int argc, const char **argv, void *data)
2776{
2777 bContext *C = static_cast<bContext *>(data);
2778
2779 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2780 if (argc > 1) {
2781# ifdef WITH_PYTHON
2782 Main *bmain = CTX_data_main(C);
2783 /* Make the path absolute because its needed for relative linked blends to be found. */
2784 Text *text = reinterpret_cast<Text *>(BKE_libblock_find_name(bmain, ID_TXT, argv[1]));
2785 bool ok;
2786
2787 if (text) {
2788 BPY_CTX_SETUP(ok = BPY_run_text(C, text, nullptr, false));
2789 }
2790 else {
2791 fprintf(stderr, "\nError: text block not found %s.\n", argv[1]);
2792 ok = false;
2793 }
2794
2795 if (!ok && app_state.exit_code_on_error.python) {
2796 fprintf(stderr, "\nError: script failed, text: '%s', exiting.\n", argv[1]);
2798 }
2799# else
2800 UNUSED_VARS(C);
2801 fprintf(stderr, "This Blender was built without Python support\n");
2802# endif /* WITH_PYTHON */
2803
2804 return 1;
2805 }
2806
2807 fprintf(stderr, "\nError: you must specify a text block after '%s'.\n", argv[0]);
2808 return 0;
2809}
2810
2812 "<expression>\n"
2813 "\tRun the given expression as a Python script.\n"
2814 "\n"
2815 "\tThe expression may be a complete multi-line script;\n"
2816 "\tyou are limited only by the platform's maximum argument length.";
2817static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
2818{
2819 bContext *C = static_cast<bContext *>(data);
2820
2821 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2822 if (argc > 1) {
2823# ifdef WITH_PYTHON
2824 bool ok;
2825 BPY_CTX_SETUP(ok = BPY_run_string_exec(C, nullptr, argv[1]));
2826 if (!ok && app_state.exit_code_on_error.python) {
2827 fprintf(stderr, "\nError: script failed, expr: '%s', exiting.\n", argv[1]);
2829 }
2830# else
2831 UNUSED_VARS(C);
2832 fprintf(stderr, "This Blender was built without Python support\n");
2833# endif /* WITH_PYTHON */
2834
2835 return 1;
2836 }
2837 fprintf(stderr, "\nError: you must specify a Python expression after '%s'.\n", argv[0]);
2838 return 0;
2839}
2840
2842 "\n\t"
2843 "Run Blender with an interactive console.";
2844static int arg_handle_python_console_run(int /*argc*/, const char ** /*argv*/, void *data)
2845{
2846 bContext *C = static_cast<bContext *>(data);
2847# ifdef WITH_PYTHON
2848 const char *imports[] = {"code", nullptr};
2849 BPY_CTX_SETUP(BPY_run_string_eval(C, imports, "code.interact()"));
2850# else
2851 UNUSED_VARS(C);
2852 fprintf(stderr, "This Blender was built without python support\n");
2853# endif /* WITH_PYTHON */
2854
2855 return 0;
2856}
2857
2859 "<code>\n"
2860 "\tSet the exit-code in [0..255] to exit if a Python exception is raised\n"
2861 "\t(only for scripts executed from the command line), zero disables.";
2862static int arg_handle_python_exit_code_set(int argc, const char **argv, void * /*data*/)
2863{
2864 const char *arg_id = "--python-exit-code";
2865 if (argc > 1) {
2866 const char *err_msg = nullptr;
2867 const int min = 0, max = 255;
2868 int exit_code;
2869 if (!parse_int_strict_range(argv[1], nullptr, min, max, &exit_code, &err_msg)) {
2870 fprintf(stderr,
2871 "\nError: %s '%s %s', expected number in [%d..%d].\n",
2872 err_msg,
2873 arg_id,
2874 argv[1],
2875 min,
2876 max);
2877 return 1;
2878 }
2879
2880 app_state.exit_code_on_error.python = uchar(exit_code);
2881 return 1;
2882 }
2883 fprintf(stderr, "\nError: you must specify an exit code number '%s'.\n", arg_id);
2884 return 0;
2885}
2886
2888 "\n"
2889 "\tAllow Python to use system environment variables such as 'PYTHONPATH'.\n"
2890 "\tThis also enables user environment, see: '--python-use-user-env'.";
2892 const char ** /*argv*/,
2893 void * /*data*/)
2894{
2895# ifdef WITH_PYTHON
2897# endif
2898 return 0;
2899}
2900
2902 "\n"
2903 "\tAllow Python to use user's site-packages directory.\n"
2904 "\tThis disables full isolation for the Python environment.";
2906 const char ** /*argv*/,
2907 void * /*data*/)
2908{
2909# ifdef WITH_PYTHON
2911# endif
2912 return 0;
2913}
2914
2915static const char arg_handle_addons_set_doc[] =
2916 "<addon(s)>\n"
2917 "\tComma separated list (no spaces) of add-ons to enable in addition to any default add-ons.";
2918static int arg_handle_addons_set(int argc, const char **argv, void *data)
2919{
2920 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2921 if (argc > 1) {
2922# ifdef WITH_PYTHON
2923 const char script_str[] =
2924 "from _bpy_internal.addons.cli import set_from_cli\n"
2925 "set_from_cli('%s')";
2926 const int slen = strlen(argv[1]) + (sizeof(script_str) - 2);
2927 char *str = static_cast<char *>(malloc(slen));
2928 bContext *C = static_cast<bContext *>(data);
2929 BLI_snprintf(str, slen, script_str, argv[1]);
2930
2931 BLI_assert(strlen(str) + 1 == slen);
2932 BPY_CTX_SETUP(BPY_run_string_exec(C, nullptr, str));
2933 free(str);
2934# else
2935 UNUSED_VARS(argv, data);
2936# endif /* WITH_PYTHON */
2937 return 1;
2938 }
2939 fprintf(stderr, "\nError: you must specify a comma separated list after '--addons'.\n");
2940 return 0;
2941}
2942
2944 "\n"
2945 "\tEnable CPU & GPU performance profiling for GPU debug groups\n"
2946 "\t(Outputs a profile.json file in the Trace Event Format to the current directory)";
2947static int arg_handle_profile_gpu_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2948{
2949 G.profile_gpu = true;
2950 return 0;
2951}
2952
2957static bool handle_load_file(bContext *C, const char *filepath_arg, const bool load_empty_file)
2958{
2959 /* Make the path absolute because its needed for relative linked blends to be found. */
2960 char filepath[FILE_MAX];
2961 STRNCPY(filepath, filepath_arg);
2962 BLI_path_canonicalize_native(filepath, sizeof(filepath));
2963
2964 const bool is_directory = BLI_is_dir(filepath);
2965
2966 /* Load the file. */
2967 ReportList reports;
2970 /* When activating from the command line there isn't an exact equivalent to operator properties.
2971 * Instead, enabling auto-execution via `--enable-autoexec` causes the auto-execution
2972 * check to be skipped (if it's set), so it's fine to always enable the check here. */
2973 const bool use_scripts_autoexec_check = true;
2974 const bool success = !is_directory ?
2975 WM_file_read(C, filepath, use_scripts_autoexec_check, &reports) :
2976 WM_file_read_project(C, filepath, &reports);
2977
2980 BKE_reports_free(&reports);
2981
2982 if (success) {
2983 if (G.background) {
2984 /* Ensure we use 'C->data.scene' for background render. */
2985 CTX_wm_window_set(C, nullptr);
2986 }
2987 return true;
2988 }
2989
2990 /* Failed to load file, stop processing arguments if running in background mode. */
2991 if (G.background) {
2992 /* Set `is_break` if running in the background mode so
2993 * blender will return non-zero exit code which then
2994 * could be used in automated script to control how
2995 * good or bad things are. */
2996 G.is_break = true;
2997 return false;
2998 }
2999
3000 if (is_directory) {
3001 return false;
3002 }
3003
3004 const char *error_msg_generic = "file could not be loaded";
3005 const char *error_msg = nullptr;
3006
3007 if (load_empty_file == false) {
3008 error_msg = error_msg_generic;
3009 }
3010 else if (!BKE_blendfile_extension_check(filepath)) {
3011 /* Non-blend. Continue loading and give warning. */
3012 G_MAIN->is_read_invalid = true;
3013 return true;
3014 }
3015 else if (BLI_exists(filepath)) {
3016 /* When a file is found but can't be loaded, handling it as a new file
3017 * could cause it to be unintentionally overwritten (data loss).
3018 * Further this is almost certainly not that a user would expect or want.
3019 * If they do, they can delete the file beforehand. */
3020 error_msg = error_msg_generic;
3021 }
3022
3023 if (error_msg) {
3024 fprintf(stderr, "Error: %s, exiting! %s\n", error_msg, filepath);
3025 WM_exit(C, EXIT_FAILURE);
3026 /* Unreachable, return for clarity. */
3027 return false;
3028 }
3029
3030 /* Behave as if a file was loaded, calling "Save" will write to the `filepath` from the CLI.
3031 *
3032 * WARNING: The path referenced may be incorrect, no attempt is made to validate the path
3033 * here or check that writing to it will work. If the users enters the path of a directory
3034 * that doesn't exist (for example) saving will fail.
3035 * Attempting to create the file at this point is possible but likely to cause more
3036 * trouble than it's worth (what with network drives), removable devices ... etc. */
3037
3038 STRNCPY(G_MAIN->filepath, filepath);
3039 printf("... opened default scene instead; saving will write to: %s\n", filepath);
3040
3041 return true;
3042}
3043
3044int main_args_handle_load_file(int /*argc*/, const char **argv, void *data)
3045{
3046 bContext *C = static_cast<bContext *>(data);
3047 const char *filepath = argv[0];
3048
3049 /* NOTE: we could skip these, but so far we always tried to load these files. */
3050 if (argv[0][0] == '-') {
3051 fprintf(stderr, "unknown argument, loading as file: %s\n", filepath);
3052 }
3053
3054 if (!handle_load_file(C, filepath, true)) {
3055 return -1;
3056 }
3057 return 0;
3058}
3059
3061 "\n\t"
3062 "Open the most recently opened blend file, instead of the default startup file.";
3063static int arg_handle_load_last_file(int /*argc*/, const char ** /*argv*/, void *data)
3064{
3065 if (G.recent_files.is_empty()) {
3066 fprintf(stderr, "Warning: no recent files known, opening default startup file instead.\n");
3067 return -1;
3068 }
3069
3070 bContext *C = static_cast<bContext *>(data);
3071 const RecentFile *recent_file = G.recent_files.first();
3072 if (!handle_load_file(C, recent_file->filepath, false)) {
3073 return -1;
3074 }
3075 return 0;
3076}
3077
3079{
3081# define CB(a) a##_doc, a
3083# define CB_EX(a, b) a##_doc_##b, a
3085# define CB_ALL(a) (all ? a##_doc_all : a##_doc), a
3086
3087 BuildDefs defs;
3088 build_defs_init(&defs, all);
3089
3090 /* end argument processing after -- */
3091 BLI_args_pass_set(ba, -1);
3092 BLI_args_add(ba, "--", nullptr, CB(arg_handle_arguments_end), nullptr);
3093
3094 /* Pass: Environment Setup
3095 *
3096 * It's important these run before any initialization is done, since they set up
3097 * the environment used to access data-files, which are be used when initializing
3098 * sub-systems such as color management. */
3101 ba, nullptr, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), nullptr);
3103 ba, nullptr, "--python-use-user-env", CB(arg_handle_python_use_user_env_set), nullptr);
3104
3105 /* Note that we could add used environment variables too. */
3107 ba, nullptr, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), nullptr);
3109 ba, nullptr, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), nullptr);
3111 ba, nullptr, "--env-system-python", CB_EX(arg_handle_env_system_set, python), nullptr);
3112 BLI_args_add(ba,
3113 nullptr,
3114 "--env-system-extensions",
3115 CB_EX(arg_handle_env_system_set, extensions),
3116 nullptr);
3117
3118 BLI_args_add(ba, "-t", "--threads", CB(arg_handle_threads_set), nullptr);
3119
3120 /* Include in the environment pass so it's possible display errors initializing subsystems,
3121 * especially `bpy.appdir` since it's useful to show errors finding paths on startup. */
3122 BLI_args_add(ba, nullptr, "--log", CB(arg_handle_log_set), ba);
3123 BLI_args_add(ba, nullptr, "--log-level", CB(arg_handle_log_level_set), ba);
3124 BLI_args_add(ba, nullptr, "--log-show-source", CB(arg_handle_log_show_source_set), ba);
3125 BLI_args_add(ba, nullptr, "--log-show-backtrace", CB(arg_handle_log_show_backtrace_set), ba);
3126 BLI_args_add(ba, nullptr, "--log-show-memory", CB(arg_handle_log_show_memory_set), ba);
3127 BLI_args_add(ba, nullptr, "--log-file", CB(arg_handle_log_file_set), ba);
3128
3129 /* GPU backend selection should be part of #ARG_PASS_ENVIRONMENT for correct GPU context
3130 * selection for animation player. */
3131 BLI_args_add(ba, nullptr, "--gpu-backend", CB_ALL(arg_handle_gpu_backend_set), nullptr);
3132 BLI_args_add(ba, nullptr, "--gpu-device", CB(arg_handle_gpu_device_set), nullptr);
3133 BLI_args_add(ba,
3134 nullptr,
3135 "--gpu-device-no-fallback",
3136 CB_EX(arg_handle_debug_mode_generic_set, gpu_device_no_fallback),
3137 reinterpret_cast<void *>(G_DEBUG_GPU_DEVICE_NO_FALLBACK));
3138 BLI_args_add(ba,
3139 nullptr,
3140 "--debug-gpu-backend-no-fallback",
3141 CB_EX(arg_handle_debug_mode_generic_set, gpu_backend_no_fallback),
3142 reinterpret_cast<void *>(G_DEBUG_GPU_BACKEND_NO_FALLBACK));
3143 BLI_args_add(ba, nullptr, "--gpu-vsync", CB(arg_handle_gpu_vsync_set), nullptr);
3144 if (defs.with_opengl_backend) {
3145 BLI_args_add(ba,
3146 nullptr,
3147 "--gpu-compilation-subprocesses",
3149 nullptr);
3150 }
3151 BLI_args_add(ba, nullptr, "--profile-gpu", CB(arg_handle_profile_gpu_set), nullptr);
3152
3153 /* Pass: Background Mode & Settings
3154 *
3155 * Also and commands that exit after usage. */
3157 BLI_args_add(ba, "-h", "--help", CB(arg_handle_print_help), ba);
3158
3159 /* MS-Windows only. */
3160 BLI_args_add(ba, "/?", nullptr, CB_EX(arg_handle_print_help, win32), ba);
3161
3162 BLI_args_add(ba, "-v", "--version", CB(arg_handle_print_version), nullptr);
3163 BLI_args_add(ba, nullptr, "--log-list-categories", CB(arg_handle_list_clog_cats), nullptr);
3164
3165 BLI_args_add(ba,
3166 "-y",
3167 "--enable-autoexec",
3169 reinterpret_cast<void *>(true));
3170 BLI_args_add(ba,
3171 "-Y",
3172 "--disable-autoexec",
3173 CB_EX(arg_handle_python_set, disable),
3174 reinterpret_cast<void *>(false));
3175
3176 BLI_args_add(ba,
3177 nullptr,
3178 "--offline-mode",
3180 reinterpret_cast<void *>(false));
3181 BLI_args_add(ba,
3182 nullptr,
3183 "--online-mode",
3185 reinterpret_cast<void *>(true));
3186
3188 ba, nullptr, "--console-crash-handler", CB(arg_handle_crash_handler_console), nullptr);
3190 ba, nullptr, "--disable-crash-handler", CB(arg_handle_crash_handler_disable), nullptr);
3192 ba, nullptr, "--disable-abort-handler", CB(arg_handle_abort_handler_disable), nullptr);
3193
3194 BLI_args_add(ba, "-q", "--quiet", CB(arg_handle_quiet_set), nullptr);
3195 BLI_args_add(ba, "-b", "--background", CB(arg_handle_background_mode_set), nullptr);
3196 /* Command implies background mode (defers execution). */
3197 BLI_args_add(ba, "-c", "--command", CB(arg_handle_command_set), C);
3198
3199 BLI_args_add(ba, nullptr, "--qos", CB(arg_handle_qos_set), nullptr);
3200
3201 BLI_args_add(ba,
3202 nullptr,
3203 "--disable-depsgraph-on-file-load",
3205 nullptr);
3206
3207 BLI_args_add(ba,
3208 nullptr,
3209 "--disable-liboverride-auto-resync",
3211 nullptr);
3212
3213 BLI_args_add(ba, "-a", nullptr, CB(arg_handle_playback_mode), nullptr);
3214
3215 BLI_args_add(ba, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);
3216
3217 if (defs.with_ffmpeg) {
3218 BLI_args_add(ba, nullptr, "--debug-ffmpeg", CB(arg_handle_debug_mode_ffmpeg), nullptr);
3219 }
3220
3221 if (defs.with_freestyle) {
3222 BLI_args_add(ba,
3223 nullptr,
3224 "--debug-freestyle",
3226 reinterpret_cast<void *>(G_DEBUG_FREESTYLE));
3227 }
3228 BLI_args_add(ba,
3229 nullptr,
3230 "--debug-python",
3232 reinterpret_cast<void *>(G_DEBUG_PYTHON));
3233 BLI_args_add(ba,
3234 nullptr,
3235 "--debug-events",
3237 reinterpret_cast<void *>(G_DEBUG_EVENTS));
3238 BLI_args_add(ba,
3239 nullptr,
3240 "--debug-handlers",
3242 reinterpret_cast<void *>(G_DEBUG_HANDLERS));
3243 BLI_args_add(ba,
3244 nullptr,
3245 "--debug-wm",
3247 reinterpret_cast<void *>(G_DEBUG_WM));
3248 if (defs.with_xr_openxr) {
3249 BLI_args_add(ba,
3250 nullptr,
3251 "--debug-xr",
3253 reinterpret_cast<void *>(G_DEBUG_XR));
3254 BLI_args_add(ba,
3255 nullptr,
3256 "--debug-xr-time",
3258 reinterpret_cast<void *>(G_DEBUG_XR_TIME));
3259 }
3260 BLI_args_add(ba,
3261 nullptr,
3262 "--debug-ghost",
3264 reinterpret_cast<void *>(G_DEBUG_GHOST));
3265 BLI_args_add(ba,
3266 nullptr,
3267 "--debug-wintab",
3269 reinterpret_cast<void *>(G_DEBUG_WINTAB));
3270 BLI_args_add(ba, nullptr, "--debug-all", CB(arg_handle_debug_mode_all), nullptr);
3271
3272 BLI_args_add(ba, nullptr, "--debug-io", CB(arg_handle_debug_mode_io), nullptr);
3273
3274 BLI_args_add(ba, nullptr, "--debug-fpe", CB(arg_handle_debug_fpe_set), nullptr);
3275
3276 if (defs.with_libmv) {
3277 BLI_args_add(ba, nullptr, "--debug-libmv", CB(arg_handle_debug_mode_libmv), nullptr);
3278 }
3279 if (defs.with_cycles) {
3280 BLI_args_add(ba, nullptr, "--debug-cycles", CB(arg_handle_debug_mode_cycles), nullptr);
3281 }
3282 BLI_args_add(ba, nullptr, "--debug-memory", CB(arg_handle_debug_mode_memory_set), nullptr);
3283
3284 BLI_args_add(ba, nullptr, "--debug-value", CB(arg_handle_debug_value_set), nullptr);
3285 BLI_args_add(ba,
3286 nullptr,
3287 "--debug-jobs",
3289 reinterpret_cast<void *>(G_DEBUG_JOBS));
3290 BLI_args_add(ba, nullptr, "--debug-gpu", CB(arg_handle_debug_gpu_set), nullptr);
3291 BLI_args_add(ba,
3292 nullptr,
3293 "--debug-gpu-compile-shaders",
3295 nullptr);
3296 BLI_args_add(ba,
3297 nullptr,
3298 "--debug-gpu-no-texture-pool",
3300 nullptr);
3301 BLI_args_add(ba,
3302 nullptr,
3303 "--debug-gpu-scope-capture",
3305 nullptr);
3307 ba, nullptr, "--debug-gpu-shader-source", CB(arg_handle_debug_gpu_shader_source), nullptr);
3308 BLI_args_add(ba,
3309 nullptr,
3310 "--debug-gpu-shader-no-preprocessor",
3312 nullptr);
3314 ba, nullptr, "--debug-gpu-shader-no-dce", CB(arg_handle_debug_gpu_shader_no_dce), nullptr);
3315 if (defs.with_renderdoc) {
3317 ba, nullptr, "--debug-gpu-renderdoc", CB(arg_handle_debug_gpu_renderdoc_set), nullptr);
3318 }
3319 BLI_args_add(ba,
3320 nullptr,
3321 "--debug-gpu-shader-debug-info",
3323 nullptr);
3324
3325 BLI_args_add(ba,
3326 nullptr,
3327 "--debug-depsgraph",
3329 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH));
3330 BLI_args_add(ba,
3331 nullptr,
3332 "--debug-depsgraph-build",
3333 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
3334 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_BUILD));
3335 BLI_args_add(ba,
3336 nullptr,
3337 "--debug-depsgraph-eval",
3339 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_EVAL));
3340 BLI_args_add(ba,
3341 nullptr,
3342 "--debug-depsgraph-tag",
3344 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_TAG));
3345 BLI_args_add(ba,
3346 nullptr,
3347 "--debug-depsgraph-time",
3349 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_TIME));
3350 BLI_args_add(ba,
3351
3352 nullptr,
3353 "--debug-depsgraph-no-threads",
3354 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads),
3355 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_NO_THREADS));
3356 BLI_args_add(ba,
3357 nullptr,
3358 "--debug-depsgraph-pretty",
3359 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty),
3360 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_PRETTY));
3361 BLI_args_add(ba,
3362 nullptr,
3363 "--debug-depsgraph-uid",
3365 reinterpret_cast<void *>(G_DEBUG_DEPSGRAPH_UID));
3366 BLI_args_add(ba,
3367 nullptr,
3368 "--debug-gpu-force-workarounds",
3369 CB_EX(arg_handle_debug_mode_generic_set, gpu_force_workarounds),
3370 reinterpret_cast<void *>(G_DEBUG_GPU_FORCE_WORKAROUNDS));
3371 if (defs.with_vulkan_backend) {
3372 BLI_args_add(ba,
3373 nullptr,
3374 "--debug-gpu-vulkan-local-read",
3375 CB_EX(arg_handle_debug_mode_generic_set, gpu_force_vulkan_local_read),
3376 reinterpret_cast<void *>(G_DEBUG_GPU_FORCE_VULKAN_LOCAL_READ));
3377 }
3378 BLI_args_add(ba,
3379 nullptr,
3380 "--debug-gpu-no-hw-raytracing",
3381 CB_EX(arg_handle_debug_mode_generic_set, gpu_no_hw_raytracing_set_doc),
3382 reinterpret_cast<void *>(G_DEBUG_GPU_NO_HW_RAYTRACING));
3383 BLI_args_add(ba, nullptr, "--debug-exit-on-error", CB(arg_handle_debug_exit_on_error), nullptr);
3384
3385 BLI_args_add(ba, nullptr, "--verbose", CB(arg_handle_verbosity_set), nullptr);
3386
3387 BLI_args_add(ba, nullptr, "--app-template", CB(arg_handle_app_template), nullptr);
3388 BLI_args_add(ba, "-X", "--factory-startup", CB(arg_handle_factory_startup_set), nullptr);
3390 ba, nullptr, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), nullptr);
3391
3392 /* Pass: Custom Window Stuff. */
3394 BLI_args_add(ba, "-p", "--window-geometry", CB(arg_handle_window_geometry), nullptr);
3395 BLI_args_add(ba, "-w", "--window-border", CB(arg_handle_window_border), nullptr);
3396 BLI_args_add(ba, "-W", "--window-fullscreen", CB(arg_handle_window_fullscreen), nullptr);
3397 BLI_args_add(ba, "-M", "--window-maximized", CB(arg_handle_window_maximized), nullptr);
3398 BLI_args_add(ba, nullptr, "--no-window-frame", CB(arg_handle_no_window_frame), nullptr);
3399 BLI_args_add(ba, nullptr, "--no-window-focus", CB(arg_handle_no_window_focus), nullptr);
3400 BLI_args_add(ba, "-con", "--start-console", CB(arg_handle_start_with_console), nullptr);
3401 BLI_args_add(ba, "-r", "--register", CB(arg_handle_register_extension), nullptr);
3402 BLI_args_add(ba, nullptr, "--register-allusers", CB(arg_handle_register_extension_all), nullptr);
3403 BLI_args_add(ba, nullptr, "--unregister", CB(arg_handle_unregister_extension), nullptr);
3405 ba, nullptr, "--unregister-allusers", CB(arg_handle_unregister_extension_all), nullptr);
3406 BLI_args_add(ba, nullptr, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
3407
3408 /* Pass: Disabling Things & Forcing Settings. */
3410 BLI_args_add_case(ba, "-noaudio", 1, nullptr, 0, CB(arg_handle_audio_disable), nullptr);
3411 BLI_args_add_case(ba, "-setaudio", 1, nullptr, 0, CB(arg_handle_audio_set), nullptr);
3412
3413 /* Pass: Processing Arguments. */
3414 /* NOTE: Use #WM_exit for these callbacks, not `exit()`
3415 * so temporary files are properly cleaned up. */
3417 BLI_args_add(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C);
3418 BLI_args_add(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C);
3419 BLI_args_add(ba, "-S", "--scene", CB(arg_handle_scene_set), C);
3420 BLI_args_add(ba, "-s", "--frame-start", CB(arg_handle_frame_start_set), C);
3421 BLI_args_add(ba, "-e", "--frame-end", CB(arg_handle_frame_end_set), C);
3422 BLI_args_add(ba, "-j", "--frame-jump", CB(arg_handle_frame_skip_set), C);
3423 BLI_args_add(ba, "-P", "--python", CB(arg_handle_python_file_run), C);
3424 BLI_args_add(ba, nullptr, "--python-text", CB(arg_handle_python_text_run), C);
3425 BLI_args_add(ba, nullptr, "--python-expr", CB(arg_handle_python_expr_run), C);
3426 BLI_args_add(ba, nullptr, "--python-console", CB(arg_handle_python_console_run), C);
3427 BLI_args_add(ba, nullptr, "--python-exit-code", CB(arg_handle_python_exit_code_set), nullptr);
3428 BLI_args_add(ba, nullptr, "--addons", CB(arg_handle_addons_set), C);
3429
3430 BLI_args_add(ba, "-o", "--render-output", CB(arg_handle_output_set), C);
3431 BLI_args_add(ba, "-E", "--engine", CB(arg_handle_engine_set), C);
3432
3433 BLI_args_add(ba, "-F", "--render-format", CB(arg_handle_image_type_set), C);
3434 BLI_args_add(ba, "-x", "--use-extension", CB(arg_handle_extension_set), C);
3435
3436 BLI_args_add(ba, nullptr, "--open-last", CB(arg_handle_load_last_file), C);
3437
3438# undef CB
3439# undef CB_EX
3440# undef CB_ALL
3441
3442# ifdef WITH_PYTHON
3443 /* Use for Python to extract help text (Python can't call directly - bad-level call). */
3445# else
3446 /* Quiet unused function warning. */
3448# endif
3449}
3450
3452
3453} // namespace blender
3454
3455#endif /* !WITH_PYTHON_MODULE */
#define BLENDER_STARTUP_FILE
Blender util stuff.
Blender CLI Generic --command Support.
#define G_MAIN
#define G_FLAG_INTERNET_OVERRIDE_PREF_ANY
#define G_DEBUG_ALL
#define ATTR_PRINTF_FORMAT(format_param, dots_param)
A general argument parsing module.
A dynamically sized string ADT.
File and directory operations.
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
#define BLENDER_MAX_THREADS
Compatibility-like things for windows.
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
Definition clog.cc:922
bool CLG_quiet_get()
Definition clog.cc:942
void CLG_output_set(void *file_handle)
Definition clog.cc:882
void CLG_output_use_memory_set(int value)
Definition clog.cc:902
void CLG_error_fn_set(void(*error_fn)(void *file_handle))
Definition clog.cc:907
void CLG_level_set(CLG_Level level)
Definition clog.cc:932
void CLG_output_use_source_set(int value)
Definition clog.cc:887
void CLG_backtrace_fn_set(void(*fatal_fn)(void *file_handle))
Definition clog.cc:917
void CLG_logref_list_all(void(*callback)(const char *identifier, void *user_data), void *user_data)
Definition clog.cc:966
void CLG_type_filter_include(const char *type_match, int type_match_len)
Definition clog.cc:927
#define CLG_LEVEL_LEN
Definition CLG_log.h:66
CLG_Level
Definition CLG_log.h:52
@ CLG_LEVEL_ERROR
Definition CLG_log.h:56
@ CLG_LEVEL_DEBUG
Definition CLG_log.h:62
@ CLG_LEVEL_INFO
Definition CLG_log.h:60
@ CLG_LEVEL_FATAL
Definition CLG_log.h:54
@ CLG_LEVEL_WARN
Definition CLG_log.h:58
@ CLG_LEVEL_TRACE
Definition CLG_log.h:64
void CLG_quiet_set(bool quiet)
Definition clog.cc:937
#define MINAFRAME
#define MAXFRAME
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define CLAMP(a, b, c)
#define UNPACK4(a)
#define BLI_assert_unreachable()
#define UNUSED_VARS(...)
#define STRINGIFY(x)
#define STRINGIFY_ARG(x)
#define ELEM(...)
#define STRCASEEQ(a, b)
#define STREQ(a, b)
btScalar max
#define PRINT(format,...)
Definition cache.cc:36
Definition scene.h:133
#define CB_EX(a, b)
#define CB_ALL(a)
#define PY_ENABLE_AUTO
#define CB(a)
#define PY_DISABLE_AUTO
#define offsetof(t, d)
#define str(s)
#define INT_MAX
bool all(VecOp< bool, D >) RET
void libmv_setLoggingVerbosity(int verbosity)
Definition logging.cc:42
void libmv_startDebugLogging(void)
Definition logging.cc:32
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str)
Definition mallocn.cc:129
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void free(Subdiv *subdiv)
Definition subdiv.cc:192
BMesh Iterators.
void BKE_sound_force_device(const char *device)
static const char arg_handle_debug_gpu_shader_debug_info_set_doc[]
static int arg_handle_output_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_gpu_shader_no_dce_doc[]
static bool parse_int_relative(const char *str, const char *str_end_test, int pos, int neg, int *r_value, const char **r_err_msg)
bool BLI_windows_unregister_blend_extension(bool all_users)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph[]
void BLI_args_destroy(struct bArgs *ba)
Definition BLI_args.cc:147
static const char arg_handle_log_set_doc[]
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
static const char arg_handle_debug_gpu_shader_no_preprocessor_doc[]
static const char arg_handle_quiet_set_doc[]
unsigned __int64 uint64_t
Definition BKE_text.h:91
void BPY_python_use_user_env()
static const char arg_handle_arguments_end_doc[]
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
int main_arg_deferred_handle()
static int arg_handle_gpu_vsync_set(int argc, const char **argv, void *)
char * STRNCPY(char(&dst)[N], const char *src)
void(*) MEM_set_memory_debug()
static const char arg_handle_crash_handler_console_doc[]
void RE_SetReports(Render *re, ReportList *reports)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition lib_id.cc:1808
@ RPT_WARNING
Definition BKE_report.hh:40
static int arg_handle_debug_mode_io(int, const char **, void *)
char build_system[]
Definition bpy_app.cc:80
void void void BLI_mempool_set_memory_debug()
void BKE_image_format_set(ImageFormatData *imf, ID *owner_id, const char imtype)
static const char arg_handle_debug_mode_generic_set_doc_gpu_force_workarounds[]
static int arg_handle_disable_depsgraph_on_file_load(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_tag[]
static const char arg_handle_debug_mode_generic_set_doc_gpu_force_vulkan_local_read[]
Scene * BKE_scene_set_name(Main *bmain, const char *name)
Definition scene.cc:2255
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool WM_platform_associate_set(bool do_register, bool all_users, char **r_error_msg)
static const char arg_handle_gpu_backend_set_doc[]
static const char arg_handle_debug_gpu_compile_shaders_set_doc[]
static int arg_handle_debug_mode_memory_set(int, const char **, void *)
static const char arg_handle_internet_allow_set_doc_online[]
void BKE_reports_free(ReportList *reports)
Definition report.cc:106
void BKE_report_print_level_set(ReportList *reports, eReportType level)
Definition report.cc:276
static const char arg_handle_env_system_set_doc_python[]
static int arg_handle_no_window_focus(int, const char **, void *)
static int arg_handle_debug_mode_generic_set(int, const char **, void *data)
static void clog_abort_on_error_callback(void *fp)
bool WM_file_read(bContext *C, const char *filepath, const bool use_scripts_autoexec_check, ReportList *reports)
Definition wm_files.cc:1036
void WM_init_window_frame_set(bool do_it)
static int arg_handle_crash_handler_disable(int, const char **, void *)
static int arg_handle_register_extension(int argc, const char **argv, void *data)
static int arg_handle_quiet_set(int, const char **, void *)
static int arg_handle_python_use_system_env_set(int, const char **, void *)
static int arg_handle_engine_set(int argc, const char **argv, void *data)
static const char arg_handle_gpu_backend_set_doc_all[]
static int arg_handle_gpu_device_set(int argc, const char **argv, void *)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_time[]
static const char arg_handle_log_level_set_doc[]
void WM_init_state_maximized_set()
static const char arg_handle_debug_mode_generic_set_doc_gpu_device_no_fallback[]
void GPU_compilation_subprocess_override_set(int count)
static const char arg_handle_debug_mode_cycles_doc[]
static const char arg_handle_debug_mode_generic_set_doc_freestyle[]
void BKE_reports_init(ReportList *reports, int flag)
Definition report.cc:91
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_actions)
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void WM_exit(bContext *C, const int exit_code)
void CTX_wm_window_set(bContext *C, wmWindow *win)
static void main_arg_deferred_exit_code_set(int exit_code)
void WM_init_window_focus_set(bool do_it)
static const char arg_handle_debug_gpu_scope_capture_set_doc[]
static int arg_handle_background_mode_set(int, const char **, void *)
void WM_init_native_pixels(bool do_it)
unsigned long ulong
Definition BKE_text.h:57
static const char arg_handle_output_set_doc[]
void BLI_system_num_threads_override_set(int num)
Definition threads.cc:294
static const char arg_handle_playback_mode_doc[]
static bool parse_int_range_relative(const char *str, const char *str_end_range, const char *str_end_test, int pos, int neg, int r_value_range[2], const char **r_err_msg)
static int arg_handle_python_use_user_env_set(int, const char **, void *)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
static const char arg_handle_qos_set_doc[]
static const char arg_handle_debug_gpu_no_texture_pool_set_doc[]
static const char arg_handle_no_window_frame_doc[]
static int arg_handle_list_clog_cats(int, const char **, void *)
static const char arg_handle_print_help_doc_win32[]
static const char arg_handle_image_type_set_doc[]
static const char arg_handle_print_help_doc[]
static int arg_handle_internet_allow_set(int, const char **, void *data)
void BKE_appdir_init()
Definition appdir.cc:95
static int arg_handle_render_frame(int argc, const char **argv, void *data)
static int arg_handle_python_text_run(int argc, const char **argv, void *data)
wmWindow * CTX_wm_window(const bContext *C)
static int arg_handle_verbosity_set(int argc, const char **argv, void *)
int main_args_handle_load_file(int, const char **argv, void *data)
static const char arg_handle_log_file_set_doc[]
static bool arg_handle_extension_registration(const bool do_register, const bool all_users)
static bool parse_int_range_relative_clamp(const char *str, const char *str_end_range, const char *str_end_test, int pos, int neg, int min, int max, int r_value_range[2], const char **r_err_msg)
static int arg_handle_debug_gpu_scope_capture_set(int argc, const char **argv, void *)
static int arg_handle_factory_startup_set(int, const char **, void *)
static const char arg_handle_crash_handler_disable_doc[]
static int arg_handle_addons_set(int argc, const char **argv, void *data)
bool bool BPY_run_text(bContext *C, Text *text, ReportList *reports, bool do_jump) ATTR_NONNULL(1
static int arg_handle_debug_exit_on_error(int, const char **, void *)
static const char arg_handle_window_fullscreen_doc[]
static const char arg_handle_debug_mode_libmv_doc[]
void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1)
void WM_init_state_normal_set()
void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, va_list args) ATTR_PRINTF_FORMAT(2
Definition BLI_dynstr.cc:97
static int arg_handle_register_extension_all(int argc, const char **argv, void *data)
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
int BKE_blender_cli_command_exec(struct bContext *C, const char *id, const int argc, const char **argv)
static int arg_handle_debug_gpu_no_texture_pool_set(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_jobs[]
static const char arg_handle_python_console_run_doc[]
static int arg_handle_log_show_source_set(int, const char **, void *)
static int arg_handle_debug_gpu_compile_shaders_set(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_wintab[]
static int arg_handle_debug_gpu_shader_no_preprocessor(int, const char **, void *)
static void build_defs_init(BuildDefs *build_defs, bool force_all)
static const char * parse_int_range_sep_search(const char *str, const char *str_end_test)
@ G_DEBUG_HANDLERS
@ G_DEBUG_GPU_SHADER_DEBUG_INFO
@ G_DEBUG_GPU_BACKEND_NO_FALLBACK
@ G_DEBUG_GPU_NO_HW_RAYTRACING
@ G_DEBUG_EVENTS
@ G_DEBUG_DEPSGRAPH_PRETTY
@ G_DEBUG_DEPSGRAPH_UID
@ G_DEBUG_GPU_DEVICE_NO_FALLBACK
@ G_DEBUG_GPU_SHADER_NO_DCE
@ G_DEBUG_FREESTYLE
@ G_DEBUG_XR_TIME
@ G_DEBUG_GPU_SHADER_NO_PREPROCESSOR
@ G_DEBUG_WINTAB
@ G_DEBUG_GPU_NO_TEXTURE_POOL
@ G_DEBUG_PYTHON
@ G_DEBUG_DEPSGRAPH_NO_THREADS
@ G_DEBUG_GPU_FORCE_VULKAN_LOCAL_READ
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
@ G_DEBUG_DEPSGRAPH_BUILD
@ G_DEBUG_DEPSGRAPH_TAG
@ G_DEBUG_DEPSGRAPH_EVAL
@ G_DEBUG_DEPSGRAPH
@ G_DEBUG_GPU_RENDERDOC
@ G_DEBUG_GHOST
@ G_DEBUG_GPU_COMPILE_SHADERS
@ G_DEBUG_DEPSGRAPH_TIME
ApplicationState app_state
Definition creator.cc:181
Global G
Definition blender.cc:57
static int arg_handle_window_border(int, const char **, void *)
static const char arg_handle_background_mode_set_doc[]
static const char arg_handle_debug_mode_generic_set_doc_wm[]
static void print_version_short()
static const char arg_handle_engine_set_doc[]
void BLI_args_add_case(struct bArgs *ba, const char *short_arg, int short_case, const char *long_arg, int long_case, const char *doc, BA_ArgCallback cb, void *data)
Definition BLI_args.cc:245
static int arg_handle_debug_fpe_set(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_events[]
int BLI_system_thread_count()
Definition threads.cc:258
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_no_threads[]
static const char arg_handle_debug_fpe_set_doc[]
unsigned int uint32_t
Definition BKE_text.h:81
static const char arg_handle_debug_exit_on_error_doc[]
void BLI_args_print_other_doc(struct bArgs *ba)
Definition BLI_args.cc:320
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
char build_commit_time[]
Definition bpy_app.cc:72
static const char arg_handle_log_show_source_set_doc[]
static const char arg_handle_log_show_backtrace_set_doc[]
static int arg_handle_debug_value_set(int argc, const char **argv, void *)
static const char arg_handle_print_version_doc[]
@ G_BACKGROUND_NO_DEPSGRAPH
@ G_LIBOVERRIDE_NO_AUTO_RESYNC
static const char arg_handle_addons_set_doc[]
char build_platform[]
Definition bpy_app.cc:75
static const char arg_handle_debug_mode_generic_set_doc_gpu_backend_no_fallback[]
void MEM_enable_fail_on_memleak(void)
static const char arg_handle_debug_mode_io_doc[]
void WM_init_state_size_set(int stax, int stay, int sizx, int sizy)
bool BPY_run_filepath(bContext *C, const char *filepath, ReportList *reports) ATTR_NONNULL(1
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static const char arg_handle_unregister_extension_doc[]
static const char arg_handle_python_set_doc_disable[]
unsigned char uchar
Definition BKE_text.h:58
int BLI_path_canonicalize_native(char *path, int path_maxncpy)
static const char arg_handle_python_file_run_doc[]
static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
static void main_arg_deferred_setup(BA_ArgCallback func, int argc, const char **argv, void *data)
static int arg_handle_debug_mode_libmv(int, const char **, void *)
static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
static int arg_handle_qos_set(int argc, const char **argv, void *)
static int arg_handle_python_file_run(int argc, const char **argv, void *data)
static const char arg_handle_audio_set_doc[]
static const char arg_handle_debug_gpu_shader_source_doc[]
void DEG_id_tag_update(ID *id, unsigned int flags)
static int arg_handle_extension_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_uid[]
BMesh const char void * data
static int arg_handle_log_show_memory_set(int, const char **, void *)
static int arg_handle_python_set(int, const char **, void *data)
static const char arg_handle_gpu_device_set_doc[]
void GPU_backend_vsync_set_override(int vsync)
void WM_init_state_start_with_console_set(bool value)
static int arg_handle_threads_set(int argc, const char **argv, void *)
static const char arg_handle_python_text_run_doc[]
static int arg_handle_debug_mode_ffmpeg(int, const char **, void *)
static const char arg_handle_python_expr_run_doc[]
wmWindowManager * CTX_wm_manager(const bContext *C)
static int arg_handle_unregister_extension_all(int argc, const char **argv, void *data)
static const char arg_handle_frame_start_set_doc[]
void main_arg_deferred_free()
static const char arg_handle_env_system_set_doc_scripts[]
void GPU_backend_type_selection_set_override(GPUBackendType backend_type)
char build_hash[]
Definition bpy_app.cc:73
static const char arg_handle_register_extension_all_doc[]
bool WM_file_read_project(bContext *C, const char *filepath, ReportList *reports)
Definition wm_files.cc:1173
static int arg_handle_python_exit_code_set(int argc, const char **argv, void *)
static const char arg_handle_scene_set_doc[]
static void background_mode_set()
void BLI_args_print_fn_set(struct bArgs *ba, ATTR_PRINTF_FORMAT(2, 0) bArgPrintFn print_fn, void *user_data)
bool BPY_run_string_eval(bContext *C, const char *imports[], const char *expr)
static const char arg_handle_threads_set_doc[]
static const char arg_handle_python_use_system_env_set_doc[]
static int arg_handle_render_animation(int, const char **, void *data)
static const char arg_handle_debug_mode_generic_set_doc_ghost[]
void main_args_setup(bContext *C, bArgs *ba, bool all)
void BLI_args_pass_set(struct bArgs *ba, int current_pass)
Definition BLI_args.cc:169
static const char arg_handle_debug_mode_generic_set_doc_gpu_no_hw_raytracing_set_doc[]
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static const char arg_handle_disable_liboverride_auto_resync_doc[]
void BKE_blender_atexit()
Definition blender.cc:509
static int arg_handle_debug_mode_all(int, const char **, void *)
static int arg_handle_print_help(int, const char **, void *data)
static int arg_handle_playback_mode(int argc, const char **argv, void *)
static const char arg_handle_debug_mode_generic_set_doc_xr_time[]
static bool parse_int_strict_range(const char *str, const char *str_end_test, const int min, const int max, int *r_value, const char **r_err_msg)
static const char arg_handle_render_frame_doc[]
static const char arg_handle_unregister_extension_all_doc[]
ListBaseT< RenderEngineType > R_engines
bool BLI_args_has_other_doc(const struct bArgs *ba)
bool RE_is_rendering_allowed(const Main &bmain, Scene *scene, ViewLayer *single_layer, Object *camera_override, ReportList *reports)
char build_linkflags[]
Definition bpy_app.cc:79
static const char arg_handle_internet_allow_set_doc_offline[]
char build_branch[]
Definition bpy_app.cc:74
static int arg_handle_scene_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_handlers[]
static const char arg_handle_env_system_set_doc_extensions[]
void main_signal_setup_fpe(void)
static const char arg_handle_abort_handler_disable_doc[]
static const char arg_handle_gpu_compilation_subprocesses_set_doc[]
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
static int arg_handle_app_template(int argc, const char **argv, void *)
char build_type[]
Definition bpy_app.cc:76
static int arg_handle_image_type_set(int argc, const char **argv, void *data)
static void print_version_full()
static const char arg_handle_app_template_doc[]
static int(* parse_int_range_relative_clamp_n(const char *str, int pos, int neg, int min, int max, int *r_value_len, const char **r_err_msg))[2]
static const char arg_handle_debug_mode_generic_set_doc_python[]
static const char arg_handle_debug_gpu_renderdoc_set_doc[]
void BLI_system_backtrace(FILE *fp)
Definition system.cc:112
static int arg_handle_log_level_set(int argc, const char **argv, void *)
static const char arg_handle_debug_mode_ffmpeg_doc[]
static int arg_handle_command_set(int argc, const char **argv, void *data)
static const char arg_handle_profile_gpu_set_doc[]
static const char arg_handle_debug_mode_all_doc[]
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_eval[]
static const char arg_handle_debug_value_set_doc[]
static int arg_handle_window_geometry(int argc, const char **argv, void *)
static int arg_handle_native_pixels_set(int, const char **, void *)
@ G_FLAG_INTERNET_OVERRIDE_PREF_OFFLINE
@ G_FLAG_USERPREF_NO_SAVE_ON_EXIT
@ G_FLAG_INTERNET_ALLOW
@ G_FLAG_INTERNET_OVERRIDE_PREF_ONLINE
@ G_FLAG_EVENT_SIMULATE
@ G_FLAG_SCRIPT_AUTOEXEC
static const char arg_handle_factory_startup_set_doc[]
Main * CTX_data_main(const bContext *C)
void WM_reports_from_reports_move(wmWindowManager *wm, ReportList *reports)
void BLI_windows_process_set_qos(QoSMode qos_mode, QoSPrecedence qos_precedence)
static int arg_handle_env_system_set(int argc, const char **argv, void *)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
char build_time[]
Definition bpy_app.cc:69
char build_cflags[]
Definition bpy_app.cc:77
static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
static int arg_handle_audio_disable(int, const char **, void *)
static bool parse_int_relative_clamp(const char *str, const char *str_end_test, int pos, int neg, int min, int max, int *r_value, const char **r_err_msg)
static const char arg_handle_window_geometry_doc[]
static int arg_handle_window_maximized(int, const char **, void *)
static char * main_args_help_as_string(bool all)
static int arg_handle_no_window_frame(int, const char **, void *)
static int arg_handle_debug_gpu_shader_debug_info_set(int, const char **, void *)
static int arg_handle_profile_gpu_set(int, const char **, void *)
char BKE_imtype_from_arg(const char *imtype_arg)
static const char arg_handle_frame_skip_set_doc[]
Render * RE_NewSceneRender(const Scene *scene)
void RE_RenderAnim(Render *re, Main *bmain, Scene *scene, ViewLayer *single_layer, Object *camera_override, int sfra, int efra, int tfra)
static const char * parse_int(const char *p, const char *end, int fallback, int &dst)
bool RE_disable_save_output_allowed(const bool is_animation, Scene &scene, ReportList *reports)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg)
Definition BLI_args.cc:290
static int arg_handle_abort_handler_disable(int, const char **, void *)
static int arg_handle_arguments_end(int, const char **, void *)
static bool main_arg_deferred_is_set()
char build_commit_date[]
Definition bpy_app.cc:71
static const char arg_handle_debug_mode_generic_set_doc_xr[]
static int arg_handle_log_file_set(int argc, const char **argv, void *)
static const char arg_handle_frame_end_set_doc[]
void WM_init_state_fullscreen_set()
static void print_help(bArgs *ba, bool all)
static const char arg_handle_python_set_doc_enable[]
void BLI_args_add(struct bArgs *ba, const char *short_arg, const char *long_arg, const char *doc, BA_ArgCallback cb, void *data)
Definition BLI_args.cc:265
static int arg_handle_debug_mode_cycles(int, const char **, void *)
void BKE_blender_cli_command_print_help()
static int arg_handle_log_show_backtrace_set(int, const char **, void *)
static int arg_handle_crash_handler_console(int, const char **, void *)
static void arg_handle_gpu_device_exit(const int exit_code)
bool BKE_blendfile_extension_check(const char *str)
Definition blendfile.cc:88
char *(*) BPY_python_app_help_text_fn(bool all)
Definition bpy_app.cc:781
static const char arg_handle_log_show_memory_set_doc[]
static int arg_handle_audio_set(int argc, const char **argv, void *)
static int arg_handle_debug_gpu_shader_no_dce(int, const char **, void *)
static void help_print_ds_fn(void *ds_v, const char *format, va_list args)
static const char arg_handle_verbosity_set_doc[]
static bool parse_int_clamp(const char *str, const char *str_end_test, int min, int max, int *r_value, const char **r_err_msg)
Scene * CTX_data_scene(const bContext *C)
static const char arg_handle_enable_event_simulate_doc[]
bool BPY_run_string_exec(bContext *C, const char *imports[], const char *expr)
void GPU_backend_preferred_device_set_override(int index, uint32_t vendor_id, uint32_t device_id)
static int arg_handle_log_set(int argc, const char **argv, void *)
bool BLI_windows_register_blend_extension(bool all_users)
static const char arg_handle_python_exit_code_set_doc[]
static const char arg_handle_start_with_console_doc[]
static const char arg_handle_window_border_doc[]
static const char arg_handle_load_last_file_doc[]
static const char arg_handle_python_use_user_env_set_doc[]
static const char arg_handle_no_window_focus_doc[]
static const char arg_handle_native_pixels_set_doc[]
static const char arg_handle_extension_set_doc[]
@ BLENDER_SYSTEM_EXTENSIONS
@ BLENDER_SYSTEM_PYTHON
@ BLENDER_SYSTEM_DATAFILES
@ BLENDER_SYSTEM_SCRIPTS
char build_date[]
Definition bpy_app.cc:68
static int arg_handle_gpu_backend_set(int argc, const char **argv, void *)
char build_cxxflags[]
Definition bpy_app.cc:78
static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
void BPY_python_use_system_env()
DynStr * BLI_dynstr_new() ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_dynstr.cc:39
static const char arg_handle_env_system_set_doc_datafiles[]
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_pretty[]
static int arg_handle_disable_liboverride_auto_resync(int, const char **, void *)
static int arg_handle_unregister_extension(int argc, const char **argv, void *data)
static const char arg_handle_register_extension_doc[]
static const char arg_handle_debug_gpu_set_doc[]
static const char arg_handle_audio_disable_doc[]
static const char arg_handle_disable_depsgraph_on_file_load_doc[]
static int arg_handle_python_console_run(int, const char **, void *data)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_build[]
struct bArgs * BLI_args_create(int argc, const char **argv)
Definition BLI_args.cc:127
static int arg_handle_debug_gpu_shader_source(int argc, const char **argv, void *)
static int arg_handle_debug_gpu_renderdoc_set(int, const char **, void *)
const char * BKE_blender_version_string()
Definition blender.cc:147
static int arg_handle_gpu_compilation_subprocesses_set(int argc, const char **argv, void *)
void CTX_data_scene_set(bContext *C, Scene *scene)
static int arg_handle_debug_gpu_set(int, const char **, void *)
static const char arg_handle_window_maximized_doc[]
static const char arg_handle_command_set_doc[]
static int arg_handle_debug_mode_set(int, const char **, void *data)
static const char arg_handle_gpu_vsync_set_doc[]
void WM_init_state_app_template_set(const char *app_template)
Definition wm_files.cc:1210
@ ARG_PASS_ENVIRONMENT
@ ARG_PASS_SETTINGS
@ ARG_PASS_SETTINGS_GUI
@ ARG_PASS_SETTINGS_FORCE
static void add_log_render_filter()
void BLI_args_print(const struct bArgs *ba)
static const char arg_handle_debug_mode_memory_set_doc[]
int(*)(int argc, const char **argv, void *data) BA_ArgCallback
Definition BLI_args.hh:26
static const char arg_handle_debug_mode_set_doc[]
static bool handle_load_file(bContext *C, const char *filepath_arg, const bool load_empty_file)
static int arg_handle_load_last_file(int, const char **, void *data)
static int arg_handle_enable_event_simulate(int, const char **, void *)
static const char arg_handle_render_animation_doc[]
int WM_main_playanim(int argc, const char **argv)
static int arg_handle_start_with_console(int, const char **, void *)
static int arg_handle_window_fullscreen(int, const char **, void *)
static const char arg_handle_list_clog_cats_doc[]
static int arg_handle_print_version(int, const char **, void *)
#define min(a, b)
Definition sort.cc:38
struct BA_ArgCallback_Deferred * main_arg_deferred
struct blender::ApplicationState::@204252132227047363156276311014221143207211224327 exit_code_on_error
struct blender::ApplicationState::@015013240256342036154333030232065173037361052222 signal
ImageFormatData im_format
struct RenderData r