Skip to content

Commit

Permalink
rust: Add --extern proc_macro in `rust.proc_macro() not in cargo tr…
Browse files Browse the repository at this point in the history
…anslation

Cargo does this by default, so it's reasonable that we do the same.

Fixes: mesonbuild#12758
  • Loading branch information
dcbaker committed Jan 30, 2024
1 parent 708a108 commit 55d30b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions mesonbuild/cargo/interpreter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2022-2023 Intel Corporation
# Copyright © 2022-2024 Intel Corporation

"""Interpreter for converting Cargo Toml definitions to Meson AST
Expand Down Expand Up @@ -418,7 +418,6 @@ def _create_lib(cargo: Manifest, build: builder.Builder, crate_type: manifest.CR

lib: mparser.BaseNode
if cargo.lib.proc_macro or crate_type == 'proc-macro':
kwargs['rust_args'] = build.array([build.string('--extern'), build.string('proc_macro')])
lib = build.method('proc_macro', build.identifier('rust'), posargs, kwargs)
else:
if crate_type in {'lib', 'rlib', 'staticlib'}:
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/modules/rust.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2020-2023 Intel Corporation
# Copyright © 2020-2024 Intel Corporation

from __future__ import annotations
import itertools
Expand Down Expand Up @@ -283,6 +283,7 @@ def bindgen(self, state: ModuleState, args: T.List, kwargs: FuncBindgen) -> Modu
def proc_macro(self, state: ModuleState, args: T.Tuple[str, SourcesVarargsType], kwargs: _kwargs.SharedLibrary) -> SharedLibrary:
kwargs['native'] = True # type: ignore
kwargs['rust_crate_type'] = 'proc-macro' # type: ignore
kwargs['rust_args'] = kwargs['rust_args'] + ['--extern', 'proc_macro']
target = state._interpreter.build_target(state.current_node, args, kwargs, SharedLibrary)
return target

Expand Down

0 comments on commit 55d30b6

Please sign in to comment.