Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to create debug builds #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ libsafetyhook.sources += AddSourceFilesFromDir(os.path.join(builder.currentSourc
])

for compiler in SafetyHook.all_targets:
binary = libsafetyhook.Configure(compiler, libsafetyhook.name, 'Release - {0}'.format(compiler.target.arch))
tag = 'Debug' if builder.options.debug == '1' else 'Release'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we decide whether or not we're in debug through a function call on SafetyHook structure ?
I'm mainly thinking of subprojects that need to include safetyhook for CDetour and might want some control over this. Granted, we're already nuking any preset compiler flags, so why should we care for debug but still.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this would require them to have a debug option in their configure.py which is a common way to enable debug builds though. How would that EnableDebug function be used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I'm thinking something like
https://github.com/alliedmodders/sourcemod/blob/master/AMBuildScript#L589

  @property
  def debug(self):
    return builder.options.debug == '1'

Or perhaps even reuse the tag property ?

binary = libsafetyhook.Configure(compiler, libsafetyhook.name, '{0} - {1}'.format(tag, compiler.target.arch))
# Configure the binary's compiler
compiler = binary.compiler
# Reset all flags, safetyhook requires specific compilation flags
Expand All @@ -32,7 +33,16 @@ for compiler in SafetyHook.all_targets:
compiler.includes = []
compiler.cxxincludes = []

# Debugging
if builder.options.debug == '1':
compiler.defines += ['DEBUG', '_DEBUG']

if compiler.target.platform == 'windows':
if builder.options.debug == '1':
compiler.cflags += ['/MTd', '/Od', '/RTC1']
compiler.defines += ['_ITERATOR_DEBUG_LEVEL=0']
else:
compiler.cflags += ['/MT']
compiler.cflags += [
"/W4",
]
Expand Down
2 changes: 2 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
parser = run.BuildParser(sourcePath = sys.path[0], api='2.2')
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
help="Override the target architecture (use commas to separate multiple targets).")
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
help='Enable debugging symbols')
parser.Configure()