Skip to content
Snippets Groups Projects
meson.build 4.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • project('EMPER', 'c', 'cpp',
    		version: '0.0.1-alpha1-SNAPSHOT',
    		default_options : [
    		  'warning_level=3',
    		  'c_std=gnu11',
    
    		  'cpp_std=c++2a',
    
    		  'b_ndebug=if-release',
    		  'werror=true',
    		])
    
    thread_dep = dependency('threads')
    
    
    liburing_version = '2.0'
    uring_dep = dependency('liburing', version: liburing_version, required: false)
    
    if not uring_dep.found()
    
    	message('liburing ' + liburing_version + ' not found in system, using liburing subproject')
    
    	liburing_sp = subproject('liburing')
    	uring_dep = liburing_sp.get_variable('uring').as_system()
    endif
    
    emper_dependencies = [thread_dep, uring_dep]
    
    boost_thread_dep = dependency('boost', modules : ['thread'], required: false)
    
    
    tools_dir = join_paths(meson.source_root(), 'tools')
    
    
    		   command: join_paths(tools_dir, 'check-iwyu'))
    
    conf_data = configuration_data()
    
    option_urcu = get_option('userspace_rcu')
    
    conf_data.set('EMPER_LIBURCU', option_urcu)
    if option_urcu
    	liburcu_dep = dependency('liburcu')
    	emper_dependencies += [liburcu_dep]
    endif
    
    
    cpp_compiler = meson.get_compiler('cpp')
    if cpp_compiler.has_header('compare')
      conf_data.set('EMPER_HAS_COMPARE_H', true)
    endif
    
    
    conf_data.set('EMPER_WORKER_SLEEP', get_option('worker_sleep'))
    
    conf_data.set('EMPER_WORKER_WAKEUP_STRATEGY', get_option('worker_wakeup_strategy'))
    
    conf_data.set('EMPER_LOCKED_WS_QUEUE', get_option('locked_ws_queue'))
    conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue'))
    
    conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue'))
    
    conf_data.set('EMPER_CHECK_ANYWHERE_QUEUE_WHILE_STEALING', get_option('check_anywhere_queue_while_stealing'))
    
    conf_data.set('EMPER_STATS', get_option('stats'))
    
    conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue'))
    
    conf_data.set('EMPER_BLOCKED_CONTEXT_SET', get_option('blocked_context_set'))
    
    conf_data.set('EMPER_SET_AFFINITY_ON_BLOCK', get_option('set_affinity_on_block'))
    
    conf_data.set('EMPER_IO_COMPLETER_SCHED_PARAM', get_option('io_completer_sched_param'))
    
    semaphore_impl = get_option('wakeup_semaphore_implementation')
    conf_data.set('EMPER_' + semaphore_impl.to_upper() + '_WAKEUP_SEMAPHORE', true)
    
    
    sleep_stratey = get_option('worker_sleep_strategy')
    if sleep_stratey == 'semaphore'
    	conf_data.set('EMPER_SEMAPHORE_SLEEP_STRATEGY', true)
    elif sleep_stratey == 'pipe'
    	conf_data.set('EMPER_PIPE_SLEEP_STRATEGY', true)
    else
    	error('Unsupported sleep strategy')
    endif
    
    
    locked_unbounded_queue_impl = get_option('locked_unbounded_queue_implementation')
    if locked_unbounded_queue_impl == 'boost_shared_mutex'
    
    	if not boost_thread_dep.found()
    		error('Boost thread module not found, but locked_unbounded_queue_implementation set to boost_shared_mutex')
    	endif
    
    	emper_dependencies += [boost_thread_dep]
    endif
    conf_data.set('EMPER_' + locked_unbounded_queue_impl.to_upper() + '_LOCKED_UNBOUNDED_QUEUE', true)
    
    
    default_scheduling_strategy = get_option('default_scheduling_strategy')
    conf_data.set('EMPER_DEFAULT_SCHEDULING_STRATEGY_' + default_scheduling_strategy.to_upper(), true)
    
    
    log_level = get_option('log_level')
    if log_level == 'automatic'
    	# output only error messages in release builds
    
    	log_level = get_option('debug') ? 'ALL' : 'Info'
    
    endif
    conf_data.set('EMPER_LOG_LEVEL', log_level)
    
    conf_data.set('EMPER_LOG_TIMESTAMP', get_option('log_timestamp'))
    
    option_io =  get_option('io')
    if option_io
    	conf_data.set('EMPER_IO', true)
    endif
    
    io_bool_options = [
    
    Florian Fischer's avatar
    Florian Fischer committed
    	'stealing',
    
    ]
    
    io_raw_options = [
    	'worker_uring_entries',
    
    ]
    
    foreach option : io_bool_options
    	value = get_option('io_' + option)
    	if value == true and not option_io
    		error('io_' + option + ' defined without io')
    	endif
    	conf_data.set('EMPER_IO_' + option.to_upper(), value)
    endforeach
    
    foreach option : io_raw_options
    	conf_data.set('EMPER_IO_' + option.to_upper(), get_option('io_' + option))
    endforeach
    
    
    io_completer_behavior = get_option('io_completer_behavior')
    if io_completer_behavior == 'maybe_wakeup'
    	if get_option('worker_sleep')
    		io_completer_behavior = 'wakeup'
    	else
    		io_completer_behavior = 'none'
    	endif
    endif
    
    conf_data.set('EMPER_IO_COMPLETER_BEHAVIOR', io_completer_behavior)
    
    
    # check io meson options consistency
    if get_option('io_single_uring')
    	if not (io_completer_behavior == 'schedule')
    		error('Using a single io_uring need a "scheduling" completer')
    	endif
    
    	if get_option('io_uring_shared_wq')
    		error('Sharing io_uring ressources is useless when using a single io_uring')
    	endif
    endif
    
    
    subdir('emper')
    subdir('tests')
    subdir('apps')
    subdir('eval')
    subdir('doc')