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

Limit usage of std::Instant to non-wasm targets #205

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

TilBlechschmidt
Copy link
Contributor

Effects

All uses of std::Instant are now limited to targets other than wasm32-*.
There should be no effect for targets other than WASM.

When targeting WebAssembly, it is now possible to use this library in environments where a time API is not available. For more details, see the original comment in #204

If this is a new feature or a bug fix ...

  • Yes, the branch I'm proposing to merge is called issue-xyz where xyz is the number of the issue.

If this change adds or modifies a validation case

  • No.
  • Yes and:
    • I have coded up, or updated, an existing test case; and
    • I have provided a GMAT script which confirms the result(s); and
    • I have updated the VALIDATION.md file with the new error data between nyx and GMAT.
    • I will specify the version of GMAT used for the validation.

@TilBlechschmidt
Copy link
Contributor Author

TilBlechschmidt commented Jul 26, 2023

For most occurrences, I have simply gated the use. For a couple I decided to "duplicate" the message, removing the elapsed time.

In case of the rhapson- modules, an elapsed Duration is returned — those have been set to 0
(hope that's okay? No idea what they are used for down the line ...)


The project compiles under both WASM and aarch64. It should be noted though that under WebAssembly the use of std::Instant does not fail to compile but instead throws a runtime exception.

image

Copy link
Member

@ChristopherRabotin ChristopherRabotin left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

Could you add a build step in the CI to build on wasm32? That'll just ensure that future changes don't break the build.

@TilBlechschmidt
Copy link
Contributor Author

It appears that the check task already runs for the wasm32-unknown-unknown target:

- name: Run cargo check for WASM target
run: cargo check --target wasm32-unknown-unknown

Corresponding action logs:
https://github.com/nyx-space/nyx/actions/runs/5674182922/job/15379332880?pr=205#step:5:1

It would probably be possible to make the test target work with wasm too but it appears as though it can't use tests with the regular #[test] macro. See wasm-bindgen-test for more details.

Note: Uses of std::Instant don't fail to compile, they throw runtime errors so check alone would not catch that.

@ChristopherRabotin ChristopherRabotin merged commit 80bbdce into nyx-space:master Jul 27, 2023
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