mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 03:54:42 +00:00 
			
		
		
		
	Support environment variable CARGO_MANIFEST_PATH.
This commit is contained in:
		
							parent
							
								
									d7e977a8f1
								
							
						
					
					
						commit
						32e09de7c2
					
				
					 5 changed files with 17 additions and 0 deletions
				
			
		|  | @ -13,6 +13,7 @@ use crate::{ | ||||||
| const CARGO_DEFINED_VARS: &[(&str, &str)] = &[ | const CARGO_DEFINED_VARS: &[(&str, &str)] = &[ | ||||||
|     ("CARGO", "Path to the cargo binary performing the build"), |     ("CARGO", "Path to the cargo binary performing the build"), | ||||||
|     ("CARGO_MANIFEST_DIR", "The directory containing the manifest of your package"), |     ("CARGO_MANIFEST_DIR", "The directory containing the manifest of your package"), | ||||||
|  |     ("CARGO_MANIFEST_PATH", "The path to the manifest of your package"), | ||||||
|     ("CARGO_PKG_VERSION", "The full version of your package"), |     ("CARGO_PKG_VERSION", "The full version of your package"), | ||||||
|     ("CARGO_PKG_VERSION_MAJOR", "The major version of your package"), |     ("CARGO_PKG_VERSION_MAJOR", "The major version of your package"), | ||||||
|     ("CARGO_PKG_VERSION_MINOR", "The minor version of your package"), |     ("CARGO_PKG_VERSION_MINOR", "The minor version of your package"), | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ pub(crate) fn inject_cargo_package_env(env: &mut Env, package: &PackageData) { | ||||||
| 
 | 
 | ||||||
|     let manifest_dir = package.manifest.parent(); |     let manifest_dir = package.manifest.parent(); | ||||||
|     env.set("CARGO_MANIFEST_DIR", manifest_dir.as_str()); |     env.set("CARGO_MANIFEST_DIR", manifest_dir.as_str()); | ||||||
|  |     env.set("CARGO_MANIFEST_PATH", package.manifest.as_str()); | ||||||
| 
 | 
 | ||||||
|     env.set("CARGO_PKG_VERSION", package.version.to_string()); |     env.set("CARGO_PKG_VERSION", package.version.to_string()); | ||||||
|     env.set("CARGO_PKG_VERSION_MAJOR", package.version.major.to_string()); |     env.set("CARGO_PKG_VERSION_MAJOR", package.version.major.to_string()); | ||||||
|  |  | ||||||
|  | @ -52,6 +52,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -136,6 +137,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -220,6 +222,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "an_example", |                 "CARGO_CRATE_NAME": "an_example", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -304,6 +307,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "it", |                 "CARGO_CRATE_NAME": "it", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -384,6 +388,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "libc", |                 "CARGO_CRATE_NAME": "libc", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", |                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", |                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", |                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", |                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", | ||||||
|  |  | ||||||
|  | @ -52,6 +52,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -136,6 +137,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -220,6 +222,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "an_example", |                 "CARGO_CRATE_NAME": "an_example", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -304,6 +307,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "it", |                 "CARGO_CRATE_NAME": "it", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -384,6 +388,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "libc", |                 "CARGO_CRATE_NAME": "libc", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", |                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", |                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", |                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", |                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", | ||||||
|  |  | ||||||
|  | @ -51,6 +51,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -134,6 +135,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "hello_world", |                 "CARGO_CRATE_NAME": "hello_world", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -217,6 +219,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "an_example", |                 "CARGO_CRATE_NAME": "an_example", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -300,6 +303,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "it", |                 "CARGO_CRATE_NAME": "it", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", |                 "CARGO_MANIFEST_DIR": "$ROOT$hello-world", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$hello-world/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "", |                 "CARGO_PKG_AUTHORS": "", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "", |                 "CARGO_PKG_DESCRIPTION": "", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "", |                 "CARGO_PKG_HOMEPAGE": "", | ||||||
|  | @ -380,6 +384,7 @@ | ||||||
|                 "CARGO": "$CARGO$", |                 "CARGO": "$CARGO$", | ||||||
|                 "CARGO_CRATE_NAME": "libc", |                 "CARGO_CRATE_NAME": "libc", | ||||||
|                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", |                 "CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98", | ||||||
|  |                 "CARGO_MANIFEST_PATH": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98/Cargo.toml", | ||||||
|                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", |                 "CARGO_PKG_AUTHORS": "The Rust Project Developers", | ||||||
|                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", |                 "CARGO_PKG_DESCRIPTION": "Raw FFI bindings to platform libraries like libc.\n", | ||||||
|                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", |                 "CARGO_PKG_HOMEPAGE": "https://github.com/rust-lang/libc", | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Victor
						Victor