如何传递可以在 makefile 中迭代的参数?

How do I pass arguments that you are able to iterate through in a makefile?

我的 makefile 中有这个:

test_x_number_times:
for time in `seq $(TIMES)` ; do \
    for dc in $(DCs) ; do \
        echo $$dc ; \
            poetry run kit test -d $$dc --testcase-id=$(TESTCASES) || true ; \
    done ; \
done ;

并希望能够为 TESTCASESDCs 传递多个值,以便我可以在 for 循环中遍历它们,但我不知道如何列出命令行上的参数以一种将值视为可以迭代的值的方式。这是我尝试过的:

  1. make make test_x_number_times TIMES=1 DCs=B1,G1 TESTCASES=1,2
  2. make make test_x_number_times TIMES=1 DCs=B1 G1 TESTCASES=1 2
  3. make make test_x_number_times TIMES=1 DCs=(B1 G1) TESTCASES=(1 2)

我该怎么做?我在文档或 Whosebug 的任何地方都找不到它。

shell for 循环期望看到以空格分隔的单词进行迭代。要在单个 shell 参数中传递空格,您需要引用它:

make make test_x_number_times TIMES=1 DCs='B1 G1' TESTCASES='1 2'