Skip to content

Call bsc.exe directly, when no binaryPath is set in settings #529

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

Merged

Conversation

fhammerschmidt
Copy link
Member

@fhammerschmidt fhammerschmidt commented Jul 27, 2022

This should fix #514 and also will make formatting faster (at least on windows).
Supersedes #521

I refactored the binary lookup a bit so that:

  • we do not need to call existsSync twice on the same file
  • the function returns the binary path itself

When no binaryPath is set, the extension will lookup and use the bsc.exe now (again).

Also the message when no binary has been found could have shown null as path. I simplified it for that case.

Edit: Fixes #530 now as well.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

Added comments on how to make this simpler and more future-proof.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

This looks great thanks.
Just need confirmation from Windows users that this works.

@@ -6,11 +6,12 @@ let platformDir =
// See https://microsoft.github.io/language-server-protocol/specification Abstract Message
// version is fixed to 2.0
export let jsonrpcVersion = "2.0";
export let platformPath = path.join("rescript", platformDir);
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO: check that platformDir computation is in sync with the compiler.

Copy link
Member Author

@fhammerschmidt fhammerschmidt Jul 31, 2022

Choose a reason for hiding this comment

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

Not quite, in rescript-vscode the platformDir also allows for "linuxarm64", the compiler does not:
https://github.com/rescript-lang/rescript-compiler/blob/master/bsc#L6-L12
https://github.com/rescript-lang/rescript-compiler/blob/master/scripts/bin_path.js#L8-L11

Edit: Or technically also "win32arm64"? Shall I adapt it to be the same as the compiler?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case the compiler is a little behind and could be updated.

Copy link
Member Author

@fhammerschmidt fhammerschmidt Jul 31, 2022

Choose a reason for hiding this comment

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

Or is the logic in rescript-vscode correct? The compiler has no directories for win32arm64 or linuxarm64, and neither do they get built in CI?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be kind of future-proof, if one wants to build from source.
But does not matter much either way, as this is rarely done I guess.

Copy link
Collaborator

@cristianoc cristianoc 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.

@cristianoc
Copy link
Collaborator

I think the README already aligns with this process to find the executable, and requires no change.

@cristianoc
Copy link
Collaborator

Merge away any time.

@cristianoc cristianoc merged commit fad3de2 into rescript-lang:master Aug 1, 2022
@fhammerschmidt fhammerschmidt deleted the call-bsc-exe-directly branch August 1, 2022 06:39
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.

Suggest installing a supported ReScript version when the binary is not found Formatting after editting is failed with v1.4.2 but ok with v1.4.1.
2 participants