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

fix #267, BAZELISK_NOJDK support #315

Closed
wants to merge 2 commits into from
Closed

Conversation

honwen
Copy link

@honwen honwen commented Apr 14, 2022

fix BAZELISK_NOJDK support

@google-cla
Copy link

google-cla bot commented Apr 14, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

For more information, open the CLA check for this pull request.

@honwen honwen changed the title fix #267 fix #267, BAZELISK_NOJDK support Apr 14, 2022
@@ -54,7 +56,11 @@ func DetermineBazelFilename(version string, includeSuffix bool) (string, error)
filenameSuffix = DetermineExecutableFilenameSuffix()
}

return fmt.Sprintf("bazel-%s-%s-%s%s", version, osName, machineName, filenameSuffix), nil
bazelFlavor := "bazel"
if val, ok := os.LookupEnv("BAZELISK_NOJDK"); ok && (val != "0") {

Choose a reason for hiding this comment

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

This would be great to fall back to read it from the config as well with getEnvOrConfig :

func GetEnvOrConfig(name string) string {

Copy link
Author

Choose a reason for hiding this comment

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

done. but package core has to be splited to break import loop

Copy link
Contributor

@sluongng sluongng left a comment

Choose a reason for hiding this comment

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

I would love to get this merged early as I want to start doing some experimentation with nojdk bazel. Thanks!

@@ -77,6 +77,8 @@ As mentioned in the previous section, the `<FORK>/<VERSION>` version format allo
If you want to create a fork with your own releases, you have to follow the naming conventions that we use in `bazelbuild/bazel` for the binary file names.
The URL format looks like `https://github.com/<FORK>/bazel/releases/download/<VERSION>/<FILENAME>`.

If the environment variable `BAZELISK_NOJDK` is set and `!= 0`, it will use the `nojdk` version of bazel.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If the environment variable `BAZELISK_NOJDK` is set and `!= 0`, it will use the `nojdk` version of bazel.
If `BAZELISK_NOJDK` is set in environment variable or `.bazeliskrc` to a value that is not `"0"`, bazelisk will use the `nojdk` version of bazel.

@@ -59,7 +62,11 @@ func DetermineBazelFilename(version string, includeSuffix bool) (string, error)
filenameSuffix = DetermineExecutableFilenameSuffix()
}

return fmt.Sprintf("bazel-%s-%s-%s%s", version, osName, machineName, filenameSuffix), nil
bazelFlavor := "bazel"
if configs.GetEnvOrConfig("BAZELISK_NOJDK") != "0" && configs.GetEnvOrConfig("BAZELISK_NOJDK") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we just set the convention to that BAZELISK_NOJDK=1 is accepted, and everything else is rejected?

That would make this a lot easier to use/manage vs having to read the code to find these 2 magic values to avoid.

If we want to stay consistent with the python implementation then we would want GetEnvOrConfig here to accept a default return value in case both env and config were not set?

@honwen
Copy link
Author

honwen commented May 23, 2023

no longer requeried

#427

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.

3 participants