gen_android_bp: add flag to force dcheck/dlog on (even in release builds).
Helpful for building only our binaries with debug logic during development.
Seems like there is no way to ask the build system itself to build a single
target as debug (it always depends on lunch target).
Change-Id: I48298e8b75f83708bcd9e5f71e14bd34c84270ee
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index dd8b467..66e2583 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -589,7 +589,7 @@
return resolved_deps
-def create_blueprint_for_targets(desc, targets):
+def create_blueprint_for_targets(desc, force_debug, targets):
"""Generate a blueprint for a list of GN targets."""
blueprint = Blueprint()
@@ -604,6 +604,9 @@
'-fvisibility=hidden',
'-Oz',
]
+ if force_debug:
+ defaults.cflags.extend(['-UNDEBUG',
+ '-DPERFETTO_ENABLE_DLOG'])
defaults.user_debug_flag = True
blueprint.add_module(defaults)
@@ -658,6 +661,12 @@
default=os.path.join(repo_root(), 'Android.bp'),
)
parser.add_argument(
+ '-d',
+ '--force_debug',
+ action='store_true',
+ help='Add flags to enable DCHECK/DLOG/etc, even in release builds.'
+ )
+ parser.add_argument(
'targets',
nargs=argparse.REMAINDER,
help='Targets to include in the blueprint (e.g., "//:perfetto_tests")')
@@ -669,8 +678,8 @@
else:
desc = create_build_description()
- blueprint = create_blueprint_for_targets(desc, args.targets
- or default_targets)
+ blueprint = create_blueprint_for_targets(desc, args.force_debug,
+ args.targets or default_targets)
output = [
"""// Copyright (C) 2017 The Android Open Source Project
//