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

Support customized UDL file. #253

Merged
merged 7 commits into from
Nov 27, 2024
Merged

Support customized UDL file. #253

merged 7 commits into from
Nov 27, 2024

Conversation

alxkzmn
Copy link
Collaborator

@alxkzmn alxkzmn commented Nov 4, 2024

  • Do not overwrite the existing UDL file;
  • If UDL exists, generate bindings based on that file instead of copying.
  • If UDL file does not exist, write the default UDL in the project src directory.

Do not overwrite the existing UDL file, generate bindings based on UDL instead of copying. Overwrite with the default UDL only if no UDL is present in the project `src` directory.
@alxkzmn alxkzmn linked an issue Nov 4, 2024 that may be closed by this pull request
@vivianjeng
Copy link
Collaborator

(forward the message from discord)
I found out the error is no such module 'moproFFI'
and it also happens with my mac

the temporarily broken one
the error message should be like

Testing failed:
    The test runner encountered an error (Failed to prepare device 'Clone 1 of iPhone 15' for impending launch. (Underlying Error: Timed out trying to boot simulator after waiting 60.00s.))
Test session results, code coverage, and logs:

Copy link

cloudflare-workers-and-pages bot commented Nov 25, 2024

Deploying mopro with  Cloudflare Pages  Cloudflare Pages

Latest commit: dbf52f7
Status: ✅  Deploy successful!
Preview URL: https://25c97380.mopro.pages.dev
Branch Preview URL: https://250-customize-udl-file.mopro.pages.dev

View logs

cli/src/template/init/build.rs Outdated Show resolved Hide resolved
mopro-ffi/src/app_config/android.rs Outdated Show resolved Hide resolved
docs/docs/setup/rust-setup.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@vivianjeng vivianjeng left a comment

Choose a reason for hiding this comment

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

LGTM!

@alxkzmn alxkzmn requested a review from sifnoc November 26, 2024 10:44
Copy link
Collaborator

@sifnoc sifnoc left a comment

Choose a reason for hiding this comment

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

I’d like to suggest a small change to help distinguish the original mopro.udl in mopro-ffi. Perhaps we could rename it to something like mopro_example.udl instead of mopro.udl?

mopro-ffi/src/app_config/ios.rs Outdated Show resolved Hide resolved
@alxkzmn
Copy link
Collaborator Author

alxkzmn commented Nov 26, 2024

@sifnoc I think if we want to introduce udls with different names, we would need to pass the name as a command line argument. This can be done as a separate issue if we need it.

@sifnoc
Copy link
Collaborator

sifnoc commented Nov 26, 2024

@sifnoc I think if we want to introduce udls with different names, we would need to pass the name as a command line argument. This can be done as a separate issue if we need it.

Agree. There are at least three places where mopro.udl files are accessed: mopro-ffi, test-e2e, and the mopro-example-app generated by the mopro CLI.
However, it seems there is not enough documentation on how to modify and update the bindings.
We can address this in another issue.

mopro-ffi/src/app_config/android.rs Outdated Show resolved Hide resolved
mopro-ffi/src/app_config/android.rs Outdated Show resolved Hide resolved
mopro-ffi/src/app_config/ios.rs Outdated Show resolved Hide resolved
mopro-ffi/src/app_config/ios.rs Outdated Show resolved Hide resolved
if let Ok(info) = fs::metadata(out_dir) {
if !info.is_dir() {
panic!("out_dir exists and is not a directory");
fn rename_module_map_recursively(bindings_out: &PathBuf) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you write a comment explaining what this function does? From context it moves a file named moproFFI.modulemap to module.modulemap in the same directory. It does this exactly once, so it doesn't fully traverse the directory structure if not needed.

let path = entry.path();
if path.is_file() && path.file_name().unwrap() == "moproFFI.modulemap" {
let dest_path = path.with_file_name("module.modulemap");
fs::rename(&path, &dest_path).expect("Failed to rename module map");
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're only looking for 1 file an explicit break or return might be good here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're looking for multiple as we're normally building for both physical device and the simulator (each corresponding folder has a modulemap). I'll add the comment.

None,
false,
)
.expect("Failed to generate bindings");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not something we should do in this PR, but in the future we should probably refactor to use anyhow::Result as the return type in all these functions (including main). In all the rust codebases i've worked in (which to be fair is only like 4) I've had to refactor to add anyhow::Result everywhere.

If there's an error case we want to handle explicitly we can always do something like

if let Err(error) = fallible_operation() {
    println!("Operation did not succeed because of reason: {}", error);
    std::process::exit(1);
}

@chancehudson
Copy link
Collaborator

Looks good to me, good PR description too. I left comments about code style only.

@alxkzmn alxkzmn merged commit d52e29b into main Nov 27, 2024
25 checks passed
@alxkzmn alxkzmn deleted the 250-customize-udl-file branch November 27, 2024 09:51
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.

Customize UDL file
4 participants