summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2024-12-10 14:34:08 -0800
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-11-04 21:56:04 +0200
commit60e3cc1c58c208c635bda23a7c62a92ae84cb6b6 (patch)
tree09e95bc8b62564211905abce8a3c30dcc1ff609c /test cases
parent66e43fa19f93e9f9367cb2008d06ecc0d261ba73 (diff)
downloadmeson-60e3cc1c58c208c635bda23a7c62a92ae84cb6b6.tar.gz
Add build target keyword parameter 'build_subdir' [v8]
Place the build products in a directory of the specified name somewhere within the build directory. This allows use of the target that includes a specific directory name: #include <subdir/configure.h> This also allows creating targets with the same basename by using different subdirectory names. v2: Move build_subdir to Target class. Error if path separator in build_dir v3: Rename to 'build_subdir' to make it clear that the name is appended to a meson-specific build directory, and does not provide the user with a way to define the overall meson build hierarchy. Allow build_subdir to include path separators. Support 'build_subdir' for configure_file. build_subdir must not exist in the source directory and must not contain '..' Add documentation and tests v4: Rebase and prepare for version 1.9.1 Add failing test case when build_subdir is present in the project. Add release note snippet v5: Clarify wording on restrictions on the value of build_subdir. Use the same wording in each place this restriction is described. v6: Move path validation to shared function, validate_build_subdir, instead of duplicating the tests in two places. v7: Update version numbers to 1.10.0 Add TypedDict updates. Remove spurious build_subdir instance variable v8: Oops, missed one version number update. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/109 custom target capture/meson.build10
-rw-r--r--test cases/common/109 custom target capture/test.json3
-rw-r--r--test cases/common/117 shared module/meson.build8
-rw-r--r--test cases/common/117 shared module/test.json5
-rw-r--r--test cases/common/14 configure file/meson.build7
-rw-r--r--test cases/common/14 configure file/test.json3
-rw-r--r--test cases/failing/136 invalid build_subdir/existing-dir/config.h.in5
-rw-r--r--test cases/failing/136 invalid build_subdir/meson.build24
-rw-r--r--test cases/failing/136 invalid build_subdir/test.json7
9 files changed, 69 insertions, 3 deletions
diff --git a/test cases/common/109 custom target capture/meson.build b/test cases/common/109 custom target capture/meson.build
index b7622014a..9fd7e22ae 100644
--- a/test cases/common/109 custom target capture/meson.build
+++ b/test cases/common/109 custom target capture/meson.build
@@ -22,3 +22,13 @@ if not os.path.exists(sys.argv[1]):
'''
test('capture-wrote', python3, args : ['-c', ct_output_exists, mytarget])
+
+mytarget = custom_target('bindat',
+ output : 'data.dat',
+ input : 'data_source.txt',
+ build_subdir : 'subdir2',
+ capture : true,
+ command : [python3, comp, '@INPUT@'],
+ install : true,
+ install_dir : 'subdir2'
+)
diff --git a/test cases/common/109 custom target capture/test.json b/test cases/common/109 custom target capture/test.json
index ba66b024a..663a8f320 100644
--- a/test cases/common/109 custom target capture/test.json
+++ b/test cases/common/109 custom target capture/test.json
@@ -1,5 +1,6 @@
{
"installed": [
- {"type": "file", "file": "usr/subdir/data.dat"}
+ {"type": "file", "file": "usr/subdir/data.dat"},
+ {"type": "file", "file": "usr/subdir2/data.dat"}
]
}
diff --git a/test cases/common/117 shared module/meson.build b/test cases/common/117 shared module/meson.build
index 94d17a716..494ce42ee 100644
--- a/test cases/common/117 shared module/meson.build
+++ b/test cases/common/117 shared module/meson.build
@@ -34,6 +34,14 @@ test('import test', e, args : m)
m2 = build_target('mymodule2', 'module.c', target_type: 'shared_module')
test('import test 2', e, args : m2)
+# Same as above, but built and installed in a sub directory
+m2_subdir = build_target('mymodule2', 'module.c',
+ target_type: 'shared_module',
+ build_subdir: 'subdir',
+ install: true,
+ install_dir: join_paths(get_option('libdir'), 'modules/subdir'))
+test('import test 2 subdir', e, args : m2_subdir)
+
# Shared module that does not export any symbols
shared_module('nosyms', 'nosyms.c',
override_options: ['werror=false'],
diff --git a/test cases/common/117 shared module/test.json b/test cases/common/117 shared module/test.json
index 33bfeff07..b24149cf3 100644
--- a/test cases/common/117 shared module/test.json
+++ b/test cases/common/117 shared module/test.json
@@ -2,6 +2,9 @@
"installed": [
{"type": "expr", "file": "usr/lib/modules/libnosyms?so"},
{"type": "implibempty", "file": "usr/lib/modules/libnosyms"},
- {"type": "pdb", "file": "usr/lib/modules/nosyms"}
+ {"type": "pdb", "file": "usr/lib/modules/nosyms"},
+ {"type": "expr", "file": "usr/lib/modules/subdir/libmymodule2?so"},
+ {"type": "implib", "file": "usr/lib/modules/subdir/libmymodule2"},
+ {"type": "pdb", "file": "usr/lib/modules/subdir/mymodule2"}
]
}
diff --git a/test cases/common/14 configure file/meson.build b/test cases/common/14 configure file/meson.build
index 3a4ff4dc9..80a5d8268 100644
--- a/test cases/common/14 configure file/meson.build
+++ b/test cases/common/14 configure file/meson.build
@@ -30,6 +30,13 @@ configure_file(input : files('config.h.in'),
output : 'config2.h',
configuration : conf)
+# Test if build_subdir works
+configure_file(input : files('config.h.in'),
+ output : 'config2.h',
+ build_subdir : 'config-subdir',
+ install_dir : 'share/appdir/config-subdir',
+ configuration : conf)
+
# Now generate a header file with an external script.
genprog = import('python3').find_python()
scriptfile = '@0@/generator.py'.format(meson.current_source_dir())
diff --git a/test cases/common/14 configure file/test.json b/test cases/common/14 configure file/test.json
index 5a6ccd57a..51e677028 100644
--- a/test cases/common/14 configure file/test.json
+++ b/test cases/common/14 configure file/test.json
@@ -4,6 +4,7 @@
{"type": "file", "file": "usr/share/appdir/config2b.h"},
{"type": "file", "file": "usr/share/appdireh/config2-1.h"},
{"type": "file", "file": "usr/share/appdirok/config2-2.h"},
- {"type": "file", "file": "usr/share/configure file test/invalid-utf8-1.bin"}
+ {"type": "file", "file": "usr/share/configure file test/invalid-utf8-1.bin"},
+ {"type": "file", "file": "usr/share/appdir/config-subdir/config2.h"}
]
}
diff --git a/test cases/failing/136 invalid build_subdir/existing-dir/config.h.in b/test cases/failing/136 invalid build_subdir/existing-dir/config.h.in
new file mode 100644
index 000000000..14a155874
--- /dev/null
+++ b/test cases/failing/136 invalid build_subdir/existing-dir/config.h.in
@@ -0,0 +1,5 @@
+#define MESSAGE "@var@"
+#define OTHER "@other@" "@second@" "@empty@"
+
+#mesondefine BE_TRUE
+#mesondefine SHOULD_BE_UNDEF
diff --git a/test cases/failing/136 invalid build_subdir/meson.build b/test cases/failing/136 invalid build_subdir/meson.build
new file mode 100644
index 000000000..b54ec9a0b
--- /dev/null
+++ b/test cases/failing/136 invalid build_subdir/meson.build
@@ -0,0 +1,24 @@
+project('invalid build_subdir test', 'c', meson_version : '>= 1.9.1')
+
+# This setup intentially tries to use a build_subdir
+# with a name matching one in the source directory.
+# produce a Ninja targets with the same name. It only works on
+# unix, because on Windows the target has a '.exe' suffix.
+#
+# This test might fail to work on different backends or when
+# output location is redirected.
+
+conf = configuration_data()
+
+conf.set('var', 'mystring')
+conf.set('other', 'string 2')
+conf.set('second', ' bonus')
+conf.set('BE_TRUE', true)
+
+configure_file(input : files('existing-dir/config.h.in'),
+ output : 'config.h',
+ build_subdir : 'existing-dir',
+ install_dir : 'share/appdir/existing-dir',
+ configuration : conf)
+
+run_target('build_dir', command: ['echo', 'clash 1'])
diff --git a/test cases/failing/136 invalid build_subdir/test.json b/test cases/failing/136 invalid build_subdir/test.json
new file mode 100644
index 000000000..f8e56dae5
--- /dev/null
+++ b/test cases/failing/136 invalid build_subdir/test.json
@@ -0,0 +1,7 @@
+{
+ "stdout": [
+ {
+ "line": "test cases/failing/136 invalid build_subdir/meson.build:18:0: ERROR: Build subdir \"existing-dir\" in \"config.h\" exists in source tree."
+ }
+ ]
+}