Skip to content

Conversation

@art-w
Copy link
Contributor

@art-w art-w commented Sep 20, 2023

Long time no see, I hope you are doing great!

This is a quick fix for compiling for mirage... but let me know if you had something else in mind :)

@dinosaure
Copy link
Collaborator

From a certain perspective, it is preferable to delegate the injection of such a function to the user. It has been mentioned that:

  1. progress is really not MirageOS friendly
  2. terminal could be inspired by notty (which is MirageOS friendly) as far as abstractions are concerned.

Can you elaborate a bit more on your goal in relation to MirageOS?

PS: CraigFe gave me a hand on progress maintenance, happy to see for another beer 🍺

@art-w
Copy link
Contributor Author

art-w commented Sep 20, 2023

Yeah I was wondering if the absence was intentional, but then the function ocaml_terminal_get_terminal_dimensions already had a dummy placeholder for unsupported platforms. Would you prefer if we remove both functions, or a refactoring of terminal to avoid those hacks?

Regarding my use-case, I was trying to compile index and irmin on mirage and they both depend on progress to report progress on long running consistency checks... so this PR was only attempting to fix the linking error in a way that seemed consistent with the existing progress code :)

PS: Oh cool! Yes let's go for beers soon!

@dinosaure
Copy link
Collaborator

Yeah I was wondering if the absence was intentional, but then the function ocaml_terminal_get_terminal_dimensions already had a dummy placeholder for unsupported platforms. Would you prefer if we remove both functions, or a refactoring of terminal to avoid those hacks?

I don't really have an opinion on this specific subject. In my opinion, the problem is broader if we take your objective into account. In other words, if it's really a question of making a unikernel (Solo5) which includes progress, the work required should be greater than that unfortunately.

Regarding my use-case, I was trying to compile index and irmin on mirage and they both depend on progress to report progress on long running consistency checks... so this PR was only attempting to fix the linking error in a way that seemed consistent with the existing progress code :)

Currently, you should have more problems than this function since progress is explicitly Unix-dependent: in other words, only the unix target should work as far as MirageOS is concerned (you should try hvt and see all the errors).

@art-w
Copy link
Contributor Author

art-w commented Sep 20, 2023

Ha yes but I've switched index and irmin to use progress.engine (instead of progress, as it doesn't depend on unix) and so it seems to run fine on hvt with this short patch :)

progress.engine is already parametrized by a Platform argument, so the C stubs from terminal are actually never called on mirage: https://github.com/craigfe/progress/blob/main/src/progress/engine/platform.ml#L21 so I could move these C stubs out of terminal and put them directly in the unixy progress (this would be a breaking change for terminal interface, but it looks like only progress depends on it anyway :) )

@dinosaure
Copy link
Collaborator

It's an interesting idea indeed. I need to spend some time thinking through all the implications, but a proposal along these lines would be interesting to continue the discussion.

@art-w
Copy link
Contributor Author

art-w commented Sep 20, 2023

Added a commit to move the C stubs out of terminal, such that they are only required when using progress :) (but one can use the progress.engine functor on mirage, since it's unix and stub free!)

@dinosaure
Copy link
Collaborator

It seems good for me, terminal becomes more and more close to what notty provides but that's fine. Thanks! I will try to see and merge others PRs before a release but you are able to use the upstream version now 👍.

@dinosaure dinosaure merged commit a99d5bb into craigfe:main Sep 25, 2023
dinosaure added a commit to dinosaure/opam-repository that referenced this pull request Apr 13, 2024
CHANGES:

- Be compatible with MirageOS and remove `ocaml_terminal_get_sigwinch` (@art-w, craigfe/progress#38)
- Clear all lines in `interject_with` (@Gbury, craigfe/progress#30)
- Add `Display.remove_line` (@mbarbin, craigfe/progress#26)
- Fix compilation for OCaml 5.2 (reported by @Gbury, fixed by @dinosaure, craigfe/progress#40)
- Add `Display.{pause,resume}` (@Gbury, craigfe/progress#37)
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.

2 participants