mirror of https://github.com/rusefi/ChibiOS.git
CI: Improve search of makefiles
Search "*.make" makefiles and exclude "Makefile" makefiles if there is the "make" subdirectory on the same level. This is needed to build each project separately and collect the results for each. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14679 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
5d565df520
commit
72a4f54cb2
|
@ -13,36 +13,41 @@ WORKFLOWS := $(ROOT)/tools/workflows
|
||||||
# Defines what targets to build in makefile based projects, the order matter.
|
# Defines what targets to build in makefile based projects, the order matter.
|
||||||
TARGETS := all clean
|
TARGETS := all clean
|
||||||
|
|
||||||
# Find all projects to build
|
# Makefile based projects
|
||||||
makefile_dirs := $(addprefix $(ROOT)/,demos test testex testhal testrt)
|
makefile_dirs := $(addprefix $(ROOT)/,demos test testex testhal testrt)
|
||||||
makefiles += $(shell find $(makefile_dirs) -type f -not -path "*/multi/*" \
|
makefiles := $(shell $(WORKFLOWS)/find.py --makefile --make --no-overlaps \
|
||||||
-name Makefile )
|
$(makefile_dirs))
|
||||||
multi_makefiles := $(shell find $(makefile_dirs) -type f -path "*/multi/*" \
|
|
||||||
-name "*.make")
|
single_makefiles := $(filter Makefile,$(makefiles))
|
||||||
|
multi_makefiles := $(filter-out Makefile,$(makefiles))
|
||||||
|
|
||||||
|
# External dependencies
|
||||||
external := $(addprefix $(ROOT)/ext/,fatfs lwip pico-sdk wolfssl)
|
external := $(addprefix $(ROOT)/ext/,fatfs lwip pico-sdk wolfssl)
|
||||||
|
|
||||||
|
# Documents
|
||||||
docs := $(shell find $(ROOT)/doc -type f -name Doxyfile_html)
|
docs := $(shell find $(ROOT)/doc -type f -name Doxyfile_html)
|
||||||
|
|
||||||
|
# Linter scripts
|
||||||
linters := $(shell find $(ROOT)/tools/style -type f -name "*.sh")
|
linters := $(shell find $(ROOT)/tools/style -type f -name "*.sh")
|
||||||
|
|
||||||
.PHONY : all makefiles external docs info lint clean
|
.PHONY : all makefiles external docs info lint clean
|
||||||
.PHONY : $(makefiles) $(multi_makefiles)
|
.PHONY : $(makefiles) $(linters) $(docs)
|
||||||
.PHONY : $(linters) $(docs)
|
|
||||||
|
|
||||||
# Build makefile based projects
|
# Build makefile based projects
|
||||||
all : makefiles
|
all : makefiles
|
||||||
makefiles : $(makefiles) $(multi_makefiles)
|
makefiles : $(makefiles)
|
||||||
@! grep -q -r -m 1 "failure" $(TEST_RESULTS) 2>&1 > /dev/null || ( \
|
@! grep -q -r -m 1 "failure" $(TEST_RESULTS) 2>&1 > /dev/null || ( \
|
||||||
echo "Exiting because there are build failures"; \
|
echo "Exiting because there are build failures"; \
|
||||||
exit 1)
|
exit 1)
|
||||||
|
|
||||||
$(makefiles) : $(external)
|
$(single_makefiles) : $(external)
|
||||||
@mkdir -p $(TEST_RESULTS)/$(subst $(ROOT)/,,$(@D))
|
@mkdir -p $(TEST_RESULTS)/$(subst $(ROOT)/,,$(@D))
|
||||||
+python $(WORKFLOWS)/make.py -C $(@D) -f $(@F) -p $(ROOT)/ \
|
+$(WORKFLOWS)/make.py -C $(@D) -f $(@F) -p $(ROOT)/ \
|
||||||
-r $(TEST_RESULTS) -s $(WORKFLOWS)/skip.yaml $(TARGETS)
|
-r $(TEST_RESULTS) -s $(WORKFLOWS)/skip.yaml $(TARGETS)
|
||||||
|
|
||||||
$(multi_makefiles) : $(external)
|
$(multi_makefiles) : $(external)
|
||||||
@mkdir -p $(TEST_RESULTS)/$(subst $(ROOT)/,,$(@D))
|
@mkdir -p $(TEST_RESULTS)/$(subst $(ROOT)/,,$(@D))
|
||||||
+python $(WORKFLOWS)/make.py -C $(dir $(@D)) -f make/$(@F) -p $(ROOT)/ \
|
+$(WORKFLOWS)/make.py -C $(dir $(@D)) -f make/$(@F) -p $(ROOT)/ \
|
||||||
-r $(TEST_RESULTS) -s $(WORKFLOWS)/skip.yaml $(TARGETS)
|
-r $(TEST_RESULTS) -s $(WORKFLOWS)/skip.yaml $(TARGETS)
|
||||||
|
|
||||||
# External projects
|
# External projects
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
Finds all makefile projects in the given directories and allows to exclude
|
||||||
|
overlaps.
|
||||||
|
|
||||||
|
To get help on usage, possible options and their descriptions, use
|
||||||
|
the following command:
|
||||||
|
|
||||||
|
find.py --help
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def find(args):
|
||||||
|
result = []
|
||||||
|
for path in args.dirs:
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
if args.makefile and 'Makefile' in files:
|
||||||
|
if args.no_overlaps and args.make and 'make' in dirs:
|
||||||
|
# Skip 'Makefile' because there is the 'make' subdir with
|
||||||
|
# more specific '*.make' makefiles.
|
||||||
|
continue
|
||||||
|
result.append(os.path.join(root, 'Makefile'))
|
||||||
|
if args.make and os.path.basename(root) == 'make':
|
||||||
|
result.extend(
|
||||||
|
os.path.join(root, make)
|
||||||
|
for make in files
|
||||||
|
if make.endswith('.make')
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description='Find makefiles')
|
||||||
|
parser.add_argument('--makefile', action='store_true',
|
||||||
|
help='Search for "Makefile" files.')
|
||||||
|
parser.add_argument('--make', action='store_true',
|
||||||
|
help='Search for "*.make" files.')
|
||||||
|
parser.add_argument('--no-overlaps', action='store_true',
|
||||||
|
help=('Exclude "Makefile" if there is the "make" '
|
||||||
|
'subdir which includes more specific "*.make" '
|
||||||
|
'files'))
|
||||||
|
parser.add_argument('dirs', metavar='dir', nargs='+',
|
||||||
|
help='Directories in which to search for makefiles.')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
makefiles = find(args)
|
||||||
|
sys.stdout.write('\n'.join(makefiles))
|
||||||
|
sys.stdout.write('\n')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue