Skip to content

Commit

Permalink
modules/rust: only use include and define args from global/project args
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbaker authored and nirbheek committed Oct 17, 2023
1 parent 658fe72 commit 5fcf347
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mesonbuild/modules/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations
import itertools
import os
import typing as T

from mesonbuild.interpreterbase.decorators import FeatureNew

from . import ExtensionModule, ModuleReturnValue, ModuleInfo
Expand Down Expand Up @@ -238,11 +240,13 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu
elif isinstance(s, CustomTarget):
depends.append(s)

clang_args.extend(state.global_args.get('c', []))
clang_args.extend(state.project_args.get('c', []))
# We only want include directories and defines, other things may not be valid
cargs = state.get_option('args', state.subproject, lang='c')
assert isinstance(cargs, list), 'for mypy'
clang_args.extend(cargs)
for a in itertools.chain(state.global_args.get('c', []), state.project_args.get('c', []), cargs):
if a.startswith(('-I', '/I', '-D', '/D', '-U', '/U')):
clang_args.append(a)

if self._bindgen_bin is None:
self._bindgen_bin = state.find_program('bindgen')
Expand Down

0 comments on commit 5fcf347

Please sign in to comment.