2023-08-15 14:20:26 +00:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 14:19:06 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2016-02-27 18:10:00 +00:00
|
|
|
|
2020-08-07 07:50:34 +00:00
|
|
|
#pragma once
|
2016-02-27 18:10:00 +00:00
|
|
|
|
2019-02-17 21:08:12 +00:00
|
|
|
/** \file
|
|
|
|
* \ingroup creator
|
2016-02-27 18:10:00 +00:00
|
|
|
*
|
|
|
|
* Functionality for main() initialization.
|
|
|
|
*/
|
|
|
|
|
2024-04-05 00:24:07 +00:00
|
|
|
struct BA_ArgCallback_Deferred;
|
2016-02-27 18:10:00 +00:00
|
|
|
struct bArgs;
|
|
|
|
struct bContext;
|
|
|
|
|
2022-09-15 17:13:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifndef WITH_PYTHON_MODULE
|
|
|
|
|
2024-03-19 02:57:00 +00:00
|
|
|
/* `creator_args.cc` */
|
2022-04-04 03:17:03 +00:00
|
|
|
|
2023-05-29 02:44:38 +00:00
|
|
|
/**
|
|
|
|
* \param all: When enabled, all arguments are initialized
|
|
|
|
* even for configurations that don't apply to the current system.
|
|
|
|
* Used for documentation (see Python API: `bpy.app.help_text(all=True)`).
|
|
|
|
*/
|
2023-05-27 07:23:19 +00:00
|
|
|
void main_args_setup(struct bContext *C, struct bArgs *ba, bool all);
|
2023-05-29 02:44:38 +00:00
|
|
|
/**
|
|
|
|
* Handler for loading blend files.
|
|
|
|
* \note arguments that cannot be parsed are assumed to be blend files.
|
|
|
|
*/
|
|
|
|
int main_args_handle_load_file(int argc, const char **argv, void *data);
|
2016-02-27 18:10:00 +00:00
|
|
|
|
2024-04-05 00:24:07 +00:00
|
|
|
/**
|
|
|
|
* Handle an argument which requested deferred evaluation.
|
|
|
|
* Needed when arguments which evaluate early need Python to be initialized for example.
|
|
|
|
*/
|
2024-04-10 01:49:08 +00:00
|
|
|
int main_arg_deferred_handle();
|
|
|
|
void main_arg_deferred_free();
|
2024-04-05 00:24:07 +00:00
|
|
|
|
2024-03-19 02:57:00 +00:00
|
|
|
/* `creator_signals.cc` */
|
2022-04-04 03:17:03 +00:00
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
void main_signal_setup(void);
|
|
|
|
void main_signal_setup_background(void);
|
|
|
|
void main_signal_setup_fpe(void);
|
|
|
|
|
2023-12-06 23:35:23 +00:00
|
|
|
#endif /* !WITH_PYTHON_MODULE */
|
2016-02-27 18:10:00 +00:00
|
|
|
|
2020-10-28 05:00:26 +00:00
|
|
|
/** Shared data for argument handlers to store state in. */
|
2016-02-27 18:10:00 +00:00
|
|
|
struct ApplicationState {
|
2019-04-17 04:17:24 +00:00
|
|
|
struct {
|
|
|
|
bool use_crash_handler;
|
|
|
|
bool use_abort_handler;
|
|
|
|
} signal;
|
|
|
|
|
2024-03-19 02:57:00 +00:00
|
|
|
/* We may want to set different exit codes for other kinds of errors. */
|
2019-04-17 04:17:24 +00:00
|
|
|
struct {
|
|
|
|
unsigned char python;
|
|
|
|
} exit_code_on_error;
|
2024-03-08 00:07:41 +00:00
|
|
|
|
2024-04-05 00:24:07 +00:00
|
|
|
/** Store the argument state for later handling. */
|
|
|
|
struct BA_ArgCallback_Deferred *main_arg_deferred;
|
2016-02-27 18:10:00 +00:00
|
|
|
};
|
2024-04-05 00:24:07 +00:00
|
|
|
|
2024-03-19 02:57:00 +00:00
|
|
|
extern struct ApplicationState app_state; /* `creator.cc` */
|
2016-02-27 18:10:00 +00:00
|
|
|
|
2020-10-28 01:58:27 +00:00
|
|
|
/**
|
|
|
|
* Passes for use by #main_args_setup.
|
|
|
|
* Keep in order of execution.
|
|
|
|
*/
|
|
|
|
enum {
|
2020-10-28 05:00:26 +00:00
|
|
|
/** Run before sub-system initialization. */
|
2020-10-28 02:07:31 +00:00
|
|
|
ARG_PASS_ENVIRONMENT = 1,
|
2020-10-28 05:00:26 +00:00
|
|
|
/** General settings parsing, also animation player. */
|
2020-10-28 02:07:31 +00:00
|
|
|
ARG_PASS_SETTINGS = 2,
|
2020-10-28 05:00:26 +00:00
|
|
|
/** Windowing & graphical settings (ignored in background mode). */
|
2020-10-28 02:07:31 +00:00
|
|
|
ARG_PASS_SETTINGS_GUI = 3,
|
2020-10-28 05:00:26 +00:00
|
|
|
/** Currently use for audio devices. */
|
2020-10-28 02:07:31 +00:00
|
|
|
ARG_PASS_SETTINGS_FORCE = 4,
|
2020-10-28 01:58:27 +00:00
|
|
|
|
2023-05-31 00:17:41 +00:00
|
|
|
/**
|
|
|
|
* Actions & fall back to loading blend file.
|
|
|
|
*
|
|
|
|
* \note arguments in the final pass must use #WM_exit instead of `exit()` environment is
|
|
|
|
* properly shut-down (temporary directory deleted, etc).
|
|
|
|
*/
|
2020-10-28 02:07:31 +00:00
|
|
|
ARG_PASS_FINAL = 5,
|
2020-10-28 01:58:27 +00:00
|
|
|
};
|
|
|
|
|
2016-02-27 18:10:00 +00:00
|
|
|
/* for the callbacks: */
|
|
|
|
#ifndef WITH_PYTHON_MODULE
|
2021-04-16 01:17:23 +00:00
|
|
|
# define BLEND_VERSION_FMT "Blender %d.%d.%d"
|
2021-02-13 06:03:20 +00:00
|
|
|
# define BLEND_VERSION_ARG (BLENDER_VERSION / 100), (BLENDER_VERSION % 100), BLENDER_VERSION_PATCH
|
2016-02-27 18:10:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_BUILDINFO_HEADER
|
|
|
|
# define BUILD_DATE
|
|
|
|
#endif
|
|
|
|
|
2022-09-19 04:47:27 +00:00
|
|
|
/* From `buildinfo.c`. */
|
2016-02-27 18:10:00 +00:00
|
|
|
#ifdef BUILD_DATE
|
2019-04-17 04:17:24 +00:00
|
|
|
extern char build_date[];
|
2016-02-27 18:10:00 +00:00
|
|
|
extern char build_time[];
|
|
|
|
extern char build_hash[];
|
|
|
|
extern unsigned long build_commit_timestamp;
|
|
|
|
|
2022-09-19 04:47:27 +00:00
|
|
|
/* TODO(@sergey): ideally size need to be in sync with `buildinfo.c`. */
|
2016-02-27 18:10:00 +00:00
|
|
|
extern char build_commit_date[16];
|
|
|
|
extern char build_commit_time[16];
|
|
|
|
|
|
|
|
extern char build_branch[];
|
|
|
|
extern char build_platform[];
|
|
|
|
extern char build_type[];
|
|
|
|
extern char build_cflags[];
|
|
|
|
extern char build_cxxflags[];
|
|
|
|
extern char build_linkflags[];
|
|
|
|
extern char build_system[];
|
2020-10-28 05:00:26 +00:00
|
|
|
#endif /* BUILD_DATE */
|
2022-09-15 17:13:01 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|