scripts/dts/extract_dts_includes.py: Cleanup yaml file finding
Cleanup how we find the yaml files for device tree bindings. Move to a
recursive dir search of the dts/ dir. This will be useful for
supporting re-organizing of the yaml files to match binding dir
structure.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
diff --git a/Makefile b/Makefile
index 1226310..a647b03 100644
--- a/Makefile
+++ b/Makefile
@@ -978,12 +978,12 @@
if test -e $(ZEPHYR_BASE)/dts/$(ARCH)/$(BOARD_NAME).fixup; then \
$(ZEPHYR_BASE)/scripts/dts/extract_dts_includes.py \
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
- -y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml \
+ -y $(ZEPHYR_BASE)/dts \
-f $(ZEPHYR_BASE)/dts/$(ARCH)/$(BOARD_NAME).fixup; \
else \
$(ZEPHYR_BASE)/scripts/dts/extract_dts_includes.py \
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
- -y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml; \
+ -y $(ZEPHYR_BASE)/dts; \
fi; \
)
endef
@@ -991,7 +991,7 @@
(echo "# WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY!"; \
$(ZEPHYR_BASE)/scripts/dts/extract_dts_includes.py \
-d dts/$(ARCH)/$(BOARD_NAME).dts_compiled \
- -y $(ZEPHYR_BASE)/dts/$(ARCH)/yaml -k; \
+ -y $(ZEPHYR_BASE)/dts -k; \
)
endef
else
diff --git a/scripts/dts/extract_dts_includes.py b/scripts/dts/extract_dts_includes.py
index 68f13c5..edaea1b 100755
--- a/scripts/dts/extract_dts_includes.py
+++ b/scripts/dts/extract_dts_includes.py
@@ -4,7 +4,7 @@
import sys
from os import listdir
-import os
+import os, fnmatch
import re
import yaml
import argparse
@@ -743,17 +743,9 @@
# scan YAML files and find the ones we are interested in
yaml_files = []
- for filename in listdir(args.yaml):
- if re.match('.*\.yaml\Z', filename):
- yaml_files.append(os.path.realpath(args.yaml + '/' + filename))
-
- # scan common YAML files and find the ones we are interested in
- zephyrbase = os.environ.get('ZEPHYR_BASE')
- if zephyrbase is not None:
- for filename in listdir(zephyrbase + '/dts/common/yaml'):
- if re.match('.*\.yaml\Z', filename):
- yaml_files.append(os.path.realpath(
- zephyrbase + '/dts/common/yaml/' + filename))
+ for root, dirnames, filenames in os.walk(args.yaml):
+ for filename in fnmatch.filter(filenames, '*.yaml'):
+ yaml_files.append(os.path.join(root, filename))
yaml_list = {}
file_load_list = set()