Skip to content

Commit

Permalink
[Godot] Custom static library config.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Sep 25, 2023
1 parent 9fc3baf commit 74885b1
Show file tree
Hide file tree
Showing 10 changed files with 1,321 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -131,3 +131,9 @@ TestResults.qpa

# Any temporary files will confuse code generation.
!scripts/code_generation_hashes/*

# Godot scons files.
*.obj
.sconsign.dblite
bin/
*.o
815 changes: 815 additions & 0 deletions SConstruct

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions godot-patches/patch_mingw_build.diff
@@ -0,0 +1,197 @@
diff --git a/include/platform/PlatformMethods.h b/include/platform/PlatformMethods.h
index a3233a2cd5..b4e684842c 100644
--- a/include/platform/PlatformMethods.h
+++ b/include/platform/PlatformMethods.h
@@ -313,7 +313,7 @@ extern "C" {
// The application should set any platform methods it cares about on the returned pointer.
// If display is not valid, behaviour is undefined.

-ANGLE_PLATFORM_EXPORT bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisplayType display,
+bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisplayType display,
const char *const methodNames[],
unsigned int methodNameCount,
void *context,
@@ -321,7 +321,7 @@ ANGLE_PLATFORM_EXPORT bool ANGLE_APIENTRY ANGLEGetDisplayPlatform(angle::EGLDisp

// Sets the platform methods back to their defaults.
// If display is not valid, behaviour is undefined.
-ANGLE_PLATFORM_EXPORT void ANGLE_APIENTRY ANGLEResetDisplayPlatform(angle::EGLDisplayType display);
+void ANGLE_APIENTRY ANGLEResetDisplayPlatform(angle::EGLDisplayType display);
} // extern "C"

namespace angle
diff --git a/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.cpp b/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.cpp
index 0e64f78d53..17ed63e66c 100644
--- a/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.cpp
@@ -38,14 +38,22 @@ bool CompositorNativeWindow11::getClientRect(LPRECT rect) const
mHostVisual.As(&visual);

ABI::Windows::Foundation::Numerics::Vector2 size;
+#if defined(MINGW_ENABLED)
+ HRESULT hr = visual->get_Size((ABI::Windows::UI::Composition::Vector2*)&size);
+#else
HRESULT hr = visual->get_Size(&size);
+#endif
if (FAILED(hr))
{
return false;
}

ABI::Windows::Foundation::Numerics::Vector3 offset;
+#if defined(MINGW_ENABLED)
+ hr = visual->get_Offset((ABI::Windows::UI::Composition::Vector3*)&offset);
+#else
hr = visual->get_Offset(&offset);
+#endif
if (FAILED(hr))
{
return false;
diff --git a/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h b/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h
index aec331a76c..be98814486 100644
--- a/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h
+++ b/src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h
@@ -12,6 +12,143 @@

#include "libANGLE/renderer/d3d/d3d11/NativeWindow11.h"

+#if defined(MINGW_ENABLED)
+#ifndef DirectXAlphaMode
+enum DirectXAlphaMode {
+ DirectXAlphaMode_Unspecified = 0,
+ DirectXAlphaMode_Premultiplied = 1,
+ DirectXAlphaMode_Straight = 2,
+ DirectXAlphaMode_Ignore = 3
+};
+#endif
+
+#ifndef DirectXPixelFormat
+enum DirectXPixelFormat {
+ DirectXPixelFormat_Unknown = 0,
+ DirectXPixelFormat_R32G32B32A32Typeless = 1,
+ DirectXPixelFormat_R32G32B32A32Float = 2,
+ DirectXPixelFormat_R32G32B32A32UInt = 3,
+ DirectXPixelFormat_R32G32B32A32Int = 4,
+ DirectXPixelFormat_R32G32B32Typeless = 5,
+ DirectXPixelFormat_R32G32B32Float = 6,
+ DirectXPixelFormat_R32G32B32UInt = 7,
+ DirectXPixelFormat_R32G32B32Int = 8,
+ DirectXPixelFormat_R16G16B16A16Typeless = 9,
+ DirectXPixelFormat_R16G16B16A16Float = 10,
+ DirectXPixelFormat_R16G16B16A16UIntNormalized = 11,
+ DirectXPixelFormat_R16G16B16A16UInt = 12,
+ DirectXPixelFormat_R16G16B16A16IntNormalized = 13,
+ DirectXPixelFormat_R16G16B16A16Int = 14,
+ DirectXPixelFormat_R32G32Typeless = 15,
+ DirectXPixelFormat_R32G32Float = 16,
+ DirectXPixelFormat_R32G32UInt = 17,
+ DirectXPixelFormat_R32G32Int = 18,
+ DirectXPixelFormat_R32G8X24Typeless = 19,
+ DirectXPixelFormat_D32FloatS8X24UInt = 20,
+ DirectXPixelFormat_R32FloatX8X24Typeless = 21,
+ DirectXPixelFormat_X32TypelessG8X24UInt = 22,
+ DirectXPixelFormat_R10G10B10A2Typeless = 23,
+ DirectXPixelFormat_R10G10B10A2UIntNormalized = 24,
+ DirectXPixelFormat_R10G10B10A2UInt = 25,
+ DirectXPixelFormat_R11G11B10Float = 26,
+ DirectXPixelFormat_R8G8B8A8Typeless = 27,
+ DirectXPixelFormat_R8G8B8A8UIntNormalized = 28,
+ DirectXPixelFormat_R8G8B8A8UIntNormalizedSrgb = 29,
+ DirectXPixelFormat_R8G8B8A8UInt = 30,
+ DirectXPixelFormat_R8G8B8A8IntNormalized = 31,
+ DirectXPixelFormat_R8G8B8A8Int = 32,
+ DirectXPixelFormat_R16G16Typeless = 33,
+ DirectXPixelFormat_R16G16Float = 34,
+ DirectXPixelFormat_R16G16UIntNormalized = 35,
+ DirectXPixelFormat_R16G16UInt = 36,
+ DirectXPixelFormat_R16G16IntNormalized = 37,
+ DirectXPixelFormat_R16G16Int = 38,
+ DirectXPixelFormat_R32Typeless = 39,
+ DirectXPixelFormat_D32Float = 40,
+ DirectXPixelFormat_R32Float = 41,
+ DirectXPixelFormat_R32UInt = 42,
+ DirectXPixelFormat_R32Int = 43,
+ DirectXPixelFormat_R24G8Typeless = 44,
+ DirectXPixelFormat_D24UIntNormalizedS8UInt = 45,
+ DirectXPixelFormat_R24UIntNormalizedX8Typeless = 46,
+ DirectXPixelFormat_X24TypelessG8UInt = 47,
+ DirectXPixelFormat_R8G8Typeless = 48,
+ DirectXPixelFormat_R8G8UIntNormalized = 49,
+ DirectXPixelFormat_R8G8UInt = 50,
+ DirectXPixelFormat_R8G8IntNormalized = 51,
+ DirectXPixelFormat_R8G8Int = 52,
+ DirectXPixelFormat_R16Typeless = 53,
+ DirectXPixelFormat_R16Float = 54,
+ DirectXPixelFormat_D16UIntNormalized = 55,
+ DirectXPixelFormat_R16UIntNormalized = 56,
+ DirectXPixelFormat_R16UInt = 57,
+ DirectXPixelFormat_R16IntNormalized = 58,
+ DirectXPixelFormat_R16Int = 59,
+ DirectXPixelFormat_R8Typeless = 60,
+ DirectXPixelFormat_R8UIntNormalized = 61,
+ DirectXPixelFormat_R8UInt = 62,
+ DirectXPixelFormat_R8IntNormalized = 63,
+ DirectXPixelFormat_R8Int = 64,
+ DirectXPixelFormat_A8UIntNormalized = 65,
+ DirectXPixelFormat_R1UIntNormalized = 66,
+ DirectXPixelFormat_R9G9B9E5SharedExponent = 67,
+ DirectXPixelFormat_R8G8B8G8UIntNormalized = 68,
+ DirectXPixelFormat_G8R8G8B8UIntNormalized = 69,
+ DirectXPixelFormat_BC1Typeless = 70,
+ DirectXPixelFormat_BC1UIntNormalized = 71,
+ DirectXPixelFormat_BC1UIntNormalizedSrgb = 72,
+ DirectXPixelFormat_BC2Typeless = 73,
+ DirectXPixelFormat_BC2UIntNormalized = 74,
+ DirectXPixelFormat_BC2UIntNormalizedSrgb = 75,
+ DirectXPixelFormat_BC3Typeless = 76,
+ DirectXPixelFormat_BC3UIntNormalized = 77,
+ DirectXPixelFormat_BC3UIntNormalizedSrgb = 78,
+ DirectXPixelFormat_BC4Typeless = 79,
+ DirectXPixelFormat_BC4UIntNormalized = 80,
+ DirectXPixelFormat_BC4IntNormalized = 81,
+ DirectXPixelFormat_BC5Typeless = 82,
+ DirectXPixelFormat_BC5UIntNormalized = 83,
+ DirectXPixelFormat_BC5IntNormalized = 84,
+ DirectXPixelFormat_B5G6R5UIntNormalized = 85,
+ DirectXPixelFormat_B5G5R5A1UIntNormalized = 86,
+ DirectXPixelFormat_B8G8R8A8UIntNormalized = 87,
+ DirectXPixelFormat_B8G8R8X8UIntNormalized = 88,
+ DirectXPixelFormat_R10G10B10XRBiasA2UIntNormalized = 89,
+ DirectXPixelFormat_B8G8R8A8Typeless = 90,
+ DirectXPixelFormat_B8G8R8A8UIntNormalizedSrgb = 91,
+ DirectXPixelFormat_B8G8R8X8Typeless = 92,
+ DirectXPixelFormat_B8G8R8X8UIntNormalizedSrgb = 93,
+ DirectXPixelFormat_BC6HTypeless = 94,
+ DirectXPixelFormat_BC6H16UnsignedFloat = 95,
+ DirectXPixelFormat_BC6H16Float = 96,
+ DirectXPixelFormat_BC7Typeless = 97,
+ DirectXPixelFormat_BC7UIntNormalized = 98,
+ DirectXPixelFormat_BC7UIntNormalizedSrgb = 99,
+ DirectXPixelFormat_Ayuv = 100,
+ DirectXPixelFormat_Y410 = 101,
+ DirectXPixelFormat_Y416 = 102,
+ DirectXPixelFormat_NV12 = 103,
+ DirectXPixelFormat_P010 = 104,
+ DirectXPixelFormat_P016 = 105,
+ DirectXPixelFormat_Opaque420 = 106,
+ DirectXPixelFormat_Yuy2 = 107,
+ DirectXPixelFormat_Y210 = 108,
+ DirectXPixelFormat_Y216 = 109,
+ DirectXPixelFormat_NV11 = 110,
+ DirectXPixelFormat_AI44 = 111,
+ DirectXPixelFormat_IA44 = 112,
+ DirectXPixelFormat_P8 = 113,
+ DirectXPixelFormat_A8P8 = 114,
+ DirectXPixelFormat_B4G4R4A4UIntNormalized = 115,
+ DirectXPixelFormat_P208 = 130,
+ DirectXPixelFormat_V208 = 131,
+ DirectXPixelFormat_V408 = 132,
+ DirectXPixelFormat_SamplerFeedbackMinMipOpaque = 189,
+ DirectXPixelFormat_SamplerFeedbackMipRegionUsedOpaque = 190
+};
+#endif
+#endif
+
#include <dispatcherqueue.h>
#include <windows.foundation.metadata.h>
#include <windows.ui.composition.h>
50 changes: 50 additions & 0 deletions godot-tools/macos.py
@@ -0,0 +1,50 @@
import os
import sys
import macos_osxcross


def options(opts):
opts.Add("macos_deployment_target", "macOS deployment target", "default")
opts.Add("macos_sdk_path", "macOS SDK path", "")
macos_osxcross.options(opts)


def exists(env):
return sys.platform == "darwin" or macos_osxcross.exists(env)


def generate(env):
if env["arch"] not in ("universal", "arm64", "x86_64"):
print("Only universal, arm64, and x86_64 are supported on macOS. Exiting.")
Exit()

if sys.platform == "darwin":
# Use clang on macOS by default
env["CXX"] = "clang++"
env["CC"] = "clang"
else:
# Use osxcross
macos_osxcross.generate(env)

if env["arch"] == "universal":
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
else:
env.Append(LINKFLAGS=["-arch", env["arch"]])
env.Append(CCFLAGS=["-arch", env["arch"]])

if env["macos_deployment_target"] != "default":
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
env.Append(LINKFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])

if env["macos_sdk_path"]:
env.Append(CCFLAGS=["-isysroot", env["macos_sdk_path"]])
env.Append(LINKFLAGS=["-isysroot", env["macos_sdk_path"]])

env.Append(
LINKFLAGS=[
"-framework",
"Cocoa",
"-Wl,-undefined,dynamic_lookup",
]
)
28 changes: 28 additions & 0 deletions godot-tools/macos_osxcross.py
@@ -0,0 +1,28 @@
import os


def options(opts):
opts.Add("osxcross_sdk", "OSXCross SDK version", "darwin16")


def exists(env):
return "OSXCROSS_ROOT" in os.environ


def generate(env):
root = os.environ.get("OSXCROSS_ROOT", "")
if env["arch"] == "arm64":
basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-"
else:
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"

env["CC"] = basecmd + "clang"
env["CXX"] = basecmd + "clang++"
env["AR"] = basecmd + "ar"
env["RANLIB"] = basecmd + "ranlib"
env["AS"] = basecmd + "as"

binpath = os.path.join(root, "target", "bin")
if binpath not in env["ENV"]["PATH"]:
# Add OSXCROSS bin folder to PATH (required for linking).
env["ENV"]["PATH"] = "%s:%s" % (binpath, env["ENV"]["PATH"])
52 changes: 52 additions & 0 deletions godot-tools/my_spawn.py
@@ -0,0 +1,52 @@
import os


def exists(env):
return os.name == "nt"


# Workaround for MinGW. See:
# http://www.scons.org/wiki/LongCmdLinesOnWin32
def configure(env):
import subprocess

def mySubProcess(cmdline, env):
# print "SPAWNED : " + cmdline
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(
cmdline,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo,
shell=False,
env=env,
)
data, err = proc.communicate()
rv = proc.wait()
if rv:
print("=====")
print(err.decode("utf-8"))
print("=====")
return rv

def mySpawn(sh, escape, cmd, args, env):

newargs = " ".join(args[1:])
cmdline = cmd + " " + newargs

rv = 0
if len(cmdline) > 32000 and cmd.endswith("ar"):
cmdline = cmd + " " + args[1] + " " + args[2] + " "
for i in range(3, len(args)):
rv = mySubProcess(cmdline + args[i], env)
if rv:
break
else:
rv = mySubProcess(cmdline, env)

return rv

env["SPAWN"] = mySpawn
env.Replace(ARFLAGS=["q"])

0 comments on commit 74885b1

Please sign in to comment.