【发布时间】:2020-05-14 04:40:26
【问题描述】:
让我们考虑.bb 文件中的以下示例:
X = "1"
A := "X is '${X}' and Y is '${Y}'"
B = "X is '${X}' and Y is '${Y}'"
X = "2"
Y = "3"
根据在线提供的bitbake 文档和许多其他示例,我希望变量A 和B 在解析结束时保持以下值:
A="X is '1' and Y is ''"
B="X is '2' and Y is '3'"
但是,运行 bitbake -e <recipe name> | grep ^A 和运行 B 会发现变量的实际值如下:
A="X is '1' and Y is '3'"
B="X is '2' and Y is '3'"
换句话说,我期望立即赋值运算符将强制一个尚未定义的变量(例如在解析A 立即赋值时的B)留空。但是,bitbake 似乎选择了变量的最后定义值。这种行为(选择变量的最后定义值)也与弱赋值和默认赋值一致。
我也为GNU Make 尝试了立即赋值的相同概念,似乎make 的行为符合我的预期:
X = 1
A := X is '$(X)' and Y is '$(Y)'
B = X is '$(X)' and Y is '$(Y)'
X = 2
Y = 3
A:
echo "$(A)"
B:
echo "$(B)"
当立即赋值包含未定义的变量时,bitbake 的行为方式是否有原因?还是只是一个错误?
我倾向于相信我错过了什么。
$ bitbake --version
BitBake Build Tool Core version 1.42.0
$ make -v
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
【问题讨论】:
-
我刚刚意识到,有没有可能
A在立即赋值后的值是X is '1' and Y is '${Y}',这样因为Y不能被替换,整个${Y}字符串被保留到位?这样,在解析结束时重新评估A是有意义的,现在,由于Y的最后一个值可用,它终于被替换了!
标签: makefile syntax undefined yocto bitbake