Skip to content

Commit 81fe208

Browse files
Martin Belangerigaw
authored andcommitted
python: Change python option from combo to feature
Signed-off-by: Martin Belanger <[email protected]>
1 parent 8c507db commit 81fe208

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ jobs:
244244
--buildtype=release
245245
--wrap-mode=nofallback
246246
--cross-file=.github/cross/ubuntu-armhf.txt
247-
-Dpython=false
247+
-Dpython=disabled
248248
meson-version: 0.61.2
249249
- uses: BSFishy/[email protected]
250250
name: test
@@ -287,7 +287,7 @@ jobs:
287287
--buildtype=release
288288
--wrap-mode=nofallback
289289
--cross-file=.github/cross/ubuntu-ppc64le.txt
290-
-Dpython=false
290+
-Dpython=disabled
291291
meson-version: 0.61.2
292292
- uses: BSFishy/[email protected]
293293
name: test
@@ -330,7 +330,7 @@ jobs:
330330
--buildtype=release
331331
--wrap-mode=nofallback
332332
--cross-file=.github/cross/ubuntu-s390x.txt
333-
-Dpython=false
333+
-Dpython=disabled
334334
meson-version: 0.61.2
335335
- uses: BSFishy/[email protected]
336336
name: test
@@ -376,7 +376,7 @@ jobs:
376376
export PATH=$(pwd)/build-tools/muon/build:$PATH
377377
378378
muon setup \
379-
-Dpython=false \
379+
-Dpython=disabled \
380380
-Dopenssl=disabled \
381381
-Dlibdbus=disabled \
382382
-Djson-c=disabled \

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ Using meson is similar to projects that use a `configure` script before running
8585
To `configure` the project:
8686

8787
```
88-
meson .build
88+
meson setup .build
8989
```
9090

9191
Which will default to build a shared library. To configure for static libraries call
9292

9393
```
94-
meson .build --default-library=static
94+
meson setup .build --default-library=static
9595
```
9696

9797
One nice feature of meson is that it doesn't mix build artifacts
@@ -160,30 +160,30 @@ rm -rf .build
160160

161161
A few build options can be specified on the command line when invoking meson.
162162

163-
| Option | Values [default] | Description |
164-
| ------ | ------------------- | ------------------------------------------------------------ |
165-
| man | true, [false] | Instruct meson to configure the project to build the `libnvme` documentation. <br />Example: `meson .build -Dman=true` |
166-
| python | [auto], true, false | Whether to build the Python bindings. When set to `auto`, the default, meson will check for the presence of the tools and libraries (e.g. `swig`) required to build the Python bindings. If found, meson will configure the project to build the Python bindings. If a tool or library is missing, then the Python bindings won't be built. Setting this to `true`, forces the Python bindings to be built. When set to `false`, meson will configure the project to not build the Python bindings.<br />Example: `meson .build -Dpython=false` |
163+
| Option | Values [default] | Description |
164+
| ------ | ------------------------- | ------------------------------------------------------------ |
165+
| man | true, [false] | Instruct meson to configure the project to build the `libnvme` documentation. <br />Example: `meson .build -Dman=true` |
166+
| python | [auto], enabled, disabled | Whether to build the Python bindings. When set to `auto`, the default, meson will check for the presence of the tools and libraries (e.g. `swig`) required to build the Python bindings. If found, meson will configure the project to build the Python bindings. If a tool or library is missing, then the Python bindings won't be built. Setting this to `enabled`, forces the Python bindings to be built. When set to `disabled`, meson will configure the project to not build the Python bindings.<br />Example: `meson setup .build -Dpython=disabled` |
167167

168168
### Changing the build options from the command-line (i.e. w/o modifying any files)
169169

170170
To configure a build for debugging purposes (i.e. optimization turned
171171
off and debug symbols enabled):
172172

173173
```bash
174-
meson .build -Dbuildtype=debug
174+
meson setup .build --buildtype=debug
175175
```
176176

177177
To enable address sanitizer (advanced debugging of memory issues):
178178

179179
```bash
180-
meson .build -Db_sanitize=address
180+
meson setup .build -Db_sanitize=address
181181
```
182182

183183
This option adds `-fsanitize=address` to the gcc options. Note that when using the sanitize feature, the library `libasan.so` must be available and must be the very first library loaded when running an executable. Ensuring that `libasan.so` gets loaded first can be achieved with the `LD_PRELOAD` environment variable as follows:
184184

185185
```
186-
meson .build -Db_sanitize=address && LD_PRELOAD=/lib64/libasan.so.6 ninja -C .build test
186+
meson setup .build -Db_sanitize=address && LD_PRELOAD=/lib64/libasan.so.6 ninja -C .build test
187187
```
188188

189189
To list configuration options that are available and possible values:

libnvme/meson.build

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
# Authors: Martin Belanger <[email protected]>
77
#
88
want_python = get_option('python')
9-
if want_python != 'false'
10-
python3 = import('python').find_installation('python3')
11-
py3_dep = python3.dependency(required: want_python == 'true')
12-
swig = find_program('swig', required: want_python == 'true')
13-
header_found = cc.has_header('Python.h', dependencies: py3_dep, required: want_python == 'true')
14-
have_python_support = py3_dep.found() and swig.found() and header_found
9+
if want_python.disabled()
10+
build_python_bindings = false
1511
else
16-
have_python_support = false
12+
python3 = import('python').find_installation('python3')
13+
py3_dep = python3.dependency(required: want_python)
14+
swig = find_program('swig', required: want_python)
15+
header_found = cc.has_header('Python.h', dependencies: py3_dep, required: want_python)
16+
build_python_bindings = py3_dep.found() and swig.found() and header_found
1717
endif
1818

19-
if have_python_support
19+
if build_python_bindings
2020
pymod_swig = custom_target(
2121
'nvme.py',
2222
input: ['nvme.i'],

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ option('rstdir', type : 'string', value : '', description : 'directory for ReST
77
option('docs', type : 'combo', choices : ['false', 'html', 'man', 'rst', 'all'], description : 'install documentation')
88
option('docs-build', type : 'boolean', value : false, description : 'build documentation')
99

10-
option('python', type : 'combo', choices : ['auto', 'true', 'false'], description : 'Generate libnvme python bindings')
10+
option('python', type : 'feature', value: 'auto', description : 'Generate libnvme python bindings')
1111
option('openssl', type : 'feature', value: 'auto', description : 'OpenSSL support')
1212
option('libdbus', type : 'feature', value: 'disabled', description : 'libdbus support')
1313
option('json-c', type : 'feature', value: 'auto', description : 'JSON support')

0 commit comments

Comments
 (0)