@@ -405,6 +405,10 @@ def visit_command(self,
if self._gen_tracing:
self._gen_trace_events.add(gen_trace(name))
with self._temp_module('./init'):
+ # TODO: This if guard should be implemented as a runtime check
+ # instead of #ifdef based ifcond.
+ # "#if TARGET_S390X && CONFIG_KVM" will become:
+ # "if (target_s390x() || kvm_enabled()) {"
with ifcontext(ifcond, self._genh, self._genc):
self._genc.add(gen_register_command(
name, features, success_response, allow_oob,
@@ -206,6 +206,8 @@ def gen_ifcond(ifcond: Optional[Union[str, Dict[str, Any]]],
def do_gen(ifcond: Union[str, Dict[str, Any]],
need_parens: bool) -> str:
if isinstance(ifcond, str):
+ if ifcond.startswith('TARGET_') or ifcond == 'CONFIG_KVM':
+ return '1 /*' + ifcond + '*/'
return cond_fmt % ifcond
assert isinstance(ifcond, dict) and len(ifcond) == 1
if 'not' in ifcond:
@@ -247,7 +249,7 @@ def gen_endif(cond: str) -> str:
if not cond:
return ''
return mcgen('''
-#endif /* %(cond)s */
+#endif // %(cond)s
''', cond=cond)
As this point, we don't do anything to hide target specific commands, as the TODO mentions in the commit. All other CONFIG_* are based on config-host, so we can safely generate ifdefs. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> --- scripts/qapi/commands.py | 4 ++++ scripts/qapi/common.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-)