title: How to conditionally specify a variable in yocto .bb recipe
body: <p>I would like to do something like this:</p>
  
  <pre><code>if [ "${BB_NO_NETWORK}" == "1" ]; then
      SRCREV ?= "a2d1f0225692c7c054014ec4dfc4dd13a35245ee"
  else
      SRCREV ?= "${AUTOREV}"
  fi
  </code></pre>
  
  <p>But I get an unparsed error </p>
  
  <p>Here is what I have got working.</p>
  
  <pre><code>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)}"
  </code></pre>
  
  <p>This attempt fails:</p>
  
  <pre><code>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') }"
  </code></pre>
  
  <p>This also fails</p>
  
  <pre><code>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') }"
  </code></pre>
  
  <p>The error for this one looks like this:</p>
  
  <pre><code>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'
  </code></pre>
  
  <p>Lastly, this fails as well:</p>
  
  <pre><code>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}'}"
  </code></pre>