diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2021-06-16 17:02:25 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2021-08-05 18:09:06 +0100 |
commit | f6053328bf855937c78d520940ab2f82fead53cd (patch) | |
tree | 81e8a2af6ab6aace2802fa5aaa83676b00a3a121 /giscanner/scannermain.py | |
parent | 3c186899ece953ba7f8b310f94e57c699554baa8 (diff) | |
download | gobject-introspection-f6053328bf855937c78d520940ab2f82fead53cd.tar.gz |
scanner: Add strict mode
To avoid introducing additional strictness onto unsuspecting libraries,
we introduce a new mode: "strict".
The strict mode is opt-in, and used to signal potential issues with the
public API once exposed by language bindings, even when it's fully
introspectable.
Diffstat (limited to 'giscanner/scannermain.py')
-rw-r--r-- | giscanner/scannermain.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index 957ba0b7..7a965c08 100644 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -205,6 +205,9 @@ match the namespace prefix.""") parser.add_option('', "--warn-error", action="store_true", dest="warn_fatal", help="Turn warnings into fatal errors") + parser.add_option('', "--strict", + action="store_true", dest="warn_strict", default=False, + help="If true, enable strict warnings for introspection") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="be verbose") @@ -576,6 +579,8 @@ def scanner_main(args): logger = message.MessageLogger.get(namespace=namespace) if options.warn_all: logger.enable_warnings(True) + if options.warn_strict: + logger.enable_strict(True) transformer = create_transformer(namespace, options) @@ -610,11 +615,12 @@ def scanner_main(args): final = IntrospectablePass(transformer, blocks) final.validate() + show_suppression = options.warn_all is False and options.warn_strict is False and options.quiet is False warning_count = logger.get_warning_count() if options.warn_fatal and warning_count > 0: message.fatal("warnings configured as fatal") return 1 - elif warning_count > 0 and options.warn_all is False and options.quiet is False: + elif warning_count > 0 and show_suppression: print("g-ir-scanner: %s: warning: %d warnings suppressed " "(use --warn-all to see them)" % (transformer.namespace.name, warning_count, )) |