将命令行参数传递给从 Makefile 调用的 python 脚本

Passing command line arguments to a python script, called from a Makefile

我刚刚开始使用 GNU 的 make 命令来实现自动化。我 运行 遇到了问题,需要一些帮助。 我有一个 python 脚本 (abc.py),它接受带有短符号 ("-t") 和长符号 ("--type") 的命令行参数,并且可以是 运行如:

python abc.py --type "blah"

但是,我希望从 Makefile 中 运行 这个脚本 (abc.py)。所以,现在我的 Makefile 看起来像:

command:
    python abc.py

我现在可以作为 make command 执行代码,但我如何接受用户输入并将其传递给 abc.py? 希望,问题格式正确。

TBH 这并不是 make 设计的真正目的。您通常会 make 以编程方式计算出参数,或者对不同的参数集使用不同的目标。这可以使用环境变量来实现。如果您将 makefile 更改为如下所示:

command:
    python abc.py ${PARAMS}

您的命令将如下所示:

make command PARAMS='--type "blah"'