diff --git a/.murdock b/.murdock index 80e7219be23d3074901d89f52daa0a2506e8715a..7a5a6ef813274790efcc14f9529f0c15b7db3322 100755 --- a/.murdock +++ b/.murdock @@ -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 diff --git a/Makefile b/Makefile index ee4f18be5acc4d180a4fd7737967d1a9e80f6483..f92f1c16bc3578766aae9cc117dadc4c43cb8c1e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dist/tools/compile_test/compile_test.py b/dist/tools/compile_test/compile_test.py index ad4af4a715500533c733aa208ad82f3c3f805ad1..fe61dc5e95af2f1724e67e8e81a571c83e108ff9 100755 --- a/dist/tools/compile_test/compile_test.py +++ b/dist/tools/compile_test/compile_test.py @@ -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) diff --git a/makefiles/app_dirs.inc.mk b/makefiles/app_dirs.inc.mk new file mode 100644 index 0000000000000000000000000000000000000000..d181aed5e39f1106da410f1eeeaab9445eef1564 --- /dev/null +++ b/makefiles/app_dirs.inc.mk @@ -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