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

Hide platform-specific code behind a single API #36

Closed
hannobraun opened this issue Jan 18, 2022 · 8 comments · Fixed by #383
Closed

Hide platform-specific code behind a single API #36

hannobraun opened this issue Jan 18, 2022 · 8 comments · Fixed by #383
Assignees
Labels
good first issue Good for newcomers type: development Work to ease development or maintenance, without direct effect on features or bugs

Comments

@hannobraun
Copy link
Owner

hannobraun commented Jan 18, 2022

There is some platform-specific code in model.rs. There's also the watch event handling code in main.rs. This is fine for now, but following this approach everywhere will get unwieldy.

I think the following concept would be better:

  • Create a new module, platforms, that contains a Platform trait.
  • This trait should define a minimal interface, such that all platform-specific code lives in implementations of that trait.
  • Otherwise those trait implementations should contain as little code as possible, to prevent duplication.
  • Avoid the use of #[cfg(...)] as much as practical. All code should be compiled on all platforms, to prevent errors from creeping in.
  • Use of cfg!(...) is fine, of course.
@hannobraun hannobraun added type: feature New features and improvements to existing features type: development Work to ease development or maintenance, without direct effect on features or bugs labels Jan 18, 2022
@hannobraun
Copy link
Owner Author

hannobraun commented Jan 18, 2022

Marking this one as https://github.com/hannobraun/Fornjot/labels/good%20first%20issue, as it concerns a limited amount of code (which I linked in the original issue description) and doesn't require lots of knowledge about Fornjot.

@hannobraun hannobraun added the good first issue Good for newcomers label Jan 18, 2022
@hannobraun hannobraun removed the type: feature New features and improvements to existing features label Jan 19, 2022
@ozghimire
Copy link
Contributor

Is anyone working on this? I would like to work on this, also has the requirements changed from last it was updated?

@hannobraun
Copy link
Owner Author

Hey @ozghimire, thank you for the interest!

As far as I know, nobody is working on this. Feel free to pick it up!

The requirements here are still up-to-date. I think the platform-specific code has changed very little, since I created this issue.

@ozghimire
Copy link
Contributor

Awesome, can you assign me this and I will start working on it.

@hannobraun
Copy link
Owner Author

You can just start working whenever you want, and don't need me to officially assign you. But since you asked, I'll happily do it 😁

@hannobraun
Copy link
Owner Author

Hey @ozghimire, two notes:

  1. I've extracted the former model module into a separate crate in Extract fj-host from fj-app #381, fj-host. The only piece of platform-independent code now lives there: https://github.com/hannobraun/Fornjot/blob/ff5564614bf6bfdd945db95daba122ee64bbdd7b/fj-host/src/lib.rs#L36-L44
  2. The issue description mentions the watch event handling code. This also lives in fj-host now, but I'm actually no longer sure what specifically I was referring to when I mentioned that. I assume that I was thinking that it might make sense to listen for different event on different platforms, but it's not clear that is the case.
    Changing the model file triggers multiple rebuilds #29 is an issue that might require listening to different events on different platforms to be resolved, but it's actually not clear whether that is the case, and what's causing the issue in the first place.
    In any case, I think you can ignore the event handling code for the purposes of this issue.

@ozghimire
Copy link
Contributor

@hannobraun So as part of the change, so the platform module should live inside the fj-host crate or it should be inside the fj-app?

@hannobraun
Copy link
Owner Author

@ozghimire

So as part of the change, so the platform module should live inside the fj-host crate or it should be inside the fj-app?

It needs to be in fj-host, as that's where it's needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: development Work to ease development or maintenance, without direct effect on features or bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants