feat: support --package to specify the package to profile #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solve #56 and #39 without breaking the architecture.
When implementing this feature, I found the method
fn validate_target
is redundant for validating the target. For Cargo builtin sub-commands, this is done by setting the fieldspec
inCompileOptions
. However, remove the methodvalidate_target
isn't enough.The way
Cargo
used to construct aComplieOptions
is like following :In implementation of
CompileOptions::new
,spec: ops::Packages::Packages(Vec::new()),
makes the fieldspec
an empty vector, which causeCargo
fail to findbin
,example
,bench
for a virtual manifest. Unless we set the fieldspec
explicitly toPackages::Default
to tellCargo
to search the whole workspace. For the sake of time, I didn't spend too much time digging in the internal logic.I implement the feature by introducing a
Enum
typePackage
that corresponds to Cargo'sPackages::Default
andPackages::Packages(Vec<String>)
respectively.I do not insist on this and will gladly to use other approach i.e. if there is a huge refactor on architecture. Right now I'm using this patch for projects having more than one package.