Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何计算makefile for循环中的操作数,并对某些计数值采取操作?_Android_Makefile - Fatal编程技术网

Android 如何计算makefile for循环中的操作数,并对某些计数值采取操作?

Android 如何计算makefile for循环中的操作数,并对某些计数值采取操作?,android,makefile,Android,Makefile,主makefile打印很多“include file…”行。我想把它缩小一点,只打印每10或100个 build/core/main.mk中的原始行: $(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk))) 我想打印包括。。。行的频率较低。此代码使用shell和eval函数更新计数。然后它进行简单的模式匹配,查找以00结尾的任何数字 define count_includes

主makefile打印很多“include file…”行。我想把它缩小一点,只打印每10或100个

build/core/main.mk
中的原始行:

$(foreach mk, $(subdir_makefiles), $(info including $(mk) ...)$(eval include $(mk)))

我想打印包括。。。行的频率较低。

此代码使用shell和eval函数更新计数。然后它进行简单的模式匹配,查找以00结尾的任何数字

define count_includes
    $(eval INCLUDE_COUNT := $(shell echo "$$(( $(INCLUDE_COUNT) + 1 ))" ) ) \
    $(if $(patsubst %00,,$(INCLUDE_COUNT)),,$(info $(INCLUDE_COUNT): including $(1) ...) )
endef

$(foreach mk, $(subdir_makefiles), $(call count_includes, $(mk))$(eval include $(mk)))
注意:我不需要在上面初始化
INCLUDE_COUNT
,因为它一开始是空的/未定义的,
$(+1))
的计算结果是
1

我运行了两个测试,删除了原始代码、此代码和所有打印。我机器上的所有时间都在35秒的1秒之内。因此,没有真正的性能损失

以下是我用于测试的makefile:

define count_includes
    $(eval INCLUDE_COUNT := $(shell echo "$$(( $(INCLUDE_COUNT) + 1 ))" ) ) \
    $(if $(patsubst %00,,$(INCLUDE_COUNT)),,$(info $(INCLUDE_COUNT): including $(1) ...) )
endef

FILELIST := $(wildcard /usr/share/man/man1/*)
$(foreach mk, $(FILELIST), $(call count_includes, $(mk)))

.PHONY: all
all:
    @echo "All done." $(INCLUDE_COUNT)
如果希望0上的间隔不是模式匹配,则可以使用shell命令输出当前计数和测试结果,然后拆分结果字符串。这只是为了避免另一个shell调用