Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 1 | project('phosphor-logging', 'cpp', |
| 2 | meson_version: '>= 0.57.0', |
| 3 | default_options: [ |
| 4 | 'buildtype=debugoptimized', |
| 5 | 'cpp_std=c++20', |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 8 | 'libonly=' + (meson.is_subproject() ? 'true' : 'false'), |
William A. Kennington III | 515653b | 2021-05-17 19:28:17 -0700 | [diff] [blame] | 9 | 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'), |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 10 | ], |
| 11 | version: '1.0.0', |
| 12 | ) |
Patrick Williams | 62bc968 | 2022-03-21 09:23:11 -0500 | [diff] [blame] | 13 | cpp = meson.get_compiler('cpp') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 14 | |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 15 | python_prog = find_program('python3', native: true) |
| 16 | systemd_dep = dependency('systemd') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 17 | |
Patrick Williams | 62bc968 | 2022-03-21 09:23:11 -0500 | [diff] [blame] | 18 | sdbusplus_dep = dependency('sdbusplus') |
| 19 | sdbusplusplus_prog = find_program('sdbus++', native: true) |
| 20 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 21 | |
Patrick Williams | 62bc968 | 2022-03-21 09:23:11 -0500 | [diff] [blame] | 22 | pdi_dep = dependency('phosphor-dbus-interfaces') |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 23 | |
| 24 | # Find the installed YAML directory, either from a configure option or |
| 25 | # by pulling it from the PDI dependency. |
| 26 | yamldir = get_option('yamldir') |
| 27 | if yamldir == '' |
| 28 | yamldir = pdi_dep.get_variable(pkgconfig: 'yamldir', internal: 'yamldir') |
| 29 | endif |
| 30 | |
| 31 | subdir('config') |
| 32 | subdir('tools') |
| 33 | subdir('lib') |
| 34 | |
| 35 | if get_option('libonly') |
| 36 | subdir_done() |
| 37 | endif |
| 38 | |
Patrick Williams | 62bc968 | 2022-03-21 09:23:11 -0500 | [diff] [blame] | 39 | sdeventplus_dep = dependency('sdeventplus') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 40 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 41 | # Get Cereal dependency. |
William A. Kennington III | 0b08776 | 2021-05-17 18:56:48 -0700 | [diff] [blame] | 42 | cereal_dep = dependency('cereal', required: false) |
| 43 | has_cereal = cpp.has_header_symbol( |
| 44 | 'cereal/cereal.hpp', |
| 45 | 'cereal::specialize', |
| 46 | dependencies: cereal_dep, |
| 47 | required: false) |
| 48 | if not has_cereal |
| 49 | cereal_opts = import('cmake').subproject_options() |
| 50 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 51 | cereal_proj = import('cmake').subproject( |
| 52 | 'cereal', |
| 53 | options: cereal_opts, |
| 54 | required: false) |
| 55 | assert(cereal_proj.found(), 'cereal is required') |
Patrick Williams | 3e55d4d | 2021-08-26 16:44:26 -0500 | [diff] [blame] | 56 | cereal_dep = cereal_proj.dependency('cereal') |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 57 | endif |
| 58 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 59 | # Generate sdbus++ files. |
| 60 | generated_sources = [] |
| 61 | generated_others = [] |
| 62 | subdir('gen') |
| 63 | subdir('gen/xyz') |
| 64 | |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 65 | # Generate callouts-gen.hpp. |
| 66 | callouts_gen = custom_target('callouts-gen.hpp'.underscorify(), |
| 67 | input: [ |
| 68 | 'callouts/callouts.py', |
| 69 | 'callouts/callouts-gen.mako.hpp', |
| 70 | get_option('callout_yaml'), |
| 71 | ], |
| 72 | output: 'callouts-gen.hpp', |
| 73 | command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ], |
| 74 | ) |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 75 | # Generate elog-lookup.cpp |
| 76 | elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(), |
| 77 | input: files( |
| 78 | 'tools/elog-gen.py', |
| 79 | 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp', |
| 80 | ), |
| 81 | output: 'elog-lookup.cpp', |
| 82 | command: [ |
| 83 | python_prog, '@INPUT0@', |
| 84 | '-t', '', |
| 85 | '-m', '@INPUT1@', |
| 86 | '-y', yamldir, |
Tim Lee | 47c7734 | 2021-07-08 09:27:58 +0800 | [diff] [blame] | 87 | '-u', meson.current_source_dir() / 'tools/', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 88 | '-o', '@OUTPUT0@', |
| 89 | ], |
| 90 | ) |
| 91 | # Generate elog-process-metadata.cpp |
| 92 | elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(), |
| 93 | input: files( |
| 94 | 'tools/elog-gen.py', |
| 95 | 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp', |
| 96 | ), |
| 97 | output: 'elog-process-metadata.cpp', |
| 98 | command: [ |
| 99 | python_prog, '@INPUT0@', |
| 100 | '-t', '', |
| 101 | '-m', '@INPUT1@', |
| 102 | '-y', yamldir, |
Tim Lee | 47c7734 | 2021-07-08 09:27:58 +0800 | [diff] [blame] | 103 | '-u', meson.current_source_dir() / 'tools/', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 104 | '-o', '@OUTPUT0@', |
| 105 | ], |
| 106 | ) |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 107 | |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 108 | log_manager_ext_sources = [] |
| 109 | log_manager_ext_deps = [] |
William A. Kennington III | 8fd187e | 2021-07-26 13:36:56 -0700 | [diff] [blame] | 110 | log_manager_ext_args = [] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 111 | |
| 112 | subdir('extensions') |
Patrick Williams | b2b2708 | 2021-04-16 20:24:12 -0500 | [diff] [blame] | 113 | subdir('phosphor-rsyslog-config') |
Patrick Williams | f06056b | 2021-04-16 13:38:55 -0500 | [diff] [blame] | 114 | |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 115 | # Generate daemon. |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 116 | log_manager_sources = [ |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 117 | generated_sources, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 118 | callouts_gen, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 119 | elog_lookup_gen, |
| 120 | elog_process_gen, |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 121 | files( |
| 122 | 'elog_entry.cpp', |
| 123 | 'elog_meta.cpp', |
| 124 | 'elog_serialize.cpp', |
| 125 | 'extensions.cpp', |
| 126 | 'log_manager.cpp', |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 127 | 'util.cpp', |
| 128 | ) |
| 129 | ] |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 130 | log_manager_deps = [ |
| 131 | cereal_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 132 | conf_h_dep, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 133 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 134 | phosphor_logging_dep, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 135 | sdbusplus_dep, |
| 136 | sdeventplus_dep, |
| 137 | ] |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 138 | executable('phosphor-log-manager', |
| 139 | log_manager_sources, |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 140 | log_manager_ext_sources, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 141 | 'log_manager_main.cpp', |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 142 | include_directories: include_directories('gen'), |
William A. Kennington III | 8fd187e | 2021-07-26 13:36:56 -0700 | [diff] [blame] | 143 | cpp_args: log_manager_ext_args, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 144 | dependencies: [ |
Patrick Williams | d9f0d64 | 2021-04-21 15:43:21 -0500 | [diff] [blame] | 145 | log_manager_deps, |
| 146 | log_manager_ext_deps, |
Patrick Williams | 0bb89f8 | 2021-04-16 16:30:04 -0500 | [diff] [blame] | 147 | ], |
| 148 | install: true, |
| 149 | ) |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 150 | # Generate test executables which run in obmc env (qemu, real hardware). |
| 151 | executable('logging-test', |
| 152 | 'logging_test.cpp', |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 153 | dependencies: [ |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 154 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 155 | phosphor_logging_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 156 | sdbusplus_dep, |
| 157 | ], |
| 158 | install: true, |
| 159 | ) |
| 160 | executable('callout-test', |
| 161 | 'callouts/callout_test.cpp', |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 162 | dependencies: [ |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 163 | conf_h_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 164 | pdi_dep, |
William A. Kennington III | e053884 | 2021-06-11 02:01:58 -0700 | [diff] [blame] | 165 | phosphor_logging_dep, |
Patrick Williams | ddd4fac | 2021-04-16 16:40:43 -0500 | [diff] [blame] | 166 | sdbusplus_dep, |
| 167 | sdeventplus_dep, |
| 168 | ], |
| 169 | install: true, |
| 170 | ) |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 171 | |
Anton D. Kachalov | 271408b | 2021-03-30 13:29:00 +0200 | [diff] [blame] | 172 | subdir('dist') |
| 173 | |
Patrick Williams | a517197 | 2021-04-16 20:10:01 -0500 | [diff] [blame] | 174 | if not get_option('tests').disabled() |
| 175 | subdir('test') |
| 176 | endif |