| project('hothd', 'cpp', |
| version: '0.1', meson_version: '>=1.1.1', |
| default_options: [ |
| 'warning_level=3', |
| 'cpp_std=c++23' |
| ]) |
| |
| build_tests = get_option('tests') |
| |
| hothd_root = meson.current_source_dir() |
| hothd_headers = include_directories('.') |
| |
| add_project_arguments('-DOMIT_VARIABLE_ARRAYS', language : 'cpp') |
| |
| libusb_dep = dependency('libusb-1.0', required: get_option('usb')) |
| libhoth_usb_dep = dependency('libhoth', required: get_option('usb')) |
| if libusb_dep.found() |
| add_global_arguments('-DHAVE_USB', language: ['c', 'cpp']) |
| endif |
| |
| sdbusplus_dep = dependency('sdbusplus', required: false) |
| if sdbusplus_dep.found() and sdbusplus_dep.type_name() != 'internal' |
| sdbusplusplus_prog = find_program('sdbus++', native: true) |
| sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
| else |
| sdbusplus_proj = subproject('sdbusplus', required: true) |
| sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') |
| sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') |
| sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable('sdbuspp_gen_meson_prog') |
| endif |
| sdeventplus_dep = dependency('sdeventplus', required: true) |
| stdplus_dep = dependency('stdplus', fallback: ['stdplus', 'stdplus_dep']) |
| threads_dep = dependency('threads') |
| |
| trivial_fs = ''' |
| #include <filesystem> |
| |
| int main() |
| { |
| std::filesystem::path("/"); |
| return 0; |
| } |
| ''' |
| |
| if not meson.get_compiler('cpp').links(trivial_fs) |
| assert( |
| meson.get_compiler('cpp').links(trivial_fs, args: '-lstdc++fs'), |
| '<filesystem> not linkable') |
| message('Using legacy stdc++fs') |
| add_project_link_arguments('-lstdc++fs', language : 'cpp') |
| endif |
| |
| subdir('xyz/openbmc_project/Control/Hoth') |
| |
| libhothd_deps = [ |
| hothd_dbus_dep, |
| libusb_dep, |
| libhoth_usb_dep, |
| sdbusplus_dep, |
| sdeventplus_dep, |
| stdplus_dep, |
| threads_dep, |
| ] |
| |
| libhothd_lib = static_library( |
| 'hothd', |
| [ |
| 'asset.cpp', |
| 'firmware_mtd_updater.cpp', |
| 'firmware_spi_updater.cpp', |
| 'hoth.cpp', |
| 'hoth_state.cpp', |
| 'host_command.cpp', |
| 'message_file.cpp', |
| 'message_util.cpp', |
| 'mtd_util.cpp', |
| 'payload_update.cpp', |
| 'ec_util.cpp', |
| 'fs.cpp', |
| 'sys.cpp', |
| 'version.cpp', |
| 'log_collector_util.cpp', |
| ] + (not libusb_dep.found() ? [ ] : [ |
| 'libusb.cpp', |
| 'libusb_impl.cpp', |
| 'message_usb.cpp', |
| 'usb_util.cpp', |
| 'libhoth_usb.cpp', |
| 'message_hoth_usb.cpp', |
| ]), |
| include_directories: hothd_headers, |
| implicit_include_directories: false, |
| dependencies: libhothd_deps) |
| |
| libhothd_dep = declare_dependency( |
| dependencies: libhothd_deps, |
| include_directories: hothd_headers, |
| link_with: libhothd_lib) |
| |
| executable( |
| 'hothd', |
| 'main.cpp', |
| implicit_include_directories: false, |
| dependencies: libhothd_dep, |
| install: true, |
| install_dir: get_option('libexecdir')) |
| |
| conf_data = configuration_data() |
| conf_data.set('libexecdir', get_option('prefix') / get_option('libexecdir')) |
| conf_data.set('datadir', get_option('prefix') / get_option('datadir')) |
| |
| systemd_dep = dependency('systemd') |
| if systemd_dep.found() |
| unit_dir = systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir') |
| rule_dir = dependency('udev').get_variable(pkgconfig: 'udev_dir') / 'rules.d' |
| |
| configure_file( |
| input: 'hothd.service.in', |
| output: 'hothd.service', |
| configuration: conf_data, |
| install: true, |
| install_dir: unit_dir) |
| |
| install_data( |
| '70-hothd.rules', |
| install_dir: rule_dir) |
| |
| if libusb_dep.found() |
| configure_file( |
| input: 'hothd_usb.sh.in', |
| output: 'hothd_usb.sh', |
| configuration: conf_data, |
| install: true, |
| install_mode: 'rwxr-xr-x', |
| install_dir: get_option('libexecdir')) |
| |
| configure_file( |
| input: 'hothd-usb@.service.in', |
| output: 'hothd-usb@.service', |
| configuration: conf_data, |
| install: true, |
| install_dir: unit_dir) |
| |
| install_data( |
| '70-hothd-usb.rules', |
| install_dir: rule_dir) |
| endif |
| endif |
| |
| install_data( |
| 'hothd.conf', |
| install_dir: get_option('datadir') / 'dbus-1/system.d') |
| |
| if not build_tests.disabled() |
| subdir('test') |
| endif |
| |
| subdir('tools') |
| |
| if not get_option('usb').disabled() |
| subdir('usb_reset') |
| endif |