Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,36 @@ jobs:
- name: build
run: |
scripts/build.sh distro

build-windows:
name: build windows
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup MSYS2
uses: msys2/setup-msys2@cafece8e6baf9247cf9b1bf95097b0b983cc558d # v2.31.0
with:
msystem: MINGW64
update: true
install: >
git
mingw-w64-x86_64-gcc
mingw-w64-x86_64-meson
mingw-w64-x86_64-ninja
mingw-w64-x86_64-pkg-config
mingw-w64-x86_64-json-c
- name: Configure (Meson)
run: |
meson setup .build-ci \
--prefix=/mingw64 \
-Dversion-tag=master \
-Ddefault_library=static
- name: Build
run: |
meson compile -C .build-ci
- name: Run tests (optional)
run: |
meson test -C .build-ci || true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ tests/*.pyc

# Ignore PyPI build artifacts
dist/

.vscode/
1 change: 1 addition & 0 deletions libnvme/examples/telemetry-listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <time.h>
#include <unistd.h>

#include <sys/select.h>
#include <sys/stat.h>

#include <ccan/endian/endian.h>
Expand Down
4 changes: 2 additions & 2 deletions libnvme/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ if want_libnvme
subdir('tools/generator') # generate code needed by src below
subdir('src') # declares: libnvme_dep
subdir('libnvme')
if get_option('tests')
if want_tests
subdir('test')
endif
if get_option('examples')
if want_examples
subdir('examples')
endif

Expand Down
59 changes: 37 additions & 22 deletions libnvme/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@
#
# Authors: Martin Belanger <[email protected]>
#
sources = [
'nvme/accessors.c',
'nvme/base64.c',
'nvme/cmds.c',
'nvme/crc32.c',
'nvme/filters.c',
'nvme/ioctl.c',
'nvme/lib.c',
'nvme/linux.c',
'nvme/log.c',
'nvme/mi-mctp.c',
'nvme/mi.c',
'nvme/sysfs.c',
'nvme/tree.c',
'nvme/util.c',
]
sources = []
if host_system == 'windows'
sources += []
else
sources += [
'nvme/accessors.c',
'nvme/base64.c',
'nvme/cmds.c',
'nvme/crc32.c',
'nvme/filters.c',
'nvme/ioctl.c',
'nvme/lib.c',
'nvme/linux.c',
'nvme/log.c',
'nvme/mi-mctp.c',
'nvme/mi.c',
'nvme/sysfs.c',
'nvme/tree.c',
'nvme/util.c',
]
endif
Comment on lines +8 to +28
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, this leaves sources empty (want_fabrics is disabled on Windows, liburing/json sources are also gated away), but the file later unconditionally creates library('nvme', sources, ...). Meson typically errors on a library target with no sources; add at least a stub source for Windows or skip building libnvme on Windows.

Suggested change
sources = []
if host_system == 'windows'
sources += []
else
sources += [
'nvme/accessors.c',
'nvme/base64.c',
'nvme/cmds.c',
'nvme/crc32.c',
'nvme/filters.c',
'nvme/ioctl.c',
'nvme/lib.c',
'nvme/linux.c',
'nvme/log.c',
'nvme/mi-mctp.c',
'nvme/mi.c',
'nvme/sysfs.c',
'nvme/tree.c',
'nvme/util.c',
]
endif
sources = []
if host_system == 'windows'
# On Windows, ensure we have at least one source file to avoid
# Meson errors when creating the nvme library with an empty source list.
sources += [
'nvme/windows-stub.c',
]
else
sources += [
'nvme/accessors.c',
'nvme/base64.c',
'nvme/cmds.c',
'nvme/crc32.c',
'nvme/filters.c',
'nvme/ioctl.c',
'nvme/lib.c',
'nvme/linux.c',
'nvme/log.c',
'nvme/mi-mctp.c',
'nvme/mi.c',
'nvme/sysfs.c',
'nvme/tree.c',
'nvme/util.c',
]
endif

Copilot uses AI. Check for mistakes.
headers = [
'nvme/accessors.h',
'nvme/cmds.h',
Expand Down Expand Up @@ -50,21 +55,31 @@ if liburing_dep.found()
sources += 'nvme/uring.c'
endif

if json_c_dep.found()
sources += 'nvme/json.c'
else
sources += 'nvme/no-json.c'
if host_system != 'windows'
if json_c_dep.found()
sources += 'nvme/json.c'
else
sources += 'nvme/no-json.c'
endif
endif

deps = [
config_dep,
ccan_dep,
json_c_dep,
keyutils_dep,
libdbus_dep,
liburing_dep,
openssl_dep,
]
if host_system == 'windows'
deps += [
kernel32_dep
]
else
deps += [
libdbus_dep,
liburing_dep,
]
endif

nvme_ld = meson.current_source_dir() / 'libnvme.ld'
nvmf_ld = meson.current_source_dir() / 'libnvmf.ld'
Expand Down
93 changes: 64 additions & 29 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ fs = import('fs')

cc = meson.get_compiler('c')
cxx_available = add_languages('cpp', required: false, native: false)
host_system = host_machine.system()

################################################################################
# Determine which features we need to build: The nvme executable, the libnvme
Expand All @@ -51,10 +52,15 @@ cxx_available = add_languages('cpp', required: false, native: false)
# dependencies are present. Also, -Dpython=enabled forces -Dlibnvme=enabled.
want_nvme = get_option('nvme').disabled() == false
want_libnvme = get_option('libnvme').disabled() == false
want_fabrics = get_option('fabrics').disabled() == false
want_fabrics = get_option('fabrics').disabled() == false and host_system != 'windows'
want_json_c = get_option('json-c').disabled() == false and host_system != 'windows'
want_tests = get_option('tests') and host_system != 'windows'
Comment on lines 53 to +57
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows builds currently still enable want_libnvme by default, but the libnvme/src/meson.build change leaves the libnvme sources list empty on Windows. Unless a Windows implementation/stub is added, consider disabling want_libnvme on Windows (similar to want_fabrics/tests/examples) to avoid Meson failing when creating the libnvme library target.

Copilot uses AI. Check for mistakes.
want_examples = get_option('examples') and host_system != 'windows'
want_docs = get_option('docs')
want_docs_build = get_option('docs-build')

is_static = get_option('default_library') == 'static' and host_system != 'windows'

feature_python = get_option('python')
if not want_fabrics or feature_python.disabled()
py3_dep = dependency('', required: false) # Needed for muon
Expand Down Expand Up @@ -131,8 +137,12 @@ conf.set('RUNDIR', '"@0@"'.format(rundir))

conf.set('CONFIG_FABRICS', want_fabrics, description: 'Is fabrics enabled')

if host_system == 'windows'
kernel32_dep = cc.find_library('kernel32', required: true)
endif

# Check for libjson-c availability
if get_option('json-c').disabled()
if not want_json_c
json_c_dep = dependency('', required: false)
else
json_c_dep = dependency(
Expand Down Expand Up @@ -363,7 +373,6 @@ conf.set10(
description: 'Is linux/mctp.h include-able?'
)

is_static = get_option('default_library') == 'static'
have_netdb = false
if not is_static
have_netdb = cc.links(
Expand Down Expand Up @@ -473,45 +482,67 @@ if want_nvme
subdir('plugins') # declares: plugin_sources
subdir('util') # declares: util_sources

sources = [
'libnvme-wrap.c',
'logging.c',
'nvme-cmds.c',
'nvme-models.c',
'nvme-print-binary.c',
'nvme-print-stdout.c',
'nvme-print.c',
'nvme-rpmb.c',
'nvme.c',
'plugin.c',
]
sources = []
if host_system == 'windows'
sources += [
'nvme-dummy.c', # Dummy source file for Windows port bring up.
]
else
sources += [
'libnvme-wrap.c',
'logging.c',
'nvme-cmds.c',
'nvme-models.c',
'nvme-print-binary.c',
'nvme-print-stdout.c',
'nvme-print.c',
'nvme-rpmb.c',
'nvme.c',
'plugin.c',
]

if json_c_dep.found()
sources += [
'nvme-print-json.c',
]
endif
endif

if want_fabrics
sources += 'fabrics.c'
endif

if json_c_dep.found()
sources += [
'nvme-print-json.c',
]
endif
sources += plugin_sources
sources += util_sources

link_args_list = []
link_deps = [
config_dep,
ccan_dep,
libnvme_dep,
json_c_dep,
]

if host_system == 'windows'
link_deps += [
kernel32_dep,
]
else
link_args_list = ['-ldl']
endif

executable(
'nvme',
sources,
dependencies: [
config_dep,
ccan_dep,
libnvme_dep,
json_c_dep,
],
link_args: '-ldl',
dependencies: link_deps,
link_args: link_args_list,
install: true,
install_dir: sbindir,
)

subdir('unit')
if host_system != 'windows'
subdir('unit')
endif
if get_option('nvme-tests')
subdir('tests')
endif
Expand Down Expand Up @@ -645,6 +676,11 @@ dep_dict = {
'python3': py3_dep.found(),
'liburing': liburing_dep.found(),
}
if host_system == 'windows'
dep_dict += {
'kernel32': kernel32_dep.found(),
}
endif
summary(dep_dict, section: 'Dependencies', bool_yn: true)

wanted_dict = {
Expand All @@ -661,4 +697,3 @@ conf_dict = {
'pdc enabled': get_option('pdc-enabled'),
}
summary(conf_dict, section: 'Configuration', bool_yn: true)

9 changes: 9 additions & 0 deletions nvme-dummy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include <stdio.h>

int main(int argc, char **argv)
{
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argc and argv are unused here; if the build enables unused-parameter warnings (or treats warnings as errors in some environments), this can fail. Consider explicitly marking them unused (e.g., casting to void) or omitting the parameters if your style allows.

Suggested change
{
{
(void)argc;
(void)argv;

Copilot uses AI. Check for mistakes.
printf("This is a dummy executable for windows port bring up.\n");
return 0;
}
6 changes: 5 additions & 1 deletion plugins/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ all_plugins = {
}

# Get the list of plugins to build
selected_plugins = get_option('plugins')
if host_system != 'windows'
selected_plugins = get_option('plugins')
else
selected_plugins = []
endif

# Build the plugin_sources list from simple plugins
plugin_sources = []
Expand Down
32 changes: 19 additions & 13 deletions util/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later

util_sources = [
'util/argconfig.c',
'util/base64.c',
'util/crc32.c',
'util/mem.c',
'util/sighdl.c',
'util/suffix.c',
'util/types.c',
'util/utils.c',
'util/table.c'
]
util_sources = []

if json_c_dep.found()
if host_system == 'windows'
util_sources += []
else
util_sources += [
'util/json.c',
'util/argconfig.c',
'util/base64.c',
'util/crc32.c',
'util/mem.c',
'util/sighdl.c',
'util/suffix.c',
'util/types.c',
'util/utils.c',
'util/table.c'
]

if json_c_dep.found()
util_sources += [
'util/json.c',
]
endif
endif
Loading