2023-03-22 02:16:37 -03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
|
2023-04-05 10:23:19 -03:00
|
|
|
import pathlib
|
2023-03-12 23:18:29 -03:00
|
|
|
|
|
|
|
|
|
|
|
def configure(cfg):
|
|
|
|
extra_src = [
|
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/core/session/stream/*.c',
|
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/core/session/*.c',
|
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/core/serialization/*.c',
|
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/util/*.c',
|
2023-04-24 02:13:32 -03:00
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/profile/transport/custom/custom_transport.c',
|
2023-03-12 23:18:29 -03:00
|
|
|
'modules/Micro-XRCE-DDS-Client/src/c/profile/transport/stream_framing/stream_framing_protocol.c',
|
|
|
|
'modules/Micro-CDR/src/c/types/*.c',
|
|
|
|
'modules/Micro-CDR/src/c/common.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
cfg.env.AP_LIB_EXTRA_SOURCES['AP_DDS'] = []
|
|
|
|
for pattern in extra_src:
|
|
|
|
s = cfg.srcnode.ant_glob(pattern, dir=False, src=True)
|
|
|
|
for x in s:
|
|
|
|
cfg.env.AP_LIB_EXTRA_SOURCES['AP_DDS'].append(str(x))
|
|
|
|
|
|
|
|
extra_src_inc = [
|
|
|
|
'modules/Micro-XRCE-DDS-Client/include',
|
|
|
|
'modules/Micro-XRCE-DDS-Client/include/uxr/client',
|
|
|
|
'modules/Micro-CDR/src/c',
|
|
|
|
'modules/Micro-CDR/include',
|
|
|
|
'modules/Micro-CDR/include/ucdr',
|
|
|
|
]
|
|
|
|
for inc in extra_src_inc:
|
|
|
|
cfg.env.INCLUDES += [str(cfg.srcnode.make_node(inc))]
|
|
|
|
|
|
|
|
# auto update submodules
|
|
|
|
cfg.env.append_value('GIT_SUBMODULES', 'Micro-XRCE-DDS-Client')
|
|
|
|
cfg.env.append_value('GIT_SUBMODULES', 'Micro-CDR')
|
|
|
|
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
config_h_in = [
|
|
|
|
'modules/Micro-XRCE-DDS-Client/include/uxr/client/config.h.in',
|
|
|
|
'modules/Micro-CDR/include/ucdr/config.h.in',
|
|
|
|
]
|
|
|
|
config_h_in_nodes = [bld.srcnode.make_node(h) for h in config_h_in]
|
|
|
|
config_h_nodes = [bld.bldnode.find_or_declare(h[:-3]) for h in config_h_in]
|
|
|
|
|
|
|
|
gen_path = "libraries/AP_DDS"
|
|
|
|
extra_bld_inc = [
|
|
|
|
'modules/Micro-CDR/include',
|
|
|
|
'modules/Micro-XRCE-DDS-Client/include',
|
2023-04-05 10:23:19 -03:00
|
|
|
str(pathlib.PurePath(gen_path, "generated")),
|
2023-03-12 23:18:29 -03:00
|
|
|
]
|
|
|
|
for inc in extra_bld_inc:
|
|
|
|
bld.env.INCLUDES += [bld.bldnode.find_or_declare(inc).abspath()]
|
|
|
|
|
|
|
|
for i in range(len(config_h_nodes)):
|
2023-04-05 10:23:19 -03:00
|
|
|
print(f"building {config_h_nodes[i].abspath()}")
|
2023-03-12 23:18:29 -03:00
|
|
|
bld(
|
|
|
|
# build config.h file
|
|
|
|
source=config_h_in_nodes[i],
|
|
|
|
target=config_h_nodes[i],
|
|
|
|
rule="%s %s/%s %s %s"
|
|
|
|
% (
|
|
|
|
bld.env.get_flat('PYTHON'),
|
|
|
|
bld.env.SRCROOT,
|
|
|
|
"libraries/AP_DDS/gen_config_h.py",
|
|
|
|
config_h_in_nodes[i].abspath(),
|
|
|
|
config_h_nodes[i].abspath(),
|
|
|
|
),
|
|
|
|
group='dynamic_sources',
|
|
|
|
)
|
|
|
|
|
2023-04-05 10:23:19 -03:00
|
|
|
# TODO instead of keeping standard IDL files in the source tree, copy them with "ros2 pkg prefix --share " tools
|
2023-03-12 23:18:29 -03:00
|
|
|
idl_files = bld.srcnode.ant_glob('libraries/AP_DDS/Idl/**/*.idl')
|
2023-04-05 10:23:19 -03:00
|
|
|
idl_include_path = bld.srcnode.make_node(str(pathlib.PurePath(gen_path, "Idl"))).abspath()
|
|
|
|
|
2023-03-12 23:18:29 -03:00
|
|
|
for idl in idl_files:
|
2024-01-29 09:36:25 -04:00
|
|
|
container_prealloc_size = 8
|
|
|
|
|
2023-04-05 10:23:19 -03:00
|
|
|
idl_path = pathlib.PurePath(idl.abspath())
|
|
|
|
b = idl_path.name
|
|
|
|
|
|
|
|
gen_h = idl_path.with_suffix('.h').name
|
|
|
|
gen_c = idl_path.with_suffix('.c').name
|
|
|
|
|
|
|
|
idl_folder = idl_path.parts[-3:-1]
|
|
|
|
dst_dir = pathlib.PurePath(gen_path, "generated", *idl_folder)
|
|
|
|
gen = [bld.bldnode.find_or_declare(str(dst_dir / name)) for name in [gen_h, gen_c]]
|
2024-01-29 09:36:25 -04:00
|
|
|
gen_cmd = f"{bld.env.MICROXRCEDDSGEN[0]} -cs -replace -default-container-prealloc-size {container_prealloc_size} -d {dst_dir} -I {idl_include_path} {idl}"
|
2023-03-12 23:18:29 -03:00
|
|
|
bld(
|
|
|
|
# build IDL file
|
|
|
|
source=idl,
|
|
|
|
target=gen,
|
2023-04-05 10:23:19 -03:00
|
|
|
rule=gen_cmd,
|
2023-03-12 23:18:29 -03:00
|
|
|
group='dynamic_sources',
|
|
|
|
)
|
2023-04-05 10:23:19 -03:00
|
|
|
|
|
|
|
bld.env.AP_LIB_EXTRA_SOURCES['AP_DDS'] += [str(gen[1])]
|