-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap Rust protoc
in Oak utils
#533
Conversation
|
@@ -68,7 +67,7 @@ pub fn run(args: Args) -> Result<()> { | |||
|
|||
let mut includes = args.includes; | |||
if includes.is_empty() { | |||
static DOT_SLICE: &'static [&'static str] = &["."]; | |||
static DOT_SLICE: &[&str] = &["."]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it due to this error: #510 (comment)
that started appearing after I added a dependency (not a build-dependency) on a protoc-rust-grpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah interesting, so it seems that these changes were made by us to satisfy clippy. @blaxill do you remember why it was necessary to revert them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pulled from upstream, the important change was the less restrictive Cargo.toml
2.8 -> 2 change, so that it could generate 2.10 protoc
files similar to the other generated proto files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did nothing break when these changes were undone though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't get "clippy'ed" as a build/dev dependency, but since we are wrapping it it is a full dependency of oak_utils
and so is clippy'ed now.
docs/programming-oak.md
Outdated
- [Persistent Storage](#persistent-storage) | ||
- [Testing](#testing) | ||
- [Testing Multi-Node Applications](#testing-multi-node-applications) | ||
- [Programming Oak](#programming-oak) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note it is not common to include the title in the TOC, or was this generated by some automated tool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't touch this file, it was changed by the format
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From within Docker? But why did it change it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw [Programming Oak](#programming-oak)
is an addition, perhaps from a merge or by accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll revert this change then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I get it
This change is automatically applied by VSCode, when I save the file.
@@ -68,7 +67,7 @@ pub fn run(args: Args) -> Result<()> { | |||
|
|||
let mut includes = args.includes; | |||
if includes.is_empty() { | |||
static DOT_SLICE: &'static [&'static str] = &["."]; | |||
static DOT_SLICE: &[&str] = &["."]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did nothing break when these changes were undone though?
|
||
// This function returns a list of files in the `new_dir` that are different from files with | ||
// same names in the `old_dir`. | ||
fn get_changed_and_removed_files(old_dir: &Path, new_dir: &Path) -> (Vec<String>, Vec<String>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the return type and the logic are getting a bit too complicated.
Perhaps another solution could be:
-
collect filenames from both maps in a single set
-
iterate over the set, and get the value from both the old and new map (as options)
-
collect the old and new option types in a struct like:
struct FileDiff { old_content: Option<String>, new_content: Option<String>, }
-
add a method on
FileDiff::action()
to figure out what to do about the file, perhaps it should return one value of some enum:enum FileAction { Ignore, Update{ new_content: String }, Remove`, }
-
apply the necessary change based on this enum value in a final step.
WDYT? I think it should be more readable, and kind of fun to implement in a "functional" style, but if you don't think that's worth it feel free to submit as it is (or do it in a future PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #548
|
||
// This function returns a list of files in the `new_dir` that are different from files with | ||
// same names in the `old_dir`. | ||
fn get_changed_and_removed_files(old_dir: &Path, new_dir: &Path) -> (Vec<String>, Vec<String>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function would be much easier to test if it took as input the corresponding maps, instead of figuring them out from the actual file system. Then the unit tests would look trivial, since you can just pass the maps without having to create any temp files. Up to you anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed in #548
I don't think this is cleaning up its temporary directories properly – I've got about 10GiB of |
I don't see temporary directories on my machine and inside Docker. |
|
@daviddrysdale this likely could this be #578 switching to not controlling out-dir, and parsing cargo json for the cargo defined directory may fix it. |
Ah, that makes more sense – sorry for the false alarm @ipetr0v. |
This change:
oak_utils
crate, that runsprotoc
/protoc_grpc
and checks updated filesbuild.rs
files to useoak_utils
Fixes #510
Checklist
cover any TODOs and/or unfinished work.
construction.