Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_DDS/gen_config_h.py
Views: 1798
#!/usr/bin/env python31'''2process a *.h.in file to produce a *.h file3'''45# TODO move to AP_DDS_Client/tools67import re8import sys910config = {11'PROJECT_VERSION_MAJOR': 1,12'PROJECT_VERSION_MINOR': 0,13'PROJECT_VERSION_PATCH': 0,14'PROJECT_VERSION': 2,15'UCLIENT_MAX_OUTPUT_BEST_EFFORT_STREAMS': 4,16'UCLIENT_MAX_OUTPUT_RELIABLE_STREAMS': 4,17'UCLIENT_MAX_INPUT_BEST_EFFORT_STREAMS': 4,18'UCLIENT_MAX_INPUT_RELIABLE_STREAMS': 2,19'UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS': 2,20'UCLIENT_MIN_SESSION_CONNECTION_INTERVAL': 1000,21'UCLIENT_MIN_HEARTBEAT_TIME_INTERVAL': 200,22'UCLIENT_UDP_TRANSPORT_MTU': 300,23'UCLIENT_TCP_TRANSPORT_MTU': 350,24'UCLIENT_SERIAL_TRANSPORT_MTU': 1024,25'UCLIENT_CUSTOM_TRANSPORT_MTU': 512,26'CONFIG_MACHINE_ENDIANNESS': 1, # little endian27'UCLIENT_SHARED_MEMORY_MAX_ENTITIES': 0,28'UCLIENT_SHARED_MEMORY_STATIC_MEM_SIZE': 0,29'UCLIENT_HARD_LIVELINESS_CHECK_TIMEOUT': 1000,30}3132defines = {33"UCLIENT_PROFILE_UDP": 0,34"UCLIENT_PROFILE_TCP": 0,35"UCLIENT_PROFILE_CAN": 0,36"UCLIENT_PROFILE_SERIAL": 0,37"UCLIENT_PROFILE_CUSTOM_TRANSPORT": 1,38"UCLIENT_PROFILE_DISCOVERY": 0,39"UCLIENT_PLATFORM_POSIX": 0,40"UCLIENT_PLATFORM_POSIX_NOPOLL": 0,41"UCLIENT_PLATFORM_WINDOWS": 0,42"UCLIENT_PLATFORM_FREERTOS_PLUS_TCP": 0,43"UCLIENT_PLATFORM_ZEPHYR": 0,44"UCLIENT_EXTERNAL_TCP": 0,45"UCLIENT_EXTERNAL_UDP": 0,46"UCLIENT_EXTERNAL_SERIAL": 0,47"UCLIENT_PROFILE_MULTITHREAD": 0,48"UCLIENT_PROFILE_SHARED_MEMORY": 0,49"UCLIENT_PROFILE_STREAM_FRAMING": 1,50"UCLIENT_PLATFORM_RTEMS_BSD_NET": 0,51"UCLIENT_TWEAK_XRCE_WRITE_LIMIT": 0,52"UCLIENT_HARD_LIVELINESS_CHECK": 0,53}5455h_in = sys.argv[1]56h = sys.argv[2]57print("Processing %s to %s" % (h_in, h))5859txt = open(h_in, 'r').read()6061for c in sorted(config.keys(), key=len, reverse=True):62txt = txt.replace("@%s@" % c, str(config[c]))6364for c in sorted(defines.keys(), key=len, reverse=True):65if defines[c] != 0:66txt = txt.replace("#cmakedefine %s" % c, "#define %s %u" % (c, defines[c]))67else:68txt = txt.replace("#cmakedefine %s" % c, "// #define %s %u" % (c, defines[c]))6970matches = re.findall(r'@(\w+)@', txt)71if len(matches) > 0:72print("Missing config elements: ", matches)73sys.exit(1)7475matches = re.findall(r'#cmakedefine\s+\w+', txt)76if len(matches) > 0:77print("Missing #cmakedefine elements: ", matches)78sys.exit(1)7980open(h, 'w').write(txt)818283