The open source OpenXR runtime

ipc: Add generation of struct names in proto.py

Structure names can be used as an input to pahole, which can then ensure
that the layout is the same in x86 and amd64

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2566>

+19
+19
src/xrt/ipc/shared/proto.py
··· 489 489 write_cpp_header_guard_end(f) 490 490 f.close() 491 491 492 + def generate_struct_names(file, p): 493 + """Generate list of structures names. 494 + 495 + Lists the structures used in the IPC protocol, this can be 496 + used for tools such as pahole. 497 + """ 498 + f = open(file, "w") 499 + f.write("ipc_shared_memory\n") 500 + types = set() 501 + for call in p.calls: 502 + for i in call.in_args + call.out_args: 503 + if i.is_aggregate: 504 + types.add(i.typename.split(" ")[-1]) 505 + for t in sorted(types): 506 + f.write(t) 507 + f.write("\n") 508 + f.close() 492 509 493 510 def main(): 494 511 """Handle command line and generate a file.""" ··· 513 530 generate_server_c(output, p) 514 531 if output.endswith("ipc_server_generated.h"): 515 532 generate_server_header(output, p) 533 + if output.endswith("structs.txt"): 534 + generate_struct_names(output, p) 516 535 517 536 518 537 if __name__ == "__main__":