我想做这样的事情:
if [ "${BB_NO_NETWORK}" == "1" ]; then
SRCREV ?= "a2d1f0225692c7c054014ec4dfc4dd13a35245ee"
else
SRCREV ?= "${AUTOREV}"
fi
但我得到一个未解析的错误
这是我的工作。
SRCREV_FORMAT = "${@bb.utils.contains('BB_NO_NETWORK', '1', "v16_pcmx", "${AUTOREV}", d)}"
SRCREV_d3v16 = "${@bb.utils.contains('BB_NO_NETWORK', '1', "a2d1f0225692c7c054014ec4dfc4dd13a35245ee", "${AUTOREV}", d)}"
SRCREV_v16 = "${@bb.utils.contains('BB_NO_NETWORK', '1', "a2d1f0225692c7c054014ec4dfc4dd13a35245ee", "${AUTOREV}", d)}"
SRCREV_pcmx-native = "${@bb.utils.contains('BB_NO_NETWORK', '1', "d09e0b91ae34d807d3df27908f045e58a52e0c4c", "${AUTOREV}", d)}"
SRCREV_pcmx-pn-pcmx = "${@bb.utils.contains('BB_NO_NETWORK', '1', "d09e0b91ae34d807d3df27908f045e58a52e0c4c", "${AUTOREV}", d)}"
SRCREV_pcmx = "${@bb.utils.contains('BB_NO_NETWORK', '1', "d09e0b91ae34d807d3df27908f045e58a52e0c4c", "${AUTOREV}", d)}"
SRCREV_pn-pcmx = "${@bb.utils.contains('BB_NO_NETWORK', '1', "d09e0b91ae34d807d3df27908f045e58a52e0c4c", "${AUTOREV}", d)}"
SRCREV = "${@bb.utils.contains('BB_NO_NETWORK', '1', "", "${AUTOREV}", d)}"
此尝试失败:
SRCREV_FORMAT = "${@ "v16_pcmx" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_d3v16 = "${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_v16 = "${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_pcmx-native = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_pcmx-pn-pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV_pn-pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
SRCREV = "${@ "" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK',TRUE)) else d.getVar('AUTOREV') }"
这也失败了
SRCREV_FORMAT = "${@ "v16_pcmx" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_d3v16 = "${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_v16 = "${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_pcmx-native = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_pcmx-pn-pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV_pn-pcmx = "${@ "d09e0b91ae34d807d3df27908f045e58a52e0c4c" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
SRCREV = "${@ "" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
这个错误看起来像这样:
bb.data_smart.ExpansionError: Failure expanding variable SRCREV_v16, expression was ${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') } which triggered exception TypeError: getVar() missing 1 required positional argument: 'expand'
最后,这也失败了:
SRCREV_FORMAT = "${@'v16_pcmx' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_d3v16 = "${@'a2d1f0225692c7c054014ec4dfc4dd13a35245ee' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_v16 = "${@'a2d1f0225692c7c054014ec4dfc4dd13a35245ee' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_pcmx-native = "${@'d09e0b91ae34d807d3df27908f045e58a52e0c4c' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_pcmx-pn-pcmx = "${@'d09e0b91ae34d807d3df27908f045e58a52e0c4c' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_pcmx = "${@'d09e0b91ae34d807d3df27908f045e58a52e0c4c' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV_pn-pcmx = "${@'d09e0b91ae34d807d3df27908f045e58a52e0c4c' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
SRCREV = "${@'' if d.getVar('BB_NO_NETWORK') == '1' else '${AUTOREV}'}"
答案 0 :(得分:4)
我想现代的OE看起来会像这样(未经测试):
SRCREV = "${@ "a2d1f0225692c7c054014ec4dfc4dd13a35245ee" if bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')) else d.getVar('AUTOREV') }"
使用inline python variable expansion。在较旧的OE上,您可能需要为d.getVar
指定第二个参数,例如d.getVar('BB_NO_NETWORK', True)
。
答案 1 :(得分:2)
您还可以使用utils.bbclass
中的base_conditional:
SRCREV = "${@base_conditional('BB_NO_NETWORK', '1', 'a2d1f0225692c7c054014ec4dfc4dd13a35245ee', '${AUTOREV}', d)}"