|
| 1 | + |
| 2 | +# VARIABLES # |
| 3 | + |
| 4 | +# Define the folder name for benchmarks files: |
| 5 | +BENCHMARKS_FOLDER ?= benchmark |
| 6 | + |
| 7 | +# Determine the host kernel: |
| 8 | +KERNEL ?= $(shell uname -s) |
| 9 | + |
| 10 | +# On Mac OSX, in order to use `|` and other regular expression operators, we need to use enhanced regular expression syntax (-E); see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/re_format.7.html#//apple_ref/doc/man/7/re_format. |
| 11 | + |
| 12 | +ifeq ($(KERNEL), Darwin) |
| 13 | + find_kernel_prefix := -E |
| 14 | +else |
| 15 | + find_kernel_prefix := |
| 16 | +endif |
| 17 | + |
| 18 | +# Define a suffix for pretty printing results as a list: |
| 19 | +find_print_benchmarks_list := -exec printf '%s\n' {} \; |
| 20 | + |
| 21 | +# Define the command flags: |
| 22 | +FIND_BENCHMARKS_FLAGS ?= \ |
| 23 | + -name "$(BENCHMARKS_PATTERN)" \ |
| 24 | + -path "$(ROOT_DIR)/**/$(BENCHMARKS_FOLDER)/**" \ |
| 25 | + -regex "$(BENCHMARKS_FILTER)" \ |
| 26 | + -not -path "$(ROOT_DIR)/.*" \ |
| 27 | + -not -path "$(NODE_MODULES)/*" \ |
| 28 | + -not -path "$(TOOLS_DIR)/*" \ |
| 29 | + -not -path "$(BUILD_DIR)/*" \ |
| 30 | + -not -path "$(REPORTS_DIR)/*" |
| 31 | + |
| 32 | + |
| 33 | +ifneq ($(KERNEL), Darwin) |
| 34 | + FIND_BENCHMARKS_FLAGS := -regextype posix-extended $(FIND_BENCHMARKS_FLAGS) |
| 35 | +endif |
| 36 | + |
| 37 | +# Define the list of benchmark files: |
| 38 | +BENCHMARKS ?= $(shell find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_BENCHMARKS_FLAGS)) |
| 39 | + |
| 40 | + |
| 41 | +# TARGETS # |
| 42 | + |
| 43 | +# List benchmark files. |
| 44 | +# |
| 45 | +# This target prints a newline-delimited list of benchmark files. |
| 46 | + |
| 47 | +list-benchmarks: |
| 48 | + @find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_BENCHMARKS_FLAGS) $(find_print_benchmarks_list) |
| 49 | + |
| 50 | +.PHONY: list-benchmarks |
0 commit comments