Remove server platform
This commit is contained in:
parent
801aadb401
commit
ae04dac2db
27
SConstruct
27
SConstruct
|
@ -665,20 +665,19 @@ if selected_platform in platform_list:
|
||||||
if not env["verbose"]:
|
if not env["verbose"]:
|
||||||
methods.no_verbose(sys, env)
|
methods.no_verbose(sys, env)
|
||||||
|
|
||||||
if not env["platform"] == "server":
|
GLSL_BUILDERS = {
|
||||||
GLSL_BUILDERS = {
|
"RD_GLSL": env.Builder(
|
||||||
"RD_GLSL": env.Builder(
|
action=env.Run(glsl_builders.build_rd_headers, 'Building RD_GLSL header: "$TARGET"'),
|
||||||
action=env.Run(glsl_builders.build_rd_headers, 'Building RD_GLSL header: "$TARGET"'),
|
suffix="glsl.gen.h",
|
||||||
suffix="glsl.gen.h",
|
src_suffix=".glsl",
|
||||||
src_suffix=".glsl",
|
),
|
||||||
),
|
"GLSL_HEADER": env.Builder(
|
||||||
"GLSL_HEADER": env.Builder(
|
action=env.Run(glsl_builders.build_raw_headers, 'Building GLSL header: "$TARGET"'),
|
||||||
action=env.Run(glsl_builders.build_raw_headers, 'Building GLSL header: "$TARGET"'),
|
suffix="glsl.gen.h",
|
||||||
suffix="glsl.gen.h",
|
src_suffix=".glsl",
|
||||||
src_suffix=".glsl",
|
),
|
||||||
),
|
}
|
||||||
}
|
env.Append(BUILDERS=GLSL_BUILDERS)
|
||||||
env.Append(BUILDERS=GLSL_BUILDERS)
|
|
||||||
|
|
||||||
scons_cache_path = os.environ.get("SCONS_CACHE")
|
scons_cache_path = os.environ.get("SCONS_CACHE")
|
||||||
if scons_cache_path != None:
|
if scons_cache_path != None:
|
||||||
|
|
|
@ -23,7 +23,7 @@ SConscript("coremidi/SCsub")
|
||||||
SConscript("winmidi/SCsub")
|
SConscript("winmidi/SCsub")
|
||||||
|
|
||||||
# Graphics drivers
|
# Graphics drivers
|
||||||
if env["platform"] != "server" and env["platform"] != "javascript":
|
if env["platform"] != "javascript":
|
||||||
SConscript("vulkan/SCsub")
|
SConscript("vulkan/SCsub")
|
||||||
else:
|
else:
|
||||||
SConscript("dummy/SCsub")
|
SConscript("dummy/SCsub")
|
||||||
|
|
|
@ -131,7 +131,7 @@ if env["builtin_harfbuzz"]:
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if env["platform"] == "android" or env["platform"] == "linuxbsd" or env["platform"] == "server":
|
if env["platform"] == "android" or env["platform"] == "linuxbsd":
|
||||||
env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
|
env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
|
||||||
|
|
||||||
if env["platform"] == "javascript":
|
if env["platform"] == "javascript":
|
||||||
|
|
|
@ -235,7 +235,7 @@ if env["platform"] == "uwp":
|
||||||
else:
|
else:
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
is_x11_or_server_arm = (env["platform"] == "linuxbsd" or env["platform"] == "server") and (
|
is_x11_or_server_arm = env["platform"] == "linuxbsd" and (
|
||||||
platform.machine().startswith("arm") or platform.machine().startswith("aarch")
|
platform.machine().startswith("arm") or platform.machine().startswith("aarch")
|
||||||
)
|
)
|
||||||
is_macos_x86 = env["platform"] == "osx" and ("arch" in env and (env["arch"] != "arm64"))
|
is_macos_x86 = env["platform"] == "osx" and ("arch" in env and (env["arch"] != "arm64"))
|
||||||
|
@ -314,12 +314,7 @@ if webm_cpu_x86:
|
||||||
if webm_cpu_arm:
|
if webm_cpu_arm:
|
||||||
if env["platform"] == "iphone":
|
if env["platform"] == "iphone":
|
||||||
env_libvpx["ASFLAGS"] = "-arch armv7"
|
env_libvpx["ASFLAGS"] = "-arch armv7"
|
||||||
elif (
|
elif env["platform"] == "android" and env["android_arch"] == "armv7" or env["platform"] == "linuxbsd":
|
||||||
env["platform"] == "android"
|
|
||||||
and env["android_arch"] == "armv7"
|
|
||||||
or env["platform"] == "linuxbsd"
|
|
||||||
or env["platform"] == "server"
|
|
||||||
):
|
|
||||||
env_libvpx["ASFLAGS"] = "-mfpu=neon"
|
env_libvpx["ASFLAGS"] = "-mfpu=neon"
|
||||||
elif env["platform"] == "uwp":
|
elif env["platform"] == "uwp":
|
||||||
env_libvpx["AS"] = "armasm"
|
env_libvpx["AS"] = "armasm"
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
Import("env")
|
|
||||||
|
|
||||||
common_server = [
|
|
||||||
"os_server.cpp",
|
|
||||||
]
|
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
|
||||||
common_server.append("#platform/osx/crash_handler_osx.mm")
|
|
||||||
else:
|
|
||||||
common_server.append("#platform/x11/crash_handler_x11.cpp")
|
|
||||||
|
|
||||||
prog = env.add_program("#bin/godot_server", ["godot_server.cpp"] + common_server)
|
|
|
@ -1,296 +0,0 @@
|
||||||
import os
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# This file is mostly based on platform/x11/detect.py.
|
|
||||||
# If editing this file, make sure to apply relevant changes here too.
|
|
||||||
|
|
||||||
|
|
||||||
def is_active():
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def get_name():
|
|
||||||
return "Server"
|
|
||||||
|
|
||||||
|
|
||||||
def get_program_suffix():
|
|
||||||
if sys.platform == "darwin":
|
|
||||||
return "osx"
|
|
||||||
return "linuxbsd"
|
|
||||||
|
|
||||||
|
|
||||||
def can_build():
|
|
||||||
if os.name != "posix":
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def get_opts():
|
|
||||||
from SCons.Variables import BoolVariable, EnumVariable
|
|
||||||
|
|
||||||
return [
|
|
||||||
BoolVariable("use_llvm", "Use the LLVM compiler", False),
|
|
||||||
BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", True),
|
|
||||||
BoolVariable("use_coverage", "Test Godot coverage", False),
|
|
||||||
BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False),
|
|
||||||
BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN)", False),
|
|
||||||
BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN)", False),
|
|
||||||
BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN)", False),
|
|
||||||
BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False),
|
|
||||||
BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
|
|
||||||
BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False),
|
|
||||||
BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def get_flags():
|
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def configure(env):
|
|
||||||
|
|
||||||
## Build type
|
|
||||||
|
|
||||||
if env["target"] == "release":
|
|
||||||
if env["optimize"] == "speed": # optimize for speed (default)
|
|
||||||
env.Prepend(CCFLAGS=["-O3"])
|
|
||||||
elif env["optimize"] == "size": # optimize for size
|
|
||||||
env.Prepend(CCFLAGS=["-Os"])
|
|
||||||
|
|
||||||
if env["debug_symbols"]:
|
|
||||||
env.Prepend(CCFLAGS=["-g2"])
|
|
||||||
|
|
||||||
elif env["target"] == "release_debug":
|
|
||||||
if env["optimize"] == "speed": # optimize for speed (default)
|
|
||||||
env.Prepend(CCFLAGS=["-O2"])
|
|
||||||
elif env["optimize"] == "size": # optimize for size
|
|
||||||
env.Prepend(CCFLAGS=["-Os"])
|
|
||||||
env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
|
|
||||||
|
|
||||||
if env["debug_symbols"]:
|
|
||||||
env.Prepend(CCFLAGS=["-g2"])
|
|
||||||
|
|
||||||
elif env["target"] == "debug":
|
|
||||||
env.Prepend(CCFLAGS=["-g3"])
|
|
||||||
env.Prepend(CPPDEFINES=["DEBUG_ENABLED"])
|
|
||||||
env.Append(LINKFLAGS=["-rdynamic"])
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
is64 = sys.maxsize > 2 ** 32
|
|
||||||
if env["bits"] == "default":
|
|
||||||
env["bits"] = "64" if is64 else "32"
|
|
||||||
|
|
||||||
## Compiler configuration
|
|
||||||
|
|
||||||
if "CXX" in env and "clang" in os.path.basename(env["CXX"]):
|
|
||||||
# Convenience check to enforce the use_llvm overrides when CXX is clang(++)
|
|
||||||
env["use_llvm"] = True
|
|
||||||
|
|
||||||
if env["use_llvm"]:
|
|
||||||
if "clang++" not in os.path.basename(env["CXX"]):
|
|
||||||
env["CC"] = "clang"
|
|
||||||
env["CXX"] = "clang++"
|
|
||||||
env.extra_suffix = ".llvm" + env.extra_suffix
|
|
||||||
env.Append(LIBS=["atomic"])
|
|
||||||
|
|
||||||
if env["use_coverage"]:
|
|
||||||
env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"])
|
|
||||||
env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"])
|
|
||||||
|
|
||||||
if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]:
|
|
||||||
env.extra_suffix += "s"
|
|
||||||
|
|
||||||
if env["use_ubsan"]:
|
|
||||||
env.Append(
|
|
||||||
CCFLAGS=[
|
|
||||||
"-fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
env.Append(LINKFLAGS=["-fsanitize=undefined"])
|
|
||||||
if env["use_llvm"]:
|
|
||||||
env.Append(
|
|
||||||
CCFLAGS=[
|
|
||||||
"-fsanitize=nullability-return,nullability-arg,function,nullability-assign,implicit-integer-sign-change"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
env.Append(CCFLAGS=["-fsanitize=bounds-strict"])
|
|
||||||
|
|
||||||
if env["use_asan"]:
|
|
||||||
env.Append(CCFLAGS=["-fsanitize=address,pointer-subtract,pointer-compare"])
|
|
||||||
env.Append(LINKFLAGS=["-fsanitize=address"])
|
|
||||||
|
|
||||||
if env["use_lsan"]:
|
|
||||||
env.Append(CCFLAGS=["-fsanitize=leak"])
|
|
||||||
env.Append(LINKFLAGS=["-fsanitize=leak"])
|
|
||||||
|
|
||||||
if env["use_tsan"]:
|
|
||||||
env.Append(CCFLAGS=["-fsanitize=thread"])
|
|
||||||
env.Append(LINKFLAGS=["-fsanitize=thread"])
|
|
||||||
|
|
||||||
if env["use_msan"] and env["use_llvm"]:
|
|
||||||
env.Append(CCFLAGS=["-fsanitize=memory"])
|
|
||||||
env.Append(CCFLAGS=["-fsanitize-memory-track-origins"])
|
|
||||||
env.Append(CCFLAGS=["-fsanitize-recover=memory"])
|
|
||||||
env.Append(LINKFLAGS=["-fsanitize=memory"])
|
|
||||||
|
|
||||||
if env["use_lto"]:
|
|
||||||
env.Append(CCFLAGS=["-flto"])
|
|
||||||
if not env["use_llvm"] and env.GetOption("num_jobs") > 1:
|
|
||||||
env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))])
|
|
||||||
else:
|
|
||||||
env.Append(LINKFLAGS=["-flto"])
|
|
||||||
if not env["use_llvm"]:
|
|
||||||
env["RANLIB"] = "gcc-ranlib"
|
|
||||||
env["AR"] = "gcc-ar"
|
|
||||||
|
|
||||||
env.Append(CCFLAGS=["-pipe"])
|
|
||||||
env.Append(LINKFLAGS=["-pipe"])
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
# FIXME: Check for existence of the libs before parsing their flags with pkg-config
|
|
||||||
|
|
||||||
# freetype depends on libpng and zlib, so bundling one of them while keeping others
|
|
||||||
# as shared libraries leads to weird issues
|
|
||||||
if (
|
|
||||||
env["builtin_freetype"]
|
|
||||||
or env["builtin_libpng"]
|
|
||||||
or env["builtin_zlib"]
|
|
||||||
or env["builtin_graphite"]
|
|
||||||
or env["builtin_harfbuzz"]
|
|
||||||
):
|
|
||||||
env["builtin_freetype"] = True
|
|
||||||
env["builtin_libpng"] = True
|
|
||||||
env["builtin_zlib"] = True
|
|
||||||
env["builtin_graphite"] = True
|
|
||||||
env["builtin_harfbuzz"] = True
|
|
||||||
|
|
||||||
if not env["builtin_freetype"]:
|
|
||||||
env.ParseConfig("pkg-config freetype2 --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_graphite"]:
|
|
||||||
env.ParseConfig("pkg-config graphite2 --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_icu"]:
|
|
||||||
env.ParseConfig("pkg-config icu-uc --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_harfbuzz"]:
|
|
||||||
env.ParseConfig("pkg-config harfbuzz harfbuzz-icu --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_libpng"]:
|
|
||||||
env.ParseConfig("pkg-config libpng16 --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_bullet"]:
|
|
||||||
# We need at least version 2.89
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip()
|
|
||||||
if str(bullet_version) < "2.89":
|
|
||||||
# Abort as system bullet was requested but too old
|
|
||||||
print(
|
|
||||||
"Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(
|
|
||||||
bullet_version, "2.89"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
sys.exit(255)
|
|
||||||
env.ParseConfig("pkg-config bullet --cflags --libs")
|
|
||||||
|
|
||||||
if False: # not env['builtin_assimp']:
|
|
||||||
# FIXME: Add min version check
|
|
||||||
env.ParseConfig("pkg-config assimp --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_enet"]:
|
|
||||||
env.ParseConfig("pkg-config libenet --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_squish"]:
|
|
||||||
env.ParseConfig("pkg-config libsquish --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_zstd"]:
|
|
||||||
env.ParseConfig("pkg-config libzstd --cflags --libs")
|
|
||||||
|
|
||||||
# Sound and video libraries
|
|
||||||
# Keep the order as it triggers chained dependencies (ogg needed by others, etc.)
|
|
||||||
|
|
||||||
if not env["builtin_libtheora"]:
|
|
||||||
env["builtin_libogg"] = False # Needed to link against system libtheora
|
|
||||||
env["builtin_libvorbis"] = False # Needed to link against system libtheora
|
|
||||||
env.ParseConfig("pkg-config theora theoradec --cflags --libs")
|
|
||||||
else:
|
|
||||||
list_of_x86 = ["x86_64", "x86", "i386", "i586"]
|
|
||||||
if any(platform.machine() in s for s in list_of_x86):
|
|
||||||
env["x86_libtheora_opt_gcc"] = True
|
|
||||||
|
|
||||||
if not env["builtin_libvpx"]:
|
|
||||||
env.ParseConfig("pkg-config vpx --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_libvorbis"]:
|
|
||||||
env["builtin_libogg"] = False # Needed to link against system libvorbis
|
|
||||||
env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_opus"]:
|
|
||||||
env["builtin_libogg"] = False # Needed to link against system opus
|
|
||||||
env.ParseConfig("pkg-config opus opusfile --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_libogg"]:
|
|
||||||
env.ParseConfig("pkg-config ogg --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_libwebp"]:
|
|
||||||
env.ParseConfig("pkg-config libwebp --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_mbedtls"]:
|
|
||||||
# mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
|
|
||||||
env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
|
|
||||||
|
|
||||||
if not env["builtin_wslay"]:
|
|
||||||
env.ParseConfig("pkg-config libwslay --cflags --libs")
|
|
||||||
|
|
||||||
if not env["builtin_miniupnpc"]:
|
|
||||||
# No pkgconfig file so far, hardcode default paths.
|
|
||||||
env.Prepend(CPPPATH=["/usr/include/miniupnpc"])
|
|
||||||
env.Append(LIBS=["miniupnpc"])
|
|
||||||
|
|
||||||
# On Linux wchar_t should be 32-bits
|
|
||||||
# 16-bit library shouldn't be required due to compiler optimisations
|
|
||||||
if not env["builtin_pcre2"]:
|
|
||||||
env.ParseConfig("pkg-config libpcre2-32 --cflags --libs")
|
|
||||||
|
|
||||||
## Flags
|
|
||||||
|
|
||||||
# Linkflags below this line should typically stay the last ones
|
|
||||||
if not env["builtin_zlib"]:
|
|
||||||
env.ParseConfig("pkg-config zlib --cflags --libs")
|
|
||||||
|
|
||||||
env.Prepend(CPPPATH=["#platform/server"])
|
|
||||||
env.Append(CPPDEFINES=["SERVER_ENABLED", "UNIX_ENABLED"])
|
|
||||||
|
|
||||||
if platform.system() == "Darwin":
|
|
||||||
env.Append(
|
|
||||||
LINKFLAGS=[
|
|
||||||
"-framework",
|
|
||||||
"Cocoa",
|
|
||||||
"-framework",
|
|
||||||
"Carbon",
|
|
||||||
"-lz",
|
|
||||||
"-framework",
|
|
||||||
"IOKit",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
env.Append(LIBS=["pthread"])
|
|
||||||
|
|
||||||
if platform.system() == "Linux":
|
|
||||||
env.Append(LIBS=["dl"])
|
|
||||||
|
|
||||||
if platform.system().find("BSD") >= 0:
|
|
||||||
env["execinfo"] = True
|
|
||||||
|
|
||||||
if env["execinfo"]:
|
|
||||||
env.Append(LIBS=["execinfo"])
|
|
||||||
|
|
||||||
# Link those statically for portability
|
|
||||||
if env["use_static_cpp"]:
|
|
||||||
env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"])
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* godot_server.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
#include "main/main.h"
|
|
||||||
#include "os_server.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
OS_Server os;
|
|
||||||
|
|
||||||
// We must override main when testing is enabled
|
|
||||||
TEST_MAIN_OVERRIDE
|
|
||||||
|
|
||||||
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
|
|
||||||
if (err != OK)
|
|
||||||
return 255;
|
|
||||||
|
|
||||||
if (Main::start())
|
|
||||||
os.run(); // it is actually the OS that decides how to run
|
|
||||||
Main::cleanup();
|
|
||||||
|
|
||||||
return os.get_exit_code();
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB |
|
@ -1,267 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* os_server.cpp */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
#include "os_server.h"
|
|
||||||
|
|
||||||
#include "core/string/print_string.h"
|
|
||||||
#include "drivers/dummy/rasterizer_dummy.h"
|
|
||||||
#include "drivers/dummy/texture_loader_dummy.h"
|
|
||||||
#include "servers/rendering/rendering_server_default.h"
|
|
||||||
|
|
||||||
#include "main/main.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int OS_Server::get_video_driver_count() const {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OS_Server::get_video_driver_name(int p_driver) const {
|
|
||||||
return "Dummy";
|
|
||||||
}
|
|
||||||
|
|
||||||
int OS_Server::get_current_video_driver() const {
|
|
||||||
return video_driver_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::initialize_core() {
|
|
||||||
crash_handler.initialize();
|
|
||||||
|
|
||||||
OS_Unix::initialize_core();
|
|
||||||
}
|
|
||||||
|
|
||||||
Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
|
||||||
args = OS::get_singleton()->get_cmdline_args();
|
|
||||||
current_videomode = p_desired;
|
|
||||||
main_loop = nullptr;
|
|
||||||
|
|
||||||
RasterizerDummy::make_current();
|
|
||||||
|
|
||||||
video_driver_index = p_video_driver; // unused in server platform, but should still be initialized
|
|
||||||
|
|
||||||
rendering_server = memnew(RenderingServerDefault);
|
|
||||||
rendering_server->init();
|
|
||||||
|
|
||||||
AudioDriverManager::initialize(p_audio_driver);
|
|
||||||
|
|
||||||
input = memnew(InputDefault);
|
|
||||||
|
|
||||||
_ensure_user_data_dir();
|
|
||||||
|
|
||||||
resource_loader_dummy.instance();
|
|
||||||
ResourceLoader::add_resource_format_loader(resource_loader_dummy);
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::finalize() {
|
|
||||||
if (main_loop)
|
|
||||||
memdelete(main_loop);
|
|
||||||
main_loop = nullptr;
|
|
||||||
|
|
||||||
rendering_server->finish();
|
|
||||||
memdelete(rendering_server);
|
|
||||||
|
|
||||||
memdelete(input);
|
|
||||||
|
|
||||||
ResourceLoader::remove_resource_format_loader(resource_loader_dummy);
|
|
||||||
resource_loader_dummy.unref();
|
|
||||||
|
|
||||||
args.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::set_mouse_show(bool p_show) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::set_mouse_grab(bool p_grab) {
|
|
||||||
grab = p_grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OS_Server::is_mouse_grab_enabled() const {
|
|
||||||
return grab;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OS_Server::get_mouse_button_state() const {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Point2 OS_Server::get_mouse_position() const {
|
|
||||||
return Point2();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::set_window_title(const String &p_title) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
|
|
||||||
}
|
|
||||||
|
|
||||||
OS::VideoMode OS_Server::get_video_mode(int p_screen) const {
|
|
||||||
return current_videomode;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size2 OS_Server::get_window_size() const {
|
|
||||||
return Vector2(current_videomode.width, current_videomode.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
|
|
||||||
}
|
|
||||||
|
|
||||||
MainLoop *OS_Server::get_main_loop() const {
|
|
||||||
return main_loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::delete_main_loop() {
|
|
||||||
if (main_loop)
|
|
||||||
memdelete(main_loop);
|
|
||||||
main_loop = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::set_main_loop(MainLoop *p_main_loop) {
|
|
||||||
main_loop = p_main_loop;
|
|
||||||
input->set_main_loop(p_main_loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_Server::get_name() const {
|
|
||||||
return "Server";
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::move_window_to_foreground() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OS_Server::_check_internal_feature_support(const String &p_feature) {
|
|
||||||
return p_feature == "pc";
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::run() {
|
|
||||||
force_quit = false;
|
|
||||||
|
|
||||||
if (!main_loop)
|
|
||||||
return;
|
|
||||||
|
|
||||||
main_loop->init();
|
|
||||||
|
|
||||||
while (!force_quit) {
|
|
||||||
if (Main::iteration())
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
|
|
||||||
main_loop->finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_Server::get_config_path() const {
|
|
||||||
if (has_environment("XDG_CONFIG_HOME")) {
|
|
||||||
return get_environment("XDG_CONFIG_HOME");
|
|
||||||
} else if (has_environment("HOME")) {
|
|
||||||
return get_environment("HOME").plus_file(".config");
|
|
||||||
} else {
|
|
||||||
return ".";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_Server::get_data_path() const {
|
|
||||||
if (has_environment("XDG_DATA_HOME")) {
|
|
||||||
return get_environment("XDG_DATA_HOME");
|
|
||||||
} else if (has_environment("HOME")) {
|
|
||||||
return get_environment("HOME").plus_file(".local/share");
|
|
||||||
} else {
|
|
||||||
return get_config_path();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_Server::get_cache_path() const {
|
|
||||||
if (has_environment("XDG_CACHE_HOME")) {
|
|
||||||
return get_environment("XDG_CACHE_HOME");
|
|
||||||
} else if (has_environment("HOME")) {
|
|
||||||
return get_environment("HOME").plus_file(".cache");
|
|
||||||
} else {
|
|
||||||
return get_config_path();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String OS_Server::get_system_dir(SystemDir p_dir) const {
|
|
||||||
String xdgparam;
|
|
||||||
|
|
||||||
switch (p_dir) {
|
|
||||||
case SYSTEM_DIR_DESKTOP: {
|
|
||||||
xdgparam = "DESKTOP";
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_DCIM: {
|
|
||||||
xdgparam = "PICTURES";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_DOCUMENTS: {
|
|
||||||
xdgparam = "DOCUMENTS";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_DOWNLOADS: {
|
|
||||||
xdgparam = "DOWNLOAD";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_MOVIES: {
|
|
||||||
xdgparam = "VIDEOS";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_MUSIC: {
|
|
||||||
xdgparam = "MUSIC";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_PICTURES: {
|
|
||||||
xdgparam = "PICTURES";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
case SYSTEM_DIR_RINGTONES: {
|
|
||||||
xdgparam = "MUSIC";
|
|
||||||
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
String pipe;
|
|
||||||
List<String> arg;
|
|
||||||
arg.push_back(xdgparam);
|
|
||||||
Error err = const_cast<OS_Server *>(this)->execute("xdg-user-dir", arg, true, nullptr, &pipe);
|
|
||||||
if (err != OK)
|
|
||||||
return ".";
|
|
||||||
return pipe.strip_edges();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OS_Server::disable_crash_handler() {
|
|
||||||
crash_handler.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OS_Server::is_disable_crash_handler() const {
|
|
||||||
return crash_handler.is_disabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
OS_Server::OS_Server() {
|
|
||||||
//adriver here
|
|
||||||
grab = false;
|
|
||||||
};
|
|
|
@ -1,116 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* os_server.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
#ifndef OS_SERVER_H
|
|
||||||
#define OS_SERVER_H
|
|
||||||
|
|
||||||
#include "core/input/input.h"
|
|
||||||
#include "drivers/dummy/texture_loader_dummy.h"
|
|
||||||
#include "drivers/unix/os_unix.h"
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#include "platform/osx/crash_handler_osx.h"
|
|
||||||
#include "platform/osx/semaphore_osx.h"
|
|
||||||
#else
|
|
||||||
#include "platform/x11/crash_handler_linuxbsd.h"
|
|
||||||
#endif
|
|
||||||
#include "servers/audio_server.h"
|
|
||||||
#include "servers/rendering/renderer_compositor.h"
|
|
||||||
#include "servers/rendering_server.h"
|
|
||||||
|
|
||||||
#undef CursorShape
|
|
||||||
|
|
||||||
class OS_Server : public OS_Unix {
|
|
||||||
RenderingServer *rendering_server = nullptr;
|
|
||||||
VideoMode current_videomode;
|
|
||||||
List<String> args;
|
|
||||||
MainLoop *main_loop = nullptr;
|
|
||||||
|
|
||||||
bool grab = false;
|
|
||||||
|
|
||||||
virtual void delete_main_loop();
|
|
||||||
|
|
||||||
bool force_quit = false;
|
|
||||||
|
|
||||||
InputDefault *input = nullptr;
|
|
||||||
|
|
||||||
CrashHandler crash_handler;
|
|
||||||
|
|
||||||
int video_driver_index = 0;
|
|
||||||
|
|
||||||
Ref<ResourceFormatDummyTexture> resource_loader_dummy;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int get_video_driver_count() const;
|
|
||||||
virtual const char *get_video_driver_name(int p_driver) const;
|
|
||||||
virtual int get_current_video_driver() const;
|
|
||||||
|
|
||||||
virtual void initialize_core();
|
|
||||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
|
||||||
virtual void finalize();
|
|
||||||
|
|
||||||
virtual void set_main_loop(MainLoop *p_main_loop);
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual String get_name() const;
|
|
||||||
|
|
||||||
virtual void set_mouse_show(bool p_show);
|
|
||||||
virtual void set_mouse_grab(bool p_grab);
|
|
||||||
virtual bool is_mouse_grab_enabled() const;
|
|
||||||
virtual Point2 get_mouse_position() const;
|
|
||||||
virtual int get_mouse_button_state() const;
|
|
||||||
virtual void set_window_title(const String &p_title);
|
|
||||||
|
|
||||||
virtual MainLoop *get_main_loop() const;
|
|
||||||
|
|
||||||
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0);
|
|
||||||
virtual VideoMode get_video_mode(int p_screen = 0) const;
|
|
||||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
|
|
||||||
|
|
||||||
virtual Size2 get_window_size() const;
|
|
||||||
|
|
||||||
virtual void move_window_to_foreground();
|
|
||||||
|
|
||||||
void run();
|
|
||||||
|
|
||||||
virtual bool _check_internal_feature_support(const String &p_feature);
|
|
||||||
|
|
||||||
virtual String get_config_path() const;
|
|
||||||
virtual String get_data_path() const;
|
|
||||||
virtual String get_cache_path() const;
|
|
||||||
|
|
||||||
virtual String get_system_dir(SystemDir p_dir) const;
|
|
||||||
|
|
||||||
void disable_crash_handler();
|
|
||||||
bool is_disable_crash_handler() const;
|
|
||||||
|
|
||||||
OS_Server();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*************************************************************************/
|
|
||||||
/* platform_config.h */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* This file is part of: */
|
|
||||||
/* GODOT ENGINE */
|
|
||||||
/* https://godotengine.org */
|
|
||||||
/*************************************************************************/
|
|
||||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
||||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
|
||||||
/* */
|
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
||||||
/* a copy of this software and associated documentation files (the */
|
|
||||||
/* "Software"), to deal in the Software without restriction, including */
|
|
||||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
||||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
||||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
||||||
/* the following conditions: */
|
|
||||||
/* */
|
|
||||||
/* The above copyright notice and this permission notice shall be */
|
|
||||||
/* included in all copies or substantial portions of the Software. */
|
|
||||||
/* */
|
|
||||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
||||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
||||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
||||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
||||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
||||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
||||||
/*************************************************************************/
|
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
|
||||||
#include <alloca.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
|
||||||
#include <stdlib.h> // alloca
|
|
||||||
// FreeBSD and OpenBSD use pthread_set_name_np, while other platforms,
|
|
||||||
// include NetBSD, use pthread_setname_np. NetBSD's version however requires
|
|
||||||
// a different format, we handle this directly in thread_posix.
|
|
||||||
#ifdef __NetBSD__
|
|
||||||
#define PTHREAD_NETBSD_SET_NAME
|
|
||||||
#else
|
|
||||||
#define PTHREAD_BSD_SET_NAME
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#define PTHREAD_RENAME_SELF
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue