mesonbuild / mesonbuild/meson

project specific options from native file are ignored

Open
#7,699 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.6k
Forks
1.9k
Avg merge
2d 6h
Merged PRs (30d)
33

Description

**Describe the bug**
according to the [meson documentation](https://mesonbuild.com/Machine-files.html#project-specific-options), native files may specify project-specific options. however, it appears that meson ignores them.

**To Reproduce**
**meson.build**:
```
project('tutorial', 'cpp')
if get_option('opt')
library('xx', 'xx.cpp')
else
library('yy', 'yy.cpp')
endif
```
**meson_options.txt**:
```
option('opt', type: 'boolean')
```
**native.ini**:
```
[project options]
opt = false
```
source files **xx.cpp** and **yy.cpp** don't exist, but it's not important to have them.

running the following command:
```
meson --native-file=native.ini build .
```
results in output:
```
meson.build:3:4: ERROR: File xx.cpp does not exist.
```
however, explicitly specifying option on command line:
```
meson --native-file=native.ini -Dopt=false build .
```
results in correct output:
```
meson.build:5:4: ERROR: File yy.cpp does not exist.
```
same result without native file:
```
meson -Dopt=false build .
```

**Expected behavior**
I'd expect `opt` option specified in native file to be respected by meson, thus **yy** library should be selected for the build.

**system parameters**
* Is this a [cross build](https://mesonbuild.com/Cross-compilation.html) or just a plain native build (for the same computer)?
nope, plain build
* what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
Windows 10
* what Python version are you using e.g. 3.8.0
Python 3.8.1
* what `meson --version`
0.55.1
* what `ninja --version` if it's a Ninja build
1.8.2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with meson.build, meson_options.txt, and native.ini using the commands shown. Trace how the native file's [project options] section is read and compare it with command-line -Dopt=false handling; done means the native-file value selects the yy library path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.