Skip to content
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

generator.py: Use cargo run instead of guessing path #1597

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

sophie-h
Copy link
Contributor

@sophie-h sophie-h commented Sep 5, 2024

Currently, the script just guesses a target path based on the default config. This fails if the project or the user has configured a different target directory.

This code is shorter and more correct.

generator.py Show resolved Hide resolved
generator.py Outdated
if conf.gir_path:
stdout, stderr = await spawn_process(conf.gir_path, args)
else:
cargo_args = ["run", "--release", "--quiet", "--manifest-path=gir/Cargo.toml", "--"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be DEFAULT_GIR_DIRECTORY? Now you're assuming that custom projects always have a submodule named gir? Perhaps we better fold this in with the configuration parameter gir_path somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be DEFAULT_GIR_DIRECTORY?

Could make sense to change this. But I'm currently following the previous code where it was hardcoded.

Now you're assuming that custom projects always have a submodule named gir?

That's nothing new, it's the same as with the previous code:

def update_workspace():
    return run_command(["cargo", "build", "--release"], "gir")

Perhaps we better fold this in with the configuration parameter gir_path somehow?

Well, that path is a binary path. Not sure how you would couple that with a source directory for gir.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By adding a "defaulted" "gir directory" path argument, and making it mutually exclusive with --gir-path perhaps? That way the default (hardcoded) "gir" suddenly becomes visible too.

Currently, the script just guesses a target path based on the default config.
This fails if the project or the user has configured a different target
directory.

This code is shorter and more correct.
Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Any other comments?

@sdroege sdroege merged commit 733904c into gtk-rs:master Sep 6, 2024
7 checks passed
@MarijnS95
Copy link
Contributor

MarijnS95 commented Oct 30, 2024

One downside of this, found now that I started using this, is that run_command("cargo build ...") which was used previously does not capture stdout/stderr. The newly used stdout, stderr = await spawn_process(...) inherently captures output, meaning that the first => Looking in path `some-crate` now takes very long without any progress indication.

@sophie-h
Copy link
Contributor Author

I don't remember how the old solution solved that, but you could bring back a separate cargo build call and use cargo run after that. With this, the run shouldn't have to do build anymore.

@MarijnS95
Copy link
Contributor

@sophie-h sure, I'll look into it 👍

Additionally, it looks like cargo build/run properly take file locks, but notice that the invocation to spawn_gir() is massively parallelized (in i.e. a tree like gstreamer-rs) when invoked without a path filter.

@MarijnS95
Copy link
Contributor

Finally tackled in #1613.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants