Make werror per subproject option

pull/6815/merge
Xavier Claessens 5 years ago committed by Jussi Pakkanen
parent b3fe9fa5d8
commit 4d7ccd1399
  1. 9
      docs/markdown/snippets/per_subproject_builtin.md
  2. 2
      mesonbuild/backend/backends.py
  3. 2
      mesonbuild/coredata.py
  4. 2
      mesonbuild/modules/hotdoc.py
  5. 5
      test cases/common/229 persubproject options/meson.build
  6. 4
      test cases/common/229 persubproject options/subprojects/sub2/foo.c
  7. 5
      test cases/common/229 persubproject options/subprojects/sub2/meson.build

@ -1,8 +1,9 @@
## Per subproject `default_library` option ## Per subproject `default_library` and `werror` options
The `default_library` built-in option can now be defined per subproject. This is The `default_library` and `werror` built-in options can now be defined per subproject.
useful for example when building shared libraries in the main project, but static This is useful for example when building shared libraries in the main project,
link a subproject. but static link a subproject, or when the main project must build with no warnings
but some subprojects cannot.
Most of the time this would be used either by the parent project by setting Most of the time this would be used either by the parent project by setting
subproject's default_options (e.g. `subproject('foo', default_options: 'default_library=static')`), subproject's default_options (e.g. `subproject('foo', default_options: 'default_library=static')`),

@ -179,7 +179,7 @@ class Backend:
if option_name in target.option_overrides: if option_name in target.option_overrides:
override = target.option_overrides[option_name] override = target.option_overrides[option_name]
return self.environment.coredata.validate_option_value(option_name, override) return self.environment.coredata.validate_option_value(option_name, override)
return self.environment.coredata.get_builtin_option(option_name) return self.environment.coredata.get_builtin_option(option_name, target.subproject)
def get_target_filename_for_linking(self, target): def get_target_filename_for_linking(self, target):
# On some platforms (msvc for instance), the file that is used for # On some platforms (msvc for instance), the file that is used for

@ -1104,7 +1104,7 @@ builtin_options = OrderedDict([
('unity', BuiltinOption(UserComboOption, 'Unity build', 'off', choices=['on', 'off', 'subprojects'])), ('unity', BuiltinOption(UserComboOption, 'Unity build', 'off', choices=['on', 'off', 'subprojects'])),
('unity_size', BuiltinOption(UserIntegerOption, 'Unity block size', (2, None, 4))), ('unity_size', BuiltinOption(UserIntegerOption, 'Unity block size', (2, None, 4))),
('warning_level', BuiltinOption(UserComboOption, 'Compiler warning level to use', '1', choices=['0', '1', '2', '3'])), ('warning_level', BuiltinOption(UserComboOption, 'Compiler warning level to use', '1', choices=['0', '1', '2', '3'])),
('werror', BuiltinOption(UserBooleanOption, 'Treat warnings as errors', False)), ('werror', BuiltinOption(UserBooleanOption, 'Treat warnings as errors', False, yielding=False)),
('wrap_mode', BuiltinOption(UserComboOption, 'Wrap mode', 'default', choices=['default', 'nofallback', 'nodownload', 'forcefallback'])), ('wrap_mode', BuiltinOption(UserComboOption, 'Wrap mode', 'default', choices=['default', 'nofallback', 'nodownload', 'forcefallback'])),
]) ])

@ -326,7 +326,7 @@ class HotdocTargetBuilder:
for path in self.include_paths.keys(): for path in self.include_paths.keys():
self.cmd.extend(['--include-path', path]) self.cmd.extend(['--include-path', path])
if self.state.environment.coredata.get_builtin_option('werror'): if self.state.environment.coredata.get_builtin_option('werror', self.state.subproject):
self.cmd.append('--fatal-warning') self.cmd.append('--fatal-warning')
self.generate_hotdoc_config() self.generate_hotdoc_config()

@ -1,6 +1,9 @@
project('persubproject options', 'c', default_options : ['default_library=both']) project('persubproject options', 'c',
default_options : ['default_library=both',
'werror=true'])
assert(get_option('default_library') == 'both', 'Parent default_library should be "both"') assert(get_option('default_library') == 'both', 'Parent default_library should be "both"')
assert(get_option('werror'))
# Check it build both by calling a method only both_libraries target implement # Check it build both by calling a method only both_libraries target implement
lib = library('lib1', 'foo.c') lib = library('lib1', 'foo.c')

@ -1,5 +1,9 @@
int foo(void); int foo(void);
#ifdef __GNUC__
#warning This should not produce error
#endif
int foo(void) { int foo(void) {
return 0; return 0;
} }

@ -1,6 +1,9 @@
project('sub2', 'c', default_options : ['default_library=shared']) project('sub2', 'c',
default_options : ['default_library=shared',
'werror=false'])
assert(get_option('default_library') == 'static', 'Parent should override default_library') assert(get_option('default_library') == 'static', 'Parent should override default_library')
assert(not get_option('werror'))
# If it doesn't build only a static library, it would make target name clash. # If it doesn't build only a static library, it would make target name clash.
library('lib1', 'foo.c') library('lib1', 'foo.c')

Loading…
Cancel
Save