Add meson option for build time schema validation
Add a meson option that controls if JSON schema validation is done
during the build and default it to enabled.
This way, it can be disabled during bitbake builds since
python3-jsonschema now brings in rust which takes quite a while to
build.
Validation does still occur during CI.
Tested:
A build with an error in a JSON file fails when validation is enabled
and passes when it isn't.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: If0a5335dd17f768adf2e40e6a132cf5cbd7eebd0
diff --git a/meson.build b/meson.build
index 9aa26bc..c1c7f97 100644
--- a/meson.build
+++ b/meson.build
@@ -207,19 +207,21 @@
filepaths += [file]
endforeach
-validate_script = files('scripts/validate_configs.py')
-autojson = custom_target(
- 'check_syntax',
- command: [
- validate_script,
- '-v',
- '-k',
- ],
- depend_files: files(filepaths),
- build_by_default: true,
- capture: true,
- output: 'validate_configs.log',
-)
+if get_option('validate-json')
+ validate_script = files('scripts/validate_configs.py')
+ autojson = custom_target(
+ 'check_syntax',
+ command: [
+ validate_script,
+ '-v',
+ '-k',
+ ],
+ depend_files: files(filepaths),
+ build_by_default: true,
+ capture: true,
+ output: 'validate_configs.log',
+ )
+endif
schemas = [
'global.json',
diff --git a/meson_options.txt b/meson_options.txt
index 770451d..ad9f7ed 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,6 @@
option(
'fru-device-resizefru', value : false, type: 'boolean', description: 'Allow FruDevice to resize FRU areas.',
)
+option(
+ 'validate-json', type: 'boolean', value: true, description: 'Run JSON schema validation during the build.',
+)