Blender  V2.93
creator_args.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #ifndef WITH_PYTHON_MODULE
22 
23 # include <errno.h>
24 # include <stdlib.h>
25 # include <string.h>
26 
27 # include "MEM_guardedalloc.h"
28 
29 # include "CLG_log.h"
30 
31 # ifdef WIN32
32 # include "BLI_winstuff.h"
33 # endif
34 
35 # include "BLI_args.h"
36 # include "BLI_fileops.h"
37 # include "BLI_listbase.h"
38 # include "BLI_mempool.h"
39 # include "BLI_path_util.h"
40 # include "BLI_string.h"
41 # include "BLI_string_utf8.h"
42 # include "BLI_system.h"
43 # include "BLI_threads.h"
44 # include "BLI_utildefines.h"
45 
46 # include "BLO_readfile.h" /* only for BLO_has_bfile_extension */
47 
48 # include "BKE_blender_version.h"
49 # include "BKE_context.h"
50 
51 # include "BKE_global.h"
52 # include "BKE_image.h"
53 # include "BKE_lib_id.h"
54 # include "BKE_main.h"
55 # include "BKE_report.h"
56 # include "BKE_scene.h"
57 # include "BKE_sound.h"
58 
59 # ifdef WITH_FFMPEG
60 # include "IMB_imbuf.h"
61 # endif
62 
63 # ifdef WITH_PYTHON
64 # include "BPY_extern_python.h"
65 # include "BPY_extern_run.h"
66 # endif
67 
68 # include "RE_engine.h"
69 # include "RE_pipeline.h"
70 
71 # include "ED_datafiles.h"
72 
73 # include "WM_api.h"
74 
75 # ifdef WITH_LIBMV
76 # include "libmv-capi.h"
77 # endif
78 
79 # ifdef WITH_CYCLES_LOGGING
80 # include "CCL_api.h"
81 # endif
82 
83 # include "DEG_depsgraph.h"
84 # include "DEG_depsgraph_build.h"
85 # include "DEG_depsgraph_debug.h"
86 
87 # include "WM_types.h"
88 
89 # include "creator_intern.h" /* own include */
90 
91 /* -------------------------------------------------------------------- */
95 static bool parse_int_relative(const char *str,
96  const char *str_end_test,
97  int pos,
98  int neg,
99  int *r_value,
100  const char **r_err_msg)
101 {
102  char *str_end = NULL;
103  long value;
104 
105  errno = 0;
106 
107  switch (*str) {
108  case '+':
109  value = pos + strtol(str + 1, &str_end, 10);
110  break;
111  case '-':
112  value = (neg - strtol(str + 1, &str_end, 10)) + 1;
113  break;
114  default:
115  value = strtol(str, &str_end, 10);
116  break;
117  }
118 
119  if (*str_end != '\0' && (str_end != str_end_test)) {
120  static const char *msg = "not a number";
121  *r_err_msg = msg;
122  return false;
123  }
124  if ((errno == ERANGE) || ((value < INT_MIN || value > INT_MAX))) {
125  static const char *msg = "exceeds range";
126  *r_err_msg = msg;
127  return false;
128  }
129  *r_value = (int)value;
130  return true;
131 }
132 
133 static const char *parse_int_range_sep_search(const char *str, const char *str_end_test)
134 {
135  const char *str_end_range = NULL;
136  if (str_end_test) {
137  str_end_range = memchr(str, '.', (str_end_test - str) - 1);
138  if (str_end_range && (str_end_range[1] != '.')) {
139  str_end_range = NULL;
140  }
141  }
142  else {
143  str_end_range = strstr(str, "..");
144  if (str_end_range && (str_end_range[2] == '\0')) {
145  str_end_range = NULL;
146  }
147  }
148  return str_end_range;
149 }
150 
156 static bool parse_int_range_relative(const char *str,
157  const char *str_end_range,
158  const char *str_end_test,
159  int pos,
160  int neg,
161  int r_value_range[2],
162  const char **r_err_msg)
163 {
164  if (parse_int_relative(str, str_end_range, pos, neg, &r_value_range[0], r_err_msg) &&
166  str_end_range + 2, str_end_test, pos, neg, &r_value_range[1], r_err_msg)) {
167  return true;
168  }
169  return false;
170 }
171 
172 static bool parse_int_relative_clamp(const char *str,
173  const char *str_end_test,
174  int pos,
175  int neg,
176  int min,
177  int max,
178  int *r_value,
179  const char **r_err_msg)
180 {
181  if (parse_int_relative(str, str_end_test, pos, neg, r_value, r_err_msg)) {
182  CLAMP(*r_value, min, max);
183  return true;
184  }
185  return false;
186 }
187 
188 static bool parse_int_range_relative_clamp(const char *str,
189  const char *str_end_range,
190  const char *str_end_test,
191  int pos,
192  int neg,
193  int min,
194  int max,
195  int r_value_range[2],
196  const char **r_err_msg)
197 {
199  str, str_end_range, str_end_test, pos, neg, r_value_range, r_err_msg)) {
200  CLAMP(r_value_range[0], min, max);
201  CLAMP(r_value_range[1], min, max);
202  return true;
203  }
204  return false;
205 }
206 
210 static bool parse_int_strict_range(const char *str,
211  const char *str_end_test,
212  const int min,
213  const int max,
214  int *r_value,
215  const char **r_err_msg)
216 {
217  char *str_end = NULL;
218  long value;
219 
220  errno = 0;
221  value = strtol(str, &str_end, 10);
222 
223  if (*str_end != '\0' && (str_end != str_end_test)) {
224  static const char *msg = "not a number";
225  *r_err_msg = msg;
226  return false;
227  }
228  if ((errno == ERANGE) || ((value < min || value > max))) {
229  static const char *msg = "exceeds range";
230  *r_err_msg = msg;
231  return false;
232  }
233  *r_value = (int)value;
234  return true;
235 }
236 
237 static bool parse_int(const char *str,
238  const char *str_end_test,
239  int *r_value,
240  const char **r_err_msg)
241 {
242  return parse_int_strict_range(str, str_end_test, INT_MIN, INT_MAX, r_value, r_err_msg);
243 }
244 
245 static bool parse_int_clamp(const char *str,
246  const char *str_end_test,
247  int min,
248  int max,
249  int *r_value,
250  const char **r_err_msg)
251 {
252  if (parse_int(str, str_end_test, r_value, r_err_msg)) {
253  CLAMP(*r_value, min, max);
254  return true;
255  }
256  return false;
257 }
258 
259 # if 0
264 static int *parse_int_relative_clamp_n(
265  const char *str, int pos, int neg, int min, int max, int *r_value_len, const char **r_err_msg)
266 {
267  const char sep = ',';
268  int len = 1;
269  for (int i = 0; str[i]; i++) {
270  if (str[i] == sep) {
271  len++;
272  }
273  }
274 
275  int *values = MEM_mallocN(sizeof(*values) * len, __func__);
276  int i = 0;
277  while (true) {
278  const char *str_end = strchr(str, sep);
279  if ((*str == sep) || (*str == '\0')) {
280  static const char *msg = "incorrect comma use";
281  *r_err_msg = msg;
282  goto fail;
283  }
284  else if (parse_int_relative_clamp(str, str_end, pos, neg, min, max, &values[i], r_err_msg)) {
285  i++;
286  }
287  else {
288  goto fail; /* error message already set */
289  }
290 
291  if (str_end) { /* next */
292  str = str_end + 1;
293  }
294  else { /* finished */
295  break;
296  }
297  }
298 
299  *r_value_len = i;
300  return values;
301 
302 fail:
303  MEM_freeN(values);
304  return NULL;
305 }
306 
307 # endif
308 
315 static int (*parse_int_range_relative_clamp_n(const char *str,
316  int pos,
317  int neg,
318  int min,
319  int max,
320  int *r_value_len,
321  const char **r_err_msg))[2]
322 {
323  const char sep = ',';
324  int len = 1;
325  for (int i = 0; str[i]; i++) {
326  if (str[i] == sep) {
327  len++;
328  }
329  }
330 
331  int(*values)[2] = MEM_mallocN(sizeof(*values) * len, __func__);
332  int i = 0;
333  while (true) {
334  const char *str_end_range;
335  const char *str_end = strchr(str, sep);
336  if (ELEM(*str, sep, '\0')) {
337  static const char *msg = "incorrect comma use";
338  *r_err_msg = msg;
339  goto fail;
340  }
341  else if ((str_end_range = parse_int_range_sep_search(str, str_end)) ?
343  str, str_end_range, str_end, pos, neg, min, max, values[i], r_err_msg) :
345  str, str_end, pos, neg, min, max, &values[i][0], r_err_msg)) {
346  if (str_end_range == NULL) {
347  values[i][1] = values[i][0];
348  }
349  i++;
350  }
351  else {
352  goto fail; /* error message already set */
353  }
354 
355  if (str_end) { /* next */
356  str = str_end + 1;
357  }
358  else { /* finished */
359  break;
360  }
361  }
362 
363  *r_value_len = i;
364  return values;
365 
366 fail:
367  MEM_freeN(values);
368  return NULL;
369 }
370 
373 /* -------------------------------------------------------------------- */
377 # ifdef WITH_PYTHON
378 
379 struct BlendePyContextStore {
380  wmWindowManager *wm;
381  Scene *scene;
382  wmWindow *win;
383  bool has_win;
384 };
385 
386 static void arg_py_context_backup(bContext *C,
387  struct BlendePyContextStore *c_py,
388  const char *script_id)
389 {
390  c_py->wm = CTX_wm_manager(C);
391  c_py->scene = CTX_data_scene(C);
392  c_py->has_win = !BLI_listbase_is_empty(&c_py->wm->windows);
393  if (c_py->has_win) {
394  c_py->win = CTX_wm_window(C);
395  CTX_wm_window_set(C, c_py->wm->windows.first);
396  }
397  else {
398  c_py->win = NULL;
399  fprintf(stderr,
400  "Python script \"%s\" "
401  "running with missing context data.\n",
402  script_id);
403  }
404 }
405 
406 static void arg_py_context_restore(bContext *C, struct BlendePyContextStore *c_py)
407 {
408  /* script may load a file, check old data is valid before using */
409  if (c_py->has_win) {
410  if ((c_py->win == NULL) || ((BLI_findindex(&G_MAIN->wm, c_py->wm) != -1) &&
411  (BLI_findindex(&c_py->wm->windows, c_py->win) != -1))) {
412  CTX_wm_window_set(C, c_py->win);
413  }
414  }
415 
416  if ((c_py->scene == NULL) || BLI_findindex(&G_MAIN->scenes, c_py->scene) != -1) {
417  CTX_data_scene_set(C, c_py->scene);
418  }
419 }
420 
421 /* macro for context setup/reset */
422 # define BPY_CTX_SETUP(_cmd) \
423  { \
424  struct BlendePyContextStore py_c; \
425  arg_py_context_backup(C, &py_c, argv[1]); \
426  { \
427  _cmd; \
428  } \
429  arg_py_context_restore(C, &py_c); \
430  } \
431  ((void)0)
432 
433 # endif /* WITH_PYTHON */
434 
437 /* -------------------------------------------------------------------- */
451 static void print_version_full(void)
452 {
453  printf("Blender %s\n", BKE_blender_version_string());
454 # ifdef BUILD_DATE
455  printf("\tbuild date: %s\n", build_date);
456  printf("\tbuild time: %s\n", build_time);
457  printf("\tbuild commit date: %s\n", build_commit_date);
458  printf("\tbuild commit time: %s\n", build_commit_time);
459  printf("\tbuild hash: %s\n", build_hash);
460  printf("\tbuild platform: %s\n", build_platform);
461  printf("\tbuild type: %s\n", build_type);
462  printf("\tbuild c flags: %s\n", build_cflags);
463  printf("\tbuild c++ flags: %s\n", build_cxxflags);
464  printf("\tbuild link flags: %s\n", build_linkflags);
465  printf("\tbuild system: %s\n", build_system);
466 # endif
467 }
468 
469 static void print_version_short(void)
470 {
471 # ifdef BUILD_DATE
472  /* NOTE: We include built time since sometimes we need to tell broken from
473  * working built of the same hash. */
474  printf("Blender %s (hash %s built %s %s)\n",
476  build_hash,
477  build_date,
478  build_time);
479 # else
480  printf("Blender %s\n", BKE_blender_version_string());
481 # endif
482 }
483 
484 static const char arg_handle_print_version_doc[] =
485  "\n\t"
486  "Print Blender version and exit.";
487 static int arg_handle_print_version(int UNUSED(argc),
488  const char **UNUSED(argv),
489  void *UNUSED(data))
490 {
492  exit(0);
493  return 0;
494 }
495 
496 static const char arg_handle_print_help_doc[] =
497  "\n\t"
498  "Print this help text and exit.";
499 static const char arg_handle_print_help_doc_win32[] =
500  "\n\t"
501  "Print this help text and exit (Windows only).";
502 static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
503 {
504  bArgs *ba = (bArgs *)data;
505 
506  printf("Blender %s\n", BKE_blender_version_string());
507  printf("Usage: blender [args ...] [file] [args ...]\n\n");
508 
509  printf("Render Options:\n");
510  BLI_args_print_arg_doc(ba, "--background");
511  BLI_args_print_arg_doc(ba, "--render-anim");
512  BLI_args_print_arg_doc(ba, "--scene");
513  BLI_args_print_arg_doc(ba, "--render-frame");
514  BLI_args_print_arg_doc(ba, "--frame-start");
515  BLI_args_print_arg_doc(ba, "--frame-end");
516  BLI_args_print_arg_doc(ba, "--frame-jump");
517  BLI_args_print_arg_doc(ba, "--render-output");
518  BLI_args_print_arg_doc(ba, "--engine");
519  BLI_args_print_arg_doc(ba, "--threads");
520 
521  printf("\n");
522  printf("Format Options:\n");
523  BLI_args_print_arg_doc(ba, "--render-format");
524  BLI_args_print_arg_doc(ba, "--use-extension");
525 
526  printf("\n");
527  printf("Animation Playback Options:\n");
528  BLI_args_print_arg_doc(ba, "-a");
529 
530  printf("\n");
531  printf("Window Options:\n");
532  BLI_args_print_arg_doc(ba, "--window-border");
533  BLI_args_print_arg_doc(ba, "--window-fullscreen");
534  BLI_args_print_arg_doc(ba, "--window-geometry");
535  BLI_args_print_arg_doc(ba, "--window-maximized");
536  BLI_args_print_arg_doc(ba, "--start-console");
537  BLI_args_print_arg_doc(ba, "--no-native-pixels");
538  BLI_args_print_arg_doc(ba, "--no-window-focus");
539 
540  printf("\n");
541  printf("Python Options:\n");
542  BLI_args_print_arg_doc(ba, "--enable-autoexec");
543  BLI_args_print_arg_doc(ba, "--disable-autoexec");
544 
545  printf("\n");
546 
547  BLI_args_print_arg_doc(ba, "--python");
548  BLI_args_print_arg_doc(ba, "--python-text");
549  BLI_args_print_arg_doc(ba, "--python-expr");
550  BLI_args_print_arg_doc(ba, "--python-console");
551  BLI_args_print_arg_doc(ba, "--python-exit-code");
552  BLI_args_print_arg_doc(ba, "--python-use-system-env");
553  BLI_args_print_arg_doc(ba, "--addons");
554 
555  printf("\n");
556  printf("Logging Options:\n");
557  BLI_args_print_arg_doc(ba, "--log");
558  BLI_args_print_arg_doc(ba, "--log-level");
559  BLI_args_print_arg_doc(ba, "--log-show-basename");
560  BLI_args_print_arg_doc(ba, "--log-show-backtrace");
561  BLI_args_print_arg_doc(ba, "--log-show-timestamp");
562  BLI_args_print_arg_doc(ba, "--log-file");
563 
564  printf("\n");
565  printf("Debug Options:\n");
566  BLI_args_print_arg_doc(ba, "--debug");
567  BLI_args_print_arg_doc(ba, "--debug-value");
568 
569  printf("\n");
570  BLI_args_print_arg_doc(ba, "--debug-events");
571 # ifdef WITH_FFMPEG
572  BLI_args_print_arg_doc(ba, "--debug-ffmpeg");
573 # endif
574  BLI_args_print_arg_doc(ba, "--debug-handlers");
575 # ifdef WITH_LIBMV
576  BLI_args_print_arg_doc(ba, "--debug-libmv");
577 # endif
578 # ifdef WITH_CYCLES_LOGGING
579  BLI_args_print_arg_doc(ba, "--debug-cycles");
580 # endif
581  BLI_args_print_arg_doc(ba, "--debug-memory");
582  BLI_args_print_arg_doc(ba, "--debug-jobs");
583  BLI_args_print_arg_doc(ba, "--debug-python");
584  BLI_args_print_arg_doc(ba, "--debug-depsgraph");
585  BLI_args_print_arg_doc(ba, "--debug-depsgraph-eval");
586  BLI_args_print_arg_doc(ba, "--debug-depsgraph-build");
587  BLI_args_print_arg_doc(ba, "--debug-depsgraph-tag");
588  BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
589  BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
590  BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
591  BLI_args_print_arg_doc(ba, "--debug-depsgraph-uuid");
592  BLI_args_print_arg_doc(ba, "--debug-ghost");
593  BLI_args_print_arg_doc(ba, "--debug-gpu");
594  BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
595  BLI_args_print_arg_doc(ba, "--debug-wm");
596 # ifdef WITH_XR_OPENXR
597  BLI_args_print_arg_doc(ba, "--debug-xr");
598  BLI_args_print_arg_doc(ba, "--debug-xr-time");
599 # endif
600  BLI_args_print_arg_doc(ba, "--debug-all");
601  BLI_args_print_arg_doc(ba, "--debug-io");
602 
603  printf("\n");
604  BLI_args_print_arg_doc(ba, "--debug-fpe");
605  BLI_args_print_arg_doc(ba, "--debug-exit-on-error");
606  BLI_args_print_arg_doc(ba, "--disable-crash-handler");
607  BLI_args_print_arg_doc(ba, "--disable-abort-handler");
608 
609  BLI_args_print_arg_doc(ba, "--verbose");
610 
611  printf("\n");
612  printf("Misc Options:\n");
613  BLI_args_print_arg_doc(ba, "--open-last");
614  BLI_args_print_arg_doc(ba, "--app-template");
615  BLI_args_print_arg_doc(ba, "--factory-startup");
616  BLI_args_print_arg_doc(ba, "--enable-event-simulate");
617  printf("\n");
618  BLI_args_print_arg_doc(ba, "--env-system-datafiles");
619  BLI_args_print_arg_doc(ba, "--env-system-scripts");
620  BLI_args_print_arg_doc(ba, "--env-system-python");
621  printf("\n");
622  BLI_args_print_arg_doc(ba, "-noaudio");
623  BLI_args_print_arg_doc(ba, "-setaudio");
624 
625  printf("\n");
626 
627  BLI_args_print_arg_doc(ba, "--help");
628  BLI_args_print_arg_doc(ba, "/?");
629 
630  /* WIN32 only (ignored for non-win32) */
631  BLI_args_print_arg_doc(ba, "-R");
632  BLI_args_print_arg_doc(ba, "-r");
633 
634  BLI_args_print_arg_doc(ba, "--version");
635 
636  BLI_args_print_arg_doc(ba, "--");
637 
638  // printf("\n");
639  // printf("Experimental Features:\n");
640 
641  /* Other options _must_ be last (anything not handled will show here).
642  *
643  * Note that it's good practice for this to remain empty,
644  * nevertheless print if any exist. */
645  if (BLI_args_has_other_doc(ba)) {
646  printf("\n");
647  printf("Other Options:\n");
649  }
650 
651  printf("\n");
652  printf("Argument Parsing:\n");
653  printf("\tArguments must be separated by white space, eg:\n");
654  printf("\t# blender -ba test.blend\n");
655  printf("\t...will exit since '-ba' is an unknown argument.\n");
656 
657  printf("Argument Order:\n");
658  printf("\tArguments are executed in the order they are given. eg:\n");
659  printf("\t# blender --background test.blend --render-frame 1 --render-output '/tmp'\n");
660  printf(
661  "\t...will not render to '/tmp' because '--render-frame 1' renders before the output path "
662  "is set.\n");
663  printf("\t# blender --background --render-output /tmp test.blend --render-frame 1\n");
664  printf(
665  "\t...will not render to '/tmp' because loading the blend-file overwrites the render output "
666  "that was set.\n");
667  printf("\t# blender --background test.blend --render-output /tmp --render-frame 1\n");
668  printf("\t...works as expected.\n\n");
669 
670  printf("Environment Variables:\n");
671  printf(" $BLENDER_USER_CONFIG Directory for user configuration files.\n");
672  printf(" $BLENDER_USER_SCRIPTS Directory for user scripts.\n");
673  printf(" $BLENDER_SYSTEM_SCRIPTS Directory for system wide scripts.\n");
674  printf(" $BLENDER_USER_DATAFILES Directory for user data files (icons, translations, ..).\n");
675  printf(" $BLENDER_SYSTEM_DATAFILES Directory for system wide data files.\n");
676  printf(" $BLENDER_SYSTEM_PYTHON Directory for system Python libraries.\n");
677 # ifdef WIN32
678  printf(" $TEMP Store temporary files here.\n");
679 # else
680  printf(" $TMP or $TMPDIR Store temporary files here.\n");
681 # endif
682 
683  exit(0);
684 
685  return 0;
686 }
687 
688 static const char arg_handle_arguments_end_doc[] =
689  "\n\t"
690  "End option processing, following arguments passed unchanged. Access via Python's "
691  "'sys.argv'.";
692 static int arg_handle_arguments_end(int UNUSED(argc),
693  const char **UNUSED(argv),
694  void *UNUSED(data))
695 {
696  return -1;
697 }
698 
699 /* only to give help message */
700 # ifndef WITH_PYTHON_SECURITY /* default */
701 # define PY_ENABLE_AUTO ", (default)"
702 # define PY_DISABLE_AUTO ""
703 # else
704 # define PY_ENABLE_AUTO ""
705 # define PY_DISABLE_AUTO ", (compiled as non-standard default)"
706 # endif
707 
708 static const char arg_handle_python_set_doc_enable[] =
709  "\n\t"
710  "Enable automatic Python script execution" PY_ENABLE_AUTO ".";
712  "\n\t"
713  "Disable automatic Python script execution (pydrivers & startup scripts)" PY_DISABLE_AUTO ".";
714 # undef PY_ENABLE_AUTO
715 # undef PY_DISABLE_AUTO
716 
717 static int arg_handle_python_set(int UNUSED(argc), const char **UNUSED(argv), void *data)
718 {
719  if ((bool)data) {
721  }
722  else {
724  }
726  return 0;
727 }
728 
730  "\n\t"
731  "Disable the crash handler.";
733  const char **UNUSED(argv),
734  void *UNUSED(data))
735 {
737  return 0;
738 }
739 
741  "\n\t"
742  "Disable the abort handler.";
744  const char **UNUSED(argv),
745  void *UNUSED(data))
746 {
748  return 0;
749 }
750 
751 static void clog_abort_on_error_callback(void *fp)
752 {
754  fflush(fp);
755  abort();
756 }
757 
759  "\n\t"
760  "Immediately exit when internal errors are detected.";
762  const char **UNUSED(argv),
763  void *UNUSED(data))
764 {
767  return 0;
768 }
769 
771  "\n\t"
772  "Run in background (often used for UI-less rendering).";
774  const char **UNUSED(argv),
775  void *UNUSED(data))
776 {
778  G.background = 1;
779  return 0;
780 }
781 
782 static const char arg_handle_log_level_set_doc[] =
783  "<level>\n"
784  "\tSet the logging verbosity level (higher for more details) defaults to 1,\n"
785  "\tuse -1 to log all levels.";
786 static int arg_handle_log_level_set(int argc, const char **argv, void *UNUSED(data))
787 {
788  const char *arg_id = "--log-level";
789  if (argc > 1) {
790  const char *err_msg = NULL;
791  if (!parse_int_clamp(argv[1], NULL, -1, INT_MAX, &G.log.level, &err_msg)) {
792  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
793  }
794  else {
795  if (G.log.level == -1) {
796  G.log.level = INT_MAX;
797  }
798  CLG_level_set(G.log.level);
799  }
800  return 1;
801  }
802  printf("\nError: '%s' no args given.\n", arg_id);
803  return 0;
804 }
805 
807  "\n\t"
808  "Only show file name in output (not the leading path).";
810  const char **UNUSED(argv),
811  void *UNUSED(data))
812 {
814  return 0;
815 }
816 
818  "\n\t"
819  "Show a back trace for each log message (debug builds only).";
821  const char **UNUSED(argv),
822  void *UNUSED(data))
823 {
824  /* Ensure types don't become incompatible. */
825  void (*fn)(FILE * fp) = BLI_system_backtrace;
826  CLG_backtrace_fn_set((void (*)(void *))fn);
827  return 0;
828 }
829 
831  "\n\t"
832  "Show a timestamp for each log message in seconds since start.";
834  const char **UNUSED(argv),
835  void *UNUSED(data))
836 {
838  return 0;
839 }
840 
841 static const char arg_handle_log_file_set_doc[] =
842  "<filename>\n"
843  "\tSet a file to output the log to.";
844 static int arg_handle_log_file_set(int argc, const char **argv, void *UNUSED(data))
845 {
846  const char *arg_id = "--log-file";
847  if (argc > 1) {
848  errno = 0;
849  FILE *fp = BLI_fopen(argv[1], "w");
850  if (fp == NULL) {
851  const char *err_msg = errno ? strerror(errno) : "unknown";
852  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
853  }
854  else {
855  if (UNLIKELY(G.log.file != NULL)) {
856  fclose(G.log.file);
857  }
858  G.log.file = fp;
859  CLG_output_set(G.log.file);
860  }
861  return 1;
862  }
863  printf("\nError: '%s' no args given.\n", arg_id);
864  return 0;
865 }
866 
867 static const char arg_handle_log_set_doc[] =
868  "<match>\n"
869  "\tEnable logging categories, taking a single comma separated argument.\n"
870  "\tMultiple categories can be matched using a '.*' suffix,\n"
871  "\tso '--log \"wm.*\"' logs every kind of window-manager message.\n"
872  "\tSub-string can be matched using a '*' prefix and suffix,\n"
873  "\tso '--log \"*undo*\"' logs every kind of undo-related message.\n"
874  "\tUse \"^\" prefix to ignore, so '--log \"*,^wm.operator.*\"' logs all except for "
875  "'wm.operators.*'\n"
876  "\tUse \"*\" to log everything.";
877 static int arg_handle_log_set(int argc, const char **argv, void *UNUSED(data))
878 {
879  const char *arg_id = "--log";
880  if (argc > 1) {
881  const char *str_step = argv[1];
882  while (*str_step) {
883  const char *str_step_end = strchr(str_step, ',');
884  int str_step_len = str_step_end ? (str_step_end - str_step) : strlen(str_step);
885 
886  if (str_step[0] == '^') {
887  CLG_type_filter_exclude(str_step + 1, str_step_len - 1);
888  }
889  else {
890  CLG_type_filter_include(str_step, str_step_len);
891  }
892 
893  if (str_step_end) {
894  /* Typically only be one, but don't fail on multiple. */
895  while (*str_step_end == ',') {
896  str_step_end++;
897  }
898  str_step = str_step_end;
899  }
900  else {
901  break;
902  }
903  }
904  return 1;
905  }
906  printf("\nError: '%s' no args given.\n", arg_id);
907  return 0;
908 }
909 
910 static const char arg_handle_debug_mode_set_doc[] =
911  "\n"
912  "\tTurn debugging on.\n"
913  "\n"
914  "\t* Enables memory error detection\n"
915  "\t* Disables mouse grab (to interact with a debugger in some cases)\n"
916  "\t* Keeps Python's 'sys.stdin' rather than setting it to None";
917 static int arg_handle_debug_mode_set(int UNUSED(argc), const char **UNUSED(argv), void *data)
918 {
919  G.debug |= G_DEBUG; /* std output printf's */
920  printf("Blender %s\n", BKE_blender_version_string());
922 # ifndef NDEBUG
924 # endif
925 
926 # ifdef WITH_BUILDINFO
927  printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
928 # endif
929 
931  return 0;
932 }
933 
934 # ifdef WITH_FFMPEG
935 static const char arg_handle_debug_mode_generic_set_doc_ffmpeg[] =
936  "\n\t"
937  "Enable debug messages from FFmpeg library.";
938 # endif
939 # ifdef WITH_FREESTYLE
940 static const char arg_handle_debug_mode_generic_set_doc_freestyle[] =
941  "\n\t"
942  "Enable debug messages for Freestyle.";
943 # endif
945  "\n\t"
946  "Enable debug messages for Python.";
948  "\n\t"
949  "Enable debug messages for the event system.";
951  "\n\t"
952  "Enable debug messages for event handling.";
954  "\n\t"
955  "Enable debug messages for the window manager, shows all operators in search, shows "
956  "keymap errors.";
957 # ifdef WITH_XR_OPENXR
958 static const char arg_handle_debug_mode_generic_set_doc_xr[] =
959  "\n\t"
960  "Enable debug messages for virtual reality contexts.\n"
961  "\tEnables the OpenXR API validation layer, (OpenXR) debug messages and general information "
962  "prints.";
963 static const char arg_handle_debug_mode_generic_set_doc_xr_time[] =
964  "\n\t"
965  "Enable debug messages for virtual reality frame rendering times.";
966 # endif
968  "\n\t"
969  "Enable time profiling for background jobs.";
971  "\n\t"
972  "Enable GPU debug context and information for OpenGL 4.3+.";
974  "\n\t"
975  "Enable all debug messages from dependency graph.";
977  "\n\t"
978  "Enable debug messages from dependency graph related on graph construction.";
980  "\n\t"
981  "Enable debug messages from dependency graph related on tagging.";
983  "\n\t"
984  "Enable debug messages from dependency graph related on timing.";
986  "\n\t"
987  "Enable debug messages from dependency graph related on evaluation.";
989  "\n\t"
990  "Switch dependency graph to a single threaded evaluation.";
992  "\n\t"
993  "Enable colors for dependency graph debug messages.";
995  "\n\t"
996  "Enable workarounds for typical GPU issues and disable all GPU extensions.";
997 
999  const char **UNUSED(argv),
1000  void *data)
1001 {
1002  G.debug |= POINTER_AS_INT(data);
1003  return 0;
1004 }
1005 
1006 static const char arg_handle_debug_mode_io_doc[] =
1007  "\n\t"
1008  "Enable debug messages for I/O (Collada, ...).";
1009 static int arg_handle_debug_mode_io(int UNUSED(argc),
1010  const char **UNUSED(argv),
1011  void *UNUSED(data))
1012 {
1013  G.debug |= G_DEBUG_IO;
1014  return 0;
1015 }
1016 
1017 static const char arg_handle_debug_mode_all_doc[] =
1018  "\n\t"
1019  "Enable all debug messages.";
1020 static int arg_handle_debug_mode_all(int UNUSED(argc),
1021  const char **UNUSED(argv),
1022  void *UNUSED(data))
1023 {
1024  G.debug |= G_DEBUG_ALL;
1025 # ifdef WITH_LIBMV
1027 # endif
1028 # ifdef WITH_CYCLES_LOGGING
1030 # endif
1031  return 0;
1032 }
1033 
1034 # ifdef WITH_LIBMV
1035 static const char arg_handle_debug_mode_libmv_doc[] =
1036  "\n\t"
1037  "Enable debug messages from libmv library.";
1038 static int arg_handle_debug_mode_libmv(int UNUSED(argc),
1039  const char **UNUSED(argv),
1040  void *UNUSED(data))
1041 {
1043 
1044  return 0;
1045 }
1046 # endif
1047 
1048 # ifdef WITH_CYCLES_LOGGING
1049 static const char arg_handle_debug_mode_cycles_doc[] =
1050  "\n\t"
1051  "Enable debug messages from Cycles.";
1052 static int arg_handle_debug_mode_cycles(int UNUSED(argc),
1053  const char **UNUSED(argv),
1054  void *UNUSED(data))
1055 {
1057  return 0;
1058 }
1059 # endif
1060 
1062  "\n\t"
1063  "Enable fully guarded memory allocation and debugging.";
1065  const char **UNUSED(argv),
1066  void *UNUSED(data))
1067 {
1069  return 0;
1070 }
1071 
1072 static const char arg_handle_debug_value_set_doc[] =
1073  "<value>\n"
1074  "\tSet debug value of <value> on startup.";
1075 static int arg_handle_debug_value_set(int argc, const char **argv, void *UNUSED(data))
1076 {
1077  const char *arg_id = "--debug-value";
1078  if (argc > 1) {
1079  const char *err_msg = NULL;
1080  int value;
1081  if (!parse_int(argv[1], NULL, &value, &err_msg)) {
1082  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1083  return 1;
1084  }
1085 
1086  G.debug_value = value;
1087 
1088  return 1;
1089  }
1090  printf("\nError: you must specify debug value to set.\n");
1091  return 0;
1092 }
1093 
1094 static const char arg_handle_debug_fpe_set_doc[] =
1095  "\n\t"
1096  "Enable floating-point exceptions.";
1097 static int arg_handle_debug_fpe_set(int UNUSED(argc),
1098  const char **UNUSED(argv),
1099  void *UNUSED(data))
1100 {
1102  return 0;
1103 }
1104 
1105 static const char arg_handle_app_template_doc[] =
1106  "<template>\n"
1107  "\tSet the application template (matching the directory name), use 'default' for none.";
1108 static int arg_handle_app_template(int argc, const char **argv, void *UNUSED(data))
1109 {
1110  if (argc > 1) {
1111  const char *app_template = STREQ(argv[1], "default") ? "" : argv[1];
1113  return 1;
1114  }
1115  printf("\nError: App template must follow '--app-template'.\n");
1116  return 0;
1117 }
1118 
1120  "\n\t"
1121  "Skip reading the " STRINGIFY(BLENDER_STARTUP_FILE) " in the users home directory.";
1123  const char **UNUSED(argv),
1124  void *UNUSED(data))
1125 {
1126  G.factory_startup = 1;
1128  return 0;
1129 }
1130 
1132  "\n\t"
1133  "Enable event simulation testing feature 'bpy.types.Window.event_simulate'.";
1135  const char **UNUSED(argv),
1136  void *UNUSED(data))
1137 {
1138  G.f |= G_FLAG_EVENT_SIMULATE;
1139  return 0;
1140 }
1141 
1143  "\n\t"
1144  "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_DATAFILES) " environment variable.";
1146  "\n\t"
1147  "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_SCRIPTS) " environment variable.";
1149  "\n\t"
1150  "Set the " STRINGIFY_ARG(BLENDER_SYSTEM_PYTHON) " environment variable.";
1151 
1152 static int arg_handle_env_system_set(int argc, const char **argv, void *UNUSED(data))
1153 {
1154  /* `--env-system-scripts` -> `BLENDER_SYSTEM_SCRIPTS` */
1155 
1156  char env[64] = "BLENDER";
1157  char *ch_dst = env + 7; /* skip BLENDER */
1158  const char *ch_src = argv[0] + 5; /* skip --env */
1159 
1160  if (argc < 2) {
1161  printf("%s requires one argument\n", argv[0]);
1162  exit(1);
1163  }
1164 
1165  for (; *ch_src; ch_src++, ch_dst++) {
1166  *ch_dst = (*ch_src == '-') ? '_' : (*ch_src) - 32; /* Inline #toupper() */
1167  }
1168 
1169  *ch_dst = '\0';
1170  BLI_setenv(env, argv[1]);
1171  return 1;
1172 }
1173 
1174 static const char arg_handle_playback_mode_doc[] =
1175  "<options> <file(s)>\n"
1176  "\tInstead of showing Blender's user interface, this runs Blender as an animation player,\n"
1177  "\tto view movies and image sequences rendered in Blender (ignored if '-b' is set).\n"
1178  "\n"
1179  "\tPlayback Arguments:\n"
1180  "\n"
1181  "\t-p <sx> <sy>\n"
1182  "\t\tOpen with lower left corner at <sx>, <sy>.\n"
1183  "\t-m\n"
1184  "\t\tRead from disk (Do not buffer).\n"
1185  "\t-f <fps> <fps-base>\n"
1186  "\t\tSpecify FPS to start with.\n"
1187  "\t-j <frame>\n"
1188  "\t\tSet frame step to <frame>.\n"
1189  "\t-s <frame>\n"
1190  "\t\tPlay from <frame>.\n"
1191  "\t-e <frame>\n"
1192  "\t\tPlay until <frame>.\n"
1193  "\t-c <cache_memory>\n"
1194  "\t\tAmount of memory in megabytes to allow for caching images during playback.\n"
1195  "\t\tZero disables (clamping to a fixed number of frames instead).";
1196 static int arg_handle_playback_mode(int argc, const char **argv, void *UNUSED(data))
1197 {
1198  /* not if -b was given first */
1199  if (G.background == 0) {
1200 # ifdef WITH_FFMPEG
1201  /* Setup FFmpeg with current debug flags. */
1202  IMB_ffmpeg_init();
1203 # endif
1204 
1205  WM_main_playanim(argc, argv); /* not the same argc and argv as before */
1206  exit(0); /* 2.4x didn't do this */
1207  }
1208 
1209  return -2;
1210 }
1211 
1212 static const char arg_handle_window_geometry_doc[] =
1213  "<sx> <sy> <w> <h>\n"
1214  "\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>.";
1215 static int arg_handle_window_geometry(int argc, const char **argv, void *UNUSED(data))
1216 {
1217  const char *arg_id = "-p / --window-geometry";
1218  int params[4], i;
1219 
1220  if (argc < 5) {
1221  fprintf(stderr, "Error: requires four arguments '%s'\n", arg_id);
1222  exit(1);
1223  }
1224 
1225  for (i = 0; i < 4; i++) {
1226  const char *err_msg = NULL;
1227  if (!parse_int(argv[i + 1], NULL, &params[i], &err_msg)) {
1228  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1229  exit(1);
1230  }
1231  }
1232 
1234 
1235  return 4;
1236 }
1237 
1239  "\n\t"
1240  "Do not use native pixel size, for high resolution displays (MacBook 'Retina').";
1242  const char **UNUSED(argv),
1243  void *UNUSED(data))
1244 {
1245  WM_init_native_pixels(false);
1246  return 0;
1247 }
1248 
1249 static const char arg_handle_with_borders_doc[] =
1250  "\n\t"
1251  "Force opening with borders.";
1252 static int arg_handle_with_borders(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
1253 {
1255  return 0;
1256 }
1257 
1258 static const char arg_handle_without_borders_doc[] =
1259  "\n\t"
1260  "Force opening in fullscreen mode.";
1261 static int arg_handle_without_borders(int UNUSED(argc),
1262  const char **UNUSED(argv),
1263  void *UNUSED(data))
1264 {
1266  return 0;
1267 }
1268 
1269 static const char arg_handle_window_maximized_doc[] =
1270  "\n\t"
1271  "Force opening maximized.";
1273  const char **UNUSED(argv),
1274  void *UNUSED(data))
1275 {
1277  return 0;
1278 }
1279 
1280 static const char arg_handle_no_window_focus_doc[] =
1281  "\n\t"
1282  "Open behind other windows and without taking focus.";
1283 static int arg_handle_no_window_focus(int UNUSED(argc),
1284  const char **UNUSED(argv),
1285  void *UNUSED(data))
1286 {
1287  WM_init_window_focus_set(false);
1288  return 0;
1289 }
1290 
1292  "\n\t"
1293  "Start with the console window open (ignored if '-b' is set), (Windows only).";
1295  const char **UNUSED(argv),
1296  void *UNUSED(data))
1297 {
1299  return 0;
1300 }
1301 
1303  "\n\t"
1304  "Register blend-file extension, then exit (Windows only).";
1306  "\n\t"
1307  "Silently register blend-file extension, then exit (Windows only).";
1308 static int arg_handle_register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data)
1309 {
1310 # ifdef WIN32
1311  if (data) {
1312  G.background = 1;
1313  }
1315 # else
1316  (void)data; /* unused */
1317 # endif
1318  return 0;
1319 }
1320 
1321 static const char arg_handle_audio_disable_doc[] =
1322  "\n\t"
1323  "Force sound system to None.";
1324 static int arg_handle_audio_disable(int UNUSED(argc),
1325  const char **UNUSED(argv),
1326  void *UNUSED(data))
1327 {
1328  BKE_sound_force_device("None");
1329  return 0;
1330 }
1331 
1332 static const char arg_handle_audio_set_doc[] =
1333  "\n\t"
1334  "Force sound system to a specific device."
1335  "\n\t"
1336  "'None' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'.";
1337 static int arg_handle_audio_set(int argc, const char **argv, void *UNUSED(data))
1338 {
1339  if (argc < 1) {
1340  fprintf(stderr, "-setaudio require one argument\n");
1341  exit(1);
1342  }
1343 
1344  BKE_sound_force_device(argv[1]);
1345  return 1;
1346 }
1347 
1348 static const char arg_handle_output_set_doc[] =
1349  "<path>\n"
1350  "\tSet the render path and file name.\n"
1351  "\tUse '//' at the start of the path to render relative to the blend-file.\n"
1352  "\n"
1353  "\tThe '#' characters are replaced by the frame number, and used to define zero padding.\n"
1354  "\n"
1355  "\t* 'animation_##_test.png' becomes 'animation_01_test.png'\n"
1356  "\t* 'test-######.png' becomes 'test-000001.png'\n"
1357  "\n"
1358  "\tWhen the filename does not contain '#', The suffix '####' is added to the filename.\n"
1359  "\n"
1360  "\tThe frame number will be added at the end of the filename, eg:\n"
1361  "\t# blender -b animation.blend -o //render_ -F PNG -x 1 -a\n"
1362  "\t'//render_' becomes '//render_####', writing frames as '//render_0001.png'";
1363 static int arg_handle_output_set(int argc, const char **argv, void *data)
1364 {
1365  bContext *C = data;
1366  if (argc > 1) {
1368  if (scene) {
1369  BLI_strncpy(scene->r.pic, argv[1], sizeof(scene->r.pic));
1371  }
1372  else {
1373  printf("\nError: no blend loaded. cannot use '-o / --render-output'.\n");
1374  }
1375  return 1;
1376  }
1377  printf("\nError: you must specify a path after '-o / --render-output'.\n");
1378  return 0;
1379 }
1380 
1381 static const char arg_handle_engine_set_doc[] =
1382  "<engine>\n"
1383  "\tSpecify the render engine.\n"
1384  "\tUse '-E help' to list available engines.";
1385 static int arg_handle_engine_set(int argc, const char **argv, void *data)
1386 {
1387  bContext *C = data;
1388  if (argc >= 2) {
1389  if (STREQ(argv[1], "help")) {
1391  printf("Blender Engine Listing:\n");
1392  for (type = R_engines.first; type; type = type->next) {
1393  printf("\t%s\n", type->idname);
1394  }
1395  exit(0);
1396  }
1397  else {
1399  if (scene) {
1400  if (BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) {
1401  BLI_strncpy_utf8(scene->r.engine, argv[1], sizeof(scene->r.engine));
1403  }
1404  else {
1405  printf("\nError: engine not found '%s'\n", argv[1]);
1406  exit(1);
1407  }
1408  }
1409  else {
1410  printf(
1411  "\nError: no blend loaded. "
1412  "order the arguments so '-E / --engine' is after a blend is loaded.\n");
1413  }
1414  }
1415 
1416  return 1;
1417  }
1418  printf("\nEngine not specified, give 'help' for a list of available engines.\n");
1419  return 0;
1420 }
1421 
1422 static const char arg_handle_image_type_set_doc[] =
1423  "<format>\n"
1424  "\tSet the render format.\n"
1425  "\tValid options are:\n"
1426  "\t'TGA' 'RAWTGA' 'JPEG' 'IRIS' 'IRIZ' 'AVIRAW' 'AVIJPEG' 'PNG' 'BMP'\n"
1427  "\n"
1428  "\tFormats that can be compiled into Blender, not available on all systems:\n"
1429  "\t'HDR' 'TIFF' 'OPEN_EXR' 'OPEN_EXR_MULTILAYER' 'MPEG' 'CINEON' 'DPX' 'DDS' 'JP2'";
1430 static int arg_handle_image_type_set(int argc, const char **argv, void *data)
1431 {
1432  bContext *C = data;
1433  if (argc > 1) {
1434  const char *imtype = argv[1];
1436  if (scene) {
1437  const char imtype_new = BKE_imtype_from_arg(imtype);
1438 
1439  if (imtype_new == R_IMF_IMTYPE_INVALID) {
1440  printf(
1441  "\nError: Format from '-F / --render-format' not known or not compiled in this "
1442  "release.\n");
1443  }
1444  else {
1445  scene->r.im_format.imtype = imtype_new;
1447  }
1448  }
1449  else {
1450  printf(
1451  "\nError: no blend loaded. "
1452  "order the arguments so '-F / --render-format' is after the blend is loaded.\n");
1453  }
1454  return 1;
1455  }
1456  printf("\nError: you must specify a format after '-F / --render-format'.\n");
1457  return 0;
1458 }
1459 
1460 static const char arg_handle_threads_set_doc[] =
1461  "<threads>\n"
1462  "\tUse amount of <threads> for rendering and other operations\n"
1463  "\t[1-" STRINGIFY(BLENDER_MAX_THREADS) "], 0 for systems processor count.";
1464 static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data))
1465 {
1466  const char *arg_id = "-t / --threads";
1467  const int min = 0, max = BLENDER_MAX_THREADS;
1468  if (argc > 1) {
1469  const char *err_msg = NULL;
1470  int threads;
1471  if (!parse_int_strict_range(argv[1], NULL, min, max, &threads, &err_msg)) {
1472  printf("\nError: %s '%s %s', expected number in [%d..%d].\n",
1473  err_msg,
1474  arg_id,
1475  argv[1],
1476  min,
1477  max);
1478  return 1;
1479  }
1480 
1482  return 1;
1483  }
1484  printf("\nError: you must specify a number of threads in [%d..%d] '%s'.\n", min, max, arg_id);
1485  return 0;
1486 }
1487 
1488 static const char arg_handle_verbosity_set_doc[] =
1489  "<verbose>\n"
1490  "\tSet the logging verbosity level for debug messages that support it.";
1491 static int arg_handle_verbosity_set(int argc, const char **argv, void *UNUSED(data))
1492 {
1493  const char *arg_id = "--verbose";
1494  if (argc > 1) {
1495  const char *err_msg = NULL;
1496  int level;
1497  if (!parse_int(argv[1], NULL, &level, &err_msg)) {
1498  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1499  }
1500 
1501 # ifdef WITH_LIBMV
1503 # elif defined(WITH_CYCLES_LOGGING)
1505 # else
1506  (void)level;
1507 # endif
1508 
1509  return 1;
1510  }
1511  printf("\nError: you must specify a verbosity level.\n");
1512  return 0;
1513 }
1514 
1515 static const char arg_handle_extension_set_doc[] =
1516  "<bool>\n"
1517  "\tSet option to add the file extension to the end of the file.";
1518 static int arg_handle_extension_set(int argc, const char **argv, void *data)
1519 {
1520  bContext *C = data;
1521  if (argc > 1) {
1523  if (scene) {
1524  if (argv[1][0] == '0') {
1525  scene->r.scemode &= ~R_EXTENSION;
1527  }
1528  else if (argv[1][0] == '1') {
1529  scene->r.scemode |= R_EXTENSION;
1531  }
1532  else {
1533  printf("\nError: Use '-x 1 / -x 0' To set the extension option or '--use-extension'\n");
1534  }
1535  }
1536  else {
1537  printf(
1538  "\nError: no blend loaded. "
1539  "order the arguments so '-o ' is after '-x '.\n");
1540  }
1541  return 1;
1542  }
1543  printf("\nError: you must specify a path after '- '.\n");
1544  return 0;
1545 }
1546 
1547 static const char arg_handle_render_frame_doc[] =
1548  "<frame>\n"
1549  "\tRender frame <frame> and save it.\n"
1550  "\n"
1551  "\t* +<frame> start frame relative, -<frame> end frame relative.\n"
1552  "\t* A comma separated list of frames can also be used (no spaces).\n"
1553  "\t* A range of frames can be expressed using '..' separator between the first and last "
1554  "frames (inclusive).\n";
1555 static int arg_handle_render_frame(int argc, const char **argv, void *data)
1556 {
1557  const char *arg_id = "-f / --render-frame";
1558  bContext *C = data;
1560  if (scene) {
1561  Main *bmain = CTX_data_main(C);
1562 
1563  if (argc > 1) {
1564  const char *err_msg = NULL;
1565  Render *re;
1566  ReportList reports;
1567 
1568  int(*frame_range_arr)[2], frames_range_len;
1569  if ((frame_range_arr = parse_int_range_relative_clamp_n(argv[1],
1570  scene->r.sfra,
1571  scene->r.efra,
1572  MINAFRAME,
1573  MAXFRAME,
1574  &frames_range_len,
1575  &err_msg)) == NULL) {
1576  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1577  return 1;
1578  }
1579 
1580  re = RE_NewSceneRender(scene);
1581  BKE_reports_init(&reports, RPT_STORE);
1582  RE_SetReports(re, &reports);
1583  for (int i = 0; i < frames_range_len; i++) {
1584  /* We could pass in frame ranges,
1585  * but prefer having exact behavior as passing in multiple frames */
1586  if ((frame_range_arr[i][0] <= frame_range_arr[i][1]) == 0) {
1587  printf("\nWarning: negative range ignored '%s %s'.\n", arg_id, argv[1]);
1588  }
1589 
1590  for (int frame = frame_range_arr[i][0]; frame <= frame_range_arr[i][1]; frame++) {
1591  RE_RenderAnim(re, bmain, scene, NULL, NULL, frame, frame, scene->r.frame_step);
1592  }
1593  }
1594  RE_SetReports(re, NULL);
1595  BKE_reports_clear(&reports);
1596  MEM_freeN(frame_range_arr);
1597  return 1;
1598  }
1599  printf("\nError: frame number must follow '%s'.\n", arg_id);
1600  return 0;
1601  }
1602  printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
1603  return 0;
1604 }
1605 
1606 static const char arg_handle_render_animation_doc[] =
1607  "\n\t"
1608  "Render frames from start to end (inclusive).";
1609 static int arg_handle_render_animation(int UNUSED(argc), const char **UNUSED(argv), void *data)
1610 {
1611  bContext *C = data;
1613  if (scene) {
1614  Main *bmain = CTX_data_main(C);
1616  ReportList reports;
1617  BKE_reports_init(&reports, RPT_STORE);
1618  RE_SetReports(re, &reports);
1620  RE_SetReports(re, NULL);
1621  BKE_reports_clear(&reports);
1622  }
1623  else {
1624  printf("\nError: no blend loaded. cannot use '-a'.\n");
1625  }
1626  return 0;
1627 }
1628 
1629 static const char arg_handle_scene_set_doc[] =
1630  "<name>\n"
1631  "\tSet the active scene <name> for rendering.";
1632 static int arg_handle_scene_set(int argc, const char **argv, void *data)
1633 {
1634  if (argc > 1) {
1635  bContext *C = data;
1637  if (scene) {
1639 
1640  /* Set the scene of the first window, see: T55991,
1641  * otherwise scrips that run later won't get this scene back from the context. */
1642  wmWindow *win = CTX_wm_window(C);
1643  if (win == NULL) {
1644  win = CTX_wm_manager(C)->windows.first;
1645  }
1646  if (win != NULL) {
1648  }
1649  }
1650  return 1;
1651  }
1652  printf("\nError: Scene name must follow '-S / --scene'.\n");
1653  return 0;
1654 }
1655 
1656 static const char arg_handle_frame_start_set_doc[] =
1657  "<frame>\n"
1658  "\tSet start to frame <frame>, supports +/- for relative frames too.";
1659 static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
1660 {
1661  const char *arg_id = "-s / --frame-start";
1662  bContext *C = data;
1664  if (scene) {
1665  if (argc > 1) {
1666  const char *err_msg = NULL;
1667  if (!parse_int_relative_clamp(argv[1],
1668  NULL,
1669  scene->r.sfra,
1670  scene->r.sfra - 1,
1671  MINAFRAME,
1672  MAXFRAME,
1673  &scene->r.sfra,
1674  &err_msg)) {
1675  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1676  }
1677  else {
1679  }
1680  return 1;
1681  }
1682  printf("\nError: frame number must follow '%s'.\n", arg_id);
1683  return 0;
1684  }
1685  printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
1686  return 0;
1687 }
1688 
1689 static const char arg_handle_frame_end_set_doc[] =
1690  "<frame>\n"
1691  "\tSet end to frame <frame>, supports +/- for relative frames too.";
1692 static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
1693 {
1694  const char *arg_id = "-e / --frame-end";
1695  bContext *C = data;
1697  if (scene) {
1698  if (argc > 1) {
1699  const char *err_msg = NULL;
1700  if (!parse_int_relative_clamp(argv[1],
1701  NULL,
1702  scene->r.efra,
1703  scene->r.efra - 1,
1704  MINAFRAME,
1705  MAXFRAME,
1706  &scene->r.efra,
1707  &err_msg)) {
1708  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1709  }
1710  else {
1712  }
1713  return 1;
1714  }
1715  printf("\nError: frame number must follow '%s'.\n", arg_id);
1716  return 0;
1717  }
1718  printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
1719  return 0;
1720 }
1721 
1722 static const char arg_handle_frame_skip_set_doc[] =
1723  "<frames>\n"
1724  "\tSet number of frames to step forward after each rendered frame.";
1725 static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
1726 {
1727  const char *arg_id = "-j / --frame-jump";
1728  bContext *C = data;
1730  if (scene) {
1731  if (argc > 1) {
1732  const char *err_msg = NULL;
1733  if (!parse_int_clamp(argv[1], NULL, 1, MAXFRAME, &scene->r.frame_step, &err_msg)) {
1734  printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
1735  }
1736  else {
1738  }
1739  return 1;
1740  }
1741  printf("\nError: number of frames to step must follow '%s'.\n", arg_id);
1742  return 0;
1743  }
1744  printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
1745  return 0;
1746 }
1747 
1748 static const char arg_handle_python_file_run_doc[] =
1749  "<filename>\n"
1750  "\tRun the given Python script file.";
1751 static int arg_handle_python_file_run(int argc, const char **argv, void *data)
1752 {
1753 # ifdef WITH_PYTHON
1754  bContext *C = data;
1755 
1756  /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
1757  if (argc > 1) {
1758  /* Make the path absolute because its needed for relative linked blends to be found */
1759  char filename[FILE_MAX];
1760  BLI_strncpy(filename, argv[1], sizeof(filename));
1761  BLI_path_abs_from_cwd(filename, sizeof(filename));
1762 
1763  bool ok;
1764  BPY_CTX_SETUP(ok = BPY_run_filepath(C, filename, NULL));
1765  if (!ok && app_state.exit_code_on_error.python) {
1766  printf("\nError: script failed, file: '%s', exiting.\n", argv[1]);
1767  BPY_python_end();
1769  }
1770  return 1;
1771  }
1772  printf("\nError: you must specify a filepath after '%s'.\n", argv[0]);
1773  return 0;
1774 
1775 # else
1776  UNUSED_VARS(argc, argv, data);
1777  printf("This Blender was built without Python support\n");
1778  return 0;
1779 # endif /* WITH_PYTHON */
1780 }
1781 
1782 static const char arg_handle_python_text_run_doc[] =
1783  "<name>\n"
1784  "\tRun the given Python script text block.";
1785 static int arg_handle_python_text_run(int argc, const char **argv, void *data)
1786 {
1787 # ifdef WITH_PYTHON
1788  bContext *C = data;
1789 
1790  /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
1791  if (argc > 1) {
1792  Main *bmain = CTX_data_main(C);
1793  /* Make the path absolute because its needed for relative linked blends to be found */
1794  struct Text *text = (struct Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
1795  bool ok;
1796 
1797  if (text) {
1798  BPY_CTX_SETUP(ok = BPY_run_text(C, text, NULL, false));
1799  }
1800  else {
1801  printf("\nError: text block not found %s.\n", argv[1]);
1802  ok = false;
1803  }
1804 
1805  if (!ok && app_state.exit_code_on_error.python) {
1806  printf("\nError: script failed, text: '%s', exiting.\n", argv[1]);
1807  BPY_python_end();
1809  }
1810 
1811  return 1;
1812  }
1813  printf("\nError: you must specify a text block after '%s'.\n", argv[0]);
1814  return 0;
1815 
1816 # else
1817  UNUSED_VARS(argc, argv, data);
1818  printf("This Blender was built without Python support\n");
1819  return 0;
1820 # endif /* WITH_PYTHON */
1821 }
1822 
1823 static const char arg_handle_python_expr_run_doc[] =
1824  "<expression>\n"
1825  "\tRun the given expression as a Python script.";
1826 static int arg_handle_python_expr_run(int argc, const char **argv, void *data)
1827 {
1828 # ifdef WITH_PYTHON
1829  bContext *C = data;
1830 
1831  /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
1832  if (argc > 1) {
1833  bool ok;
1834  BPY_CTX_SETUP(ok = BPY_run_string_exec(C, NULL, argv[1]));
1835  if (!ok && app_state.exit_code_on_error.python) {
1836  printf("\nError: script failed, expr: '%s', exiting.\n", argv[1]);
1837  BPY_python_end();
1839  }
1840  return 1;
1841  }
1842  printf("\nError: you must specify a Python expression after '%s'.\n", argv[0]);
1843  return 0;
1844 
1845 # else
1846  UNUSED_VARS(argc, argv, data);
1847  printf("This Blender was built without Python support\n");
1848  return 0;
1849 # endif /* WITH_PYTHON */
1850 }
1851 
1853  "\n\t"
1854  "Run Blender with an interactive console.";
1855 static int arg_handle_python_console_run(int UNUSED(argc), const char **argv, void *data)
1856 {
1857 # ifdef WITH_PYTHON
1858  bContext *C = data;
1859 
1860  BPY_CTX_SETUP(BPY_run_string_eval(C, (const char *[]){"code", NULL}, "code.interact()"));
1861 
1862  return 0;
1863 # else
1864  UNUSED_VARS(argv, data);
1865  printf("This Blender was built without python support\n");
1866  return 0;
1867 # endif /* WITH_PYTHON */
1868 }
1869 
1871  "<code>\n"
1872  "\tSet the exit-code in [0..255] to exit if a Python exception is raised\n"
1873  "\t(only for scripts executed from the command line), zero disables.";
1874 static int arg_handle_python_exit_code_set(int argc, const char **argv, void *UNUSED(data))
1875 {
1876  const char *arg_id = "--python-exit-code";
1877  if (argc > 1) {
1878  const char *err_msg = NULL;
1879  const int min = 0, max = 255;
1880  int exit_code;
1881  if (!parse_int_strict_range(argv[1], NULL, min, max, &exit_code, &err_msg)) {
1882  printf("\nError: %s '%s %s', expected number in [%d..%d].\n",
1883  err_msg,
1884  arg_id,
1885  argv[1],
1886  min,
1887  max);
1888  return 1;
1889  }
1890 
1891  app_state.exit_code_on_error.python = (unsigned char)exit_code;
1892  return 1;
1893  }
1894  printf("\nError: you must specify an exit code number '%s'.\n", arg_id);
1895  return 0;
1896 }
1897 
1899  "\n\t"
1900  "Allow Python to use system environment variables such as 'PYTHONPATH' and the user "
1901  "site-packages directory.";
1903  const char **UNUSED(argv),
1904  void *UNUSED(data))
1905 {
1906 # ifdef WITH_PYTHON
1908 # endif
1909  return 0;
1910 }
1911 
1912 static const char arg_handle_addons_set_doc[] =
1913  "<addon(s)>\n"
1914  "\tComma separated list of add-ons (no spaces).";
1915 static int arg_handle_addons_set(int argc, const char **argv, void *data)
1916 {
1917  /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
1918  if (argc > 1) {
1919 # ifdef WITH_PYTHON
1920  const char script_str[] =
1921  "from addon_utils import check, enable\n"
1922  "for m in '%s'.split(','):\n"
1923  " if check(m)[1] is False:\n"
1924  " enable(m, persistent=True)";
1925  const int slen = strlen(argv[1]) + (sizeof(script_str) - 2);
1926  char *str = malloc(slen);
1927  bContext *C = data;
1928  BLI_snprintf(str, slen, script_str, argv[1]);
1929 
1930  BLI_assert(strlen(str) + 1 == slen);
1931  BPY_CTX_SETUP(BPY_run_string_exec(C, NULL, str));
1932  free(str);
1933 # else
1934  UNUSED_VARS(argv, data);
1935 # endif /* WITH_PYTHON */
1936  return 1;
1937  }
1938  printf("\nError: you must specify a comma separated list after '--addons'.\n");
1939  return 0;
1940 }
1941 
1942 static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data)
1943 {
1944  bContext *C = data;
1945  ReportList reports;
1946  bool success;
1947 
1948  /* Make the path absolute because its needed for relative linked blends to be found */
1949  char filename[FILE_MAX];
1950 
1951  /* note, we could skip these, but so far we always tried to load these files */
1952  if (argv[0][0] == '-') {
1953  fprintf(stderr, "unknown argument, loading as file: %s\n", argv[0]);
1954  }
1955 
1956  BLI_strncpy(filename, argv[0], sizeof(filename));
1957  BLI_path_abs_from_cwd(filename, sizeof(filename));
1958 
1959  /* load the file */
1960  BKE_reports_init(&reports, RPT_PRINT);
1961  WM_file_autoexec_init(filename);
1962  success = WM_file_read(C, filename, &reports);
1963  BKE_reports_clear(&reports);
1964 
1965  if (success) {
1966  if (G.background) {
1967  /* Ensure we use 'C->data.scene' for background render. */
1969  }
1970  }
1971  else {
1972  /* failed to load file, stop processing arguments if running in background mode */
1973  if (G.background) {
1974  /* Set is_break if running in the background mode so
1975  * blender will return non-zero exit code which then
1976  * could be used in automated script to control how
1977  * good or bad things are.
1978  */
1979  G.is_break = true;
1980  return -1;
1981  }
1982 
1983  if (BLO_has_bfile_extension(filename)) {
1984  /* Just pretend a file was loaded, so the user can press Save and it'll
1985  * save at the filename from the CLI. */
1986  BLI_strncpy(G_MAIN->name, filename, FILE_MAX);
1987  G.relbase_valid = true;
1988  G.save_over = true;
1989  printf("... opened default scene instead; saving will write to: %s\n", filename);
1990  }
1991  else {
1992  printf(
1993  "Error: argument has no '.blend' file extension, not using as new file, exiting! %s\n",
1994  filename);
1995  G.is_break = true;
1996  WM_exit(C);
1997  }
1998  }
1999 
2000  G.file_loaded = 1;
2001 
2002  return 0;
2003 }
2004 
2005 static const char arg_handle_load_last_file_doc[] =
2006  "\n\t"
2007  "Open the most recently opened blend file, instead of the default startup file.";
2008 static int arg_handle_load_last_file(int UNUSED(argc), const char **UNUSED(argv), void *data)
2009 {
2010  if (BLI_listbase_is_empty(&G.recent_files)) {
2011  printf("Warning: no recent files known, opening default startup file instead.\n");
2012  return -1;
2013  }
2014 
2015  const RecentFile *recent_file = G.recent_files.first;
2016  const char *fake_argv[] = {recent_file->filepath};
2017  return arg_handle_load_file(ARRAY_SIZE(fake_argv), fake_argv, data);
2018 }
2019 
2021 {
2022 
2023 # define CB(a) a##_doc, a
2024 # define CB_EX(a, b) a##_doc_##b, a
2025 
2026  /* end argument processing after -- */
2027  BLI_args_pass_set(ba, -1);
2029 
2030  /* Pass: Environment Setup
2031  *
2032  * It's important these run before any initialization is done, since they set up
2033  * the environment used to access data-files, which are be used when initializing
2034  * sub-systems such as color management. */
2036  BLI_args_add(
2037  ba, NULL, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), NULL);
2038 
2039  /* Note that we could add used environment variables too. */
2040  BLI_args_add(
2041  ba, NULL, "--env-system-datafiles", CB_EX(arg_handle_env_system_set, datafiles), NULL);
2042  BLI_args_add(ba, NULL, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), NULL);
2043  BLI_args_add(ba, NULL, "--env-system-python", CB_EX(arg_handle_env_system_set, python), NULL);
2044 
2045  BLI_args_add(ba, "-t", "--threads", CB(arg_handle_threads_set), NULL);
2046 
2047  /* Include in the environment pass so it's possible display errors initializing subsystems,
2048  * especially `bpy.appdir` since it's useful to show errors finding paths on startup. */
2049  BLI_args_add(ba, NULL, "--log", CB(arg_handle_log_set), ba);
2050  BLI_args_add(ba, NULL, "--log-level", CB(arg_handle_log_level_set), ba);
2051  BLI_args_add(ba, NULL, "--log-show-basename", CB(arg_handle_log_show_basename_set), ba);
2052  BLI_args_add(ba, NULL, "--log-show-backtrace", CB(arg_handle_log_show_backtrace_set), ba);
2053  BLI_args_add(ba, NULL, "--log-show-timestamp", CB(arg_handle_log_show_timestamp_set), ba);
2054  BLI_args_add(ba, NULL, "--log-file", CB(arg_handle_log_file_set), ba);
2055 
2056  /* Pass: Background Mode & Settings
2057  *
2058  * Also and commands that exit after usage. */
2060  BLI_args_add(ba, "-h", "--help", CB(arg_handle_print_help), ba);
2061  /* Windows only */
2062  BLI_args_add(ba, "/?", NULL, CB_EX(arg_handle_print_help, win32), ba);
2063 
2064  BLI_args_add(ba, "-v", "--version", CB(arg_handle_print_version), NULL);
2065 
2066  BLI_args_add(ba, "-y", "--enable-autoexec", CB_EX(arg_handle_python_set, enable), (void *)true);
2067  BLI_args_add(
2068  ba, "-Y", "--disable-autoexec", CB_EX(arg_handle_python_set, disable), (void *)false);
2069 
2070  BLI_args_add(ba, NULL, "--disable-crash-handler", CB(arg_handle_crash_handler_disable), NULL);
2071  BLI_args_add(ba, NULL, "--disable-abort-handler", CB(arg_handle_abort_handler_disable), NULL);
2072 
2073  BLI_args_add(ba, "-b", "--background", CB(arg_handle_background_mode_set), NULL);
2074 
2076 
2077  BLI_args_add(ba, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);
2078 
2079 # ifdef WITH_FFMPEG
2080  BLI_args_add(ba,
2081  NULL,
2082  "--debug-ffmpeg",
2084  (void *)G_DEBUG_FFMPEG);
2085 # endif
2086 
2087 # ifdef WITH_FREESTYLE
2088  BLI_args_add(ba,
2089 
2090  NULL,
2091  "--debug-freestyle",
2093  (void *)G_DEBUG_FREESTYLE);
2094 # endif
2095 
2096  BLI_args_add(ba,
2097 
2098  NULL,
2099  "--debug-python",
2101  (void *)G_DEBUG_PYTHON);
2102  BLI_args_add(ba,
2103 
2104  NULL,
2105  "--debug-events",
2107  (void *)G_DEBUG_EVENTS);
2108  BLI_args_add(ba,
2109 
2110  NULL,
2111  "--debug-handlers",
2113  (void *)G_DEBUG_HANDLERS);
2114  BLI_args_add(
2115  ba, NULL, "--debug-wm", CB_EX(arg_handle_debug_mode_generic_set, wm), (void *)G_DEBUG_WM);
2116 # ifdef WITH_XR_OPENXR
2117  BLI_args_add(
2118  ba, NULL, "--debug-xr", CB_EX(arg_handle_debug_mode_generic_set, xr), (void *)G_DEBUG_XR);
2119  BLI_args_add(ba,
2120 
2121  NULL,
2122  "--debug-xr-time",
2124  (void *)G_DEBUG_XR_TIME);
2125 # endif
2126  BLI_args_add(ba,
2127  NULL,
2128  "--debug-ghost",
2130  (void *)G_DEBUG_GHOST);
2131  BLI_args_add(ba, NULL, "--debug-all", CB(arg_handle_debug_mode_all), NULL);
2132 
2133  BLI_args_add(ba, NULL, "--debug-io", CB(arg_handle_debug_mode_io), NULL);
2134 
2135  BLI_args_add(ba, NULL, "--debug-fpe", CB(arg_handle_debug_fpe_set), NULL);
2136 
2137 # ifdef WITH_LIBMV
2138  BLI_args_add(ba, NULL, "--debug-libmv", CB(arg_handle_debug_mode_libmv), NULL);
2139 # endif
2140 # ifdef WITH_CYCLES_LOGGING
2141  BLI_args_add(ba, NULL, "--debug-cycles", CB(arg_handle_debug_mode_cycles), NULL);
2142 # endif
2143  BLI_args_add(ba, NULL, "--debug-memory", CB(arg_handle_debug_mode_memory_set), NULL);
2144 
2145  BLI_args_add(ba, NULL, "--debug-value", CB(arg_handle_debug_value_set), NULL);
2146  BLI_args_add(ba,
2147  NULL,
2148  "--debug-jobs",
2150  (void *)G_DEBUG_JOBS);
2151  BLI_args_add(
2152  ba, NULL, "--debug-gpu", CB_EX(arg_handle_debug_mode_generic_set, gpu), (void *)G_DEBUG_GPU);
2153  BLI_args_add(ba,
2154  NULL,
2155  "--debug-depsgraph",
2157  (void *)G_DEBUG_DEPSGRAPH);
2158  BLI_args_add(ba,
2159  NULL,
2160  "--debug-depsgraph-build",
2161  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
2162  (void *)G_DEBUG_DEPSGRAPH_BUILD);
2163  BLI_args_add(ba,
2164  NULL,
2165  "--debug-depsgraph-eval",
2166  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_eval),
2167  (void *)G_DEBUG_DEPSGRAPH_EVAL);
2168  BLI_args_add(ba,
2169  NULL,
2170  "--debug-depsgraph-tag",
2171  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_tag),
2172  (void *)G_DEBUG_DEPSGRAPH_TAG);
2173  BLI_args_add(ba,
2174  NULL,
2175  "--debug-depsgraph-time",
2176  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_time),
2177  (void *)G_DEBUG_DEPSGRAPH_TIME);
2178  BLI_args_add(ba,
2179 
2180  NULL,
2181  "--debug-depsgraph-no-threads",
2182  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads),
2184  BLI_args_add(ba,
2185  NULL,
2186  "--debug-depsgraph-pretty",
2187  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty),
2188  (void *)G_DEBUG_DEPSGRAPH_PRETTY);
2189  BLI_args_add(ba,
2190  NULL,
2191  "--debug-depsgraph-uuid",
2192  CB_EX(arg_handle_debug_mode_generic_set, depsgraph_build),
2193  (void *)G_DEBUG_DEPSGRAPH_UUID);
2194  BLI_args_add(ba,
2195  NULL,
2196  "--debug-gpu-force-workarounds",
2197  CB_EX(arg_handle_debug_mode_generic_set, gpu_force_workarounds),
2199  BLI_args_add(ba, NULL, "--debug-exit-on-error", CB(arg_handle_debug_exit_on_error), NULL);
2200 
2201  BLI_args_add(ba, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
2202 
2203  BLI_args_add(ba, NULL, "--app-template", CB(arg_handle_app_template), NULL);
2204  BLI_args_add(ba, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);
2205  BLI_args_add(ba, NULL, "--enable-event-simulate", CB(arg_handle_enable_event_simulate), NULL);
2206 
2207  /* Pass: Custom Window Stuff. */
2209  BLI_args_add(ba, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL);
2210  BLI_args_add(ba, "-w", "--window-border", CB(arg_handle_with_borders), NULL);
2211  BLI_args_add(ba, "-W", "--window-fullscreen", CB(arg_handle_without_borders), NULL);
2212  BLI_args_add(ba, "-M", "--window-maximized", CB(arg_handle_window_maximized), NULL);
2213  BLI_args_add(ba, NULL, "--no-window-focus", CB(arg_handle_no_window_focus), NULL);
2214  BLI_args_add(ba, "-con", "--start-console", CB(arg_handle_start_with_console), NULL);
2216  BLI_args_add(ba, "-r", NULL, CB_EX(arg_handle_register_extension, silent), ba);
2217  BLI_args_add(ba, NULL, "--no-native-pixels", CB(arg_handle_native_pixels_set), ba);
2218 
2219  /* Pass: Disabling Things & Forcing Settings. */
2221  BLI_args_add_case(ba, "-noaudio", 1, NULL, 0, CB(arg_handle_audio_disable), NULL);
2222  BLI_args_add_case(ba, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL);
2223 
2224  /* Pass: Processing Arguments. */
2226  BLI_args_add(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C);
2227  BLI_args_add(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C);
2228  BLI_args_add(ba, "-S", "--scene", CB(arg_handle_scene_set), C);
2229  BLI_args_add(ba, "-s", "--frame-start", CB(arg_handle_frame_start_set), C);
2230  BLI_args_add(ba, "-e", "--frame-end", CB(arg_handle_frame_end_set), C);
2231  BLI_args_add(ba, "-j", "--frame-jump", CB(arg_handle_frame_skip_set), C);
2232  BLI_args_add(ba, "-P", "--python", CB(arg_handle_python_file_run), C);
2233  BLI_args_add(ba, NULL, "--python-text", CB(arg_handle_python_text_run), C);
2234  BLI_args_add(ba, NULL, "--python-expr", CB(arg_handle_python_expr_run), C);
2235  BLI_args_add(ba, NULL, "--python-console", CB(arg_handle_python_console_run), C);
2236  BLI_args_add(ba, NULL, "--python-exit-code", CB(arg_handle_python_exit_code_set), NULL);
2237  BLI_args_add(ba, NULL, "--addons", CB(arg_handle_addons_set), C);
2238 
2239  BLI_args_add(ba, "-o", "--render-output", CB(arg_handle_output_set), C);
2240  BLI_args_add(ba, "-E", "--engine", CB(arg_handle_engine_set), C);
2241 
2242  BLI_args_add(ba, "-F", "--render-format", CB(arg_handle_image_type_set), C);
2243  BLI_args_add(ba, "-x", "--use-extension", CB(arg_handle_extension_set), C);
2244 
2245  BLI_args_add(ba, NULL, "--open-last", CB(arg_handle_load_last_file), C);
2246 
2247 # undef CB
2248 # undef CB_EX
2249 }
2250 
2255 {
2257 }
2258 
2261 #endif /* WITH_PYTHON_MODULE */
@ BLENDER_SYSTEM_DATAFILES
Definition: BKE_appdir.h:87
@ BLENDER_SYSTEM_PYTHON
Definition: BKE_appdir.h:89
@ BLENDER_SYSTEM_SCRIPTS
Definition: BKE_appdir.h:88
#define BLENDER_STARTUP_FILE
Definition: BKE_appdir.h:99
const char * BKE_blender_version_string(void)
Definition: blender.c:142
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
void CTX_data_scene_set(bContext *C, struct Scene *scene)
Definition: context.c:1197
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
void CTX_wm_window_set(bContext *C, struct wmWindow *win)
Definition: context.c:942
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
#define G_MAIN
Definition: BKE_global.h:232
@ G_DEBUG
Definition: BKE_global.h:133
@ G_DEBUG_GPU
Definition: BKE_global.h:151
@ G_DEBUG_GHOST
Definition: BKE_global.h:157
@ G_DEBUG_XR
Definition: BKE_global.h:154
@ G_DEBUG_HANDLERS
Definition: BKE_global.h:137
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:140
@ G_DEBUG_IO
Definition: BKE_global.h:152
@ G_DEBUG_JOBS
Definition: BKE_global.h:139
@ G_DEBUG_GPU_FORCE_WORKAROUNDS
Definition: BKE_global.h:153
@ G_DEBUG_FFMPEG
Definition: BKE_global.h:134
@ G_DEBUG_DEPSGRAPH_PRETTY
Definition: BKE_global.h:146
@ G_DEBUG_XR_TIME
Definition: BKE_global.h:155
@ G_DEBUG_DEPSGRAPH_TIME
Definition: BKE_global.h:144
@ G_DEBUG_DEPSGRAPH
Definition: BKE_global.h:148
@ G_DEBUG_DEPSGRAPH_EVAL
Definition: BKE_global.h:142
@ G_DEBUG_DEPSGRAPH_NO_THREADS
Definition: BKE_global.h:145
@ G_DEBUG_DEPSGRAPH_TAG
Definition: BKE_global.h:143
@ G_DEBUG_WM
Definition: BKE_global.h:138
@ G_DEBUG_EVENTS
Definition: BKE_global.h:136
@ G_DEBUG_PYTHON
Definition: BKE_global.h:135
@ G_DEBUG_DEPSGRAPH_BUILD
Definition: BKE_global.h:141
@ G_DEBUG_DEPSGRAPH_UUID
Definition: BKE_global.h:147
#define G_DEBUG_ALL
Definition: BKE_global.h:160
@ G_FLAG_SCRIPT_OVERRIDE_PREF
Definition: BKE_global.h:118
@ G_FLAG_EVENT_SIMULATE
Definition: BKE_global.h:113
@ G_FLAG_USERPREF_NO_SAVE_ON_EXIT
Definition: BKE_global.h:114
@ G_FLAG_SCRIPT_AUTOEXEC
Definition: BKE_global.h:116
char BKE_imtype_from_arg(const char *arg)
Definition: image.c:1569
struct ID * BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: lib_id.c:1333
void BKE_reports_clear(ReportList *reports)
Definition: report.c:84
void BKE_reports_init(ReportList *reports, int flag)
Definition: report.c:66
struct Scene * BKE_scene_set_name(struct Main *bmain, const char *name)
Definition: scene.c:2145
void BKE_sound_force_device(const char *device)
A general argument parsing module.
void BLI_args_parse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *data)
Definition: BLI_args.c:289
void BLI_args_print(struct bArgs *ba)
Definition: BLI_args.c:144
void BLI_args_print_other_doc(struct bArgs *ba)
Definition: BLI_args.c:268
void BLI_args_print_arg_doc(struct bArgs *ba, const char *arg)
Definition: BLI_args.c:255
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.c:210
void BLI_args_pass_set(struct bArgs *ba, int current_pass)
Definition: BLI_args.c:138
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.c:230
bool BLI_args_has_other_doc(const struct bArgs *ba)
Definition: BLI_args.c:279
#define BLI_assert(a)
Definition: BLI_assert.h:58
File and directory operations.
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:1003
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void void void BLI_mempool_set_memory_debug(void)
Definition: BLI_mempool.c:769
#define FILE_MAX
void BLI_setenv(const char *env, const char *val) ATTR_NONNULL(1)
Definition: path_util.c:1274
bool BLI_path_abs_from_cwd(char *path, const size_t maxlen) ATTR_NONNULL()
Definition: path_util.c:1128
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string_utf8.c:258
void BLI_system_backtrace(FILE *fp)
Definition: system.c:79
void BLI_system_num_threads_override_set(int num)
Definition: threads.cc:345
#define BLENDER_MAX_THREADS
Definition: BLI_threads.h:35
#define UNPACK4(a)
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define STRINGIFY(x)
#define STRINGIFY_ARG(x)
#define UNUSED(x)
#define POINTER_AS_INT(i)
#define UNLIKELY(x)
#define ELEM(...)
#define STREQ(a, b)
Compatibility-like things for windows.
void BLI_windows_register_blend_extension(const bool background)
external readfile function prototypes.
bool BLO_has_bfile_extension(const char *str)
Definition: readfile.c:1684
void BPY_python_use_system_env(void)
void BPY_python_end(void)
bool BPY_run_string_eval(struct bContext *C, const char *imports[], const char *expr)
bool BPY_run_text(struct bContext *C, struct Text *text, struct ReportList *reports, const bool do_jump)
bool BPY_run_string_exec(struct bContext *C, const char *imports[], const char *expr)
bool BPY_run_filepath(struct bContext *C, const char *filepath, struct ReportList *reports)
void CLG_type_filter_include(const char *type_filter, int type_filter_len)
Definition: clog.c:755
void CLG_output_set(void *file_handle)
Definition: clog.c:720
void CLG_output_use_basename_set(int value)
Definition: clog.c:725
void CLG_error_fn_set(void(*error_fn)(void *file_handle))
Definition: clog.c:735
void CLG_backtrace_fn_set(void(*fatal_fn)(void *file_handle))
Definition: clog.c:745
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len)
Definition: clog.c:750
void CLG_level_set(int level)
Definition: clog.c:760
void CLG_output_use_timestamp_set(int value)
Definition: clog.c:730
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_TXT
Definition: DNA_ID_enums.h:74
#define R_EXTENSION
#define MINAFRAME
#define R_IMF_IMTYPE_INVALID
#define MAXFRAME
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void IMB_ffmpeg_init(void)
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
#define C
Definition: RandGen.cpp:39
void CCL_logging_verbosity_set(int verbosity)
void CCL_start_debug_logging()
char build_type[]
Definition: buildinfo.c:54
char build_cflags[]
Definition: buildinfo.c:62
char build_hash[]
Definition: buildinfo.c:47
char build_commit_date[]
Definition: buildinfo.c:49
char build_commit_time[]
Definition: buildinfo.c:50
char build_linkflags[]
Definition: buildinfo.c:64
char build_system[]
Definition: buildinfo.c:65
char build_date[]
Definition: buildinfo.c:45
char build_cxxflags[]
Definition: buildinfo.c:63
char build_time[]
Definition: buildinfo.c:46
char build_platform[]
Definition: buildinfo.c:53
struct ApplicationState app_state
Definition: creator.c:117
static int arg_handle_audio_set(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_engine_set_doc[]
static const char arg_handle_debug_mode_io_doc[]
static int arg_handle_debug_mode_set(int UNUSED(argc), const char **UNUSED(argv), void *data)
Definition: creator_args.c:917
static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data))
static int arg_handle_audio_disable(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_factory_startup_set_doc[]
static int arg_handle_render_frame(int argc, const char **argv, void *data)
static const char arg_handle_scene_set_doc[]
static const char arg_handle_debug_mode_generic_set_doc_jobs[]
Definition: creator_args.c:967
static const char arg_handle_frame_start_set_doc[]
static bool parse_int_relative(const char *str, const char *str_end_test, int pos, int neg, int *r_value, const char **r_err_msg)
Definition: creator_args.c:95
static const char arg_handle_output_set_doc[]
static int arg_handle_register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data)
static const char arg_handle_render_animation_doc[]
static const char arg_handle_debug_mode_generic_set_doc_wm[]
Definition: creator_args.c:953
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 const char arg_handle_print_version_doc[]
Definition: creator_args.c:484
static const char arg_handle_debug_value_set_doc[]
static const char arg_handle_with_borders_doc[]
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 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]
Definition: creator_args.c:315
#define CB_EX(a, b)
static int arg_handle_load_file(int UNUSED(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)
Definition: creator_args.c:188
static const char arg_handle_log_set_doc[]
Definition: creator_args.c:867
static void print_version_full(void)
Definition: creator_args.c:451
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)
Definition: creator_args.c:156
static const char arg_handle_native_pixels_set_doc[]
static int arg_handle_native_pixels_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static int arg_handle_enable_event_simulate(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static int arg_handle_debug_value_set(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_debug_mode_generic_set_doc_handlers[]
Definition: creator_args.c:950
static int arg_handle_crash_handler_disable(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:732
static const char arg_handle_log_level_set_doc[]
Definition: creator_args.c:782
static const char arg_handle_python_console_run_doc[]
static int arg_handle_render_animation(int UNUSED(argc), const char **UNUSED(argv), void *data)
static const char arg_handle_debug_mode_set_doc[]
Definition: creator_args.c:910
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)
Definition: creator_args.c:245
static const char arg_handle_frame_end_set_doc[]
static const char arg_handle_register_extension_doc[]
static int arg_handle_window_geometry(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_no_threads[]
Definition: creator_args.c:988
static int arg_handle_extension_set(int argc, const char **argv, void *data)
static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
Definition: creator_args.c:502
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[]
Definition: creator_args.c:944
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_time[]
Definition: creator_args.c:982
static const char arg_handle_python_exit_code_set_doc[]
static int arg_handle_without_borders(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_register_extension_doc_silent[]
static int arg_handle_load_last_file(int UNUSED(argc), const char **UNUSED(argv), void *data)
static const char arg_handle_without_borders_doc[]
static const char arg_handle_python_expr_run_doc[]
void main_args_setup(bContext *C, bArgs *ba)
static int arg_handle_python_exit_code_set(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_frame_skip_set_doc[]
static const char arg_handle_python_set_doc_disable[]
Definition: creator_args.c:711
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_eval[]
Definition: creator_args.c:985
#define PY_ENABLE_AUTO
Definition: creator_args.c:701
static int arg_handle_print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:487
#define CB(a)
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_build[]
Definition: creator_args.c:976
static int arg_handle_playback_mode(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_env_system_set_doc_scripts[]
static const char arg_handle_window_maximized_doc[]
static const char arg_handle_python_text_run_doc[]
static int arg_handle_app_template(int argc, const char **argv, void *UNUSED(data))
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)
Definition: creator_args.c:751
static int arg_handle_env_system_set(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_render_frame_doc[]
static const char arg_handle_print_help_doc_win32[]
Definition: creator_args.c:499
static int arg_handle_debug_fpe_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static int arg_handle_background_mode_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:773
static const char arg_handle_audio_disable_doc[]
static void print_version_short(void)
Definition: creator_args.c:469
static bool parse_int(const char *str, const char *str_end_test, int *r_value, const char **r_err_msg)
Definition: creator_args.c:237
static const char arg_handle_start_with_console_doc[]
static int arg_handle_log_set(int argc, const char **argv, void *UNUSED(data))
Definition: creator_args.c:877
static const char arg_handle_addons_set_doc[]
static int arg_handle_arguments_end(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:692
static int arg_handle_addons_set(int argc, const char **argv, void *data)
static int arg_handle_image_type_set(int argc, const char **argv, void *data)
static const char arg_handle_print_help_doc[]
Definition: creator_args.c:496
static int arg_handle_abort_handler_disable(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:743
static int arg_handle_python_use_system_env_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_log_show_basename_set_doc[]
Definition: creator_args.c:806
static int arg_handle_no_window_focus(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_extension_set_doc[]
static int arg_handle_debug_mode_memory_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
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)
Definition: creator_args.c:172
static const char * parse_int_range_sep_search(const char *str, const char *str_end_test)
Definition: creator_args.c:133
static const char arg_handle_debug_mode_memory_set_doc[]
static const char arg_handle_background_mode_set_doc[]
Definition: creator_args.c:770
static int arg_handle_python_console_run(int UNUSED(argc), const char **argv, void *data)
static int arg_handle_debug_mode_generic_set(int UNUSED(argc), const char **UNUSED(argv), void *data)
Definition: creator_args.c:998
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_tag[]
Definition: creator_args.c:979
static int arg_handle_log_show_backtrace_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:820
static const char arg_handle_log_show_backtrace_set_doc[]
Definition: creator_args.c:817
static int arg_handle_factory_startup_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
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)
Definition: creator_args.c:210
static int arg_handle_python_set(int UNUSED(argc), const char **UNUSED(argv), void *data)
Definition: creator_args.c:717
static const char arg_handle_debug_mode_generic_set_doc_depsgraph[]
Definition: creator_args.c:973
static int arg_handle_start_with_console(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static int arg_handle_debug_mode_io(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static int arg_handle_with_borders(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_debug_fpe_set_doc[]
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[]
Definition: creator_args.c:991
void main_args_setup_post(bContext *C, bArgs *ba)
static int arg_handle_frame_end_set(int argc, const char **argv, void *data)
static int arg_handle_verbosity_set(int argc, const char **argv, void *UNUSED(data))
static const char arg_handle_log_file_set_doc[]
Definition: creator_args.c:841
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[]
Definition: creator_args.c:708
#define PY_DISABLE_AUTO
Definition: creator_args.c:702
static const char arg_handle_arguments_end_doc[]
Definition: creator_args.c:688
static const char arg_handle_load_last_file_doc[]
static const char arg_handle_crash_handler_disable_doc[]
Definition: creator_args.c:729
static const char arg_handle_app_template_doc[]
static int arg_handle_log_show_timestamp_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:833
static int arg_handle_log_show_basename_set(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:809
static const char arg_handle_threads_set_doc[]
static const char arg_handle_python_use_system_env_set_doc[]
static const char arg_handle_log_show_timestamp_set_doc[]
Definition: creator_args.c:830
static const char arg_handle_debug_mode_generic_set_doc_gpu[]
Definition: creator_args.c:970
static int arg_handle_debug_mode_all(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_abort_handler_disable_doc[]
Definition: creator_args.c:740
static const char arg_handle_debug_exit_on_error_doc[]
Definition: creator_args.c:758
static const char arg_handle_playback_mode_doc[]
static const char arg_handle_debug_mode_generic_set_doc_events[]
Definition: creator_args.c:947
static int arg_handle_log_file_set(int argc, const char **argv, void *UNUSED(data))
Definition: creator_args.c:844
static int arg_handle_window_maximized(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
static const char arg_handle_debug_mode_generic_set_doc_gpu_force_workarounds[]
Definition: creator_args.c:994
static int arg_handle_frame_skip_set(int argc, const char **argv, void *data)
static int arg_handle_frame_start_set(int argc, const char **argv, void *data)
static int arg_handle_debug_exit_on_error(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
Definition: creator_args.c:761
static int arg_handle_log_level_set(int argc, const char **argv, void *UNUSED(data))
Definition: creator_args.c:786
static const char arg_handle_no_window_focus_doc[]
static int arg_handle_engine_set(int argc, const char **argv, void *data)
static const char arg_handle_debug_mode_all_doc[]
static const char arg_handle_audio_set_doc[]
@ ARG_PASS_ENVIRONMENT
@ ARG_PASS_SETTINGS_FORCE
@ ARG_PASS_SETTINGS_GUI
@ ARG_PASS_FINAL
@ ARG_PASS_SETTINGS
void main_signal_setup_fpe(void)
Scene scene
const Depsgraph * depsgraph
ListBase R_engines
Definition: engine.c:72
#define str(s)
uint pos
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void MEM_enable_fail_on_memleak(void)
void libmv_setLoggingVerbosity(int verbosity)
Definition: logging.cc:57
void libmv_startDebugLogging(void)
Definition: logging.cc:47
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void(* MEM_set_memory_debug)(void)
Definition: mallocn.c:58
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
ListBase threads
list of all thread for every CPUDevice in cpudevices a thread exists.
Render * RE_NewSceneRender(const Scene *scene)
Definition: pipeline.c:598
void RE_RenderAnim(Render *re, Main *bmain, Scene *scene, ViewLayer *single_layer, Object *camera_override, int sfra, int efra, int tfra)
Definition: pipeline.c:2314
void RE_SetReports(Render *re, ReportList *reports)
Definition: pipeline.c:1831
#define min(a, b)
Definition: sort.c:51
struct ApplicationState::@1183 exit_code_on_error
struct ApplicationState::@1182 signal
unsigned char python
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
char * filepath
Definition: WM_types.h:991
char engine[32]
struct ImageFormatData im_format
char pic[1024]
struct RenderData r
Definition: BLI_args.c:61
float max
#define G(x, y, z)
uint len
void WM_init_state_app_template_set(const char *app_template)
Definition: wm_files.c:863
bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
Definition: wm_files.c:736
char app_template[64]
Definition: wm_files.c:853
void WM_file_autoexec_init(const char *filepath)
Definition: wm_files.c:536
void WM_exit(bContext *C)
Main exit function to close Blender ordinarily.
Definition: wm_init_exit.c:679
void WM_init_state_start_with_console_set(bool value)
Definition: wm_init_exit.c:164
void WM_main_playanim(int argc, const char **argv)
Definition: wm_playanim.c:1841
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
Definition: wm_window.c:2257
void WM_init_state_normal_set(void)
Definition: wm_window.c:2044
void WM_init_native_pixels(bool do_it)
Definition: wm_window.c:2061
void WM_init_state_maximized_set(void)
Definition: wm_window.c:2050
void WM_init_state_size_set(int stax, int stay, int sizx, int sizy)
Definition: wm_window.c:2028
void WM_init_state_fullscreen_set(void)
Definition: wm_window.c:2038
void WM_init_window_focus_set(bool do_it)
Definition: wm_window.c:2056