Skip to content
Snippets Groups Projects
Unverified Commit 0c1a207b authored by Alexandre Abadie's avatar Alexandre Abadie Committed by GitHub
Browse files

Merge pull request #9867 from kaspar030/pr/unify_app_folder_search

make: unify app folder search (examples/*, tests/*, ...)
parents fad4d9be de552658
No related branches found
No related tags found
No related merge requests found
...@@ -72,9 +72,8 @@ _greplist() { ...@@ -72,9 +72,8 @@ _greplist() {
# get list of all app directories # get list of all app directories
get_apps() { get_apps() {
find tests/ examples/ \ make -f makefiles/app_dirs.inc.mk info-applications \
-mindepth 2 -maxdepth 2 -name Makefile -type f \ | $(_greplist $APPS) | sort
| xargs dirname | $(_greplist $APPS) | sort
} }
# take app dir as parameter, print all boards that are supported # take app dir as parameter, print all boards that are supported
......
...@@ -20,11 +20,11 @@ docclean: ...@@ -20,11 +20,11 @@ docclean:
clean: clean:
@echo "Cleaning all build products for the current board" @echo "Cleaning all build products for the current board"
@find ./examples/ ./tests/ -maxdepth 2 -mindepth 2 -type f -name Makefile -execdir "$(MAKE)" clean ';' @for dir in $(APPLICATION_DIRS); do "$(MAKE)" -C$$dir clean; done
distclean: docclean distclean: docclean
@echo "Cleaning all build products" @echo "Cleaning all build products"
@find ./examples/ ./tests/ -maxdepth 2 -mindepth 2 -type f -name Makefile -execdir "$(MAKE)" distclean ';' @for dir in $(APPLICATION_DIRS); do "$(MAKE)" -C$$dir distclean; done
welcome: welcome:
@echo "Welcome to RIOT - The friendly OS for IoT!" @echo "Welcome to RIOT - The friendly OS for IoT!"
...@@ -37,4 +37,6 @@ welcome: ...@@ -37,4 +37,6 @@ welcome:
@echo "Or ask questions on our mailing list:" @echo "Or ask questions on our mailing list:"
@echo " users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)" @echo " users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)"
include makefiles/app_dirs.inc.mk
-include makefiles/tests.inc.mk -include makefiles/tests.inc.mk
...@@ -21,11 +21,14 @@ ...@@ -21,11 +21,14 @@
from __future__ import print_function from __future__ import print_function
from collections import defaultdict
from itertools import groupby from itertools import groupby
from os import devnull, environ, listdir from os import devnull, environ
from os.path import abspath, dirname, isfile, join from os.path import abspath, dirname, isfile, join
from subprocess import CalledProcessError, check_call, check_output, PIPE, Popen from subprocess import CalledProcessError, check_call, check_output, PIPE, Popen
from sys import exit, stdout, argv from sys import argv, exit, stdout
try: try:
# Python 2.x # Python 2.x
from StringIO import StringIO from StringIO import StringIO
...@@ -86,12 +89,33 @@ def get_results_and_output_from(fd): ...@@ -86,12 +89,33 @@ def get_results_and_output_from(fd):
output.write(line) output.write(line)
def get_app_dirs():
return check_output(["make", "-f", "makefiles/app_dirs.inc.mk", "info-applications"]) \
.decode("utf-8", errors="ignore")\
.split()
def split_apps_by_dir(app_dirs):
""" creates a dictionary as follows:
{ "examples": ["hello_world", "gnrc_networking" ],
"tests": ["minimal", "fmt_print" ]
}
"""
res = defaultdict(list)
for app_dir in app_dirs:
folder, app = app_dir.split("/", 1)
res[folder].append(app)
return res
def build_all(): def build_all():
riotbase = environ.get('RIOTBASE') or abspath(join(dirname(abspath(__file__)), '../' * 3)) riotbase = environ.get('RIOTBASE') or abspath(join(dirname(abspath(__file__)), '../' * 3))
for folder in ('examples', 'tests'): app_folders = split_apps_by_dir(get_app_dirs())
for folder in sorted(app_folders):
print('Building all applications in: {}'.format(colorize_str(folder, Termcolor.blue))) print('Building all applications in: {}'.format(colorize_str(folder, Termcolor.blue)))
applications = listdir(join(riotbase, folder)) applications = app_folders[folder]
applications = filter(lambda app: is_tracked(join(riotbase, folder, app)), applications) applications = filter(lambda app: is_tracked(join(riotbase, folder, app)), applications)
applications = sorted(applications) applications = sorted(applications)
......
# fallback so empty RIOTBASE won't lead to "/examples/"
RIOTBASE ?= .
# 1. use wildcard to find Makefiles
# 2. use patsubst to drop trailing "/"
# 3. use patsubst to drop possible leading "./"
# 4. sort
APPLICATION_DIRS := $(sort $(patsubst ./%,%,$(patsubst %/,%,$(dir $(wildcard \
$(RIOTBASE)/examples/*/Makefile \
$(RIOTBASE)/tests/*/Makefile \
)))))
info-applications:
@for dir in $(APPLICATION_DIRS); do echo $$dir; done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment