blob: 7d1b06e27d2bf78aac75c1e3ddfc2a11558e94fc [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
Patrick Williams601cea42025-02-01 08:36:51 -05002 'openpower-occ-control',
3 'cpp',
4 version: '1.0.0',
Patrick Williams50cfb702023-07-12 11:15:24 -05005 meson_version: '>=1.1.1',
George Liubddcf852021-09-08 08:46:22 +08006 default_options: [
7 'warning_level=3',
8 'werror=true',
Patrick Williams50cfb702023-07-12 11:15:24 -05009 'cpp_std=c++23',
Patrick Williams601cea42025-02-01 08:36:51 -050010 'buildtype=debugoptimized',
11 ],
George Liubddcf852021-09-08 08:46:22 +080012)
13
Eddie Jamescbad2192021-10-07 09:39:39 -050014cxx = meson.get_compiler('cpp')
15
George Liubddcf852021-09-08 08:46:22 +080016conf_data = configuration_data()
17conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control')
18conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control')
19conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors')
20conf_data.set_quoted('CPU_NAME', 'cpu')
21conf_data.set_quoted('OCC_NAME', 'occ')
22conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1')
23conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ')
Patrick Williams601cea42025-02-01 08:36:51 -050024conf_data.set_quoted(
25 'CPU_SUBPATH',
26 '/xyz/openbmc_project/inventory/system/chassis/motherboard',
27)
28conf_data.set_quoted(
29 'OCC_CONTROL_PERSIST_PATH',
30 '/var/lib/openpower-occ-control',
31)
Dhruvaraj Subhashchandran1173b2b2024-06-01 11:12:13 -050032conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path'))
George Liubddcf852021-09-08 08:46:22 +080033
34conf_data.set('MAX_CPUS', get_option('max-cpus'))
35conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0)
36conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0)
Eddie James3f710bd2021-10-20 13:40:52 -050037conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor'))
George Liubddcf852021-09-08 08:46:22 +080038
Sheldon Bailey16a5adb2025-06-10 14:10:06 -050039conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/')
40conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/')
George Liubddcf852021-09-08 08:46:22 +080041
Chris Cain720a3842025-01-09 10:23:36 -060042conf_data.set('PHAL_SUPPORT', get_option('phal-support').allowed())
George Liubddcf852021-09-08 08:46:22 +080043
Eddie James88811ad2024-08-27 13:39:05 -050044if get_option('transport-implementation') == 'mctp-demux'
45 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1)
46elif get_option('transport-implementation') == 'af-mctp'
47 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1)
48endif
49
Rashmica Gupta52328cb2023-02-15 10:38:16 +110050if cxx.has_header('poll.h')
51 conf_data.set('PLDM_HAS_POLL', 1)
52endif
53
Patrick Williams601cea42025-02-01 08:36:51 -050054configure_file(output: 'config.h', configuration: conf_data)
George Liubddcf852021-09-08 08:46:22 +080055
Patrick Williams601cea42025-02-01 08:36:51 -050056install_data(
57 'occ-active.sh',
Chris Cain7bd6d142023-01-11 13:41:09 -060058 install_mode: 'rwxr-xr-x',
Patrick Williams601cea42025-02-01 08:36:51 -050059 install_dir: get_option('bindir'),
Chris Cain7bd6d142023-01-11 13:41:09 -060060)
61
62systemd = dependency('systemd')
Patrick Williams601cea42025-02-01 08:36:51 -050063systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
Chris Cain7bd6d142023-01-11 13:41:09 -060064subdir('service_files')
65
Patrick Williamse2a58512022-09-13 11:26:57 -050066sdbusplus_dep = dependency('sdbusplus')
Patrick Williamse2a58512022-09-13 11:26:57 -050067
George Liubddcf852021-09-08 08:46:22 +080068python_prog = find_program('python3', required: true)
George Liubddcf852021-09-08 08:46:22 +080069
70deps = []
71sources = []
Patrick Williams9bec8af2023-09-07 14:02:27 -050072
Patrick Williamsf6992a42024-02-28 11:12:24 -060073cereal_dep = dependency('cereal', required: false)
74has_cereal = cxx.has_header_symbol(
75 'cereal/cereal.hpp',
76 'cereal::specialize',
77 dependencies: cereal_dep,
Patrick Williams601cea42025-02-01 08:36:51 -050078 required: false,
79)
Patrick Williamsf6992a42024-02-28 11:12:24 -060080if not has_cereal
81 cereal_opts = import('cmake').subproject_options()
82 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
83 cereal_proj = import('cmake').subproject(
84 'cereal',
85 options: cereal_opts,
Patrick Williams601cea42025-02-01 08:36:51 -050086 required: false,
87 )
Patrick Williamsf6992a42024-02-28 11:12:24 -060088 assert(cereal_proj.found(), 'cereal is required')
89 cereal_dep = cereal_proj.dependency('cereal')
90endif
91
Patrick Williamsa9374912023-12-07 17:22:45 -060092nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams447c1832024-02-28 11:15:33 -060093phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
94phosphor_logging_dep = dependency('phosphor-logging')
95sdeventplus_dep = dependency('sdeventplus')
Sheldon Bailey16a5adb2025-06-10 14:10:06 -050096libpldm_dep = dependency('libpldm')
Patrick Williams9bec8af2023-09-07 14:02:27 -050097
Patrick Williams9bec8af2023-09-07 14:02:27 -050098deps += [
Patrick Williamsf6992a42024-02-28 11:12:24 -060099 cereal_dep,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500100 nlohmann_json_dep,
101 phosphor_dbus_interfaces_dep,
102 phosphor_logging_dep,
103 sdbusplus_dep,
104 sdeventplus_dep,
Sheldon Bailey16a5adb2025-06-10 14:10:06 -0500105 libpldm_dep,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500106]
Patrick Williamsd86651f2023-02-08 09:31:48 -0600107
Patrick Williams9bec8af2023-09-07 14:02:27 -0500108sources += [
109 'app.cpp',
110 'occ_pass_through.cpp',
111 'occ_manager.cpp',
112 'occ_status.cpp',
113 'occ_device.cpp',
114 'occ_errors.cpp',
115 'occ_ffdc.cpp',
116 'occ_presence.cpp',
117 'occ_command.cpp',
118 'occ_dbus.cpp',
119 'powercap.cpp',
Sheldon Bailey16a5adb2025-06-10 14:10:06 -0500120 'powermode.cpp',
121 'pldm.cpp',
Patrick Williams9bec8af2023-09-07 14:02:27 -0500122 'utils.cpp',
123]
124
Chris Cain720a3842025-01-09 10:23:36 -0600125if get_option('phal-support').allowed()
Patrick Williams601cea42025-02-01 08:36:51 -0500126 deps += [cxx.find_library('pdbg'), cxx.find_library('phal')]
Chris Cain720a3842025-01-09 10:23:36 -0600127endif
128
Patrick Williams9bec8af2023-09-07 14:02:27 -0500129yamldir = get_option('yamldir')
130if yamldir == ''
131 yamldir = meson.project_source_root() / 'example'
132endif
George Liubddcf852021-09-08 08:46:22 +0800133
Patrick Williams9bec8af2023-09-07 14:02:27 -0500134# Generate occ-sensor.hpp.
135occ_sensor_hpp = custom_target(
136 'occ-sensor.hpp',
Patrick Williams601cea42025-02-01 08:36:51 -0500137 command: [
Patrick Williams9bec8af2023-09-07 14:02:27 -0500138 python_prog,
139 meson.project_source_root() + '/sensor_gen.py',
Patrick Williams601cea42025-02-01 08:36:51 -0500140 '-i',
141 yamldir,
Patrick Williams9bec8af2023-09-07 14:02:27 -0500142 ],
Patrick Williams601cea42025-02-01 08:36:51 -0500143 output: 'occ-sensor.hpp',
144)
145sources += [occ_sensor_hpp]
George Liubddcf852021-09-08 08:46:22 +0800146
Patrick Williams601cea42025-02-01 08:36:51 -0500147executable(
148 'openpower-occ-control',
149 sources,
150 include_directories: '.',
151 implicit_include_directories: true,
152 dependencies: deps,
153 install: true,
154 install_dir: get_option('bindir'),
155)
George Liubddcf852021-09-08 08:46:22 +0800156
Patrick Williamseb888052025-01-30 17:47:34 -0500157if get_option('tests').allowed()
Patrick Williams601cea42025-02-01 08:36:51 -0500158 subdir('test')
George Liubddcf852021-09-08 08:46:22 +0800159endif