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