From 88e367a4066773a6fbfe2ea25dc2e81d2035d791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Rold=C3=A1n=20Etcheverry?= Date: Tue, 28 Dec 2021 23:25:16 +0100 Subject: C#/netcore: Add base desktop game export implementation This base implementation is still very barebones but it defines the path for how exporting will work (at least when embedding the .NET runtime). Many manual steps are still needed, which should be automatized in the future. For example, in addition to the API assemblies, now you also need to copy the GodotPlugins assembly to each game project. --- modules/mono/build_scripts/mono_configure.py | 44 ++++++++++++++++------------ 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'modules/mono/build_scripts') diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index 5d2030f756..39c9d58eee 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -25,7 +25,7 @@ def configure(env, env_mono): if tools_enabled and not module_supports_tools_on(env["platform"]): raise RuntimeError("This module does not currently support building for this platform with tools enabled") - if env["tools"] or env["target"] != "release": + if env["tools"]: env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"]) app_host_dir = find_dotnet_app_host_dir(env) @@ -47,29 +47,33 @@ def configure(env, env_mono): check_app_host_file_exists("hostfxr.h") check_app_host_file_exists("coreclr_delegates.h") - env.Append(LIBPATH=[app_host_dir]) env_mono.Prepend(CPPPATH=app_host_dir) - libnethost_path = os.path.join(app_host_dir, "libnethost.lib" if os.name == "nt" else "libnethost.a") + env.Append(LIBPATH=[app_host_dir]) + + # Only the editor build links nethost, which is needed to find hostfxr. + # Exported games don't need this logic as hostfxr is bundled with them. + if tools_enabled: + libnethost_path = os.path.join(app_host_dir, "libnethost.lib" if os.name == "nt" else "libnethost.a") - if env["platform"] == "windows": - env_mono.Append(CPPDEFINES=["NETHOST_USE_AS_STATIC"]) + if env["platform"] == "windows": + env_mono.Append(CPPDEFINES=["NETHOST_USE_AS_STATIC"]) - if env.msvc: - env.Append(LINKFLAGS="libnethost.lib") + if env.msvc: + env.Append(LINKFLAGS="libnethost.lib") + else: + env.Append(LINKFLAGS=["-Wl,-whole-archive", libnethost_path, "-Wl,-no-whole-archive"]) else: - env.Append(LINKFLAGS=["-Wl,-whole-archive", libnethost_path, "-Wl,-no-whole-archive"]) - else: - is_apple = env["platform"] in ["macos", "ios"] - # is_macos = is_apple and not is_ios + is_apple = env["platform"] in ["macos", "ios"] + # is_macos = is_apple and not is_ios - # if is_ios and not is_ios_sim: - # env_mono.Append(CPPDEFINES=["IOS_DEVICE"]) + # if is_ios and not is_ios_sim: + # env_mono.Append(CPPDEFINES=["IOS_DEVICE"]) - if is_apple: - env.Append(LINKFLAGS=["-Wl,-force_load," + libnethost_path]) - else: - env.Append(LINKFLAGS=["-Wl,-whole-archive", libnethost_path, "-Wl,-no-whole-archive"]) + if is_apple: + env.Append(LINKFLAGS=["-Wl,-force_load," + libnethost_path]) + else: + env.Append(LINKFLAGS=["-Wl,-whole-archive", libnethost_path, "-Wl,-no-whole-archive"]) def find_dotnet_app_host_dir(env): @@ -156,7 +160,8 @@ def find_app_host_version(dotnet_cmd, search_version_str): search_version = LooseVersion(search_version_str) try: - lines = subprocess.check_output([dotnet_cmd, "--list-runtimes"]).splitlines() + env = dict(os.environ, DOTNET_CLI_UI_LANGUAGE="en-US") + lines = subprocess.check_output([dotnet_cmd, "--list-runtimes"], env=env).splitlines() for line_bytes in lines: line = line_bytes.decode("utf-8") @@ -188,7 +193,8 @@ def find_dotnet_sdk(dotnet_cmd, search_version_str): search_version = LooseVersion(search_version_str) try: - lines = subprocess.check_output([dotnet_cmd, "--list-sdks"]).splitlines() + env = dict(os.environ, DOTNET_CLI_UI_LANGUAGE="en-US") + lines = subprocess.check_output([dotnet_cmd, "--list-sdks"], env=env).splitlines() for line_bytes in lines: line = line_bytes.decode("utf-8") -- cgit v1.2.3