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

Add BAZEL_SKIP_XCODE_FETCH to reduce toolchain configuration time #191

Conversation

keith
Copy link
Member

@keith keith commented Feb 15, 2023

Since this toolchain requires Xcode, running xcode_locator during
toolchain setup is potentially duplicative. The only things it's used
for is to check that they exist, and to add to the allowed include
directories. The include directories already includes /Applications
which is where most people likely have Xcode installed, so as long
as that can be relied on, fetching these values isn't necessary. This
saves a few seconds when the toolchain is reconfigured.

https://bazelbuild.slack.com/archives/CD3QY5C2X/p1652819625121889

Since this toolchain requires Xcode, running xcode_locator during
toolchain setup is potentially duplicative. The only things it's used
for is to check that they exist, and to add to the allowed include
directories. The include directories already includes `/Applications`
which is where _most_ people likely have Xcode installed, so as long
as that can be relied on, fetching these values isn't necessary. This
saves a few seconds when the toolchain is reconfigured.

https://bazelbuild.slack.com/archives/CD3QY5C2X/p1652819625121889
@keith keith force-pushed the ks/add-bazel_skip_xcode_fetch-to-reduce-toolchain-configuration-time branch from 5a46fc6 to c5dc29e Compare February 15, 2023 17:41
brentleyjones
brentleyjones previously approved these changes Feb 15, 2023
@keith
Copy link
Member Author

keith commented Feb 15, 2023

maybe instead of this we should flip this around and do an env var if you want to allow Xcode versions outside of /Applications. i think that if you had one somewhere else and we didn't do the logic we're doing here to add it to the include paths, bazel would catch it for undeclared header inclusions

@keith
Copy link
Member Author

keith commented Feb 16, 2023

here's what that would look like #197

(xcode_toolchains, xcodeloc_err) = run_xcode_locator(repository_ctx, xcode_locator)
if not xcode_toolchains:
return False
skip_xcode_fetch = "BAZEL_SKIP_XCODE_FETCH" in repository_ctx.os.environ and repository_ctx.os.environ["BAZEL_SKIP_XCODE_FETCH"] == "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about using bool to evaluate the environment variable value? It allows folks to pick their favorite representation.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is what the upstream CC toolchain vars enforce so I figure we might as well keep the same behavior

@cgrindel
Copy link
Contributor

The one upside to this implementation vs #197. It may seem like a more understandable change in behavior for those who run into it. Of course, folks have to opt into the benefit. Perhaps, we can recommend that it be enabled in the useful flags doc.

@keith
Copy link
Member Author

keith commented Mar 1, 2023

going with #197 in the spirit of trying to have the right defaults

@keith keith closed this Mar 1, 2023
@keith keith deleted the ks/add-bazel_skip_xcode_fetch-to-reduce-toolchain-configuration-time branch March 1, 2023 23:19
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