This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f30221
commit 767bdaf
Showing
9 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Configuration } from './components/configuration/Configuration'; | ||
import { Rustup } from './components/configuration/Rustup'; | ||
|
||
/** | ||
* The class defines functions which can be used to get data required to invoke Cargo | ||
*/ | ||
export class CargoInvocationManager { | ||
private _configuration: Configuration; | ||
private _rustup: Rustup | undefined; | ||
|
||
public constructor(configuration: Configuration, rustup: Rustup | undefined) { | ||
this._configuration = configuration; | ||
this._rustup = rustup; | ||
} | ||
|
||
/** | ||
* Cargo can be accessible from multiple places, but the only one is correct. | ||
* This function determines the path to the executable which either Cargo itself or proxy to | ||
* Cargo. If the executable is a proxy to Cargo, then the proxy may require some arguments to | ||
* understand that Cargo is requested. An example is running Cargo using rustup. | ||
*/ | ||
public getExecutableAndArgs(): { executable: string, args: string[] } { | ||
const userCargoPath = this._configuration.getCargoPath(); | ||
if (userCargoPath) { | ||
return { executable: userCargoPath, args: [] }; | ||
} | ||
const userToolchain = this._rustup ? this._rustup.getUserToolchain() : undefined; | ||
if (!userToolchain) { | ||
return { executable: 'cargo', args: [] }; | ||
} | ||
const args = ['run', userToolchain.toString(true, false), 'cargo']; | ||
return { executable: Rustup.getRustupExecutable(), args }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters