Skip to content

Commit

Permalink
build: Use builtin sanitizer option in Meson
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Feb 14, 2024
1 parent dc7ad2d commit 7c24cea
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
8 changes: 2 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,8 @@ if cxx_has_uchar
add_project_arguments('-DHAVE_UCHAR_H', language: [ 'c', 'cpp' ])
endif

if get_option('enable-sanitizer') == 'address'
add_project_arguments('-fsanitize=address,undefined', language: [ 'c', 'cpp' ])
endif

if get_option('enable-sanitizer') == 'thread'
add_project_arguments('-fsanitize=thread', language: [ 'c', 'cpp' ])
if get_option('b_sanitize').contains('address')
add_project_arguments('-DPOSEIDON_ENABLE_ADDRESS_SANITIZER', language: [ 'c', 'cpp' ])
endif

add_project_arguments(
Expand Down
18 changes: 14 additions & 4 deletions meson.options
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
## Copyright (C) 2024 by LH_Mouse <[email protected]>
##
## Permission to use, copy, modify, and/or distribute this
## software for any purpose with or without fee is hereby granted.
##
## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
## WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
## WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
## THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
## CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
## LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
## NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
## CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

option('enable-debug-checks',
type: 'boolean', value: false,
description: 'enable run-time assertions')

option('enable-sanitizer',
type: 'combo', choices: [ 'none', 'address', 'thread' ],
description: 'enable sanitizer library')

option('enable-repl',
type: 'boolean', value: true,
description: 'enable interactive interpretor')
Expand Down
11 changes: 9 additions & 2 deletions setup_meson.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash -e

meson setup -Dbuildtype=debug -Denable-debug-checks=true build_debug
meson setup -Dbuildtype=release build_release
meson setup \
-Dbuildtype=debug \
-Denable-debug-checks=true \
-Db_sanitize=address,undefined \
build_debug

meson setup \
-Dbuildtype=release \
build_release

0 comments on commit 7c24cea

Please sign in to comment.