diff options
-rw-r--r-- | docs/markdown/Reference-manual.md | 3 | ||||
-rw-r--r-- | docs/markdown/Release-notes-for-0.50.0.md | 8 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 8 | ||||
-rw-r--r-- | mesonbuild/build.py | 5 | ||||
-rw-r--r-- | test cases/common/209 custom target build by default/docgen.py | 12 | ||||
-rw-r--r-- | test cases/common/209 custom target build by default/installed_files.txt | 0 | ||||
-rw-r--r-- | test cases/common/209 custom target build by default/meson.build | 10 |
7 files changed, 43 insertions, 3 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 5436ec3..e913e25 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -266,6 +266,9 @@ following. - `build_by_default` *(added 0.38)* causes, when set to true, to have this target be built by default, that is, when invoking plain `ninja`; the default value is false + *(changed in 0.50)* if `build_by_default` is explicitly set to false, `install` + will no longer override it. If `build_by_default` is not set, `install` will + still determine its default. - `build_always` (deprecated) if `true` this target is always considered out of date and is rebuilt every time. Equivalent to setting both `build_always_stale` and `build_by_default` to true. diff --git a/docs/markdown/Release-notes-for-0.50.0.md b/docs/markdown/Release-notes-for-0.50.0.md index cb4fe0d..a08edfb 100644 --- a/docs/markdown/Release-notes-for-0.50.0.md +++ b/docs/markdown/Release-notes-for-0.50.0.md @@ -15,3 +15,11 @@ whose contents should look like this: A short description explaining the new feature and how it should be used. +## custom_target: install no longer overrides build_by_default + +Earlier, if `build_by_default` was set to false and `install` was set to true in +a `custom_target`, `install` would override it and the `custom_target` would +always be built by default. +Now if `build_by_default` is explicitly set to false it will no longer be +overridden. If `build_by_default` is not set, its default will still be +determined by the value of `install` for greater backward compatibility. diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 0637905..9f3f5d6 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -813,7 +813,7 @@ class Backend: result = OrderedDict() # Get all build and custom targets that must be built by default for name, t in self.build.get_targets().items(): - if t.build_by_default or t.install: + if t.build_by_default: result[name] = t # Get all targets used as test executables and arguments. These must # also be built by default. XXX: Sometime in the future these should be @@ -1074,7 +1074,8 @@ class Backend: if num_outdirs == 1 and num_out > 1: for output in t.get_outputs(): f = os.path.join(self.get_target_dir(t), output) - i = TargetInstallData(f, outdirs[0], {}, False, {}, None, install_mode) + i = TargetInstallData(f, outdirs[0], {}, False, {}, None, install_mode, + optional=not t.build_by_default) d.targets.append(i) else: for output, outdir in zip(t.get_outputs(), outdirs): @@ -1082,7 +1083,8 @@ class Backend: if outdir is False: continue f = os.path.join(self.get_target_dir(t), output) - i = TargetInstallData(f, outdir, {}, False, {}, None, install_mode) + i = TargetInstallData(f, outdir, {}, False, {}, None, install_mode, + optional=not t.build_by_default) d.targets.append(i) def generate_custom_install_script(self, d): diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 52af562..d20b576 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -408,6 +408,11 @@ a hard error in the future.''' % name) self.build_by_default = kwargs['build_by_default'] if not isinstance(self.build_by_default, bool): raise InvalidArguments('build_by_default must be a boolean value.') + elif kwargs.get('install', False): + # For backward compatibility, if build_by_default is not explicitly + # set, use the value of 'install' if it's enabled. + self.build_by_default = True + self.option_overrides = self.parse_overrides(kwargs) def parse_overrides(self, kwargs): diff --git a/test cases/common/209 custom target build by default/docgen.py b/test cases/common/209 custom target build by default/docgen.py new file mode 100644 index 0000000..f343f21 --- /dev/null +++ b/test cases/common/209 custom target build by default/docgen.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import sys + +out = sys.argv[1] + +os.mkdir(out) + +for name in ('a', 'b', 'c'): + with open(os.path.join(out, name + '.txt'), 'w') as f: + f.write(name) diff --git a/test cases/common/209 custom target build by default/installed_files.txt b/test cases/common/209 custom target build by default/installed_files.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/209 custom target build by default/installed_files.txt diff --git a/test cases/common/209 custom target build by default/meson.build b/test cases/common/209 custom target build by default/meson.build new file mode 100644 index 0000000..7c81aa2 --- /dev/null +++ b/test cases/common/209 custom target build by default/meson.build @@ -0,0 +1,10 @@ +project('custom-target-dir-install', 'c') + +docgen = find_program('docgen.py') + +custom_target('docgen', + output : 'html', + command : [docgen, '@OUTPUT@'], + install : true, + build_by_default : false, + install_dir : join_paths(get_option('datadir'), 'doc/testpkgname')) |