Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
185 lines (157 loc) · 6.6 KB
/
Copy pathmeson.build
File metadata and controls
185 lines (157 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project('nixl', 'CPP', version: '0.1.1',
default_options: ['buildtype=debug',
'werror=true',
'cpp_std=c++17',
'prefix=/opt/nvidia/nvda_nixl'],
meson_version: '>= 0.64.0'
)
# set up some global vars for compiler, platform, configuration, etc.
cpp = meson.get_compiler('cpp')
dl_dep = cpp.find_library('dl', required: true)
thread_dep = dependency('threads')
# Forced to ignore this error due to:
# https://github.com/abseil/abseil-cpp/issues/1779
# This must be global since subprojects cannot be assigned with arguments.
# Adding this configuration only for release build to consider it while developing.
if get_option('buildtype') == 'release'
abseil_flags = cpp.get_supported_arguments('-Wno-error=maybe-uninitialized', '-Wno-maybe-uninitialized')
add_global_arguments(abseil_flags, language: 'cpp')
endif
abseil_proj = subproject('abseil-cpp')
cuda_inc_path = get_option('cudapath_inc')
cuda_lib_path = get_option('cudapath_lib')
cuda_stub_path = get_option('cudapath_stub')
if cuda_lib_path == ''
cuda_dep = dependency('cuda', required : false, modules : [ 'cudart', 'cuda' ])
else
message('cuda lib path ', cuda_lib_path)
if cuda_stub_path == ''
cuda_stub_path = cuda_lib_path + '/stubs'
endif
cuda_dep = declare_dependency(
link_args : ['-L' + cuda_lib_path, '-L' + cuda_stub_path, '-lcuda', '-lcudart'],
include_directories : include_directories(cuda_inc_path))
endif
prefix_path = get_option('prefix')
prefix_inc = prefix_path + '/include'
ucx_path = get_option('ucx_path')
if ucx_path != ''
ucx_lib_path = ucx_path + '/lib'
ucx_inc_path = ucx_path + '/include'
ucx_dep = declare_dependency(
link_args : ['-L' + ucx_lib_path, '-lucp', '-lucs', '-luct'],
include_directories : include_directories(ucx_inc_path))
else
ucx_dep = dependency('ucx', modules: ['ucx::ucs', 'ucx::ucp', 'ucx::uct'])
endif
if get_option('disable_gds_backend')
add_project_arguments('-DDISABLE_GDS_BACKEND', language: 'cpp')
endif
# Logging
# Determine the actual log level based on user choice or build type
log_level_opt = get_option('log_level')
buildtype = get_option('buildtype')
actual_log_level = log_level_opt
if actual_log_level == 'auto'
if buildtype == 'debug'
actual_log_level = 'trace'
else # release, debugoptimized, or plain
actual_log_level = 'info'
endif
endif
# Add define for the determined log level
add_project_arguments('-DLOG_LEVEL_' + actual_log_level.to_upper() , language: 'cpp')
# Configure Abseil log stripping and NDEBUG for release builds
if get_option('buildtype') == 'release'
# Map our log levels to Abseil severity integers
absl_log_level_map = {
'trace': 0, # Treat trace/debug as below INFO for stripping
'debug': 0,
'info': 0, # kInfo
'warning': 1, # kWarning
'error': 2, # kError
'fatal': 3, # kFatal
}
absl_min_log_level = absl_log_level_map.get(actual_log_level, 0) # Default to info if level unknown
# Required by Abseil to strip logs at compile time based on the determined level
add_project_arguments('-DABSL_MIN_LOG_LEVEL=@0@'.format(absl_min_log_level), language : 'cpp')
# Required by Abseil to strip DCHECK assertions at compile time
add_project_arguments('-DNDEBUG', language: 'cpp')
endif
static_plugins = []
# Check for static plugins, then set compiler flags to enable
if get_option('static_plugins') != ''
static_plugins = get_option('static_plugins').split(',')
foreach p : static_plugins
flagname = '-DSTATIC_PLUGIN_' + p
add_project_arguments(flagname, language: 'cpp')
endforeach
endif
# Define a specific plugin directory
plugin_install_dir = join_paths(get_option('libdir'), 'plugins')
plugin_build_dir = meson.current_build_dir()
# Add to global args so plugin managers can find it
if get_option('buildtype') == 'debug'
add_project_arguments('-DNIXL_USE_PLUGIN_FILE="' + plugin_build_dir + '/pluginlist"', language: 'cpp')
endif
nixl_inc_dirs = include_directories('src/api/cpp', 'src/infra', 'src/core')
utils_inc_dirs = include_directories('src/utils')
subdir('src')
if get_option('buildtype') != 'release'
subdir('test')
subdir('examples')
endif
if get_option('install_headers')
install_headers('src/api/cpp/nixl.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_types.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_params.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_descriptors.h', install_dir: prefix_inc)
install_headers('src/utils/serdes/serdes.h', install_dir: prefix_inc + '/utils/serdes')
install_headers('src/utils/common/nixl_time.h', install_dir: prefix_inc + '/utils/common')
install_headers('src/api/cpp/backend/backend_engine.h', install_dir: prefix_inc + '/backend')
install_headers('src/api/cpp/backend/backend_aux.h', install_dir: prefix_inc + '/backend')
install_headers('src/core/transfer_request.h', install_dir: prefix_inc)
install_headers('src/core/agent_data.h', install_dir: prefix_inc)
install_headers('src/infra/mem_section.h', install_dir: prefix_inc)
endif
# Doxygen documentation
if get_option('build_docs')
doxygen = find_program('doxygen', required: false)
if not doxygen.found()
error('Doxygen not found, but documentation requested')
endif
docs_dir = join_paths(meson.current_build_dir(), 'docs')
doxyfile = join_paths(meson.current_source_dir(), 'Doxyfile')
doxygen_output_dir = join_paths(docs_dir, 'doxygen')
# Create the output directory
run_command('mkdir', '-p', doxygen_output_dir, check: true)
# Configure Doxyfile with the correct output directory
configure_file(
input: doxyfile,
output: 'Doxyfile.configured',
configuration: {
'DOXYGEN_OUTPUT_DIR': doxygen_output_dir,
}
)
custom_target('docs',
output: 'docs',
command: [doxygen, join_paths(meson.current_build_dir(), 'Doxyfile.configured')],
install: true,
install_dir: join_paths(prefix_path),
build_by_default: true
)
endif