-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Windows support #38
Conversation
Makefile.variable
Outdated
ifeq (, $(shell $(TEST_FOR_DART))) | ||
$(error $(ERR_PUB_NOT_FOUND)) | ||
else | ||
PUB_PREFIX := dart |
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.
Since rid
doesn't actually depend on Flutter, I added an extra check here for dart pub
.
if cfg!(target_os = "windows") { | ||
cmd.args(&["-c", FFIGEN_RUNNER]); | ||
} | ||
|
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 have no idea why this didn't work on Windows. I tried it on two different machines. The original code caused the build script to fail with a cryptic error - something like "the system could not find the file specified" with no stack trace.
binding_file: None, | ||
swift_plugin_file: None, | ||
} | ||
} |
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 don't know what this does but the other OSes have an entry here and I didn't want Windows to feel left out.
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.
Only iOS + macOS will have swift_plugin_file
entry. All should have a binding_file
.
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.
Hmm... Android and Linux don't have one either. Should this follow the same format as above?
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 you'd follow closer to Linux/Android for Windows in this case as no Swift is used there either.
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 apologize, I'm confused. Linux and android don't have a binding_file
. Should I leave this out on Windows as well?
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.
If no binding.h
file needs to be copied anywhere to make this work on windows then yes you should just leave it out.
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.
Okay. This isn't something I encountered on Windows, so either it's not needed or it was somehow already where it needed to be. I'll definitely be looking out for this though, in case there was something weird that I missed!
@@ -3,15 +3,13 @@ include ../../../Makefile.variable | |||
test-all: | |||
$(MAKE) test TEST=todo | |||
|
|||
test: ./.dart_tool/ | |||
test: | |||
$(PUB_PREFIX) pub get |
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 replaced the ./.dart_tool/
step in each Makefile
, first with $(MAKE) ./.dart_tool/
and then with a direct call to pub get
. At first it wasn't running at all for me. With the first change it would run sometimes, but I had issues with the package resolution being stale and causing errors. Running it every time fixed the issue, and it's hardly slower on my machine. Pub exits quickly when it has nothing to update.
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.
Not sure about this one, what this is basically saying is:
This is how to produce the
./.dart_tool/
directory if it is not there
./.dart_tool/:
$(PUB_PREFIX) pub get
The test task needs the
./.dart_tool/
directory to be present (otherwise it'll run$(PUB_PREFIX) pub get
since we told it above how to produce that directory.
test: ./.dart_tool/
....
With your change we now always run pub get
when starting the tests even if it is not necessary if we ran that step before (indicated by the presence of ./.dart_tool/
).
It could be that on windows that directory has a different name or the info of installed packages is stored elsewhere.
This is what it looks like for me:
➝ ls ./.dart_tool/
package_config.json pub version
package_config_subset test
`
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.
Thanks for the explanation.
With your change we now always run
pub get
when starting the tests even if it is not necessary if we ran that step before (indicated by the presence of./.dart_tool/
).
That matches what I saw. My experience was that pub would get in a state where ./.dart_tool/
was present but the contents were stale. I had a specific file-not-found error that I fixed with this change, where pub definitely needed to run but it wasn't being run.
I can change this back but it wasn't working for me.
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 I understand. I think making things less brittle should be preferred over optimization, even though you could just delete ./.dart_tool/
or run flutter pub get
manually in order to fix the state.
Another reason I used this approach was to be able to work offline.
However it's annoying if things break for odd reasons so I'd opt for your change in this case.
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.
Maybe the best case then is to run pub but soft-fail if it doesn't work? Though maybe that's what it's already doing, I'm still not super strong with make
. I'll check this out when I update the 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.
I just checked in on this. On my system, pub get
doesn't seem to fail when you're offline, so I don't think anything needs to change.
Sure thing, will do that in a bit. |
RbJopDLvRc.mp4 |
Looks like you should already have access. Here's a link to the PR I opened over there to trigger CI runs: https://github.com/SecondFlight/rid/pull/4 Let me know if you can't access it. |
@@ -18,7 +18,7 @@ cp $TEMPLATE_ROOT/rust/Cargo.toml $APP_ROOT/Cargo.toml | |||
perl -pi -w -e "s/<package>/$APP_NAME/;" $APP_ROOT/Cargo.toml | |||
|
|||
# Plugin | |||
flutter create --platforms=android,ios,macos --template=plugin $APP_ROOT/plugin | |||
flutter create --platforms=android,ios,macos,linux,windows --template=plugin $APP_ROOT/plugin |
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.
What happens here if I'm not on windows? Will it just create the folders and work even if I don't have the respective binaries to support windows on flutter? Or would it break?
This is not a huge deal either way as the CLI tool will take care of selecting the proper commands given the platforms a user wants to support, however I want to avoid breaking devs coming to the project and setting up an example.
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.
A good question. This tells flutter what platforms you want your code to work on, not what platform you're currently on. If I create a repo like this on Windows and you pull it down on macOS then you will be able to build it as a desktop app, whereas if I didn't include macOS then you wouldn't.
Awesome pretty much LGTM at this point. Related to #39 I'd like to not split up these github action files, but would be willing to merge for now and have this fixed in a separate PR. Or could you take care of this as part of this PR? And thanks, I'm excited to see this run on windows as well 😄 |
Thanks for the suggestion! It makes a lot of sense to me. I may as well fold the macOS stuff into this PR as well in that case. I'm out right now but I'll try to get that in before tomorrow. |
That makes sense to me as well. No worries, there is no rush at all with this, take your time. |
This should be good to merge now from my side. Passing build here: https://github.com/SecondFlight/rid/runs/3853411516 |
rid-build/src/ffigen/run_ffigen.rs
Outdated
// expected. | ||
|
||
let mut cmd = Command::new( | ||
if cfg!(target_os = "windows") {"powershell"} else {FFIGEN_RUNNER} |
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.
Formatting looks odd here, does your editor/IDE not autoformat? If it was it should've picked up the settings in rustfmt.toml
and changed it to something like:
let mut cmd = Command::new(if cfg!(target_os = "windows") {
"powershell"
} else {
FFIGEN_RUNNER
});
I suppose running rustfmt
on the file should do the trick as well.
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.
Okay, weird. ctrl+shift+p
-> format document
looks like its doing something but it definitely isn't. I'll use the regular command line rustfmt
for now.
After updating the binding file related code + fixing the minor formatting NIT this looks good to merge. Awesome job! |
Okay, so I "fixed" it by just making the Would you mind checking this on your machine? I'd be happy to revert this change and just keep it locally, and if you know what I'm missing please let me know! |
OK I'll have to look into this ... but it seems to be working for me (even though I get some error which I'll look into). It maybe a windows issue with links. I posted how this works on my machine below. For now please just revert f43a4bd but keep the format fixes in. We'll figure the issue out later. Once we do I'll add a check to the build task to track this automatically in the future. Thanks for your patience with the How it works on Macos(from ➝ cargo fmt
error[internal]: left behind trailing whitespace
--> ~/rid/rid/rid-macro-impl/src/render_rust/render_return_type.rs:74:74:1
|
74 |
| ^^^^^^^^
|
error[internal]: left behind trailing whitespace
--> ~/rid/rid/rid-macro-impl/src/render_rust/render_to_return_type.rs:55:55:58
|
55 | K::Composite(Composite::Vec, rust_type, _) =>
| ^
|
warning: rustfmt has failed to format. See previous 2 errors.
➝ git st
M src/render_rust/render_return_type.rs
M src/render_rust/render_to_return_type.rs
M src/reply/mod.rs From project root:
with exact same results. Obviously since I'm getting errors here this means that the |
Thanks for looking into this. Very strange. I'll revert f43a4bd for now. |
When I run
😕 |
That's odd .. does it indicate which toml file? |
That's good with me. It doesn't say which file, but f43a4bd fixes it for me and those files all have a period at line 1 column 1, so I think that must be what it's referring to. |
I'm getting the below warning when running the tests:
It's not happening in CI, so it might be due to me being on the beta channel:
It's not a blocker for this PR, so we only should address it now if you know right away what the cause could be. Otherwise we'll take care of it later. |
Prior to #35, In light of that deprecation, I'd suggest preferring |
MgGJq4f1SM.mp4
Resolves #33.
This patch adds Windows support to rid, as well as an action to run
make test
on Windows.