@@ -34,6 +34,7 @@ fs = import('fs')
3434
3535cc = meson .get_compiler(' c' )
3636cxx_available = add_languages (' cpp' , required : false , native : false )
37+ host_system = host_machine .system()
3738
3839################################################################################
3940# Determine which features we need to build: The nvme executable, the libnvme
@@ -51,10 +52,15 @@ cxx_available = add_languages('cpp', required: false, native: false)
5152# dependencies are present. Also, -Dpython=enabled forces -Dlibnvme=enabled.
5253want_nvme = get_option (' nvme' ).disabled() == false
5354want_libnvme = get_option (' libnvme' ).disabled() == false
54- want_fabrics = get_option (' fabrics' ).disabled() == false
55+ want_fabrics = get_option (' fabrics' ).disabled() == false and host_system != ' windows'
56+ want_json_c = get_option (' json-c' ).disabled() == false and host_system != ' windows'
57+ want_tests = get_option (' tests' ) and host_system != ' windows'
58+ want_examples = get_option (' examples' ) and host_system != ' windows'
5559want_docs = get_option (' docs' )
5660want_docs_build = get_option (' docs-build' )
5761
62+ is_static = get_option (' default_library' ) == ' static' and host_system != ' windows'
63+
5864feature_python = get_option (' python' )
5965if not want_fabrics or feature_python.disabled()
6066 py3_dep = dependency ('' , required : false ) # Needed for muon
@@ -131,8 +137,12 @@ conf.set('RUNDIR', '"@0@"'.format(rundir))
131137
132138conf.set(' CONFIG_FABRICS' , want_fabrics, description : ' Is fabrics enabled' )
133139
140+ if host_system == ' windows'
141+ kernel32_dep = cc.find_library (' kernel32' , required : true )
142+ endif
143+
134144# Check for libjson-c availability
135- if get_option ( ' json-c ' ).disabled()
145+ if not want_json_c
136146 json_c_dep = dependency ('' , required : false )
137147else
138148 json_c_dep = dependency (
@@ -363,7 +373,6 @@ conf.set10(
363373 description : ' Is linux/mctp.h include-able?'
364374)
365375
366- is_static = get_option (' default_library' ) == ' static'
367376have_netdb = false
368377if not is_static
369378 have_netdb = cc.links(
@@ -473,45 +482,67 @@ if want_nvme
473482 subdir (' plugins' ) # declares: plugin_sources
474483 subdir (' util' ) # declares: util_sources
475484
476- sources = [
477- ' libnvme-wrap.c' ,
478- ' logging.c' ,
479- ' nvme-cmds.c' ,
480- ' nvme-models.c' ,
481- ' nvme-print-binary.c' ,
482- ' nvme-print-stdout.c' ,
483- ' nvme-print.c' ,
484- ' nvme-rpmb.c' ,
485- ' nvme.c' ,
486- ' plugin.c' ,
487- ]
485+ sources = []
486+ if host_system == ' windows'
487+ sources += [
488+ ' nvme-dummy.c' , # Dummy source file for Windows port bring up.
489+ ]
490+ else
491+ sources += [
492+ ' libnvme-wrap.c' ,
493+ ' logging.c' ,
494+ ' nvme-cmds.c' ,
495+ ' nvme-models.c' ,
496+ ' nvme-print-binary.c' ,
497+ ' nvme-print-stdout.c' ,
498+ ' nvme-print.c' ,
499+ ' nvme-rpmb.c' ,
500+ ' nvme.c' ,
501+ ' plugin.c' ,
502+ ]
503+
504+ if json_c_dep.found()
505+ sources += [
506+ ' nvme-print-json.c' ,
507+ ]
508+ endif
509+ endif
510+
488511 if want_fabrics
489512 sources += ' fabrics.c'
490513 endif
491514
492- if json_c_dep.found()
493- sources += [
494- ' nvme-print-json.c' ,
495- ]
496- endif
497515 sources += plugin_sources
498516 sources += util_sources
499517
518+ link_args_list = []
519+ link_deps = [
520+ config_dep,
521+ ccan_dep,
522+ libnvme_dep,
523+ json_c_dep,
524+ ]
525+
526+ if host_system == ' windows'
527+ link_deps += [
528+ kernel32_dep,
529+ ]
530+ else
531+ link_args_list = [' -ldl' ]
532+ endif
533+
500534 executable (
501535 ' nvme' ,
502536 sources,
503- dependencies : [
504- config_dep,
505- ccan_dep,
506- libnvme_dep,
507- json_c_dep,
508- ],
509- link_args : ' -ldl' ,
537+ dependencies : link_deps,
538+ link_args : link_args_list,
510539 install : true ,
511540 install_dir : sbindir,
512541 )
513542
514- subdir (' unit' )
543+ if host_system != ' windows'
544+ subdir (' unit' )
545+ endif
515546 if get_option (' nvme-tests' )
516547 subdir (' tests' )
517548 endif
@@ -645,6 +676,11 @@ dep_dict = {
645676 ' python3' : py3_dep.found(),
646677 ' liburing' : liburing_dep.found(),
647678}
679+ if host_system == ' windows'
680+ dep_dict += {
681+ ' kernel32' : kernel32_dep.found(),
682+ }
683+ endif
648684summary (dep_dict, section : ' Dependencies' , bool_yn : true )
649685
650686wanted_dict = {
@@ -661,4 +697,3 @@ conf_dict = {
661697 ' pdc enabled' : get_option (' pdc-enabled' ),
662698}
663699summary (conf_dict, section : ' Configuration' , bool_yn : true )
664-
0 commit comments