1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

Merge pull request #9867 from kaspar030/pr/unify_app_folder_search

make: unify app folder search (examples/*, tests/*, ...)
This commit is contained in:
Alexandre Abadie 2018-09-06 09:30:12 +02:00 committed by GitHub
commit 0c1a207bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 9 deletions

View File

@ -72,9 +72,8 @@ _greplist() {
# get list of all app directories
get_apps() {
find tests/ examples/ \
-mindepth 2 -maxdepth 2 -name Makefile -type f \
| xargs dirname | $(_greplist $APPS) | sort
make -f makefiles/app_dirs.inc.mk info-applications \
| $(_greplist $APPS) | sort
}
# take app dir as parameter, print all boards that are supported

View File

@ -20,11 +20,11 @@ docclean:
clean:
@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
@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:
@echo "Welcome to RIOT - The friendly OS for IoT!"
@ -37,4 +37,6 @@ welcome:
@echo "Or ask questions on our mailing list:"
@echo " users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)"
include makefiles/app_dirs.inc.mk
-include makefiles/tests.inc.mk

View File

@ -21,11 +21,14 @@
from __future__ import print_function
from collections import defaultdict
from itertools import groupby
from os import devnull, environ, listdir
from os import devnull, environ
from os.path import abspath, dirname, isfile, join
from subprocess import CalledProcessError, check_call, check_output, PIPE, Popen
from sys import exit, stdout, argv
from sys import argv, exit, stdout
try:
# Python 2.x
from StringIO import StringIO
@ -86,12 +89,33 @@ def get_results_and_output_from(fd):
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():
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)))
applications = listdir(join(riotbase, folder))
applications = app_folders[folder]
applications = filter(lambda app: is_tracked(join(riotbase, folder, app)), applications)
applications = sorted(applications)

14
makefiles/app_dirs.inc.mk Normal file
View File

@ -0,0 +1,14 @@
# 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