File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -997,7 +997,21 @@ def construct_arguments(
997997
998998 # Both ctx.label.workspace_root and ctx.label.package are relative paths
999999 # and either can be empty strings. Avoid trailing/double slashes in the path.
1000- components = "${{pwd}}/{}/{}" .format (ctx .label .workspace_root , ctx .label .package ).split ("/" )
1000+ #
1001+ # When transform_sources moves source files into bazel-out (due to mixed
1002+ # generated/non-generated sources), the crate root ends up under a different
1003+ # directory than the original source package. We must derive CARGO_MANIFEST_DIR
1004+ # from the actual crate root path so proc-macros can find Cargo.toml in the
1005+ # sandbox.
1006+ _package_path = "/" .join ([c for c in [ctx .label .workspace_root , ctx .label .package ] if c ])
1007+ if crate_info .root .is_source :
1008+ components = "${{pwd}}/{}/{}" .format (ctx .label .workspace_root , ctx .label .package ).split ("/" )
1009+ else :
1010+ # Crate root was transformed (symlinked into bazel-out). The file is at
1011+ # <root.root.path>/<workspace_root>/<package>/<relative_path>, so the
1012+ # manifest directory is <root.root.path>/<workspace_root>/<package>.
1013+ _manifest_dir = "/" .join ([c for c in [crate_info .root .root .path , _package_path ] if c ])
1014+ components = "${{pwd}}/{}" .format (_manifest_dir ).split ("/" )
10011015 env ["CARGO_MANIFEST_DIR" ] = "/" .join ([c for c in components if c ])
10021016
10031017 if out_dir != None :
You can’t perform that action at this time.
0 commit comments