diff options
author | Andrei Alexeyev <0x416b617269@gmail.com> | 2018-07-01 19:55:38 +0300 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-07-01 16:55:38 +0000 |
commit | f7f5e2a725d63eb15f627713129bb6c22d573106 (patch) | |
tree | 6202837b2e818b706beca2983abb59f1774e6e79 | |
parent | dc683218a4dbb099d0da1c46e4e7bfe4f19ad9ce (diff) | |
download | meson-f7f5e2a725d63eb15f627713129bb6c22d573106.zip meson-f7f5e2a725d63eb15f627713129bb6c22d573106.tar.gz meson-f7f5e2a725d63eb15f627713129bb6c22d573106.tar.bz2 |
Don't let build_always take precedence over build_by_default (#3816)
* Don't let build_always take precedence over build_by_default
* Test for proper interaction of build_by_default with build_always
Fixes #3815
-rw-r--r-- | mesonbuild/build.py | 3 | ||||
-rwxr-xr-x | run_unittests.py | 16 | ||||
-rw-r--r-- | test cases/common/137 build by default/checkexists.py | 10 | ||||
-rw-r--r-- | test cases/common/137 build by default/meson.build | 39 |
4 files changed, 53 insertions, 15 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index ec0d8cc..6ee13d2 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1797,7 +1797,8 @@ class CustomTarget(Target): raise InvalidArguments('build_always and build_always_stale are mutually exclusive. Combine build_by_default and build_always_stale.') elif 'build_always' in kwargs: mlog.warning('build_always is deprecated. Combine build_by_default and build_always_stale instead.') - self.build_by_default = kwargs['build_always'] + if 'build_by_default' not in kwargs: + self.build_by_default = kwargs['build_always'] self.build_always_stale = kwargs['build_always'] elif 'build_always_stale' in kwargs: self.build_always_stale = kwargs['build_always_stale'] diff --git a/run_unittests.py b/run_unittests.py index 8b664a3..0444199 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1122,12 +1122,18 @@ class AllPlatformTests(BasePlatformTests): testdir = os.path.join(self.common_test_dir, '137 build by default') self.init(testdir) self.build() - genfile = os.path.join(self.builddir, 'generated.dat') - exe = os.path.join(self.builddir, 'fooprog' + exe_suffix) - self.assertPathExists(genfile) - self.assertPathDoesNotExist(exe) + genfile1 = os.path.join(self.builddir, 'generated1.dat') + genfile2 = os.path.join(self.builddir, 'generated2.dat') + exe1 = os.path.join(self.builddir, 'fooprog' + exe_suffix) + exe2 = os.path.join(self.builddir, 'barprog' + exe_suffix) + self.assertPathExists(genfile1) + self.assertPathExists(genfile2) + self.assertPathDoesNotExist(exe1) + self.assertPathDoesNotExist(exe2) self.build(target=('fooprog' + exe_suffix)) - self.assertPathExists(exe) + self.assertPathExists(exe1) + self.build(target=('barprog' + exe_suffix)) + self.assertPathExists(exe2) def test_internal_include_order(self): testdir = os.path.join(self.common_test_dir, '138 include order') diff --git a/test cases/common/137 build by default/checkexists.py b/test cases/common/137 build by default/checkexists.py new file mode 100644 index 0000000..6664f72 --- /dev/null +++ b/test cases/common/137 build by default/checkexists.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +import os.path, sys + +invert = False +for path in sys.argv[1:]: + if path == '--not': + invert = True + elif not os.path.exists(path) ^ invert: + sys.exit(1) diff --git a/test cases/common/137 build by default/meson.build b/test cases/common/137 build by default/meson.build index 6569548..b28b634 100644 --- a/test cases/common/137 build by default/meson.build +++ b/test cases/common/137 build by default/meson.build @@ -3,22 +3,43 @@ project('build on all', 'c') py3_mod = import('python3') py3 = py3_mod.find_python() -executable('fooprog', 'foo.c', build_by_default : false) +executable('fooprog', 'foo.c', + build_by_default : false, +) + +executable('barprog', 'foo.c', + build_by_default : false, + build_always : true, +) + comp = files('mygen.py') -mytarget = custom_target('gendat', - output : 'generated.dat', +checkexists = files('checkexists.py') + +mytarget = custom_target('gendat1', + output : 'generated1.dat', + input : 'source.txt', + command : [py3] + comp + ['@INPUT@', '@OUTPUT@'], + build_by_default : true, +) + +mytarget = custom_target('gendat2', + output : 'generated2.dat', input : 'source.txt', command : [py3] + comp + ['@INPUT@', '@OUTPUT@'], build_by_default : true, + build_always : false, ) -ct_output = join_paths(meson.build_root(), 'generated.dat') -exe_output = join_paths(meson.build_root(), 'fooprog') +ct1_output = join_paths(meson.build_root(), 'generated1.dat') +ct2_output = join_paths(meson.build_root(), 'generated2.dat') +exe1_output = join_paths(meson.build_root(), 'fooprog') +exe2_output = join_paths(meson.build_root(), 'barprog') + if host_machine.system() == 'windows' - exe_output += '.exe' + exe1_output += '.exe' + exe2_output += '.exe' endif -ct_exists_exe_nexists = 'import os.path, sys; sys.exit(not os.path.exists(sys.argv[1]) and os.path.exists(sys.argv[2]))' - test('check-build-by-default', py3, - args : ['-c', ct_exists_exe_nexists, ct_output, exe_output]) + args : [checkexists, + ct1_output, ct2_output, '--not', exe1_output, exe2_output]) |