SCons: add disable_xr option

Currently only disables all xr modules (openxr, webxr, mobile_vr) and xr nodes

Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
This commit is contained in:
Yevhen Babiichuk (DustDFG) 2024-09-25 19:11:10 +03:00
parent 88e3255191
commit f98d398004
7 changed files with 26 additions and 10 deletions

View file

@ -257,6 +257,7 @@ opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False))
opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot")
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "")
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False))
opts.Add(BoolVariable("disable_xr", "Disable XR nodes for a smaller executable", False))
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
opts.Add("build_profile", "Path to a file containing a feature build profile", "")
opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True))
@ -999,6 +1000,13 @@ if env["disable_3d"]:
Exit(255)
else:
env.Append(CPPDEFINES=["_3D_DISABLED"])
env["disable_xr"] = True
if env["disable_xr"]:
if env.editor_build:
print_error("Build option `disable_xr=yes` cannot be used for editor builds, only for export template builds.")
Exit(255)
else:
env.Append(CPPDEFINES=["_XR_DISABLED"])
if env["disable_advanced_gui"]:
if env.editor_build:
print_error(

View file

@ -612,7 +612,7 @@ void Main::print_help(const char *p_binary) {
print_help_option("--position <X>,<Y>", "Request window position.\n");
print_help_option("--screen <N>", "Request window screen.\n");
print_help_option("--single-window", "Use a single window (no separate subwindows).\n");
#ifndef _3D_DISABLED
#ifndef _XR_DISABLED
print_help_option("--xr-mode <mode>", "Select XR (Extended Reality) mode [\"default\", \"off\", \"on\"].\n");
#endif
@ -1722,7 +1722,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->disable_crash_handler();
} else if (arg == "--skip-breakpoints") {
skip_breakpoints = true;
#ifndef _3D_DISABLED
#ifndef _XR_DISABLED
} else if (arg == "--xr-mode") {
if (N) {
String xr_mode = N->get().to_lower();

View file

@ -1,5 +1,5 @@
def can_build(env, platform):
return not env["disable_3d"]
return not env["disable_xr"]
def configure(env):

View file

@ -1,6 +1,6 @@
def can_build(env, platform):
if platform in ("linuxbsd", "windows", "android", "macos"):
return env["openxr"] and not env["disable_3d"]
return env["openxr"] and not env["disable_xr"]
else:
# not supported on these platforms
return False

View file

@ -1,5 +1,5 @@
def can_build(env, platform):
return env["opengl3"] and not env["disable_3d"]
return env["opengl3"] and not env["disable_xr"]
def configure(env):

View file

@ -7,4 +7,5 @@ env.add_source_files(env.scene_sources, "*.cpp")
# Chain load SCsubs
SConscript("physics/SCsub")
SConscript("xr/SCsub")
if not env["disable_xr"]:
SConscript("xr/SCsub")

View file

@ -284,10 +284,6 @@
#include "scene/3d/visible_on_screen_notifier_3d.h"
#include "scene/3d/voxel_gi.h"
#include "scene/3d/world_environment.h"
#include "scene/3d/xr/xr_body_modifier_3d.h"
#include "scene/3d/xr/xr_face_modifier_3d.h"
#include "scene/3d/xr/xr_hand_modifier_3d.h"
#include "scene/3d/xr/xr_nodes.h"
#include "scene/animation/root_motion_view.h"
#include "scene/resources/3d/box_shape_3d.h"
#include "scene/resources/3d/capsule_shape_3d.h"
@ -307,6 +303,13 @@
#include "scene/resources/3d/world_boundary_shape_3d.h"
#endif // _3D_DISABLED
#ifndef _XR_DISABLED
#include "scene/3d/xr/xr_body_modifier_3d.h"
#include "scene/3d/xr/xr_face_modifier_3d.h"
#include "scene/3d/xr/xr_hand_modifier_3d.h"
#include "scene/3d/xr/xr_nodes.h"
#endif // _XR_DISABLED
static Ref<ResourceFormatSaverText> resource_saver_text;
static Ref<ResourceFormatLoaderText> resource_loader_text;
@ -544,6 +547,8 @@ void register_scene_types() {
GDREGISTER_VIRTUAL_CLASS(GeometryInstance3D);
GDREGISTER_CLASS(Camera3D);
GDREGISTER_CLASS(AudioListener3D);
#ifndef _XR_DISABLED
GDREGISTER_CLASS(XRCamera3D);
GDREGISTER_CLASS(XRNode3D);
GDREGISTER_CLASS(XRController3D);
@ -552,6 +557,8 @@ void register_scene_types() {
GDREGISTER_CLASS(XRBodyModifier3D);
GDREGISTER_CLASS(XRHandModifier3D);
GDREGISTER_CLASS(XRFaceModifier3D);
#endif // _XR_DISABLED
GDREGISTER_CLASS(MeshInstance3D);
GDREGISTER_CLASS(OccluderInstance3D);
GDREGISTER_ABSTRACT_CLASS(Occluder3D);