godot/platform/osx/detect.py
Hein-Pieter van Braam 88be952fc9 Create separate debug info files by default
Now that we have a built-in stacktrace on a segfault it would be useful
to have debug information on debug_release builds so that bugreports can
include this information. Without this debug info we will still get
function names in the backtrace but not file location.

This commit will by default build all targets with minimal debug info
and then strip the information into separate files. On MacOS this is a
.dSYM file, on Linux/MingW this is a .debug file. MacOSX will
automatically load a dSYM file if it exists in its debugger. On
Linux/MingW we create a 'gnu debuglink' meaning that gdb and friends
will automatically find the debug symbols if they exist.

Existing workflow for developers does not change at all, except that we
now create two instead of one build artifact by default.

This commit also adds a 'debug_symbols' option to X11, MacOS, and MingW
targets. The default is 'yes' which corresponds to -g1. The alternatives
are 'no' (don't generate debug infos at all) or 'full' which runs with
-g2. A target=debug build will now build with -g3.
2017-09-16 12:00:46 +02:00

111 lines
3.3 KiB
Python

import os
import sys
def is_active():
return True
def get_name():
return "OSX"
def can_build():
if (sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ)):
return True
return False
def get_opts():
return [
('osxcross_sdk', 'OSXCross SDK version', 'darwin14'),
('debug_symbols', 'Add debug symbols to release version (yes/no/full)', 'yes'),
]
def get_flags():
return [
]
def configure(env):
## Build type
if (env["target"] == "release"):
env.Prepend(CCFLAGS=['-O3', '-ffast-math', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2'])
if (env["debug_symbols"] == "yes"):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "release_debug"):
env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
if (env["debug_symbols"] == "yes"):
env.Prepend(CCFLAGS=['-g1'])
if (env["debug_symbols"] == "full"):
env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "debug"):
env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
## Architecture
is64 = sys.maxsize > 2**32
if (env["bits"] == "default"):
env["bits"] = "64" if is64 else "32"
## Compiler configuration
if (not os.environ.has_key("OSXCROSS_ROOT")): # regular native build
if (env["bits"] == "fat"):
env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
elif (env["bits"] == "32"):
env.Append(CCFLAGS=['-arch', 'i386'])
env.Append(LINKFLAGS=['-arch', 'i386'])
else: # 64-bit, default
env.Append(CCFLAGS=['-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'x86_64'])
else: # osxcross build
root = os.environ.get("OSXCROSS_ROOT", 0)
if env["bits"] == "fat":
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
env.Append(CCFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
env.Append(LINKFLAGS=['-arch', 'i386', '-arch', 'x86_64'])
elif env["bits"] == "32":
basecmd = root + "/target/bin/i386-apple-" + env["osxcross_sdk"] + "-"
else: # 64-bit, default
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
env['CC'] = basecmd + "cc"
env['CXX'] = basecmd + "c++"
env['AR'] = basecmd + "ar"
env['RANLIB'] = basecmd + "ranlib"
env['AS'] = basecmd + "as"
if (env["CXX"] == "clang++"):
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
env["CC"] = "clang"
env["LD"] = "clang++"
## Dependencies
if (env['builtin_libtheora'] != 'no'):
env["x86_libtheora_opt_gcc"] = True
## Flags
env.Append(CPPPATH=['#platform/osx'])
env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS'])
env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback'])
env.Append(LIBS=['pthread'])
env.Append(CPPFLAGS=['-mmacosx-version-min=10.9'])
env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])