From 7e1529501883ce8741d8689c150f589ab68a814f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 7 Feb 2020 01:55:27 +0100 Subject: rename unstable-kconfig to unstable-keyval Discussions in #6524 have shown that there are various possible uses of the kconfig module and even disagreements in the exact file format between Python-based kconfiglib and the tools in Linux. Instead of trying to reconcile them, just rename the module to something less suggestive and leave any policy to meson.build files. In the future it may be possible to add some kind of parsing through keyword arguments such as bool_true, quoted_strings, etc. and possibly creation of key-value lists too. For now, configuration_data objects provide an easy way to access quoted strings. Note that Kconfig stores false as "absent" so it was already necessary to write "x.has_key('abc')" rather than the more compact "x['abc']". Therefore, having to use configuration_data does not make things much more verbose. --- test cases/keyval/1 basic/.config | 3 +++ test cases/keyval/1 basic/meson.build | 16 ++++++++++++++++ test cases/keyval/2 subdir/.config | 2 ++ test cases/keyval/2 subdir/dir/meson.build | 13 +++++++++++++ test cases/keyval/2 subdir/meson.build | 4 ++++ test cases/keyval/3 load_config files/dir/config | 2 ++ test cases/keyval/3 load_config files/dir/meson.build | 13 +++++++++++++ test cases/keyval/3 load_config files/meson.build | 4 ++++ test cases/keyval/4 load_config builddir/config | 2 ++ test cases/keyval/4 load_config builddir/meson.build | 14 ++++++++++++++ 10 files changed, 73 insertions(+) create mode 100644 test cases/keyval/1 basic/.config create mode 100644 test cases/keyval/1 basic/meson.build create mode 100644 test cases/keyval/2 subdir/.config create mode 100644 test cases/keyval/2 subdir/dir/meson.build create mode 100644 test cases/keyval/2 subdir/meson.build create mode 100644 test cases/keyval/3 load_config files/dir/config create mode 100644 test cases/keyval/3 load_config files/dir/meson.build create mode 100644 test cases/keyval/3 load_config files/meson.build create mode 100644 test cases/keyval/4 load_config builddir/config create mode 100644 test cases/keyval/4 load_config builddir/meson.build (limited to 'test cases/keyval') diff --git a/test cases/keyval/1 basic/.config b/test cases/keyval/1 basic/.config new file mode 100644 index 0000000..071d185 --- /dev/null +++ b/test cases/keyval/1 basic/.config @@ -0,0 +1,3 @@ +CONFIG_VAL1=y +# CONFIG_VAL2 is not set +CONFIG_VAL_VAL=4 diff --git a/test cases/keyval/1 basic/meson.build b/test cases/keyval/1 basic/meson.build new file mode 100644 index 0000000..fc7ddb3 --- /dev/null +++ b/test cases/keyval/1 basic/meson.build @@ -0,0 +1,16 @@ +project('keyval basic test') + +k = import('unstable-keyval') +conf = k.load('.config') + +if not conf.has_key('CONFIG_VAL1') + error('Expected CONFIG_VAL1 to be set, but it wasn\'t') +endif + +if conf.has_key('CONFIG_VAL2') + error('Expected CONFIG_VAL2 not be set, but it was') +endif + +if conf.get('CONFIG_VAL_VAL').to_int() != 4 + error('Expected CONFIG_VAL_VAL to be 4') +endif diff --git a/test cases/keyval/2 subdir/.config b/test cases/keyval/2 subdir/.config new file mode 100644 index 0000000..0599d46 --- /dev/null +++ b/test cases/keyval/2 subdir/.config @@ -0,0 +1,2 @@ +CONFIG_IS_SET=y +# CONFIG_NOT_IS_SET is not set diff --git a/test cases/keyval/2 subdir/dir/meson.build b/test cases/keyval/2 subdir/dir/meson.build new file mode 100644 index 0000000..dc1b478 --- /dev/null +++ b/test cases/keyval/2 subdir/dir/meson.build @@ -0,0 +1,13 @@ + +k = import('unstable-keyval') + +conf = k.load(meson.source_root() / '.config') + +if not conf.has_key('CONFIG_IS_SET') + error('Expected CONFIG_IS_SET to be set, but it wasn\'t') +endif + +if conf.has_key('CONFIG_NOT_IS_SET') + error('Expected CONFIG_NOT_IS_SET not be set, but it was') +endif + diff --git a/test cases/keyval/2 subdir/meson.build b/test cases/keyval/2 subdir/meson.build new file mode 100644 index 0000000..0651acf --- /dev/null +++ b/test cases/keyval/2 subdir/meson.build @@ -0,0 +1,4 @@ +project('keyval subdir test') + +# Test into sub directory +subdir('dir') diff --git a/test cases/keyval/3 load_config files/dir/config b/test cases/keyval/3 load_config files/dir/config new file mode 100644 index 0000000..0599d46 --- /dev/null +++ b/test cases/keyval/3 load_config files/dir/config @@ -0,0 +1,2 @@ +CONFIG_IS_SET=y +# CONFIG_NOT_IS_SET is not set diff --git a/test cases/keyval/3 load_config files/dir/meson.build b/test cases/keyval/3 load_config files/dir/meson.build new file mode 100644 index 0000000..43fba13 --- /dev/null +++ b/test cases/keyval/3 load_config files/dir/meson.build @@ -0,0 +1,13 @@ + +k = import('unstable-keyval') + +conf = k.load(files('config')) + +if not conf.has_key('CONFIG_IS_SET') + error('Expected CONFIG_IS_SET to be set, but it wasn\'t') +endif + +if conf.has_key('CONFIG_NOT_IS_SET') + error('Expected CONFIG_NOT_IS_SET not be set, but it was') +endif + diff --git a/test cases/keyval/3 load_config files/meson.build b/test cases/keyval/3 load_config files/meson.build new file mode 100644 index 0000000..0651acf --- /dev/null +++ b/test cases/keyval/3 load_config files/meson.build @@ -0,0 +1,4 @@ +project('keyval subdir test') + +# Test into sub directory +subdir('dir') diff --git a/test cases/keyval/4 load_config builddir/config b/test cases/keyval/4 load_config builddir/config new file mode 100644 index 0000000..0599d46 --- /dev/null +++ b/test cases/keyval/4 load_config builddir/config @@ -0,0 +1,2 @@ +CONFIG_IS_SET=y +# CONFIG_NOT_IS_SET is not set diff --git a/test cases/keyval/4 load_config builddir/meson.build b/test cases/keyval/4 load_config builddir/meson.build new file mode 100644 index 0000000..1bb0285 --- /dev/null +++ b/test cases/keyval/4 load_config builddir/meson.build @@ -0,0 +1,14 @@ +project('keyval builddir test') + +k = import('unstable-keyval') + +out_conf = configure_file(input: 'config', output: 'out-config', copy: true) +conf = k.load(out_conf) + +if not conf.has_key('CONFIG_IS_SET') + error('Expected CONFIG_IS_SET to be set, but it wasn\'t') +endif + +if conf.has_key('CONFIG_NOT_IS_SET') + error('Expected CONFIG_NOT_IS_SET not be set, but it was') +endif -- cgit v1.1 From aa0d75deaee925b9ceb3d98ef8f5de0167587c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 13 Jul 2020 12:52:39 +0400 Subject: Stabilize keyval module We have experimented with the module for about a year in a qemu branch (https://wiki.qemu.org/Features/Meson), and we would like to start moving the build system to meson. For that, keyval should have the stability guarantees. Cc: Paolo Bonzini --- test cases/keyval/1 basic/meson.build | 2 +- test cases/keyval/2 subdir/dir/meson.build | 2 +- test cases/keyval/3 load_config files/dir/meson.build | 2 +- test cases/keyval/4 load_config builddir/meson.build | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test cases/keyval') diff --git a/test cases/keyval/1 basic/meson.build b/test cases/keyval/1 basic/meson.build index fc7ddb3..c3e4466 100644 --- a/test cases/keyval/1 basic/meson.build +++ b/test cases/keyval/1 basic/meson.build @@ -1,6 +1,6 @@ project('keyval basic test') -k = import('unstable-keyval') +k = import('keyval') conf = k.load('.config') if not conf.has_key('CONFIG_VAL1') diff --git a/test cases/keyval/2 subdir/dir/meson.build b/test cases/keyval/2 subdir/dir/meson.build index dc1b478..291ad93 100644 --- a/test cases/keyval/2 subdir/dir/meson.build +++ b/test cases/keyval/2 subdir/dir/meson.build @@ -1,5 +1,5 @@ -k = import('unstable-keyval') +k = import('keyval') conf = k.load(meson.source_root() / '.config') diff --git a/test cases/keyval/3 load_config files/dir/meson.build b/test cases/keyval/3 load_config files/dir/meson.build index 43fba13..adc5289 100644 --- a/test cases/keyval/3 load_config files/dir/meson.build +++ b/test cases/keyval/3 load_config files/dir/meson.build @@ -1,5 +1,5 @@ -k = import('unstable-keyval') +k = import('keyval') conf = k.load(files('config')) diff --git a/test cases/keyval/4 load_config builddir/meson.build b/test cases/keyval/4 load_config builddir/meson.build index 1bb0285..6bd83db 100644 --- a/test cases/keyval/4 load_config builddir/meson.build +++ b/test cases/keyval/4 load_config builddir/meson.build @@ -1,6 +1,6 @@ project('keyval builddir test') -k = import('unstable-keyval') +k = import('keyval') out_conf = configure_file(input: 'config', output: 'out-config', copy: true) conf = k.load(out_conf) -- cgit v1.1 From 1c945511eb50134974192a34e06bac7f3ce7a74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 15 Jul 2020 10:45:58 +0400 Subject: Print a warning when importing a stabilized module --- test cases/keyval/1 basic/meson.build | 2 ++ test cases/keyval/1 basic/test.json | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 test cases/keyval/1 basic/test.json (limited to 'test cases/keyval') diff --git a/test cases/keyval/1 basic/meson.build b/test cases/keyval/1 basic/meson.build index c3e4466..4207b8e 100644 --- a/test cases/keyval/1 basic/meson.build +++ b/test cases/keyval/1 basic/meson.build @@ -14,3 +14,5 @@ endif if conf.get('CONFIG_VAL_VAL').to_int() != 4 error('Expected CONFIG_VAL_VAL to be 4') endif + +k = import('unstable-keyval') diff --git a/test cases/keyval/1 basic/test.json b/test cases/keyval/1 basic/test.json new file mode 100644 index 0000000..dbdc5af --- /dev/null +++ b/test cases/keyval/1 basic/test.json @@ -0,0 +1,7 @@ +{ + "stdout": [ + { + "line": "WARNING: Module unstable-keyval is now stable, please use the keyval module instead." + } + ] +} -- cgit v1.1