Blender V4.5
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
9#ifndef WITH_PYTHON_MODULE
10
11# include <cerrno>
12# include <cstdlib>
13# include <cstring>
14
15# include "MEM_guardedalloc.h"
16
17# include "CLG_log.h"
18
19# ifdef WIN32
20# include "BLI_winstuff.h"
21# endif
22
23# include "BLI_args.h"
24# include "BLI_dynstr.h"
25# include "BLI_fileops.h"
26# include "BLI_listbase.h"
27# include "BLI_path_utils.hh"
28# include "BLI_string.h"
29# include "BLI_string_utf8.h"
30# include "BLI_system.h"
31# include "BLI_threads.h"
32# include "BLI_utildefines.h"
33# ifndef NDEBUG
34# include "BLI_mempool.h"
35# endif
36
37# include "BKE_appdir.hh"
39# include "BKE_blender_version.h"
40# include "BKE_blendfile.hh"
41# include "BKE_context.hh"
42
43# include "BKE_global.hh"
44# include "BKE_image_format.hh"
45# include "BKE_lib_id.hh"
46# include "BKE_main.hh"
47# include "BKE_report.hh"
48# include "BKE_scene.hh"
49# include "BKE_sound.h"
50
51# include "GPU_context.hh"
52# ifdef WITH_OPENGL_BACKEND
53# include "GPU_capabilities.hh"
55# endif
56
57# ifdef WITH_PYTHON
58# include "BPY_extern_python.hh"
59# include "BPY_extern_run.hh"
60# endif
61
62# include "RE_engine.h"
63# include "RE_pipeline.h"
64
65# include "WM_api.hh"
66
67# ifdef WITH_LIBMV
68# include "libmv-capi.h"
69# endif
70
71# ifdef WITH_CYCLES_LOGGING
72# include "CCL_api.h"
73# endif
74
75# include "DEG_depsgraph.hh"
76
77# include "WM_types.hh"
78
79# include "creator_intern.h" /* Own include. */
80
81/* -------------------------------------------------------------------- */
100
101static void build_defs_init(BuildDefs *build_defs, bool force_all)
102{
103 if (force_all) {
104 bool *var_end = (bool *)(build_defs + 1);
105 for (bool *var = (bool *)build_defs; var < var_end; var++) {
106 *var = true;
107 }
108 return;
109 }
110
111 memset(build_defs, 0x0, sizeof(*build_defs));
112
113# ifdef WIN32
114 build_defs->win32 = true;
115# endif
116# ifdef WITH_CYCLES
117 build_defs->with_cycles = true;
118# endif
119# ifdef WITH_CYCLES_LOGGING
120 build_defs->with_cycles_logging = true;
121# endif
122# ifdef WITH_FFMPEG
123 build_defs->with_ffmpeg = true;
124# endif
125# ifdef WITH_FREESTYLE
126 build_defs->with_freestyle = true;
127# endif
128# ifdef WITH_LIBMV
129 build_defs->with_libmv = true;
130# endif
131# ifdef WITH_OPENCOLORIO
132 build_defs->with_opencolorio = true;
133# endif
134# ifdef WITH_RENDERDOC
135 build_defs->with_renderdoc = true;
136# endif
137# ifdef WITH_XR_OPENXR
138 build_defs->with_xr_openxr = true;
139# endif
140}
141
144/* -------------------------------------------------------------------- */
148static bool parse_int_relative(const char *str,
149 const char *str_end_test,
150 int pos,
151 int neg,
152 int *r_value,
153 const char **r_err_msg)
154{
155 char *str_end = nullptr;
156 long value;
157
158 errno = 0;
159
160 switch (*str) {
161 case '+':
162 value = pos + strtol(str + 1, &str_end, 10);
163 break;
164 case '-':
165 value = (neg - strtol(str + 1, &str_end, 10)) + 1;
166 break;
167 default:
168 value = strtol(str, &str_end, 10);
169 break;
170 }
171
172 if (*str_end != '\0' && (str_end != str_end_test)) {
173 static const char *msg = "not a number";
174 *r_err_msg = msg;
175 return false;
176 }
177 if ((errno == ERANGE) || ((value < INT_MIN) || (value > INT_MAX))) {
178 static const char *msg = "exceeds range";
179 *r_err_msg = msg;
180 return false;
181 }
182 *r_value = int(value);
183 return true;
184}
185
186static const char *parse_int_range_sep_search(const char *str, const char *str_end_test)
187{
188 const char *str_end_range = nullptr;
189 if (str_end_test) {
190 str_end_range = static_cast<const char *>(memchr(str, '.', (str_end_test - str) - 1));
191 if (str_end_range && (str_end_range[1] != '.')) {
192 str_end_range = nullptr;
193 }
194 }
195 else {
196 str_end_range = strstr(str, "..");
197 if (str_end_range && (str_end_range[2] == '\0')) {
198 str_end_range = nullptr;
199 }
200 }
201 return str_end_range;
202}
203
209static bool parse_int_range_relative(const char *str,
210 const char *str_end_range,
211 const char *str_end_test,
212 int pos,
213 int neg,
214 int r_value_range[2],
215 const char **r_err_msg)
216{
217 if (parse_int_relative(str, str_end_range, pos, neg, &r_value_range[0], r_err_msg) &&
218 parse_int_relative(str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg))
219 {
220 return true;
221 }
222 return false;
223}
224
225static bool parse_int_relative_clamp(const char *str,
226 const char *str_end_test,
227 int pos,
228 int neg,
229 int min,
230 int max,
231 int *r_value,
232 const char **r_err_msg)
233{
234 if (parse_int_relative(str, str_end_test, pos, neg, r_value, r_err_msg)) {
235 CLAMP(*r_value, min, max);
236 return true;
237 }
238 return false;
239}
240
241static bool parse_int_range_relative_clamp(const char *str,
242 const char *str_end_range,
243 const char *str_end_test,
244 int pos,
245 int neg,
246 int min,
247 int max,
248 int r_value_range[2],
249 const char **r_err_msg)
250{
252 str, str_end_range, str_end_test, pos, neg, r_value_range, r_err_msg))
253 {
254 CLAMP(r_value_range[0], min, max);
255 CLAMP(r_value_range[1], min, max);
256 return true;
257 }
258 return false;
259}
260
264static bool parse_int_strict_range(const char *str,
265 const char *str_end_test,
266 const int min,
267 const int max,
268 int *r_value,
269 const char **r_err_msg)
270{
271 char *str_end = nullptr;
272 long value;
273
274 errno = 0;
275 value = strtol(str, &str_end, 10);
276
277 if (*str_end != '\0' && (str_end != str_end_test)) {
278 static const char *msg = "not a number";
279 *r_err_msg = msg;
280 return false;
281 }
282 if ((errno == ERANGE) || ((value < min) || (value > max))) {
283 static const char *msg = "exceeds range";
284 *r_err_msg = msg;
285 return false;
286 }
287 *r_value = int(value);
288 return true;
289}
290
291static bool parse_int(const char *str,
292 const char *str_end_test,
293 int *r_value,
294 const char **r_err_msg)
295{
296 return parse_int_strict_range(str, str_end_test, INT_MIN, INT_MAX, r_value, r_err_msg);
297}
298
299static bool parse_int_clamp(const char *str,
300 const char *str_end_test,
301 int min,
302 int max,
303 int *r_value,
304 const char **r_err_msg)
305{
306 if (parse_int(str, str_end_test, r_value, r_err_msg)) {
307 CLAMP(*r_value, min, max);
308 return true;
309 }
310 return false;
311}
312
313# if 0
318static int *parse_int_relative_clamp_n(
319 const char *str, int pos, int neg, int min, int max, int *r_value_len, const char **r_err_msg)
320{
321 const char sep = ',';
322 int len = 1;
323 for (int i = 0; str[i]; i++) {
324 if (str[i] == sep) {
325 len++;
326 }
327 }
328
329 int *values = MEM_malloc_arrayN<int>(size_t(len), __func__);
330 int i = 0;
331 while (true) {
332 const char *str_end = strchr(str, sep);
333 if (ELEM(*str, sep, '\0')) {
334 static const char *msg = "incorrect comma use";
335 *r_err_msg = msg;
336 goto fail;
337 }
338 else if (parse_int_relative_clamp(str, str_end, pos, neg, min, max, &values[i], r_err_msg)) {
339 i++;
340 }
341 else {
342 goto fail; /* Error message already set. */
343 }
344
345 if (str_end) { /* Next. */
346 str = str_end + 1;
347 }
348 else { /* Finished. */
349 break;
350 }
351 }
352
353 *r_value_len = i;
354 return values;
355
356fail:
357 MEM_freeN(values);
358 return nullptr;
359}
360
361# endif
362
369static int (*parse_int_range_relative_clamp_n(const char *str,
370 int pos,
371 int neg,
372 int min,
373 int max,
374 int *r_value_len,
375 const char **r_err_msg))[2]
376{
377 const char sep = ',';
378 int len = 1;
379 for (int i = 0; str[i]; i++) {
380 if (str[i] == sep) {
381 len++;
382 }
383 }
384
385 int(*values)[2] = MEM_malloc_arrayN<int[2]>(size_t(len), __func__);
386 int i = 0;
387 while (true) {
388 const char *str_end_range;
389 const char *str_end = strchr(str, sep);
390 if (ELEM(*str, sep, '\0')) {
391 static const char *msg = "incorrect comma use";
392 *r_err_msg = msg;
393 goto fail;
394 }
395 else if ((str_end_range = parse_int_range_sep_search(str, str_end)) ?
397 str, str_end_range, str_end, pos, neg, min, max, values[i], r_err_msg) :
399 str, str_end, pos, neg, min, max, &values[i][0], r_err_msg))
400 {
401 if (str_end_range == nullptr) {
402 values[i][1] = values[i][0];
403 }
404 i++;
405 }
406 else {
407 goto fail; /* Error message already set. */
408 }
409
410 if (str_end) { /* Next. */
411 str = str_end + 1;
412 }
413 else { /* Finished. */
414 break;
415 }
416 }
417
418 *r_value_len = i;
419 return values;
420
421fail:
422 MEM_freeN(values);
423 return nullptr;
424}
425
428/* -------------------------------------------------------------------- */
436/* When the deferred argument is handled on Windows the `argv` will have been freed,
437 * see `USE_WIN32_UNICODE_ARGS` in `creator.cc`. */
438
439# ifdef WIN32
440static char **argv_duplicate(const char **argv, int argc)
441{
442 char **argv_copy = MEM_malloc_arrayN<char *>(size_t(argc), __func__);
443 for (int i = 0; i < argc; i++) {
444 argv_copy[i] = BLI_strdup(argv[i]);
445 }
446 return argv_copy;
447}
448
449static void argv_free(char **argv, int argc)
450{
451 for (int i = 0; i < argc; i++) {
452 MEM_freeN(argv[i]);
453 }
454 MEM_freeN(argv);
455}
456# endif /* !WIN32 */
457
466
468{
469 return app_state.main_arg_deferred != nullptr;
470}
471
472static void main_arg_deferred_setup(BA_ArgCallback func, int argc, const char **argv, void *data)
473{
476 d->func = func;
477 d->argc = argc;
478 d->argv = argv;
479 d->data = data;
480 d->exit_code = 0;
481# ifdef WIN32
482 d->argv = const_cast<const char **>(argv_duplicate(d->argv, d->argc));
483# endif
485}
486
488{
491# ifdef WIN32
492 argv_free(const_cast<char **>(d->argv), d->argc);
493# endif
494 MEM_freeN(d);
495}
496
497static void main_arg_deferred_exit_code_set(int exit_code)
498{
500 BLI_assert(d != nullptr);
501 d->exit_code = exit_code;
502}
503
505{
507 d->func(d->argc, d->argv, d->data);
508 return d->exit_code;
509}
510
513/* -------------------------------------------------------------------- */
517# ifdef WITH_PYTHON
518
519struct BlendePyContextStore {
520 wmWindowManager *wm;
521 Scene *scene;
522 wmWindow *win;
523 bool has_win;
524};
525
526static void arg_py_context_backup(bContext *C, BlendePyContextStore *c_py)
527{
528 c_py->wm = CTX_wm_manager(C);
529 c_py->scene = CTX_data_scene(C);
530 c_py->has_win = c_py->wm && !BLI_listbase_is_empty(&c_py->wm->windows);
531 if (c_py->has_win) {
532 c_py->win = CTX_wm_window(C);
533 CTX_wm_window_set(C, static_cast<wmWindow *>(c_py->wm->windows.first));
534 }
535 else {
536 /* NOTE: this should never happen, although it may be possible when loading
537 * `.blend` files without windowing data. Whatever the case, it shouldn't crash,
538 * although typical scripts that accesses the context is not expected to work usefully. */
539 c_py->win = nullptr;
540 fprintf(stderr, "Python script running with missing context data.\n");
541 }
542}
543
544static void arg_py_context_restore(bContext *C, BlendePyContextStore *c_py)
545{
546 /* Script may load a file, check old data is valid before using. */
547 if (c_py->has_win) {
548 if ((c_py->win == nullptr) || ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) &&
549 (BLI_findindex(&c_py->wm->windows, c_py->win) != -1)))
550 {
551 CTX_wm_window_set(C, c_py->win);
552 }
553 }
554
555 if ((c_py->scene == nullptr) || BLI_findindex(&G_MAIN->scenes, c_py->scene) != -1) {
556 CTX_data_scene_set(C, c_py->scene);
557 }
558}
559
560/* Macro for context setup/reset. */
561# define BPY_CTX_SETUP(_cmd) \
562 { \
563 BlendePyContextStore py_c; \
564 arg_py_context_backup(C, &py_c); \
565 { \
566 _cmd; \
567 } \
568 arg_py_context_restore(C, &py_c); \
569 } \
570 ((void)0)
571
572# endif /* WITH_PYTHON */
573
576/* -------------------------------------------------------------------- */
591{
592 printf("Blender %s\n", BKE_blender_version_string());
593# ifdef BUILD_DATE
594 printf("\tbuild date: %s\n", build_date);
595 printf("\tbuild time: %s\n", build_time);
596 printf("\tbuild commit date: %s\n", build_commit_date);
597 printf("\tbuild commit time: %s\n", build_commit_time);
598 printf("\tbuild hash: %s\n", build_hash);
599 printf("\tbuild branch: %s\n", build_branch);
600 printf("\tbuild platform: %s\n", build_platform);
601 printf("\tbuild type: %s\n", build_type);
602 printf("\tbuild c flags: %s\n", build_cflags);
603 printf("\tbuild c++ flags: %s\n", build_cxxflags);
604 printf("\tbuild link flags: %s\n", build_linkflags);
605 printf("\tbuild system: %s\n", build_system);
606# endif
607}
608
610{
611# ifdef BUILD_DATE
612 /* NOTE: We include built time since sometimes we need to tell broken from
613 * working built of the same hash. */
614 printf("Blender %s (hash %s built %s %s)\n",
618 build_time);
619# else
620 printf("Blender %s\n", BKE_blender_version_string());
621# endif
622}
623
624static const char arg_handle_print_version_doc[] =
625 "\n\t"
626 "Print Blender version and exit.";
627static int arg_handle_print_version(int /*argc*/, const char ** /*argv*/, void * /*data*/)
628{
630 exit(EXIT_SUCCESS);
632 return 0;
633}
634
635static void print_help(bArgs *ba, bool all)
636{
637 BuildDefs defs;
638 build_defs_init(&defs, all);
639
640/* All printing must go via `PRINT` macro. */
641# define printf __ERROR__
642
643# define PRINT(...) BLI_args_printf(ba, __VA_ARGS__)
644
645 PRINT("Blender %s\n", BKE_blender_version_string());
646 PRINT("Usage: blender [args ...] [file] [args ...]\n");
647 PRINT("\n");
648
649 PRINT("Render Options:\n");
650 BLI_args_print_arg_doc(ba, "--background");
651 BLI_args_print_arg_doc(ba, "--render-anim");
652 BLI_args_print_arg_doc(ba, "--scene");
653 BLI_args_print_arg_doc(ba, "--render-frame");
654 BLI_args_print_arg_doc(ba, "--frame-start");
655 BLI_args_print_arg_doc(ba, "--frame-end");
656 BLI_args_print_arg_doc(ba, "--frame-jump");
657 BLI_args_print_arg_doc(ba, "--render-output");
658 BLI_args_print_arg_doc(ba, "--engine");
659 BLI_args_print_arg_doc(ba, "--threads");
660
661 if (defs.with_cycles) {
662 PRINT("Cycles Render Options:\n");
663 PRINT("\tCycles add-on options must be specified following a double dash.\n");
664 PRINT("\n");
665 PRINT("--cycles-device <device>\n");
666 PRINT("\tSet the device used for rendering.\n");
667 PRINT("\tValid options are: 'CPU' 'CUDA' 'OPTIX' 'HIP' 'ONEAPI' 'METAL'.\n");
668 PRINT("\n");
669 PRINT("\tAppend +CPU to a GPU device to render on both CPU and GPU.\n");
670 PRINT("\n");
671 PRINT("\tExample:\n");
672 PRINT("\t# blender -b file.blend -f 20 -- --cycles-device OPTIX\n");
673 PRINT("--cycles-print-stats\n");
674 PRINT("\tLog statistics about render memory and time usage.\n");
675 }
676
677 PRINT("\n");
678 PRINT("Format Options:\n");
679 BLI_args_print_arg_doc(ba, "--render-format");
680 BLI_args_print_arg_doc(ba, "--use-extension");
681
682 PRINT("\n");
683 PRINT("Animation Playback Options:\n");
684 BLI_args_print_arg_doc(ba, "-a");
685
686 PRINT("\n");
687 PRINT("Window Options:\n");
688 BLI_args_print_arg_doc(ba, "--window-border");
689 BLI_args_print_arg_doc(ba, "--window-fullscreen");
690 BLI_args_print_arg_doc(ba, "--window-geometry");
691 BLI_args_print_arg_doc(ba, "--window-maximized");
692 BLI_args_print_arg_doc(ba, "--start-console");
693 BLI_args_print_arg_doc(ba, "--no-native-pixels");
694 BLI_args_print_arg_doc(ba, "--no-window-focus");
695
696 PRINT("\n");
697 PRINT("Python Options:\n");
698 BLI_args_print_arg_doc(ba, "--enable-autoexec");
699 BLI_args_print_arg_doc(ba, "--disable-autoexec");
700
701 PRINT("\n");
702
703 BLI_args_print_arg_doc(ba, "--python");
704 BLI_args_print_arg_doc(ba, "--python-text");
705 BLI_args_print_arg_doc(ba, "--python-expr");
706 BLI_args_print_arg_doc(ba, "--python-console");
707 BLI_args_print_arg_doc(ba, "--python-exit-code");
708 BLI_args_print_arg_doc(ba, "--python-use-system-env");
709 BLI_args_print_arg_doc(ba, "--addons");
710
711 PRINT("\n");
712 PRINT("Network Options:\n");
713 BLI_args_print_arg_doc(ba, "--online-mode");
714 BLI_args_print_arg_doc(ba, "--offline-mode");
715
716 PRINT("\n");
717 PRINT("Logging Options:\n");
718 BLI_args_print_arg_doc(ba, "--log");
719 BLI_args_print_arg_doc(ba, "--log-level");
720 BLI_args_print_arg_doc(ba, "--log-show-basename");
721 BLI_args_print_arg_doc(ba, "--log-show-backtrace");
722 BLI_args_print_arg_doc(ba, "--log-show-timestamp");
723 BLI_args_print_arg_doc(ba, "--log-file");
724
725 PRINT("\n");
726 PRINT("Debug Options:\n");
727 BLI_args_print_arg_doc(ba, "--debug");
728 BLI_args_print_arg_doc(ba, "--debug-value");
729
730 PRINT("\n");
731 BLI_args_print_arg_doc(ba, "--debug-events");
732 if (defs.with_ffmpeg) {
733 BLI_args_print_arg_doc(ba, "--debug-ffmpeg");
734 }
735 BLI_args_print_arg_doc(ba, "--debug-handlers");
736 if (defs.with_libmv) {
737 BLI_args_print_arg_doc(ba, "--debug-libmv");
738 }
739 if (defs.with_cycles_logging) {
740 BLI_args_print_arg_doc(ba, "--debug-cycles");
741 }
742 BLI_args_print_arg_doc(ba, "--debug-memory");
743 BLI_args_print_arg_doc(ba, "--debug-jobs");
744 BLI_args_print_arg_doc(ba, "--debug-python");
745 BLI_args_print_arg_doc(ba, "--debug-depsgraph");
746 BLI_args_print_arg_doc(ba, "--debug-depsgraph-eval");
747 BLI_args_print_arg_doc(ba, "--debug-depsgraph-build");
748 BLI_args_print_arg_doc(ba, "--debug-depsgraph-tag");
749 BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
750 BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
751 BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
752 BLI_args_print_arg_doc(ba, "--debug-depsgraph-uid");
753 BLI_args_print_arg_doc(ba, "--debug-ghost");
754 BLI_args_print_arg_doc(ba, "--debug-wintab");
755 BLI_args_print_arg_doc(ba, "--debug-gpu");
756 BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
757 BLI_args_print_arg_doc(ba, "--debug-gpu-compile-shaders");
758 if (defs.with_renderdoc) {
759 BLI_args_print_arg_doc(ba, "--debug-gpu-scope-capture");
760 BLI_args_print_arg_doc(ba, "--debug-gpu-renderdoc");
761 }
762# ifdef WITH_VULKAN_BACKEND
763 BLI_args_print_arg_doc(ba, "--debug-gpu-vulkan-local-read");
764# endif
765 BLI_args_print_arg_doc(ba, "--debug-wm");
766 if (defs.with_xr_openxr) {
767 BLI_args_print_arg_doc(ba, "--debug-xr");
768 BLI_args_print_arg_doc(ba, "--debug-xr-time");
769 }
770 BLI_args_print_arg_doc(ba, "--debug-all");
771 BLI_args_print_arg_doc(ba, "--debug-io");
772
773 PRINT("\n");
774 BLI_args_print_arg_doc(ba, "--debug-fpe");
775 BLI_args_print_arg_doc(ba, "--debug-exit-on-error");
776 if (defs.with_freestyle) {
777 BLI_args_print_arg_doc(ba, "--debug-freestyle");
778 }
779 BLI_args_print_arg_doc(ba, "--disable-crash-handler");
780 BLI_args_print_arg_doc(ba, "--disable-abort-handler");
781
782 BLI_args_print_arg_doc(ba, "--verbose");
783 BLI_args_print_arg_doc(ba, "--quiet");
784
785 PRINT("\n");
786 PRINT("GPU Options:\n");
787 BLI_args_print_arg_doc(ba, "--gpu-backend");
788# ifdef WITH_OPENGL_BACKEND
789 BLI_args_print_arg_doc(ba, "--gpu-compilation-subprocesses");
790# endif
791 BLI_args_print_arg_doc(ba, "--profile-gpu");
792
793 PRINT("\n");
794 PRINT("Misc Options:\n");
795 BLI_args_print_arg_doc(ba, "--open-last");
796 BLI_args_print_arg_doc(ba, "--app-template");
797 BLI_args_print_arg_doc(ba, "--factory-startup");
798 BLI_args_print_arg_doc(ba, "--enable-event-simulate");
799 PRINT("\n");
800 BLI_args_print_arg_doc(ba, "--env-system-datafiles");
801 BLI_args_print_arg_doc(ba, "--env-system-scripts");
802 BLI_args_print_arg_doc(ba, "--env-system-extensions");
803 BLI_args_print_arg_doc(ba, "--env-system-python");
804 PRINT("\n");
805 BLI_args_print_arg_doc(ba, "-noaudio");
806 BLI_args_print_arg_doc(ba, "-setaudio");
807 PRINT("\n");
808 BLI_args_print_arg_doc(ba, "--command");
809
810 PRINT("\n");
811
812 BLI_args_print_arg_doc(ba, "--help");
813 BLI_args_print_arg_doc(ba, "/?");
814
815 /* WIN32 only (ignored for non-WIN32). */
816 BLI_args_print_arg_doc(ba, "--register");
817 BLI_args_print_arg_doc(ba, "--register-allusers");
818 BLI_args_print_arg_doc(ba, "--unregister");
819 BLI_args_print_arg_doc(ba, "--unregister-allusers");
820
821 BLI_args_print_arg_doc(ba, "--version");
822
823 BLI_args_print_arg_doc(ba, "--");
824
825 // PRINT("\n");
826 // PRINT("Experimental Features:\n");
827
828 /* Other options _must_ be last (anything not handled will show here).
829 *
830 * Note that it's good practice for this to remain empty,
831 * nevertheless print if any exist. */
832 if (BLI_args_has_other_doc(ba)) {
833 PRINT("\n");
834 PRINT("Other Options:\n");
836 }
837
838 PRINT("\n");
839 PRINT("Argument Parsing:\n");
840 PRINT("\tArguments must be separated by white space, eg:\n");
841 PRINT("\t# blender -ba test.blend\n");
842 PRINT("\t...will exit since '-ba' is an unknown argument.\n");
843 PRINT("\n");
844
845 PRINT("Argument Order:\n");
846 PRINT("\tArguments are executed in the order they are given. eg:\n");
847 PRINT("\t# blender --background test.blend --render-frame 1 --render-output \"/tmp\"\n");
848 PRINT(
849 "\t...will not render to '/tmp' because '--render-frame 1' renders before the output path "
850 "is set.\n");
851 PRINT("\t# blender --background --render-output /tmp test.blend --render-frame 1\n");
852 PRINT(
853 "\t...will not render to '/tmp' because loading the blend-file overwrites the render output "
854 "that was set.\n");
855 PRINT("\t# blender --background test.blend --render-output /tmp --render-frame 1\n");
856 PRINT("\t...works as expected.\n");
857 PRINT("\n");
858
859 PRINT("Environment Variables:\n");
860 PRINT(" $BLENDER_USER_RESOURCES Replace default directory of all user files.\n");
861 PRINT(" Other 'BLENDER_USER_*' variables override when set.\n");
862 PRINT(" $BLENDER_USER_CONFIG Directory for user configuration files.\n");
863 PRINT(" $BLENDER_USER_SCRIPTS Directory for user scripts.\n");
864 PRINT(" $BLENDER_USER_EXTENSIONS Directory for user extensions.\n");
865 PRINT(" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n");
866 PRINT("\n");
867 PRINT(" $BLENDER_SYSTEM_RESOURCES Replace default directory of all bundled resource files.\n");
868 PRINT(" $BLENDER_SYSTEM_SCRIPTS Directories to add extra scripts.\n");
869 PRINT(" $BLENDER_SYSTEM_EXTENSIONS Directory for system extensions repository.\n");
870 PRINT(" $BLENDER_SYSTEM_DATAFILES Directory to replace bundled datafiles.\n");
871 PRINT(" $BLENDER_SYSTEM_PYTHON Directory to replace bundled Python libraries.\n");
872 PRINT(" $BLENDER_CUSTOM_SPLASH Full path to an image that replaces the splash screen.\n");
873 PRINT(
874 " $BLENDER_CUSTOM_SPLASH_BANNER Full path to an image to overlay on the splash screen.\n");
875
876 if (defs.with_opencolorio) {
877 PRINT(" $OCIO Path to override the OpenColorIO configuration file.\n");
878 }
879 if (defs.win32 || all) {
880 PRINT(" $TEMP Store temporary files here (MS-Windows).\n");
881 }
882 if (!defs.win32 || all) {
883 /* NOTE: while `TMP` checked, don't include here as it's non-standard & may be removed. */
884 PRINT(" $TMPDIR Store temporary files here (UNIX Systems).\n");
885 }
886 PRINT(
887 " The path must reference an existing directory "
888 "or it will be ignored.\n");
889
890# undef printf
891# undef PRINT
892}
893
895static void help_print_ds_fn(void *ds_v, const char *format, va_list args)
896{
897 DynStr *ds = static_cast<DynStr *>(ds_v);
898 BLI_dynstr_vappendf(ds, format, args);
899}
900
902{
903 DynStr *ds = BLI_dynstr_new();
904 {
905 bArgs *ba = BLI_args_create(0, nullptr);
906 main_args_setup(nullptr, ba, all);
908 print_help(ba, all);
910 }
911 char *buf = BLI_dynstr_get_cstring(ds);
912 BLI_dynstr_free(ds);
913 return buf;
914}
915
916static const char arg_handle_print_help_doc[] =
917 "\n\t"
918 "Print this help text and exit.";
920 "\n\t"
921 "Print this help text and exit (Windows only).";
922static int arg_handle_print_help(int /*argc*/, const char ** /*argv*/, void *data)
923{
924 bArgs *ba = (bArgs *)data;
925
926 print_help(ba, false);
927
928 exit(EXIT_SUCCESS);
930
931 return 0;
932}
933
934static const char arg_handle_arguments_end_doc[] =
935 "\n\t"
936 "End option processing, following arguments passed unchanged. Access via Python's "
937 "'sys.argv'.";
938static int arg_handle_arguments_end(int /*argc*/, const char ** /*argv*/, void * /*data*/)
939{
940 return -1;
941}
942
943/* Only to give help message. */
944# ifdef WITH_PYTHON_SECURITY /* Default. */
945# define PY_ENABLE_AUTO ""
946# define PY_DISABLE_AUTO ", (default)"
947# else
948# define PY_ENABLE_AUTO ", (default, non-standard compilation option)"
949# define PY_DISABLE_AUTO ""
950# endif
951
953 "\n\t"
954 "Enable automatic Python script execution" PY_ENABLE_AUTO ".";
956 "\n\t"
957 "Disable automatic Python script execution "
958 "(Python-drivers & startup scripts)" PY_DISABLE_AUTO ".";
959# undef PY_ENABLE_AUTO
960# undef PY_DISABLE_AUTO
961
962static int arg_handle_python_set(int /*argc*/, const char ** /*argv*/, void *data)
963{
964 const bool use_autoexec = bool(data);
965 if (use_autoexec) {
967 }
968 else {
969 G.f &= ~G_FLAG_SCRIPT_AUTOEXEC;
970 }
971 G.autoexec_override = use_autoexec;
972 return 0;
973}
974
976 "\n\t"
977 "Allow internet access, overriding the preference.";
979 "\n\t"
980 "Disallow internet access, overriding the preference.";
981
982static int arg_handle_internet_allow_set(int /*argc*/, const char ** /*argv*/, void *data)
983{
984 G.f &= ~G_FLAG_INTERNET_OVERRIDE_PREF_ANY;
985 if (bool(data)) {
988 }
989 else {
990 G.f &= ~G_FLAG_INTERNET_ALLOW;
992 }
993 return 0;
994}
995
997 "\n\t"
998 "Disable the crash handler.";
999static int arg_handle_crash_handler_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1000{
1002 return 0;
1003}
1004
1006 "\n\t"
1007 "Disable the abort handler.";
1008static int arg_handle_abort_handler_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1009{
1011 return 0;
1012}
1013
1014static void clog_abort_on_error_callback(void *fp)
1015{
1016 BLI_system_backtrace(static_cast<FILE *>(fp));
1017 fflush(static_cast<FILE *>(fp));
1018 abort();
1019}
1020
1022 "\n\t"
1023 "Immediately exit when internal errors are detected.";
1024static int arg_handle_debug_exit_on_error(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1025{
1028 return 0;
1029}
1030
1031static const char arg_handle_quiet_set_doc[] =
1032 "\n\t"
1033 "Suppress status printing (warnings & errors are still printed).";
1034static int arg_handle_quiet_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1035{
1036 G.quiet = true;
1037 return 0;
1038}
1039
1042{
1043 G.background = true;
1044
1045 /* Background Mode Defaults:
1046 *
1047 * In general background mode should strive to match the behavior of running
1048 * Blender inside a graphical session, any exception to this should have a well
1049 * justified reason and be noted in the doc-string. */
1050
1051 /* NOTE(@ideasman42): While there is no requirement for sound to be disabled in background-mode,
1052 * the use case for playing audio in background mode is enough of a special-case
1053 * that users who wish to do this can explicitly enable audio in background mode.
1054 * While the down sides for connecting to an audio device aren't terrible they include:
1055 * - Listing Blender as an active application which may output audio.
1056 * - Unnecessary overhead running an operation in background mode or ...
1057 * - Having to remember to include `-noaudio` with batch operations.
1058 * - A quiet but audible click when Blender starts & configures its audio device.
1059 */
1060 BKE_sound_force_device("None");
1061}
1062
1064 "\n"
1065 "\tRun in background (often used for UI-less rendering).\n"
1066 "\n"
1067 "\tThe audio device is disabled in background-mode by default\n"
1068 "\tand can be re-enabled by passing in '-setaudio Default' afterwards.";
1069static int arg_handle_background_mode_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1070{
1071 if (!G.quiet) {
1073 }
1075 return 0;
1076}
1077
1078static const char arg_handle_command_set_doc[] =
1079 "<command>\n"
1080 "\tRun a command which consumes all remaining arguments.\n"
1081 "\tUse '-c help' to list all other commands.\n"
1082 "\tPass '--help' after the command to see its help text.\n"
1083 "\n"
1084 "\tThis implies '--background' mode.";
1085static int arg_handle_command_set(int argc, const char **argv, void *data)
1086{
1087 if (!main_arg_deferred_is_set()) {
1088 if (argc < 2) {
1089 fprintf(stderr, "%s requires at least one argument\n", argv[0]);
1090 exit(EXIT_FAILURE);
1092 }
1093 /* Application "info" messages get in the way of command line output, suppress them. */
1094 G.quiet = true;
1095
1097
1099 }
1100 else {
1101 bContext *C = static_cast<bContext *>(data);
1102 const char *id = argv[1];
1103 int exit_code;
1104 if (STREQ(id, "help")) {
1106 exit_code = EXIT_SUCCESS;
1107 }
1108 else {
1109 exit_code = BKE_blender_cli_command_exec(C, id, argc - 2, argv + 2);
1110 }
1112 }
1113
1114 /* Consume remaining arguments. */
1115 return argc - 1;
1116}
1117
1119 "\n"
1120 "\tBackground mode: Do not systematically build and evaluate ViewLayers' dependency graphs\n"
1121 "\twhen loading a blend-file in background mode ('-b' or '-c' options).\n"
1122 "\n"
1123 "\tScripts requiring evaluated data then need to explicitly ensure that\n"
1124 "\tan evaluated depsgraph is available\n"
1125 "\t(e.g. by calling 'depsgraph = context.evaluated_depsgraph_get()').\n"
1126 "\n"
1127 "\tNOTE: this is a temporary option, in the future depsgraph will never be\n"
1128 "\tautomatically generated on file load in background mode.";
1130 const char ** /*argv*/,
1131 void * /*data*/)
1132{
1133 G.fileflags |= G_BACKGROUND_NO_DEPSGRAPH;
1134 return 0;
1135}
1136
1138 "\n"
1139 "\tDo not perform library override automatic resync when loading a new blend-file.\n"
1140 "\n"
1141 "\tNOTE: this is an alternative way to get the same effect as when setting the\n"
1142 "\t'No Override Auto Resync' User Preferences Debug option.";
1144 const char ** /*argv*/,
1145 void * /*data*/)
1146{
1147 G.fileflags |= G_LIBOVERRIDE_NO_AUTO_RESYNC;
1148 return 0;
1149}
1150
1151static const char arg_handle_log_level_set_doc[] =
1152 "<level>\n"
1153 "\tSet the logging verbosity level (higher for more details) defaults to 1,\n"
1154 "\tuse -1 to log all levels.";
1155static int arg_handle_log_level_set(int argc, const char **argv, void * /*data*/)
1156{
1157 const char *arg_id = "--log-level";
1158 if (argc > 1) {
1159 const char *err_msg = nullptr;
1160 if (!parse_int_clamp(argv[1], nullptr, -1, INT_MAX, &G.log.level, &err_msg)) {
1161 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1162 }
1163 else {
1164 if (G.log.level == -1) {
1165 G.log.level = INT_MAX;
1166 }
1167 CLG_level_set(G.log.level);
1168 }
1169 return 1;
1170 }
1171 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1172 return 0;
1173}
1174
1176 "\n\t"
1177 "Only show file name in output (not the leading path).";
1178static int arg_handle_log_show_basename_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1179{
1181 return 0;
1182}
1183
1185 "\n\t"
1186 "Show a back trace for each log message (debug builds only).";
1187static int arg_handle_log_show_backtrace_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1188{
1189 /* Ensure types don't become incompatible. */
1190 void (*fn)(FILE *fp) = BLI_system_backtrace;
1191 CLG_backtrace_fn_set((void (*)(void *))fn);
1192 return 0;
1193}
1194
1196 "\n\t"
1197 "Show a timestamp for each log message in seconds since start.";
1198static int arg_handle_log_show_timestamp_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1199{
1201 return 0;
1202}
1203
1204static const char arg_handle_log_file_set_doc[] =
1205 "<filepath>\n"
1206 "\tSet a file to output the log to.";
1207static int arg_handle_log_file_set(int argc, const char **argv, void * /*data*/)
1208{
1209 const char *arg_id = "--log-file";
1210 if (argc > 1) {
1211 errno = 0;
1212 FILE *fp = BLI_fopen(argv[1], "w");
1213 if (fp == nullptr) {
1214 const char *err_msg = errno ? strerror(errno) : "unknown";
1215 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1216 }
1217 else {
1218 if (UNLIKELY(G.log.file != nullptr)) {
1219 fclose(static_cast<FILE *>(G.log.file));
1220 }
1221 G.log.file = fp;
1222 CLG_output_set(G.log.file);
1223 }
1224 return 1;
1225 }
1226 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1227 return 0;
1228}
1229
1230static const char arg_handle_log_set_doc[] =
1231 "<match>\n"
1232 "\tEnable logging categories, taking a single comma separated argument.\n"
1233 "\tMultiple categories can be matched using a '.*' suffix,\n"
1234 "\tso '--log \"wm.*\"' logs every kind of window-manager message.\n"
1235 "\tSub-string can be matched using a '*' prefix and suffix,\n"
1236 "\tso '--log \"*undo*\"' logs every kind of undo-related message.\n"
1237 "\tUse \"^\" prefix to ignore, so '--log \"*,^wm.operator.*\"' logs all except for "
1238 "'wm.operators.*'\n"
1239 "\tUse \"*\" to log everything.";
1240static int arg_handle_log_set(int argc, const char **argv, void * /*data*/)
1241{
1242 const char *arg_id = "--log";
1243 if (argc > 1) {
1244 const char *str_step = argv[1];
1245 while (*str_step) {
1246 const char *str_step_end = strchr(str_step, ',');
1247 int str_step_len = str_step_end ? (str_step_end - str_step) : strlen(str_step);
1248
1249 if (str_step[0] == '^') {
1250 CLG_type_filter_exclude(str_step + 1, str_step_len - 1);
1251 }
1252 else {
1253 CLG_type_filter_include(str_step, str_step_len);
1254 }
1255
1256 if (str_step_end) {
1257 /* Typically only be one, but don't fail on multiple. */
1258 while (*str_step_end == ',') {
1259 str_step_end++;
1260 }
1261 str_step = str_step_end;
1262 }
1263 else {
1264 break;
1265 }
1266 }
1267 return 1;
1268 }
1269 fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
1270 return 0;
1271}
1272
1274 "\n"
1275 "\tTurn debugging on.\n"
1276 "\n"
1277 "\t* Enables memory error detection\n"
1278 "\t* Disables mouse grab (to interact with a debugger in some cases)\n"
1279 "\t* Keeps Python's 'sys.stdin' rather than setting it to None";
1280static int arg_handle_debug_mode_set(int /*argc*/, const char ** /*argv*/, void *data)
1281{
1282 G.debug |= G_DEBUG;
1283 printf("Blender %s\n", BKE_blender_version_string());
1285# ifndef NDEBUG
1287# endif
1288
1289# ifdef WITH_BUILDINFO
1290 printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
1291# endif
1292
1293 BLI_args_print(static_cast<bArgs *>(data));
1294 return 0;
1295}
1296
1298 "\n\t"
1299 "Enable debug messages from FFmpeg library.";
1301 "\n\t"
1302 "Enable debug messages for Freestyle.";
1304 "\n\t"
1305 "Enable debug messages for Python.";
1307 "\n\t"
1308 "Enable debug messages for the event system.";
1310 "\n\t"
1311 "Enable debug messages for event handling.";
1313 "\n\t"
1314 "Enable debug messages for the window manager, shows all operators in search, shows "
1315 "keymap errors.";
1317 "\n\t"
1318 "Enable debug messages for Ghost (Linux only).";
1320 "\n\t"
1321 "Enable debug messages for Wintab.";
1323 "\n\t"
1324 "Enable debug messages for virtual reality contexts.\n"
1325 "\tEnables the OpenXR API validation layer, (OpenXR) debug messages and general information "
1326 "prints.";
1328 "\n\t"
1329 "Enable debug messages for virtual reality frame rendering times.";
1331 "\n\t"
1332 "Enable time profiling for background jobs.";
1334 "\n\t"
1335 "Enable all debug messages from dependency graph.";
1337 "\n\t"
1338 "Enable debug messages from dependency graph related on graph construction.";
1340 "\n\t"
1341 "Enable debug messages from dependency graph related on tagging.";
1343 "\n\t"
1344 "Enable debug messages from dependency graph related on timing.";
1346 "\n\t"
1347 "Enable debug messages from dependency graph related on evaluation.";
1349 "\n\t"
1350 "Switch dependency graph to a single threaded evaluation.";
1352 "\n\t"
1353 "Enable colors for dependency graph debug messages.";
1355 "\n\t"
1356 "Verify validness of session-wide identifiers assigned to ID data-blocks.";
1358 "\n\t"
1359 "Enable workarounds for typical GPU issues and disable all GPU extensions.";
1360# ifdef WITH_VULKAN_BACKEND
1361static const char arg_handle_debug_mode_generic_set_doc_gpu_force_vulkan_local_read[] =
1362 "\n\t"
1363 "Force Vulkan dynamic rendering local read when supported by device.";
1364# endif
1365
1366static int arg_handle_debug_mode_generic_set(int /*argc*/, const char ** /*argv*/, void *data)
1367{
1368 G.debug |= POINTER_AS_INT(data);
1369 return 0;
1370}
1371
1372static const char arg_handle_debug_mode_io_doc[] =
1373 "\n\t"
1374 "Enable debug messages for I/O (Collada, ...).";
1375static int arg_handle_debug_mode_io(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1376{
1377 G.debug |= G_DEBUG_IO;
1378 return 0;
1379}
1380
1382 "\n\t"
1383 "Enable all debug messages.";
1384static int arg_handle_debug_mode_all(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1385{
1386 G.debug |= G_DEBUG_ALL;
1387# ifdef WITH_LIBMV
1389# endif
1390# ifdef WITH_CYCLES_LOGGING
1392# endif
1393 return 0;
1394}
1395
1397 "\n\t"
1398 "Enable debug messages from libmv library.";
1399static int arg_handle_debug_mode_libmv(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1400{
1401# ifdef WITH_LIBMV
1403# endif
1404 return 0;
1405}
1406
1408 "\n\t"
1409 "Enable debug messages from Cycles.";
1410static int arg_handle_debug_mode_cycles(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1411{
1412# ifdef WITH_CYCLES_LOGGING
1414# endif
1415 return 0;
1416}
1417
1419 "\n\t"
1420 "Enable fully guarded memory allocation and debugging.";
1421static int arg_handle_debug_mode_memory_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1422{
1424 return 0;
1425}
1426
1428 "<value>\n"
1429 "\tSet debug value of <value> on startup.";
1430static int arg_handle_debug_value_set(int argc, const char **argv, void * /*data*/)
1431{
1432 const char *arg_id = "--debug-value";
1433 if (argc > 1) {
1434 const char *err_msg = nullptr;
1435 int value;
1436 if (!parse_int(argv[1], nullptr, &value, &err_msg)) {
1437 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1438 return 1;
1439 }
1440
1441 G.debug_value = value;
1442
1443 return 1;
1444 }
1445 fprintf(stderr, "\nError: you must specify debug value to set.\n");
1446 return 0;
1447}
1448
1449static const char arg_handle_debug_gpu_set_doc[] =
1450 "\n"
1451 "\tEnable GPU debug context and information for OpenGL 4.3+.";
1452static int arg_handle_debug_gpu_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1453{
1454 /* Also enable logging because that how gl errors are reported. */
1455 const char *gpu_filter = "gpu.*";
1456 CLG_type_filter_include(gpu_filter, strlen(gpu_filter));
1457 G.debug |= G_DEBUG_GPU;
1458 return 0;
1459}
1460
1462 "\n"
1463 "\tCompile all statically defined shaders to test platform compatibility.";
1465 const char ** /*argv*/,
1466 void * /*data*/)
1467{
1469 return 0;
1470}
1471
1473 "\n"
1474 "\tCapture the GPU commands issued inside the give scope name.";
1475static int arg_handle_debug_gpu_scope_capture_set(int argc, const char **argv, void * /*data*/)
1476{
1477 if (argc > 1) {
1478 STRNCPY(G.gpu_debug_scope_name, argv[1]);
1479 return 1;
1480 }
1481 fprintf(stderr, "\nError: you must specify a scope name to capture.\n");
1482 return 0;
1483}
1484
1486 "\n"
1487 "\tEnable RenderDoc integration for GPU frame grabbing and debugging.";
1489 const char ** /*argv*/,
1490 void * /*data*/)
1491{
1492# ifdef WITH_RENDERDOC
1494# endif
1495 return 0;
1496}
1497
1499 "\n"
1500 "\tForce to use a specific GPU backend. Valid options: "
1501 "'vulkan', "
1502 "'metal', "
1503 "'opengl'.";
1505 "\n"
1506 "\tForce to use a specific GPU backend. Valid options: "
1507# ifdef WITH_OPENGL_BACKEND
1508 "'opengl'"
1509# endif
1510# ifdef WITH_METAL_BACKEND
1511 "'metal'"
1512# endif
1513# ifdef WITH_VULKAN_BACKEND
1514# if defined(WITH_OPENGL_BACKEND) || defined(WITH_METAL_BACKEND)
1515 " or "
1516# endif
1517 "'vulkan'"
1518# endif
1519 ".";
1520static int arg_handle_gpu_backend_set(int argc, const char **argv, void * /*data*/)
1521{
1522 if (argc < 2) {
1523 fprintf(stderr, "\nError: GPU backend must follow '--gpu-backend'.\n");
1524 return 0;
1525 }
1526 const char *backends_supported[3] = {nullptr};
1527 int backends_supported_num = 0;
1528
1529 eGPUBackendType gpu_backend = GPU_BACKEND_NONE;
1530
1531 /* NOLINTBEGIN: bugprone-assignment-in-if-condition */
1532 if (false) {
1533 /* Just a dummy if to make the following ifdef blocks work. */
1534 }
1535# ifdef WITH_OPENGL_BACKEND
1536 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "opengl"))) {
1537 gpu_backend = GPU_BACKEND_OPENGL;
1538 }
1539# endif
1540# ifdef WITH_VULKAN_BACKEND
1541 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "vulkan"))) {
1542 gpu_backend = GPU_BACKEND_VULKAN;
1543 }
1544# endif
1545# ifdef WITH_METAL_BACKEND
1546 else if (STREQ(argv[1], (backends_supported[backends_supported_num++] = "metal"))) {
1547 gpu_backend = GPU_BACKEND_METAL;
1548 }
1549# endif
1550 else {
1551 fprintf(stderr, "\nError: Unrecognized GPU backend for '--gpu-backend', expected one of [");
1552 for (int i = 0; i < backends_supported_num; i++) {
1553 fprintf(stderr, (i + 1 != backends_supported_num) ? "%s, " : "%s", backends_supported[i]);
1554 }
1555 fprintf(stderr, "].\n");
1556 return 1;
1557 }
1558 /* NOLINTEND: bugprone-assignment-in-if-condition */
1559
1561
1562 return 1;
1563}
1564
1565# ifdef WITH_OPENGL_BACKEND
1566static const char arg_handle_gpu_compilation_subprocesses_set_doc[] =
1567 "\n"
1568 "\tOverride the Max Compilation Subprocesses setting (OpenGL only).";
1569static int arg_handle_gpu_compilation_subprocesses_set(int argc,
1570 const char **argv,
1571 void * /*data*/)
1572{
1573 const char *arg_id = "--gpu-compilation-subprocesses";
1574 const int min = 0, max = BLI_system_thread_count();
1575 if (argc > 1) {
1576 const char *err_msg = nullptr;
1577 int subprocesses;
1578 if (!parse_int_strict_range(argv[1], nullptr, min, max, &subprocesses, &err_msg)) {
1579 fprintf(stderr,
1580 "\nError: %s '%s %s', expected number in [%d..%d].\n",
1581 err_msg,
1582 arg_id,
1583 argv[1],
1584 min,
1585 max);
1586 return 0;
1587 }
1588
1590 return 1;
1591 }
1592 fprintf(stderr,
1593 "\nError: you must specify a number of subprocesses in [%d..%d] '%s'.\n",
1594 min,
1595 max,
1596 arg_id);
1597 return 0;
1598}
1599# endif
1600
1601static const char arg_handle_debug_fpe_set_doc[] =
1602 "\n\t"
1603 "Enable floating-point exceptions.";
1604static int arg_handle_debug_fpe_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1605{
1607 return 0;
1608}
1609
1610static const char arg_handle_app_template_doc[] =
1611 "<template>\n"
1612 "\tSet the application template (matching the directory name), use 'default' for none.";
1613static int arg_handle_app_template(int argc, const char **argv, void * /*data*/)
1614{
1615 if (argc > 1) {
1616 const char *app_template = STREQ(argv[1], "default") ? "" : argv[1];
1618 return 1;
1619 }
1620 fprintf(stderr, "\nError: App template must follow '--app-template'.\n");
1621 return 0;
1622}
1623
1625 "\n\t"
1626 "Skip reading the '" BLENDER_STARTUP_FILE "' in the users home directory.";
1627static int arg_handle_factory_startup_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1628{
1629 G.factory_startup = true;
1631 return 0;
1632}
1633
1635 "\n\t"
1636 "Enable event simulation testing feature 'bpy.types.Window.event_simulate'.";
1637static int arg_handle_enable_event_simulate(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1638{
1640 return 0;
1641}
1642
1644 "\n\t"
1645 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES) " environment variable.";
1647 "\n\t"
1648 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS) " environment variable.";
1650 "\n\t"
1651 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON) " environment variable.";
1653 "\n\t"
1654 "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_EXTENSIONS) " environment variable.";
1655
1656static int arg_handle_env_system_set(int argc, const char **argv, void * /*data*/)
1657{
1658 /* `--env-system-scripts` -> `BLENDER_SYSTEM_SCRIPTS` */
1659
1660 char env[64] = "BLENDER";
1661 char *ch_dst = env + 7; /* Skip `BLENDER`. */
1662 const char *ch_src = argv[0] + 5; /* Skip `--env`. */
1663
1664 if (argc < 2) {
1665 fprintf(stderr, "%s requires one argument\n", argv[0]);
1666 exit(EXIT_FAILURE);
1668 }
1669
1670 for (; *ch_src; ch_src++, ch_dst++) {
1671 *ch_dst = (*ch_src == '-') ? '_' : (*ch_src) - 32; /* Inline #toupper(). */
1672 }
1673
1674 *ch_dst = '\0';
1675 BLI_setenv(env, argv[1]);
1676 return 1;
1677}
1678
1679static const char arg_handle_playback_mode_doc[] =
1680 "<options> <file(s)>\n"
1681 "\tInstead of showing Blender's user interface, this runs Blender as an animation player,\n"
1682 "\tto view movies and image sequences rendered in Blender (ignored if '-b' is set).\n"
1683 "\n"
1684 "\tPlayback Arguments:\n"
1685 "\n"
1686 "\t-p <sx> <sy>\n"
1687 "\t\tOpen with lower left corner at <sx>, <sy>.\n"
1688 "\t-m\n"
1689 "\t\tRead from disk (Do not buffer).\n"
1690 "\t-f <fps> <fps_base>\n"
1691 "\t\tSpecify FPS to start with.\n"
1692 "\t-j <frame>\n"
1693 "\t\tSet frame step to <frame>.\n"
1694 "\t-s <frame>\n"
1695 "\t\tPlay from <frame>.\n"
1696 "\t-e <frame>\n"
1697 "\t\tPlay until <frame>.\n"
1698 "\t-c <cache_memory>\n"
1699 "\t\tAmount of memory in megabytes to allow for caching images during playback.\n"
1700 "\t\tZero disables (clamping to a fixed number of frames instead).";
1701static int arg_handle_playback_mode(int argc, const char **argv, void * /*data*/)
1702{
1703 /* Ignore the animation player if `-b` was given first. */
1704 if (G.background == 0) {
1705 /* Skip this argument (`-a`). */
1706 WM_main_playanim(argc - 1, argv + 1);
1707
1708 exit(EXIT_SUCCESS);
1709 }
1710
1711 return -2;
1712}
1713
1715 "<sx> <sy> <w> <h>\n"
1716 "\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>.";
1717static int arg_handle_window_geometry(int argc, const char **argv, void * /*data*/)
1718{
1719 const char *arg_id = "-p / --window-geometry";
1720 int params[4], i;
1721
1722 if (argc < 5) {
1723 fprintf(stderr, "Error: requires four arguments '%s'\n", arg_id);
1724 exit(1);
1725 }
1726
1727 for (i = 0; i < 4; i++) {
1728 const char *err_msg = nullptr;
1729 if (!parse_int(argv[i + 1], nullptr, &params[i], &err_msg)) {
1730 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1731 exit(1);
1732 }
1733 }
1734
1736
1737 return 4;
1738}
1739
1741 "\n\t"
1742 "Do not use native pixel size, for high resolution displays (MacBook 'Retina').";
1743static int arg_handle_native_pixels_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1744{
1745 WM_init_native_pixels(false);
1746 return 0;
1747}
1748
1749static const char arg_handle_with_borders_doc[] =
1750 "\n\t"
1751 "Force opening with borders.";
1752static int arg_handle_with_borders(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1753{
1755 return 0;
1756}
1757
1759 "\n\t"
1760 "Force opening in full-screen mode.";
1761static int arg_handle_without_borders(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1762{
1764 return 0;
1765}
1766
1768 "\n\t"
1769 "Force opening maximized.";
1770static int arg_handle_window_maximized(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1771{
1773 return 0;
1774}
1775
1777 "\n\t"
1778 "Open behind other windows and without taking focus.";
1779static int arg_handle_no_window_focus(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1780{
1782 return 0;
1783}
1784
1786 "\n\t"
1787 "Start with the console window open (ignored if '-b' is set), (Windows only).";
1788static int arg_handle_start_with_console(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1789{
1791 return 0;
1792}
1793
1794static bool arg_handle_extension_registration(const bool do_register, const bool all_users)
1795{
1796 /* Logic runs in #main_args_handle_registration. */
1797# ifdef WIN32
1798 /* This process has been launched with the permissions needed
1799 * to register or unregister, so just do it now and then exit. */
1800 if (do_register) {
1802 }
1803 else {
1805 }
1806 TerminateProcess(GetCurrentProcess(), 0);
1807 return true;
1808# else
1809 char *error_msg = nullptr;
1810 bool result = WM_platform_associate_set(do_register, all_users, &error_msg);
1811 if (error_msg) {
1812 fprintf(stderr, "Error: %s\n", error_msg);
1813 MEM_freeN(error_msg);
1814 }
1815 return result;
1816# endif
1817}
1818
1820 "\n\t"
1821 "Register blend-file extension for current user, then exit (Windows & Linux only).";
1822static int arg_handle_register_extension(int argc, const char **argv, void *data)
1823{
1824 G.quiet = true;
1826
1827# if !(defined(WIN32) && defined(__APPLE__))
1828 if (!main_arg_deferred_is_set()) {
1830 return argc - 1;
1831 }
1832# endif
1834 return argc - 1;
1835}
1836
1838 "\n\t"
1839 "Register blend-file extension for all users, then exit (Windows & Linux only).";
1840static int arg_handle_register_extension_all(int argc, const char **argv, void *data)
1841{
1842 G.quiet = true;
1844
1845# if !(defined(WIN32) && defined(__APPLE__))
1846 if (!main_arg_deferred_is_set()) {
1848 return argc - 1;
1849 }
1850# endif
1852 return argc - 1;
1853}
1854
1856 "\n\t"
1857 "Unregister blend-file extension for current user, then exit (Windows & Linux only).";
1858static int arg_handle_unregister_extension(int argc, const char **argv, void *data)
1859{
1860 G.quiet = true;
1862
1863# if !(defined(WIN32) && defined(__APPLE__))
1864 if (!main_arg_deferred_is_set()) {
1866 return argc - 1;
1867 }
1868# endif
1870 return 0;
1871}
1872
1874 "\n\t"
1875 "Unregister blend-file extension for all users, then exit (Windows & Linux only).";
1876static int arg_handle_unregister_extension_all(int argc, const char **argv, void *data)
1877{
1878 G.quiet = true;
1880
1881# if !(defined(WIN32) && defined(__APPLE__))
1882 if (!main_arg_deferred_is_set()) {
1884 return argc - 1;
1885 }
1886# endif
1888 return 0;
1889}
1890
1891static const char arg_handle_audio_disable_doc[] =
1892 "\n\t"
1893 "Force sound system to None.";
1894static int arg_handle_audio_disable(int /*argc*/, const char ** /*argv*/, void * /*data*/)
1895{
1896 BKE_sound_force_device("None");
1897 return 0;
1898}
1899
1900static const char arg_handle_audio_set_doc[] =
1901 "\n\t"
1902 "Force sound system to a specific device.\n"
1903 "\t'None' 'Default' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'.";
1904static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/)
1905{
1906 if (argc < 1) {
1907 fprintf(stderr, "-setaudio requires one argument\n");
1908 exit(1);
1909 }
1910
1911 const char *device = argv[1];
1912 if (STREQ(device, "Default")) {
1913 /* Unset any forced device. */
1914 device = nullptr;
1915 }
1916
1917 BKE_sound_force_device(device);
1918 return 1;
1919}
1920
1921static const char arg_handle_output_set_doc[] =
1922 "<path>\n"
1923 "\tSet the render path and file name.\n"
1924 "\tUse '//' at the start of the path to render relative to the blend-file.\n"
1925 "\n"
1926 "\tYou can use path templating features such as '{blend_name}' in the path.\n"
1927 "\tSee Blender's documentation on path templates for more details.\n"
1928 "\n"
1929 "\tThe '#' characters are replaced by the frame number, and used to define zero padding.\n"
1930 "\n"
1931 "\t* 'animation_##_test.png' becomes 'animation_01_test.png'\n"
1932 "\t* 'test-######.png' becomes 'test-000001.png'\n"
1933 "\n"
1934 "\tWhen the filename does not contain '#', the suffix '####' is added to the filename.\n"
1935 "\n"
1936 "\tThe frame number will be added at the end of the filename, eg:\n"
1937 "\t# blender -b animation.blend -o //render_ -F PNG -x 1 -a\n"
1938 "\t'//render_' becomes '//render_####', writing frames as '//render_0001.png'";
1939static int arg_handle_output_set(int argc, const char **argv, void *data)
1940{
1941 bContext *C = static_cast<bContext *>(data);
1942 if (argc > 1) {
1944 if (scene) {
1945 STRNCPY(scene->r.pic, argv[1]);
1947 }
1948 else {
1949 fprintf(stderr, "\nError: no blend loaded. cannot use '-o / --render-output'.\n");
1950 }
1951 return 1;
1952 }
1953 fprintf(stderr, "\nError: you must specify a path after '-o / --render-output'.\n");
1954 return 0;
1955}
1956
1957static const char arg_handle_engine_set_doc[] =
1958 "<engine>\n"
1959 "\tSpecify the render engine.\n"
1960 "\tUse '-E help' to list available engines.";
1961static int arg_handle_engine_set(int argc, const char **argv, void *data)
1962{
1963 bContext *C = static_cast<bContext *>(data);
1964 if (argc >= 2) {
1965 if (STREQ(argv[1], "help")) {
1966 printf("Blender Engine Listing:\n");
1968 printf("\t%s\n", type->idname);
1969 }
1970 exit(0);
1971 }
1972 else {
1974 if (scene) {
1975 if (BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) {
1976 STRNCPY_UTF8(scene->r.engine, argv[1]);
1978 }
1979 else {
1980 fprintf(stderr, "\nError: engine not found '%s'\n", argv[1]);
1981 exit(1);
1982 }
1983 }
1984 else {
1985 fprintf(stderr,
1986 "\nError: no blend loaded. "
1987 "order the arguments so '-E / --engine' is after a blend is loaded.\n");
1988 }
1989 }
1990
1991 return 1;
1992 }
1993 fprintf(stderr, "\nEngine not specified, give 'help' for a list of available engines.\n");
1994 return 0;
1995}
1996
1998 "<format>\n"
1999 "\tSet the render format.\n"
2000 "\tValid options are:\n"
2001 "\t'TGA' 'RAWTGA' 'JPEG' 'IRIS' 'AVIRAW' 'AVIJPEG' 'PNG' 'BMP' 'HDR' 'TIFF'.\n"
2002 "\n"
2003 "\tFormats that can be compiled into Blender, not available on all systems:\n"
2004 "\t'OPEN_EXR' 'OPEN_EXR_MULTILAYER' 'FFMPEG' 'CINEON' 'DPX' 'JP2' 'WEBP'.";
2005static int arg_handle_image_type_set(int argc, const char **argv, void *data)
2006{
2007 bContext *C = static_cast<bContext *>(data);
2008 if (argc > 1) {
2009 const char *imtype = argv[1];
2011 if (scene) {
2012 const char imtype_new = BKE_imtype_from_arg(imtype);
2013
2014 if (imtype_new == R_IMF_IMTYPE_INVALID) {
2015 fprintf(stderr,
2016 "\nError: Format from '-F / --render-format' not known or not compiled in this "
2017 "release.\n");
2018 }
2019 else {
2020 BKE_image_format_set(&scene->r.im_format, &scene->id, imtype_new);
2022 }
2023 }
2024 else {
2025 fprintf(stderr,
2026 "\nError: no blend loaded. "
2027 "order the arguments so '-F / --render-format' is after the blend is loaded.\n");
2028 }
2029 return 1;
2030 }
2031 fprintf(stderr, "\nError: you must specify a format after '-F / --render-format'.\n");
2032 return 0;
2033}
2034
2035static const char arg_handle_threads_set_doc[] =
2036 "<threads>\n"
2037 "\tUse amount of <threads> for rendering and other operations\n"
2038 "\t[1-" STRINGIFY(BLENDER_MAX_THREADS) "], 0 to use the systems processor count.";
2039static int arg_handle_threads_set(int argc, const char **argv, void * /*data*/)
2040{
2041 const char *arg_id = "-t / --threads";
2042 const int min = 0, max = BLENDER_MAX_THREADS;
2043 if (argc > 1) {
2044 const char *err_msg = nullptr;
2045 int threads;
2046 if (!parse_int_strict_range(argv[1], nullptr, min, max, &threads, &err_msg)) {
2047 fprintf(stderr,
2048 "\nError: %s '%s %s', expected number in [%d..%d].\n",
2049 err_msg,
2050 arg_id,
2051 argv[1],
2052 min,
2053 max);
2054 return 1;
2055 }
2056
2058 return 1;
2059 }
2060 fprintf(stderr,
2061 "\nError: you must specify a number of threads in [%d..%d] '%s'.\n",
2062 min,
2063 max,
2064 arg_id);
2065 return 0;
2066}
2067
2068static const char arg_handle_verbosity_set_doc[] =
2069 "<verbose>\n"
2070 "\tSet the logging verbosity level for debug messages that support it.";
2071static int arg_handle_verbosity_set(int argc, const char **argv, void * /*data*/)
2072{
2073 const char *arg_id = "--verbose";
2074 if (argc > 1) {
2075 const char *err_msg = nullptr;
2076 int level;
2077 if (!parse_int(argv[1], nullptr, &level, &err_msg)) {
2078 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2079 }
2080
2081# ifdef WITH_LIBMV
2083# elif defined(WITH_CYCLES_LOGGING)
2085# else
2086 (void)level;
2087# endif
2088
2089 return 1;
2090 }
2091 fprintf(stderr, "\nError: you must specify a verbosity level.\n");
2092 return 0;
2093}
2094
2095static const char arg_handle_extension_set_doc[] =
2096 "<bool>\n"
2097 "\tSet option to add the file extension to the end of the file.";
2098static int arg_handle_extension_set(int argc, const char **argv, void *data)
2099{
2100 bContext *C = static_cast<bContext *>(data);
2101 if (argc > 1) {
2103 if (scene) {
2104 if (argv[1][0] == '0') {
2105 scene->r.scemode &= ~R_EXTENSION;
2107 }
2108 else if (argv[1][0] == '1') {
2111 }
2112 else {
2113 fprintf(stderr,
2114 "\nError: Use '-x 1 / -x 0' To set the extension option or '--use-extension'\n");
2115 }
2116 }
2117 else {
2118 fprintf(stderr,
2119 "\nError: no blend loaded. "
2120 "order the arguments so '-o ' is after '-x '.\n");
2121 }
2122 return 1;
2123 }
2124 fprintf(stderr, "\nError: you must specify a path after '- '.\n");
2125 return 0;
2126}
2127
2128static const char arg_handle_render_frame_doc[] =
2129 "<frame>\n"
2130 "\tRender frame <frame> and save it.\n"
2131 "\n"
2132 "\t* +<frame> start frame relative, -<frame> end frame relative.\n"
2133 "\t* A comma separated list of frames can also be used (no spaces).\n"
2134 "\t* A range of frames can be expressed using '..' separator between the first and last "
2135 "frames (inclusive).\n";
2136static int arg_handle_render_frame(int argc, const char **argv, void *data)
2137{
2138 const char *arg_id = "-f / --render-frame";
2139 bContext *C = static_cast<bContext *>(data);
2141 if (scene) {
2142 Main *bmain = CTX_data_main(C);
2143
2144 if (argc > 1) {
2145 const char *err_msg = nullptr;
2146 Render *re;
2147 ReportList reports;
2148
2149 int(*frame_range_arr)[2], frames_range_len;
2150 if ((frame_range_arr = parse_int_range_relative_clamp_n(argv[1],
2151 scene->r.sfra,
2152 scene->r.efra,
2153 MINAFRAME,
2154 MAXFRAME,
2155 &frames_range_len,
2156 &err_msg)) == nullptr)
2157 {
2158 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2159 return 1;
2160 }
2161
2163 BKE_reports_init(&reports, RPT_STORE);
2164 RE_SetReports(re, &reports);
2165 for (int i = 0; i < frames_range_len; i++) {
2166 /* We could pass in frame ranges,
2167 * but prefer having exact behavior as passing in multiple frames. */
2168 if ((frame_range_arr[i][0] <= frame_range_arr[i][1]) == 0) {
2169 fprintf(stderr, "\nWarning: negative range ignored '%s %s'.\n", arg_id, argv[1]);
2170 }
2171
2172 for (int frame = frame_range_arr[i][0]; frame <= frame_range_arr[i][1]; frame++) {
2173 RE_RenderAnim(re, bmain, scene, nullptr, nullptr, frame, frame, scene->r.frame_step);
2174 }
2175 }
2176 RE_SetReports(re, nullptr);
2177 BKE_reports_free(&reports);
2178 MEM_freeN(frame_range_arr);
2179 return 1;
2180 }
2181 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2182 return 0;
2183 }
2184 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2185 return 0;
2186}
2187
2189 "\n\t"
2190 "Render frames from start to end (inclusive).";
2191static int arg_handle_render_animation(int /*argc*/, const char ** /*argv*/, void *data)
2192{
2193 bContext *C = static_cast<bContext *>(data);
2195 if (scene) {
2196 Main *bmain = CTX_data_main(C);
2198 ReportList reports;
2199 BKE_reports_init(&reports, RPT_STORE);
2200 RE_SetReports(re, &reports);
2202 re, bmain, scene, nullptr, nullptr, scene->r.sfra, scene->r.efra, scene->r.frame_step);
2203 RE_SetReports(re, nullptr);
2204 BKE_reports_free(&reports);
2205 }
2206 else {
2207 fprintf(stderr, "\nError: no blend loaded. cannot use '-a'.\n");
2208 }
2209 return 0;
2210}
2211
2212static const char arg_handle_scene_set_doc[] =
2213 "<name>\n"
2214 "\tSet the active scene <name> for rendering.";
2215static int arg_handle_scene_set(int argc, const char **argv, void *data)
2216{
2217 if (argc > 1) {
2218 bContext *C = static_cast<bContext *>(data);
2220 if (scene) {
2222
2223 /* Set the scene of the first window, see: #55991,
2224 * otherwise scripts that run later won't get this scene back from the context. */
2225 wmWindow *win = CTX_wm_window(C);
2226 if (win == nullptr) {
2227 win = static_cast<wmWindow *>(CTX_wm_manager(C)->windows.first);
2228 }
2229 if (win != nullptr) {
2231 }
2232 }
2233 return 1;
2234 }
2235 fprintf(stderr, "\nError: Scene name must follow '-S / --scene'.\n");
2236 return 0;
2237}
2238
2240 "<frame>\n"
2241 "\tSet start to frame <frame>, supports +/- for relative frames too.";
2242static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
2243{
2244 const char *arg_id = "-s / --frame-start";
2245 bContext *C = static_cast<bContext *>(data);
2247 if (scene) {
2248 if (argc > 1) {
2249 const char *err_msg = nullptr;
2250 if (!parse_int_relative_clamp(argv[1],
2251 nullptr,
2252 scene->r.sfra,
2253 scene->r.sfra - 1,
2254 MINAFRAME,
2255 MAXFRAME,
2256 &scene->r.sfra,
2257 &err_msg))
2258 {
2259 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2260 }
2261 else {
2263 }
2264 return 1;
2265 }
2266 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2267 return 0;
2268 }
2269 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2270 return 0;
2271}
2272
2273static const char arg_handle_frame_end_set_doc[] =
2274 "<frame>\n"
2275 "\tSet end to frame <frame>, supports +/- for relative frames too.";
2276static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
2277{
2278 const char *arg_id = "-e / --frame-end";
2279 bContext *C = static_cast<bContext *>(data);
2281 if (scene) {
2282 if (argc > 1) {
2283 const char *err_msg = nullptr;
2284 if (!parse_int_relative_clamp(argv[1],
2285 nullptr,
2286 scene->r.efra,
2287 scene->r.efra - 1,
2288 MINAFRAME,
2289 MAXFRAME,
2290 &scene->r.efra,
2291 &err_msg))
2292 {
2293 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2294 }
2295 else {
2297 }
2298 return 1;
2299 }
2300 fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
2301 return 0;
2302 }
2303 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2304 return 0;
2305}
2306
2308 "<frames>\n"
2309 "\tSet number of frames to step forward after each rendered frame.";
2310static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
2311{
2312 const char *arg_id = "-j / --frame-jump";
2313 bContext *C = static_cast<bContext *>(data);
2315 if (scene) {
2316 if (argc > 1) {
2317 const char *err_msg = nullptr;
2318 if (!parse_int_clamp(argv[1], nullptr, 1, MAXFRAME, &scene->r.frame_step, &err_msg)) {
2319 fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
2320 }
2321 else {
2323 }
2324 return 1;
2325 }
2326 fprintf(stderr, "\nError: number of frames to step must follow '%s'.\n", arg_id);
2327 return 0;
2328 }
2329 fprintf(stderr, "\nError: no blend loaded. cannot use '%s'.\n", arg_id);
2330 return 0;
2331}
2332
2334 "<filepath>\n"
2335 "\tRun the given Python script file.";
2336static int arg_handle_python_file_run(int argc, const char **argv, void *data)
2337{
2338 bContext *C = static_cast<bContext *>(data);
2339
2340 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2341 if (argc > 1) {
2342# ifdef WITH_PYTHON
2343 /* Make the path absolute because its needed for relative linked blends to be found. */
2344 char filepath[FILE_MAX];
2345 STRNCPY(filepath, argv[1]);
2346 BLI_path_canonicalize_native(filepath, sizeof(filepath));
2347
2348 bool ok;
2349 BPY_CTX_SETUP(ok = BPY_run_filepath(C, filepath, nullptr));
2350 if (!ok && app_state.exit_code_on_error.python) {
2351 fprintf(stderr, "\nError: script failed, file: '%s', exiting.\n", argv[1]);
2353 }
2354# else
2355 UNUSED_VARS(C);
2356 fprintf(stderr, "This Blender was built without Python support\n");
2357# endif /* WITH_PYTHON */
2358
2359 return 1;
2360 }
2361 fprintf(stderr, "\nError: you must specify a filepath after '%s'.\n", argv[0]);
2362 return 0;
2363}
2364
2366 "<name>\n"
2367 "\tRun the given Python script text block.";
2368static int arg_handle_python_text_run(int argc, const char **argv, void *data)
2369{
2370 bContext *C = static_cast<bContext *>(data);
2371
2372 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2373 if (argc > 1) {
2374# ifdef WITH_PYTHON
2375 Main *bmain = CTX_data_main(C);
2376 /* Make the path absolute because its needed for relative linked blends to be found. */
2377 Text *text = (Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
2378 bool ok;
2379
2380 if (text) {
2381 BPY_CTX_SETUP(ok = BPY_run_text(C, text, nullptr, false));
2382 }
2383 else {
2384 fprintf(stderr, "\nError: text block not found %s.\n", argv[1]);
2385 ok = false;
2386 }
2387
2388 if (!ok && app_state.exit_code_on_error.python) {
2389 fprintf(stderr, "\nError: script failed, text: '%s', exiting.\n", argv[1]);
2391 }
2392# else
2393 UNUSED_VARS(C);
2394 fprintf(stderr, "This Blender was built without Python support\n");
2395# endif /* WITH_PYTHON */
2396
2397 return 1;
2398 }
2399
2400 fprintf(stderr, "\nError: you must specify a text block after '%s'.\n", argv[0]);
2401 return 0;
2402}
2403
2405 "<expression>\n"
2406 "\tRun the given expression as a Python script.";
2407static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
2408{
2409 bContext *C = static_cast<bContext *>(data);
2410
2411 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2412 if (argc > 1) {
2413# ifdef WITH_PYTHON
2414 bool ok;
2415 BPY_CTX_SETUP(ok = BPY_run_string_exec(C, nullptr, argv[1]));
2416 if (!ok && app_state.exit_code_on_error.python) {
2417 fprintf(stderr, "\nError: script failed, expr: '%s', exiting.\n", argv[1]);
2419 }
2420# else
2421 UNUSED_VARS(C);
2422 fprintf(stderr, "This Blender was built without Python support\n");
2423# endif /* WITH_PYTHON */
2424
2425 return 1;
2426 }
2427 fprintf(stderr, "\nError: you must specify a Python expression after '%s'.\n", argv[0]);
2428 return 0;
2429}
2430
2432 "\n\t"
2433 "Run Blender with an interactive console.";
2434static int arg_handle_python_console_run(int /*argc*/, const char ** /*argv*/, void *data)
2435{
2436 bContext *C = static_cast<bContext *>(data);
2437# ifdef WITH_PYTHON
2438 const char *imports[] = {"code", nullptr};
2439 BPY_CTX_SETUP(BPY_run_string_eval(C, imports, "code.interact()"));
2440# else
2441 UNUSED_VARS(C);
2442 fprintf(stderr, "This Blender was built without python support\n");
2443# endif /* WITH_PYTHON */
2444
2445 return 0;
2446}
2447
2449 "<code>\n"
2450 "\tSet the exit-code in [0..255] to exit if a Python exception is raised\n"
2451 "\t(only for scripts executed from the command line), zero disables.";
2452static int arg_handle_python_exit_code_set(int argc, const char **argv, void * /*data*/)
2453{
2454 const char *arg_id = "--python-exit-code";
2455 if (argc > 1) {
2456 const char *err_msg = nullptr;
2457 const int min = 0, max = 255;
2458 int exit_code;
2459 if (!parse_int_strict_range(argv[1], nullptr, min, max, &exit_code, &err_msg)) {
2460 fprintf(stderr,
2461 "\nError: %s '%s %s', expected number in [%d..%d].\n",
2462 err_msg,
2463 arg_id,
2464 argv[1],
2465 min,
2466 max);
2467 return 1;
2468 }
2469
2471 return 1;
2472 }
2473 fprintf(stderr, "\nError: you must specify an exit code number '%s'.\n", arg_id);
2474 return 0;
2475}
2476
2478 "\n\t"
2479 "Allow Python to use system environment variables such as 'PYTHONPATH' and the user "
2480 "site-packages directory.";
2482 const char ** /*argv*/,
2483 void * /*data*/)
2484{
2485# ifdef WITH_PYTHON
2487# endif
2488 return 0;
2489}
2490
2491static const char arg_handle_addons_set_doc[] =
2492 "<addon(s)>\n"
2493 "\tComma separated list (no spaces) of add-ons to enable in addition to any default add-ons.";
2494static int arg_handle_addons_set(int argc, const char **argv, void *data)
2495{
2496 /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */
2497 if (argc > 1) {
2498# ifdef WITH_PYTHON
2499 const char script_str[] =
2500 "from _bpy_internal.addons.cli import set_from_cli\n"
2501 "set_from_cli('%s')";
2502 const int slen = strlen(argv[1]) + (sizeof(script_str) - 2);
2503 char *str = static_cast<char *>(malloc(slen));
2504 bContext *C = static_cast<bContext *>(data);
2505 BLI_snprintf(str, slen, script_str, argv[1]);
2506
2507 BLI_assert(strlen(str) + 1 == slen);
2508 BPY_CTX_SETUP(BPY_run_string_exec(C, nullptr, str));
2509 free(str);
2510# else
2511 UNUSED_VARS(argv, data);
2512# endif /* WITH_PYTHON */
2513 return 1;
2514 }
2515 fprintf(stderr, "\nError: you must specify a comma separated list after '--addons'.\n");
2516 return 0;
2517}
2518
2520 "\n"
2521 "\tEnable CPU & GPU performance profiling for GPU debug groups\n"
2522 "\t(Outputs a profile.json file in the Trace Event Format to the current directory)";
2523static int arg_handle_profile_gpu_set(int /*argc*/, const char ** /*argv*/, void * /*data*/)
2524{
2525 G.profile_gpu = true;
2526 return 0;
2527}
2528
2533static bool handle_load_file(bContext *C, const char *filepath_arg, const bool load_empty_file)
2534{
2535 /* Make the path absolute because its needed for relative linked blends to be found. */
2536 char filepath[FILE_MAX];
2537 STRNCPY(filepath, filepath_arg);
2538 BLI_path_canonicalize_native(filepath, sizeof(filepath));
2539
2540 /* Load the file. */
2541 ReportList reports;
2542 BKE_reports_init(&reports, RPT_PRINT);
2543 /* When activating from the command line there isn't an exact equivalent to operator properties.
2544 * Instead, enabling auto-execution via `--enable-autoexec` causes the auto-execution
2545 * check to be skipped (if it's set), so it's fine to always enable the check here. */
2546 const bool use_scripts_autoexec_check = true;
2547 const bool success = WM_file_read(C, filepath, use_scripts_autoexec_check, &reports);
2548 BKE_reports_free(&reports);
2549
2550 if (success) {
2551 if (G.background) {
2552 /* Ensure we use 'C->data.scene' for background render. */
2553 CTX_wm_window_set(C, nullptr);
2554 }
2555 }
2556 else {
2557 /* Failed to load file, stop processing arguments if running in background mode. */
2558 if (G.background) {
2559 /* Set `is_break` if running in the background mode so
2560 * blender will return non-zero exit code which then
2561 * could be used in automated script to control how
2562 * good or bad things are. */
2563 G.is_break = true;
2564 return false;
2565 }
2566
2567 const char *error_msg_generic = "file could not be loaded";
2568 const char *error_msg = nullptr;
2569
2570 if (load_empty_file == false) {
2571 error_msg = error_msg_generic;
2572 }
2573 else if (BLI_exists(filepath)) {
2574 /* When a file is found but can't be loaded, handling it as a new file
2575 * could cause it to be unintentionally overwritten (data loss).
2576 * Further this is almost certainly not that a user would expect or want.
2577 * If they do, they can delete the file beforehand. */
2578 error_msg = error_msg_generic;
2579 }
2580 else if (!BKE_blendfile_extension_check(filepath)) {
2581 /* Unrelated arguments should not be treated as new blend files. */
2582 error_msg = "argument has no '.blend' file extension, not using as new file";
2583 }
2584
2585 if (error_msg) {
2586 fprintf(stderr, "Error: %s, exiting! %s\n", error_msg, filepath);
2587 WM_exit(C, EXIT_FAILURE);
2588 /* Unreachable, return for clarity. */
2589 return false;
2590 }
2591
2592 /* Behave as if a file was loaded, calling "Save" will write to the `filepath` from the CLI.
2593 *
2594 * WARNING: The path referenced may be incorrect, no attempt is made to validate the path
2595 * here or check that writing to it will work. If the users enters the path of a directory
2596 * that doesn't exist (for example) saving will fail.
2597 * Attempting to create the file at this point is possible but likely to cause more
2598 * trouble than it's worth (what with network drives), removable devices ... etc. */
2599
2600 STRNCPY(G_MAIN->filepath, filepath);
2601 printf("... opened default scene instead; saving will write to: %s\n", filepath);
2602 }
2603
2604 return true;
2605}
2606
2607int main_args_handle_load_file(int /*argc*/, const char **argv, void *data)
2608{
2609 bContext *C = static_cast<bContext *>(data);
2610 const char *filepath = argv[0];
2611
2612 /* NOTE: we could skip these, but so far we always tried to load these files. */
2613 if (argv[0][0] == '-') {
2614 fprintf(stderr, "unknown argument, loading as file: %s\n", filepath);
2615 }
2616
2617 if (!handle_load_file(C, filepath, true)) {
2618 return -1;
2619 }
2620 return 0;
2621}
2622
2624 "\n\t"
2625 "Open the most recently opened blend file, instead of the default startup file.";
2626static int arg_handle_load_last_file(int /*argc*/, const char ** /*argv*/, void *data)
2627{
2628 if (BLI_listbase_is_empty(&G.recent_files)) {
2629 fprintf(stderr, "Warning: no recent files known, opening default startup file instead.\n");
2630 return -1;
2631 }
2632
2633 bContext *C = static_cast<bContext *>(data);
2634 const RecentFile *recent_file = static_cast<const RecentFile *>(G.recent_files.first);
2635 if (!handle_load_file(C, recent_file->filepath, false)) {
2636 return -1;
2637 }
2638 return 0;
2639}
2640
2642{
2644# define CB(a) a##_doc, a
2646# define CB_EX(a, b) a##_doc_##b, a
2648# define CB_ALL(a) (all ? a##_doc_all : a##_doc), a
2649
2650 BuildDefs defs;
2651 build_defs_init(&defs, all);
2652
2653 /* end argument processing after -- */
2654 BLI_args_pass_set(ba, -1);
2655 BLI_args_add(ba, "--", nullptr, CB(arg_handle_arguments_end), nullptr);
2656
2657 /* Pass: Environment Setup
2658 *
2659 * It's important these run before any initialization is done, since they set up
2660 * the environment used to access data-files, which are be used when initializing
2661 * sub-systems such as color management. */
2664 ba, nullptr, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), nullptr);
2665
2666 /* Note that we could add used environment variables too. */
2668 ba, nullptr, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), nullptr);
2670 ba, nullptr, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), nullptr);
2672 ba, nullptr, "--env-system-python", CB_EX(arg_handle_env_system_set, python), nullptr);
2673 BLI_args_add(ba,
2674 nullptr,
2675 "--env-system-extensions",
2676 CB_EX(arg_handle_env_system_set, extensions),
2677 nullptr);
2678
2679 BLI_args_add(ba, "-t", "--threads", CB(arg_handle_threads_set), nullptr);
2680
2681 /* Include in the environment pass so it's possible display errors initializing subsystems,
2682 * especially `bpy.appdir` since it's useful to show errors finding paths on startup. */
2683 BLI_args_add(ba, nullptr, "--log", CB(arg_handle_log_set), ba);
2684 BLI_args_add(ba, nullptr, "--log-level", CB(arg_handle_log_level_set), ba);
2685 BLI_args_add(ba, nullptr, "--log-show-basename", CB(arg_handle_log_show_basename_set), ba);
2686 BLI_args_add(ba, nullptr, "--log-show-backtrace", CB(arg_handle_log_show_backtrace_set), ba);
2687 BLI_args_add(ba, nullptr, "--log-show-timestamp", CB(arg_handle_log_show_timestamp_set), ba);
2688 BLI_args_add(ba, nullptr, "--log-file", CB(arg_handle_log_file_set), ba);
2689
2690 /* GPU backend selection should be part of #ARG_PASS_ENVIRONMENT for correct GPU context
2691 * selection for animation player. */
2692 BLI_args_add(ba, nullptr, "--gpu-backend", CB_ALL(arg_handle_gpu_backend_set), nullptr);
2693# ifdef WITH_OPENGL_BACKEND
2694 BLI_args_add(ba,
2695 nullptr,
2696 "--gpu-compilation-subprocesses",
2697 CB(arg_handle_gpu_compilation_subprocesses_set),
2698 nullptr);
2699# endif
2700 BLI_args_add(ba, nullptr, "--profile-gpu", CB(arg_handle_profile_gpu_set), nullptr);
2701
2702 /* Pass: Background Mode & Settings
2703 *
2704 * Also and commands that exit after usage. */
2706 BLI_args_add(ba, "-h", "--help", CB(arg_handle_print_help), ba);
2707 /* MS-Windows only. */
2708 BLI_args_add(ba, "/?", nullptr, CB_EX(arg_handle_print_help, win32), ba);
2709
2710 BLI_args_add(ba, "-v", "--version", CB(arg_handle_print_version), nullptr);
2711
2712 BLI_args_add(ba, "-y", "--enable-autoexec", CB_EX(arg_handle_python_set, enable), (void *)true);
2714 ba, "-Y", "--disable-autoexec", CB_EX(arg_handle_python_set, disable), (void *)false);
2715
2717 ba, nullptr, "--offline-mode", CB_EX(arg_handle_internet_allow_set, offline), (void *)false);
2719 ba, nullptr, "--online-mode", CB_EX(arg_handle_internet_allow_set, online), (void *)true);
2720
2722 ba, nullptr, "--disable-crash-handler", CB(arg_handle_crash_handler_disable), nullptr);
2724 ba, nullptr, "--disable-abort-handler", CB(arg_handle_abort_handler_disable), nullptr);
2725
2726 BLI_args_add(ba, "-q", "--quiet", CB(arg_handle_quiet_set), nullptr);
2727 BLI_args_add(ba, "-b", "--background", CB(arg_handle_background_mode_set), nullptr);
2728 /* Command implies background mode (defers execution). */
2729 BLI_args_add(ba, "-c", "--command", CB(arg_handle_command_set), C);
2730
2731 BLI_args_add(ba,
2732 nullptr,
2733 "--disable-depsgraph-on-file-load",
2735 nullptr);
2736
2737 BLI_args_add(ba,
2738 nullptr,
2739 "--disable-liboverride-auto-resync",
2741 nullptr);
2742
2743 BLI_args_add(ba, "-a", nullptr, CB(arg_handle_playback_mode), nullptr);
2744
2745 BLI_args_add(ba, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);
2746
2747 if (defs.with_ffmpeg) {
2748 BLI_args_add(ba,
2749 nullptr,
2750 "--debug-ffmpeg",
2752 (void *)G_DEBUG_FFMPEG);
2753 }
2754
2755 if (defs.with_freestyle) {
2756 BLI_args_add(ba,
2757 nullptr,
2758 "--debug-freestyle",
2760 (void *)G_DEBUG_FREESTYLE);
2761 }
2762 BLI_args_add(ba,
2763 nullptr,
2764 "--debug-python",
2766 (void *)G_DEBUG_PYTHON);
2767 BLI_args_add(ba,
2768 nullptr,
2769 "--debug-events",
2771 (void *)G_DEBUG_EVENTS);
2772 BLI_args_add(ba,
2773 nullptr,
2774 "--debug-handlers",
2776 (void *)G_DEBUG_HANDLERS);
2778 ba, nullptr, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
2779 if (defs.with_xr_openxr) {
2780 BLI_args_add(ba,
2781 nullptr,
2782 "--debug-xr",
2784 (void *)G_DEBUG_XR);
2785 BLI_args_add(ba,
2786 nullptr,
2787 "--debug-xr-time",
2789 (void *)G_DEBUG_XR_TIME);
2790 }
2791 BLI_args_add(ba,
2792 nullptr,
2793 "--debug-ghost",
2795 (void *)G_DEBUG_GHOST);
2796 BLI_args_add(ba,
2797 nullptr,
2798 "--debug-wintab",
2800 (void *)G_DEBUG_WINTAB);
2801 BLI_args_add(ba, nullptr, "--debug-all", CB(arg_handle_debug_mode_all), nullptr);
2802
2803 BLI_args_add(ba, nullptr, "--debug-io", CB(arg_handle_debug_mode_io), nullptr);
2804
2805 BLI_args_add(ba, nullptr, "--debug-fpe", CB(arg_handle_debug_fpe_set), nullptr);
2806
2807 if (defs.with_libmv) {
2808 BLI_args_add(ba, nullptr, "--debug-libmv", CB(arg_handle_debug_mode_libmv), nullptr);
2809 }
2810 if (defs.with_cycles_logging) {
2811 BLI_args_add(ba, nullptr, "--debug-cycles", CB(arg_handle_debug_mode_cycles), nullptr);
2812 }
2813 BLI_args_add(ba, nullptr, "--debug-memory", CB(arg_handle_debug_mode_memory_set), nullptr);
2814
2815 BLI_args_add(ba, nullptr, "--debug-value", CB(arg_handle_debug_value_set), nullptr);
2816 BLI_args_add(ba,
2817 nullptr,
2818 "--debug-jobs",
2820 (void *)G_DEBUG_JOBS);
2821 BLI_args_add(ba, nullptr, "--debug-gpu", CB(arg_handle_debug_gpu_set), nullptr);
2822 BLI_args_add(ba,
2823 nullptr,
2824 "--debug-gpu-compile-shaders",
2826 nullptr);
2827 if (defs.with_renderdoc) {
2828 BLI_args_add(ba,
2829 nullptr,
2830 "--debug-gpu-scope-capture",
2832 nullptr);
2834 ba, nullptr, "--debug-gpu-renderdoc", CB(arg_handle_debug_gpu_renderdoc_set), nullptr);
2835 }
2836
2837 BLI_args_add(ba,
2838 nullptr,
2839 "--debug-depsgraph",
2841 (void *)G_DEBUG_DEPSGRAPH);
2842 BLI_args_add(ba,
2843 nullptr,
2844 "--debug-depsgraph-build",
2845 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
2846 (void *)G_DEBUG_DEPSGRAPH_BUILD);
2847 BLI_args_add(ba,
2848 nullptr,
2849 "--debug-depsgraph-eval",
2851 (void *)G_DEBUG_DEPSGRAPH_EVAL);
2852 BLI_args_add(ba,
2853 nullptr,
2854 "--debug-depsgraph-tag",
2856 (void *)G_DEBUG_DEPSGRAPH_TAG);
2857 BLI_args_add(ba,
2858 nullptr,
2859 "--debug-depsgraph-time",
2861 (void *)G_DEBUG_DEPSGRAPH_TIME);
2862 BLI_args_add(ba,
2863
2864 nullptr,
2865 "--debug-depsgraph-no-threads",
2866 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads),
2868 BLI_args_add(ba,
2869 nullptr,
2870 "--debug-depsgraph-pretty",
2871 CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty),
2872 (void *)G_DEBUG_DEPSGRAPH_PRETTY);
2873 BLI_args_add(ba,
2874 nullptr,
2875 "--debug-depsgraph-uid",
2877 (void *)G_DEBUG_DEPSGRAPH_UID);
2878 BLI_args_add(ba,
2879 nullptr,
2880 "--debug-gpu-force-workarounds",
2881 CB_EX(arg_handle_debug_mode_generic_set, gpu_force_workarounds),
2883# ifdef WITH_VULKAN_BACKEND
2884 BLI_args_add(ba,
2885 nullptr,
2886 "--debug-gpu-vulkan-local-read",
2887 CB_EX(arg_handle_debug_mode_generic_set, gpu_force_vulkan_local_read),
2889# endif
2890 BLI_args_add(ba, nullptr, "--debug-exit-on-error", CB(arg_handle_debug_exit_on_error), nullptr);
2891
2892 BLI_args_add(ba, nullptr, "--verbose", CB(arg_handle_verbosity_set), nullptr);
2893
2894 BLI_args_add(ba, nullptr, "--app-template", CB(arg_handle_app_template), nullptr);
2895 BLI_args_add(ba, nullptr, "--factory-startup", CB(arg_handle_factory_startup_set), nullptr);
2897 ba, nullptr, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), nullptr);
2898
2899 /* Pass: Custom Window Stuff. */
2901 BLI_args_add(ba, "-p", "--window-geometry", CB(arg_handle_window_geometry), nullptr);
2902 BLI_args_add(ba, "-w", "--window-border", CB(arg_handle_with_borders), nullptr);
2903 BLI_args_add(ba, "-W", "--window-fullscreen", CB(arg_handle_without_borders), nullptr);
2904 BLI_args_add(ba, "-M", "--window-maximized", CB(arg_handle_window_maximized), nullptr);
2905 BLI_args_add(ba, nullptr, "--no-window-focus", CB(arg_handle_no_window_focus), nullptr);
2906 BLI_args_add(ba, "-con", "--start-console", CB(arg_handle_start_with_console), nullptr);
2907 BLI_args_add(ba, "-r", "--register", CB(arg_handle_register_extension), nullptr);
2908 BLI_args_add(ba, nullptr, "--register-allusers", CB(arg_handle_register_extension_all), nullptr);
2909 BLI_args_add(ba, nullptr, "--unregister", CB(arg_handle_unregister_extension), nullptr);
2911 ba, nullptr, "--unregister-allusers", CB(arg_handle_unregister_extension_all), nullptr);
2912 BLI_args_add(ba, nullptr, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
2913
2914 /* Pass: Disabling Things & Forcing Settings. */
2916 BLI_args_add_case(ba, "-noaudio", 1, nullptr, 0, CB(arg_handle_audio_disable), nullptr);
2917 BLI_args_add_case(ba, "-setaudio", 1, nullptr, 0, CB(arg_handle_audio_set), nullptr);
2918
2919 /* Pass: Processing Arguments. */
2920 /* NOTE: Use #WM_exit for these callbacks, not `exit()`
2921 * so temporary files are properly cleaned up. */
2923 BLI_args_add(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C);
2924 BLI_args_add(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C);
2925 BLI_args_add(ba, "-S", "--scene", CB(arg_handle_scene_set), C);
2926 BLI_args_add(ba, "-s", "--frame-start", CB(arg_handle_frame_start_set), C);
2927 BLI_args_add(ba, "-e", "--frame-end", CB(arg_handle_frame_end_set), C);
2928 BLI_args_add(ba, "-j", "--frame-jump", CB(arg_handle_frame_skip_set), C);
2929 BLI_args_add(ba, "-P", "--python", CB(arg_handle_python_file_run), C);
2930 BLI_args_add(ba, nullptr, "--python-text", CB(arg_handle_python_text_run), C);
2931 BLI_args_add(ba, nullptr, "--python-expr", CB(arg_handle_python_expr_run), C);
2932 BLI_args_add(ba, nullptr, "--python-console", CB(arg_handle_python_console_run), C);
2933 BLI_args_add(ba, nullptr, "--python-exit-code", CB(arg_handle_python_exit_code_set), nullptr);
2934 BLI_args_add(ba, nullptr, "--addons", CB(arg_handle_addons_set), C);
2935
2936 BLI_args_add(ba, "-o", "--render-output", CB(arg_handle_output_set), C);
2937 BLI_args_add(ba, "-E", "--engine", CB(arg_handle_engine_set), C);
2938
2939 BLI_args_add(ba, "-F", "--render-format", CB(arg_handle_image_type_set), C);
2940 BLI_args_add(ba, "-x", "--use-extension", CB(arg_handle_extension_set), C);
2941
2942 BLI_args_add(ba, nullptr, "--open-last", CB(arg_handle_load_last_file), C);
2943
2944# undef CB
2945# undef CB_EX
2946# undef CB_ALL
2947
2948# ifdef WITH_PYTHON
2949 /* Use for Python to extract help text (Python can't call directly - bad-level call). */
2951# else
2952 /* Quiet unused function warning. */
2954# endif
2955}
2956
2959#endif /* !WITH_PYTHON_MODULE */
@ BLENDER_SYSTEM_DATAFILES
@ BLENDER_SYSTEM_EXTENSIONS
@ BLENDER_SYSTEM_PYTHON
@ BLENDER_SYSTEM_SCRIPTS
#define BLENDER_STARTUP_FILE
Blender CLI Generic --command Support.
int BKE_blender_cli_command_exec(struct bContext *C, const char *id, const int argc, const char **argv)
void BKE_blender_cli_command_print_help()
const char * BKE_blender_version_string(void)
Definition blender.cc:143
bool BKE_blendfile_extension_check(const char *str)
Definition blendfile.cc:84
wmWindow * CTX_wm_window(const bContext *C)
void CTX_data_scene_set(bContext *C, Scene *scene)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
@ G_BACKGROUND_NO_DEPSGRAPH
@ G_LIBOVERRIDE_NO_AUTO_RESYNC
@ G_DEBUG_DEPSGRAPH_UID
@ G_DEBUG
@ G_DEBUG_GPU
@ G_DEBUG_GHOST
@ G_DEBUG_XR
@ G_DEBUG_HANDLERS
@ G_DEBUG_FREESTYLE
@ G_DEBUG_IO
@ G_DEBUG_JOBS
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
@ G_DEBUG_FFMPEG
@ G_DEBUG_DEPSGRAPH_PRETTY
@ G_DEBUG_XR_TIME
@ G_DEBUG_WINTAB
@ G_DEBUG_DEPSGRAPH_TIME
@ G_DEBUG_DEPSGRAPH
@ G_DEBUG_DEPSGRAPH_EVAL
@ G_DEBUG_GPU_FORCE_VULKAN_LOCAL_READ
@ G_DEBUG_GPU_RENDERDOC
@ G_DEBUG_DEPSGRAPH_NO_THREADS
@ G_DEBUG_GPU_COMPILE_SHADERS
@ G_DEBUG_DEPSGRAPH_TAG
@ G_DEBUG_WM
@ G_DEBUG_EVENTS
@ G_DEBUG_PYTHON
@ G_DEBUG_DEPSGRAPH_BUILD
#define G_MAIN
@ G_FLAG_INTERNET_OVERRIDE_PREF_ONLINE
@ G_FLAG_EVENT_SIMULATE
@ G_FLAG_INTERNET_OVERRIDE_PREF_OFFLINE
@ G_FLAG_USERPREF_NO_SAVE_ON_EXIT
@ G_FLAG_SCRIPT_AUTOEXEC
@ G_FLAG_INTERNET_ALLOW
#define G_DEBUG_ALL
char BKE_imtype_from_arg(const char *imtype_arg)
void BKE_image_format_set(ImageFormatData *imf, ID *owner_id, const char imtype)
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:1679
void BKE_reports_free(ReportList *reports)
Definition report.cc:70
void BKE_reports_init(ReportList *reports, int flag)
Definition report.cc:55
Scene * BKE_scene_set_name(Main *bmain, const char *name)
Definition scene.cc:2065
void BKE_sound_force_device(const char *device)
A general argument parsing module.
void BLI_args_destroy(struct bArgs *ba)
Definition BLI_args.cc:144
void BLI_args_print_other_doc(struct bArgs *ba)
Definition BLI_args.cc:317
void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg)
Definition BLI_args.cc:287
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:242
void BLI_args_pass_set(struct bArgs *ba, int current_pass)
Definition BLI_args.cc:166
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:262
int(*)(int argc, const char **argv, void *data) BA_ArgCallback
Definition BLI_args.h:24
void BLI_args_print_fn_set(struct bArgs *ba, ATTR_PRINTF_FORMAT(2, 0) bArgPrintFn print_fn, void *user_data)
bool BLI_args_has_other_doc(const struct bArgs *ba)
struct bArgs * BLI_args_create(int argc, const char **argv)
Definition BLI_args.cc:124
void BLI_args_print(const struct bArgs *ba)
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
#define BLI_assert(a)
Definition BLI_assert.h:46
#define ATTR_PRINTF_FORMAT(format_param, dots_param)
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition BLI_dynstr.cc:36
void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, va_list args) ATTR_PRINTF_FORMAT(2
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:373
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_kdtree_nd_ free(KDTree *tree)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:608
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void void BLI_mempool_set_memory_debug()
#define FILE_MAX
void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1)
int BLI_path_canonicalize_native(char *path, int path_maxncpy)
std::string data
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:688
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
unsigned char uchar
void BLI_system_backtrace(FILE *fp)
Definition system.cc:102
void BLI_system_num_threads_override_set(int num)
Definition threads.cc:289
int BLI_system_thread_count(void)
Definition threads.cc:253
#define BLENDER_MAX_THREADS
Definition BLI_threads.h:16
#define CLAMP(a, b, c)
#define UNPACK4(a)
#define UNUSED_VARS(...)
#define STRINGIFY(x)
#define STRINGIFY_ARG(x)
#define POINTER_AS_INT(i)
#define UNLIKELY(x)
#define ELEM(...)
#define STREQ(a, b)
Compatibility-like things for windows.
bool BLI_windows_unregister_blend_extension(bool all_users)
bool BLI_windows_register_blend_extension(bool all_users)
void BPY_python_use_system_env()
char *(* BPY_python_app_help_text_fn)(bool all)
Definition bpy_app.cc:628
bool bool BPY_run_text(bContext *C, Text *text, ReportList *reports, bool do_jump) ATTR_NONNULL(1
bool BPY_run_filepath(bContext *C, const char *filepath, ReportList *reports) ATTR_NONNULL(1
bool BPY_run_string_eval(bContext *C, const char *imports[], const char *expr)
bool BPY_run_string_exec(bContext *C, const char *imports[], const char *expr)
void CCL_start_debug_logging(void)
Definition logging.cpp:13
void CCL_logging_verbosity_set(const int verbosity)
Definition logging.cpp:18
void CLG_type_filter_exclude(const char *type_match, int type_match_len)
Definition clog.c:739
void CLG_output_set(void *file_handle)
Definition clog.c:709
void CLG_output_use_basename_set(int value)
Definition clog.c:714
void CLG_error_fn_set(void(*error_fn)(void *file_handle))
Definition clog.c:724
void CLG_backtrace_fn_set(void(*fatal_fn)(void *file_handle))
Definition clog.c:734
void CLG_type_filter_include(const char *type_match, int type_match_len)
Definition clog.c:744
void CLG_level_set(int level)
Definition clog.c:749
void CLG_output_use_timestamp_set(int value)
Definition clog.c:719
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
@ ID_TXT
@ R_EXTENSION
#define MINAFRAME
@ R_IMF_IMTYPE_INVALID
#define MAXFRAME
void GPU_compilation_subprocess_override_set(int count)
void GPU_backend_type_selection_set_override(eGPUBackendType backend_type)
Read Guarded memory(de)allocation.
char build_type[]
Definition bpy_app.cc:70
char build_cflags[]
Definition bpy_app.cc:71
char build_hash[]
Definition bpy_app.cc:67
char build_commit_date[]
Definition bpy_app.cc:65
char build_commit_time[]
Definition bpy_app.cc:66
char build_linkflags[]
Definition bpy_app.cc:73
char build_system[]
Definition bpy_app.cc:74
char build_branch[]
Definition bpy_app.cc:68
char build_date[]
Definition bpy_app.cc:62
char build_cxxflags[]
Definition bpy_app.cc:72
char build_time[]
Definition bpy_app.cc:63
char build_platform[]
Definition bpy_app.cc:69
btScalar max
ApplicationState app_state
Definition creator.cc:118
static int arg_handle_python_exit_code_set(int argc, const char **argv, void *)
static int arg_handle_command_set(int argc, const char **argv, void *data)
static int arg_handle_debug_gpu_renderdoc_set(int, const char **, void *)
static const char arg_handle_engine_set_doc[]
static const char arg_handle_debug_mode_io_doc[]
static const char arg_handle_debug_mode_generic_set_doc_xr[]
static const char arg_handle_factory_startup_set_doc[]
static int arg_handle_unregister_extension(int argc, const char **argv, void *data)
static int arg_handle_debug_gpu_set(int, const char **, void *)
static int arg_handle_log_set(int argc, const char **argv, void *)
static int arg_handle_render_frame(int argc, const char **argv, void *data)
static int arg_handle_python_use_system_env_set(int, const char **, void *)
static int arg_handle_audio_set(int argc, const char **argv, void *)
static const char * parse_int_range_sep_search(const char *str, const char *str_end_test)
static const char arg_handle_scene_set_doc[]
static const char arg_handle_debug_mode_generic_set_doc_jobs[]
static const char arg_handle_frame_start_set_doc[]
static int arg_handle_log_file_set(int argc, const char **argv, void *)
static bool arg_handle_extension_registration(const bool do_register, const bool all_users)
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)
static int arg_handle_debug_gpu_compile_shaders_set(int, const char **, void *)
static const char arg_handle_output_set_doc[]
static int arg_handle_python_set(int, const char **, void *data)
static int arg_handle_playback_mode(int argc, const char **argv, void *)
static const char arg_handle_render_animation_doc[]
#define PRINT(...)
static int arg_handle_python_console_run(int, const char **, void *data)
static int arg_handle_without_borders(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_wm[]
static const char arg_handle_env_system_set_doc_datafiles[]
static const char arg_handle_verbosity_set_doc[]
static const char arg_handle_env_system_set_doc_python[]
static void print_version_short()
static const char arg_handle_print_version_doc[]
static int arg_handle_print_help(int, const char **, void *data)
static const char arg_handle_debug_value_set_doc[]
static const char arg_handle_with_borders_doc[]
static const char arg_handle_debug_mode_generic_set_doc_ghost[]
static int arg_handle_with_borders(int, const char **, void *)
static int arg_handle_python_text_run(int argc, const char **argv, void *data)
static int arg_handle_output_set(int argc, const char **argv, void *data)
static const char arg_handle_internet_allow_set_doc_offline[]
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 bool main_arg_deferred_is_set()
static int arg_handle_debug_mode_all(int, const char **, void *)
#define CB_EX(a, b)
static int arg_handle_unregister_extension_all(int argc, const char **argv, void *data)
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_mode_memory_set(int, const char **, void *)
static const char arg_handle_log_set_doc[]
static int arg_handle_env_system_set(int argc, const char **argv, void *)
static int arg_handle_log_show_basename_set(int, const char **, void *)
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 const char arg_handle_native_pixels_set_doc[]
static const char arg_handle_debug_gpu_set_doc[]
static int arg_handle_enable_event_simulate(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_handlers[]
static int arg_handle_verbosity_set(int argc, const char **argv, void *)
static const char arg_handle_log_level_set_doc[]
#define printf
static const char arg_handle_python_console_run_doc[]
static const char arg_handle_debug_mode_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)
void main_arg_deferred_free()
static const char arg_handle_frame_end_set_doc[]
static const char arg_handle_register_extension_doc[]
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_no_threads[]
static int arg_handle_extension_set(int argc, const char **argv, void *data)
static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_python[]
static int arg_handle_profile_gpu_set(int, const char **, void *)
static int arg_handle_register_extension_all(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_time[]
static int arg_handle_quiet_set(int, const char **, void *)
static const char arg_handle_python_exit_code_set_doc[]
#define CB_ALL(a)
static const char arg_handle_without_borders_doc[]
static int arg_handle_debug_gpu_scope_capture_set(int argc, const char **argv, void *)
static const char arg_handle_python_expr_run_doc[]
static const char arg_handle_frame_skip_set_doc[]
static const char arg_handle_python_set_doc_disable[]
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_eval[]
#define PY_ENABLE_AUTO
#define CB(a)
static void main_arg_deferred_setup(BA_ArgCallback func, int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_build[]
static const char arg_handle_env_system_set_doc_scripts[]
static const char arg_handle_window_maximized_doc[]
static int arg_handle_render_animation(int, const char **, void *data)
static int arg_handle_native_pixels_set(int, const char **, void *)
static const char arg_handle_python_text_run_doc[]
static int arg_handle_debug_mode_cycles(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_uid[]
static int arg_handle_scene_set(int argc, const char **argv, void *data)
static const char arg_handle_image_type_set_doc[]
static void clog_abort_on_error_callback(void *fp)
static const char arg_handle_render_frame_doc[]
static const char arg_handle_print_help_doc_win32[]
static const char arg_handle_debug_mode_libmv_doc[]
static const char arg_handle_audio_disable_doc[]
static const char arg_handle_gpu_backend_set_doc_all[]
static const char arg_handle_env_system_set_doc_extensions[]
static void print_version_full()
static bool parse_int(const char *str, const char *str_end_test, int *r_value, const char **r_err_msg)
static const char arg_handle_start_with_console_doc[]
static int arg_handle_debug_mode_libmv(int, const char **, void *)
static int arg_handle_debug_exit_on_error(int, const char **, void *)
static const char arg_handle_gpu_backend_set_doc[]
static int arg_handle_window_maximized(int, const char **, void *)
static void build_defs_init(BuildDefs *build_defs, bool force_all)
static int arg_handle_threads_set(int argc, const char **argv, void *)
static const char arg_handle_addons_set_doc[]
static int arg_handle_addons_set(int argc, const char **argv, void *data)
static int arg_handle_crash_handler_disable(int, const char **, void *)
static const char arg_handle_debug_gpu_renderdoc_set_doc[]
static int arg_handle_image_type_set(int argc, const char **argv, void *data)
static bool handle_load_file(bContext *C, const char *filepath_arg, const bool load_empty_file)
static const char arg_handle_print_help_doc[]
static int arg_handle_debug_mode_io(int, const char **, void *)
static int arg_handle_log_show_timestamp_set(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_xr_time[]
static void main_arg_deferred_exit_code_set(int exit_code)
static int arg_handle_arguments_end(int, const char **, void *)
static int arg_handle_log_show_backtrace_set(int, const char **, void *)
static int arg_handle_app_template(int argc, const char **argv, void *)
static const char arg_handle_log_show_basename_set_doc[]
static const char arg_handle_quiet_set_doc[]
static const char arg_handle_extension_set_doc[]
static const char arg_handle_disable_liboverride_auto_resync_doc[]
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_debug_mode_memory_set_doc[]
static const char arg_handle_background_mode_set_doc[]
static int arg_handle_window_geometry(int argc, const char **argv, void *)
static int arg_handle_log_level_set(int argc, const char **argv, void *)
static char * main_args_help_as_string(bool all)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_tag[]
static void print_help(bArgs *ba, bool all)
static const char arg_handle_register_extension_all_doc[]
static int arg_handle_audio_disable(int, const char **, void *)
static const char arg_handle_log_show_backtrace_set_doc[]
static void background_mode_set()
static const char arg_handle_enable_event_simulate_doc[]
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 int arg_handle_gpu_backend_set(int argc, const char **argv, void *)
static int arg_handle_abort_handler_disable(int, const char **, void *)
static int arg_handle_factory_startup_set(int, const char **, void *)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph[]
static int arg_handle_register_extension(int argc, const char **argv, void *data)
static int arg_handle_disable_depsgraph_on_file_load(int, const char **, void *)
static const char arg_handle_unregister_extension_doc[]
static const char arg_handle_debug_gpu_scope_capture_set_doc[]
static const char arg_handle_debug_fpe_set_doc[]
static int arg_handle_load_last_file(int, const char **, void *data)
static int arg_handle_python_file_run(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_pretty[]
static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_gpu_compile_shaders_set_doc[]
static void help_print_ds_fn(void *ds_v, const char *format, va_list args)
int main_args_handle_load_file(int, const char **argv, void *data)
static const char arg_handle_log_file_set_doc[]
static const char arg_handle_window_geometry_doc[]
static const char arg_handle_python_file_run_doc[]
static const char arg_handle_python_set_doc_enable[]
#define PY_DISABLE_AUTO
static const char arg_handle_arguments_end_doc[]
static const char arg_handle_load_last_file_doc[]
static const char arg_handle_debug_mode_generic_set_doc_freestyle[]
static int arg_handle_debug_mode_generic_set(int, const char **, void *data)
static const char arg_handle_crash_handler_disable_doc[]
static const char arg_handle_app_template_doc[]
static const char arg_handle_threads_set_doc[]
static const char arg_handle_python_use_system_env_set_doc[]
static int arg_handle_disable_liboverride_auto_resync(int, const char **, void *)
static int arg_handle_print_version(int, const char **, void *)
static const char arg_handle_log_show_timestamp_set_doc[]
static const char arg_handle_debug_mode_generic_set_doc_ffmpeg[]
static int arg_handle_debug_value_set(int argc, const char **argv, void *)
static int arg_handle_background_mode_set(int, const char **, void *)
static const char arg_handle_abort_handler_disable_doc[]
static const char arg_handle_debug_exit_on_error_doc[]
static const char arg_handle_unregister_extension_all_doc[]
static const char arg_handle_playback_mode_doc[]
static const char arg_handle_debug_mode_generic_set_doc_events[]
static const char arg_handle_internet_allow_set_doc_online[]
static const char arg_handle_command_set_doc[]
static const char arg_handle_profile_gpu_set_doc[]
static const char arg_handle_debug_mode_generic_set_doc_wintab[]
static const char arg_handle_debug_mode_generic_set_doc_gpu_force_workarounds[]
int main_arg_deferred_handle()
void main_args_setup(bContext *C, bArgs *ba, bool all)
static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
static const char arg_handle_disable_depsgraph_on_file_load_doc[]
static int arg_handle_start_with_console(int, const char **, void *)
static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
static int arg_handle_debug_mode_set(int, const char **, void *data)
static int arg_handle_internet_allow_set(int, const char **, void *data)
static const char arg_handle_no_window_focus_doc[]
static const char arg_handle_debug_mode_cycles_doc[]
static int arg_handle_debug_fpe_set(int, const char **, void *)
static int arg_handle_engine_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_all_doc[]
static int arg_handle_no_window_focus(int, const char **, void *)
static const char arg_handle_audio_set_doc[]
void main_signal_setup_fpe(void)
@ ARG_PASS_ENVIRONMENT
@ ARG_PASS_SETTINGS_FORCE
@ ARG_PASS_SETTINGS_GUI
@ ARG_PASS_FINAL
@ ARG_PASS_SETTINGS
Scene scene
const Depsgraph * depsgraph
#define offsetof(t, d)
#define str(s)
uint pos
bool all(VecOp< bool, D >) RET
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ListBase R_engines
void MEM_enable_fail_on_memleak()
format
void libmv_setLoggingVerbosity(int verbosity)
Definition logging.cc:42
void libmv_startDebugLogging(void)
Definition logging.cc:32
void(* MEM_set_memory_debug)(void)
Definition mallocn.cc:69
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
#define G(x, y, z)
#define min(a, b)
Definition sort.cc:36
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)
void RE_SetReports(Render *re, ReportList *reports)
struct ApplicationState::@1376 signal
struct ApplicationState::@1377 exit_code_on_error
struct BA_ArgCallback_Deferred * main_arg_deferred
unsigned char python
bool with_opencolorio
bool with_libmv
bool with_renderdoc
bool with_ffmpeg
bool with_cycles
bool with_xr_openxr
bool with_cycles_logging
bool with_freestyle
void * first
char * filepath
Definition WM_types.hh:1446
char engine[32]
struct ImageFormatData im_format
char pic[1024]
struct RenderData r
float frame
uint len
bool WM_file_read(bContext *C, const char *filepath, const bool use_scripts_autoexec_check, ReportList *reports)
Definition wm_files.cc:1044
void WM_init_state_app_template_set(const char *app_template)
Definition wm_files.cc:1185
char app_template[64]
Definition wm_files.cc:1181
void WM_exit(bContext *C, const int exit_code)
void WM_init_state_start_with_console_set(bool value)
bool WM_platform_associate_set(bool do_register, bool all_users, char **r_error_msg)
void WM_main_playanim(int argc, const char **argv)
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
void WM_init_state_maximized_set()
void WM_init_native_pixels(bool do_it)
void WM_init_state_size_set(int stax, int stay, int sizx, int sizy)
void WM_init_state_fullscreen_set()
void WM_init_state_normal_set()
void WM_init_window_focus_set(bool do_it)