summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-03-14 15:01:02 -0700
committerNathaniel Graff <nathaniel.graff@sifive.com>2019-03-14 16:24:59 -0700
commit7083079297ea072a5a76b07ab53785372442d01f (patch)
tree7dec28d14b25d450cb12b5c6401f442a87363835
parent28956117d173b478d6e47b570aa05ea38d605976 (diff)
list-targets accepts TARGET_REQUIRE_TAGS as filter
make list-targets TARGET_REQUIRE_TAGS="tag1 tag2 tag3" will list only the BSPs with all of the requested tags. Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
-rw-r--r--Makefile10
-rwxr-xr-xscripts/filter-targets21
2 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index c513359..c97db4c 100644
--- a/Makefile
+++ b/Makefile
@@ -107,11 +107,14 @@ clean:
# Freedom Studio dev team.
#############################################################
-# Finds all directories in bsp/ with settings.mk, extracts the name of those directories, and sorts them
-ALL_TARGETS = $(sort $(patsubst $(TARGET_ROOT)/bsp/%/,%,$(dir $(shell find $(TARGET_ROOT)/bsp -name settings.mk))))
+# Find all settings.mk with TARGET_REQUIRE_TAGS in TARGET_TAGS
+MATCHING_SETTINGS = $(shell scripts/filter-targets $(TARGET_ROOT)/bsp $(TARGET_REQUIRE_TAGS))
+
+# Get the name of the containing directory of all matching settings.mk
+MATCHING_TARGETS = $(patsubst $(TARGET_ROOT)/bsp/%/,%,$(dir $(MATCHING_SETTINGS)))
list-targets:
- @echo bsp-list: $(ALL_TARGETS)
+ @echo bsp-list: $(sort $(MATCHING_TARGETS))
# Metal programs are any submodules in the software folder
list-programs:
@@ -228,3 +231,4 @@ debug: $(PROGRAM_ELF)
scripts/debug --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg
endif
+
diff --git a/scripts/filter-targets b/scripts/filter-targets
new file mode 100755
index 0000000..580a433
--- /dev/null
+++ b/scripts/filter-targets
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+set -o pipefail
+
+unset tag
+unset bsp_dir
+unset all_settings
+
+bsp_dir="$1"
+shift 1
+
+all_settings=`find ${bsp_dir} -name settings.mk`
+
+while [[ "$1" != "" ]]
+do
+ all_settings=`grep -le "TARGET_TAGS.*=.*$1.*" ${all_settings}`
+ shift 1
+done
+
+echo ${all_settings}