summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-02-28 15:59:25 +0200
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2023-03-01 20:56:53 +0530
commitf5841cb69b80f351d5fe0c9440d71cb8609bf560 (patch)
treed4ed8ef586634756c2016d750e7750ac69e4ae73
parent36e2c864d0ff9889829886889db20d7f655445c6 (diff)
downloadmeson-f5841cb69b80f351d5fe0c9440d71cb8609bf560.tar.gz
rust: Fix handling of proc-macros in rust-project.json
The proc-macro code was not running at all because of a missing dash in the crate type, and the proc macro dylib path was not generated as a path but including the `-o ` commandline parameter prefix.
-rw-r--r--mesonbuild/backend/ninjabackend.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 8a0465db9..258fab4d0 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1778,8 +1778,8 @@ class NinjaBackend(backends.Backend):
return orderdeps, first_file
def _add_rust_project_entry(self, name: str, main_rust_file: str, args: CompilerArgs,
- from_subproject: bool, is_proc_macro: bool,
- output: str, deps: T.List[RustDep]) -> None:
+ from_subproject: bool, proc_macro_dylib_path: T.Optional[str],
+ deps: T.List[RustDep]) -> None:
raw_edition: T.Optional[str] = mesonlib.first(reversed(args), lambda x: x.startswith('--edition'))
edition: RUST_EDITIONS = '2015' if not raw_edition else raw_edition.split('=')[-1]
@@ -1799,8 +1799,8 @@ class NinjaBackend(backends.Backend):
deps,
cfg,
is_workspace_member=not from_subproject,
- is_proc_macro=is_proc_macro,
- proc_macro_dylib_path=output if is_proc_macro else None,
+ is_proc_macro=proc_macro_dylib_path is not None,
+ proc_macro_dylib_path=proc_macro_dylib_path,
)
self.rust_crates[name] = crate
@@ -2021,13 +2021,15 @@ class NinjaBackend(backends.Backend):
for rpath_arg in rpath_args:
args += ['-C', 'link-arg=' + rpath_arg + ':' + os.path.join(rustc.get_sysroot(), 'lib')]
+ proc_macro_dylib_path = None
+ if getattr(target, 'rust_crate_type', '') == 'proc-macro':
+ proc_macro_dylib_path = os.path.abspath(os.path.join(target.subdir, target.get_filename()))
+
self._add_rust_project_entry(target.name,
os.path.abspath(os.path.join(self.environment.build_dir, main_rust_file)),
args,
bool(target.subproject),
- #XXX: There is a fix for this pending
- getattr(target, 'rust_crate_type', '') == 'procmacro',
- output,
+ proc_macro_dylib_path,
project_deps)
compiler_name = self.compiler_to_rule_name(rustc)