mirror of
https://github.com/godotengine/godot-nir-static.git
synced 2026-01-04 06:09:47 +03:00
Initial commit.
This commit is contained in:
BIN
godot-tools/__pycache__/macos.cpython-310.pyc
Normal file
BIN
godot-tools/__pycache__/macos.cpython-310.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/macos.cpython-311.pyc
Normal file
BIN
godot-tools/__pycache__/macos.cpython-311.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/macos_osxcross.cpython-310.pyc
Normal file
BIN
godot-tools/__pycache__/macos_osxcross.cpython-310.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/macos_osxcross.cpython-311.pyc
Normal file
BIN
godot-tools/__pycache__/macos_osxcross.cpython-311.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/my_spawn.cpython-310.pyc
Normal file
BIN
godot-tools/__pycache__/my_spawn.cpython-310.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/my_spawn.cpython-311.pyc
Normal file
BIN
godot-tools/__pycache__/my_spawn.cpython-311.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/targets.cpython-310.pyc
Normal file
BIN
godot-tools/__pycache__/targets.cpython-310.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/targets.cpython-311.pyc
Normal file
BIN
godot-tools/__pycache__/targets.cpython-311.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/windows.cpython-310.pyc
Normal file
BIN
godot-tools/__pycache__/windows.cpython-310.pyc
Normal file
Binary file not shown.
BIN
godot-tools/__pycache__/windows.cpython-311.pyc
Normal file
BIN
godot-tools/__pycache__/windows.cpython-311.pyc
Normal file
Binary file not shown.
50
godot-tools/macos.py
Normal file
50
godot-tools/macos.py
Normal file
@@ -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
godot-tools/macos_osxcross.py
Normal file
28
godot-tools/macos_osxcross.py
Normal file
@@ -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
godot-tools/my_spawn.py
Normal file
52
godot-tools/my_spawn.py
Normal file
@@ -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"])
|
||||
73
godot-tools/targets.py
Normal file
73
godot-tools/targets.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import os
|
||||
import sys
|
||||
from SCons.Script import ARGUMENTS
|
||||
from SCons.Variables import *
|
||||
from SCons.Variables.BoolVariable import _text2bool
|
||||
|
||||
|
||||
def get_cmdline_bool(option, default):
|
||||
"""We use `ARGUMENTS.get()` to check if options were manually overridden on the command line,
|
||||
and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings.
|
||||
"""
|
||||
cmdline_val = ARGUMENTS.get(option)
|
||||
if cmdline_val is not None:
|
||||
return _text2bool(cmdline_val)
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
def options(opts):
|
||||
opts.Add(
|
||||
EnumVariable(
|
||||
"optimize",
|
||||
"The desired optimization flags",
|
||||
"speed_trace",
|
||||
("none", "custom", "debug", "speed", "speed_trace", "size"),
|
||||
)
|
||||
)
|
||||
opts.Add(BoolVariable("debug_symbols", "Build with debugging symbols", True))
|
||||
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
|
||||
def generate(env):
|
||||
opt_level = "speed"
|
||||
|
||||
env["optimize"] = ARGUMENTS.get("optimize", opt_level)
|
||||
env["debug_symbols"] = get_cmdline_bool("debug_symbols", False)
|
||||
|
||||
if env.get("is_msvc", False):
|
||||
if env["debug_symbols"]:
|
||||
env.Append(CCFLAGS=["/Zi", "/FS"])
|
||||
env.Append(LINKFLAGS=["/DEBUG:FULL"])
|
||||
|
||||
if env["optimize"] == "speed" or env["optimize"] == "speed_trace":
|
||||
env.Append(CCFLAGS=["/O2"])
|
||||
env.Append(LINKFLAGS=["/OPT:REF"])
|
||||
elif env["optimize"] == "size":
|
||||
env.Append(CCFLAGS=["/O1"])
|
||||
env.Append(LINKFLAGS=["/OPT:REF"])
|
||||
|
||||
if env["optimize"] == "debug" or env["optimize"] == "none":
|
||||
env.Append(CCFLAGS=["/Od"])
|
||||
|
||||
else:
|
||||
if env["debug_symbols"]:
|
||||
if env.dev_build:
|
||||
env.Append(CCFLAGS=["-g3"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-g2"])
|
||||
|
||||
if env["optimize"] == "speed":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
# `-O2` is friendlier to debuggers than `-O3`, leading to better crash backtraces.
|
||||
elif env["optimize"] == "speed_trace":
|
||||
env.Append(CCFLAGS=["-O2"])
|
||||
elif env["optimize"] == "size":
|
||||
env.Append(CCFLAGS=["-Os"])
|
||||
elif env["optimize"] == "debug":
|
||||
env.Append(CCFLAGS=["-Og"])
|
||||
elif env["optimize"] == "none":
|
||||
env.Append(CCFLAGS=["-O0"])
|
||||
94
godot-tools/windows.py
Normal file
94
godot-tools/windows.py
Normal file
@@ -0,0 +1,94 @@
|
||||
import sys
|
||||
|
||||
import my_spawn
|
||||
|
||||
from SCons.Tool import msvc, mingw
|
||||
from SCons.Variables import *
|
||||
|
||||
|
||||
def options(opts):
|
||||
opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
|
||||
opts.Add(BoolVariable("use_clang_cl", "Use the clang driver instead of MSVC - only effective on Windows", False))
|
||||
opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True))
|
||||
opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
|
||||
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False))
|
||||
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
||||
|
||||
def generate(env):
|
||||
base = None
|
||||
if not env["use_mingw"] and msvc.exists(env):
|
||||
if env["arch"] == "x86_64":
|
||||
env["TARGET_ARCH"] = "amd64"
|
||||
elif env["arch"] == "x86_32":
|
||||
env["TARGET_ARCH"] = "x86"
|
||||
env["is_msvc"] = True
|
||||
|
||||
# MSVC, linker, and archiver.
|
||||
msvc.generate(env)
|
||||
env.Tool("mslib")
|
||||
env.Tool("mslink")
|
||||
|
||||
env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"])
|
||||
env.Append(CCFLAGS=["/EHsc", "/utf-8"])
|
||||
if env["debug_crt"]:
|
||||
# Always use dynamic runtime, static debug CRT breaks thread_local.
|
||||
env.AppendUnique(CCFLAGS=["/MDd"])
|
||||
else:
|
||||
if env["use_static_cpp"]:
|
||||
env.AppendUnique(CCFLAGS=["/MT"])
|
||||
else:
|
||||
env.AppendUnique(CCFLAGS=["/MD"])
|
||||
env.Append(LINKFLAGS=["/WX"])
|
||||
|
||||
if env["use_clang_cl"]:
|
||||
env["CC"] = "clang-cl"
|
||||
env["CXX"] = "clang-cl"
|
||||
|
||||
elif sys.platform == "win32" or sys.platform == "msys":
|
||||
env["use_mingw"] = True
|
||||
mingw.generate(env)
|
||||
env.Append(CPPDEFINES=["MINGW_ENABLED"])
|
||||
# Don't want lib prefixes
|
||||
env["IMPLIBPREFIX"] = ""
|
||||
env["SHLIBPREFIX"] = ""
|
||||
# Want dll suffix
|
||||
env["SHLIBSUFFIX"] = ".dll"
|
||||
# Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other).
|
||||
my_spawn.configure(env)
|
||||
|
||||
else:
|
||||
env["use_mingw"] = True
|
||||
# Cross-compilation using MinGW
|
||||
prefix = "i686" if env["arch"] == "x86_32" else env["arch"]
|
||||
if env["use_llvm"]:
|
||||
env["CXX"] = prefix + "-w64-mingw32-clang"
|
||||
env["CC"] = prefix + "-w64-mingw32-clang++"
|
||||
env["AR"] = prefix + "-w64-mingw32-ar"
|
||||
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
|
||||
env["LINK"] = prefix + "-w64-mingw32-clang"
|
||||
else:
|
||||
env["CXX"] = prefix + "-w64-mingw32-g++"
|
||||
env["CC"] = prefix + "-w64-mingw32-gcc"
|
||||
env["AR"] = prefix + "-w64-mingw32-ar"
|
||||
env["RANLIB"] = prefix + "-w64-mingw32-ranlib"
|
||||
env["LINK"] = prefix + "-w64-mingw32-g++"
|
||||
|
||||
env.Append(CPPDEFINES=["MINGW_ENABLED"])
|
||||
env.Append(CCFLAGS=["-O3", "-Wwrite-strings"])
|
||||
if env["arch"] == "x86_32":
|
||||
if env["use_static_cpp"]:
|
||||
env.Append(LINKFLAGS=["-static"])
|
||||
env.Append(LINKFLAGS=["-static-libgcc"])
|
||||
env.Append(LINKFLAGS=["-static-libstdc++"])
|
||||
else:
|
||||
if env["use_static_cpp"]:
|
||||
env.Append(LINKFLAGS=["-static"])
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"-Wl,--no-undefined",
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user