简体   繁体   English

Makefile中的VAR评估

[英]VAR evaluation in Makefile

I want that make wheel print the wheel name make wheel印出车轮名称

cat Makefile
wheel:
    @rm -fr build dist
    @python setup.py bdist_wheel
    $(eval WHEEL=$(shell find . -name '*.whl'))
    @printf '\n => wheel ready %s\n\n' $(WHEEL)

This almost work, effectively because eval is evaluated BEFORE the call to setup.py the dist folder is empty. 几乎可以正常工作,因为在调用setup.py之前dist文件夹为空之前已评估eval。

I've tryed with WHEEL:=$(shell find . -name '*.whl') too, same result 我也尝试过WHEEL:=$(shell find . -name '*.whl') ,同样的结果

Use a different target to create the files. 使用其他目标来创建文件。 Store the command in a variable with $(shell) (you're using GNU Make, right?), using it will run the associated command: 将命令存储在带有$(shell)的变量中(您正在使用GNU Make,对吗?),使用它将运行关联的命令:

WHEEL = $(shell find . -name '*.whl')

wheel: create_wheel
    printf '\n => wheel ready %s\n\n' $(WHEEL)

create_wheel:
    @rm -fr build dist
    @python setup.py bdist_wheel

You need to use = when assigning the command, otherwise (with := ) it will be evaluated at the beginning of the make process. 分配命令时需要使用= ,否则(使用:= )将在生成过程的开始进行评估。

Putting the results in a variable seems completely misdirected. 将结果放在变量中似乎完全是错误的。

wheel:
    @rm -fr build dist
    python setup.py bdist_wheel
    @printf '\n => wheel ready %s\n\n' $$(find . -name '*.whl')

The printf newlines look wacky but maybe you like spurious empty lines. printf换行符看起来很古怪,但也许您喜欢虚假的空行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM