| commit | 9db98c4f0a0f6d81e0981a6ab2359e7c52f8c255 | [log] [tgz] |
|---|---|---|
| author | brandjon <brandjon@google.com> | Mon Aug 24 08:43:55 2020 -0700 |
| committer | Copybara-Service <copybara-worker@google.com> | Mon Aug 24 08:45:07 2020 -0700 |
| tree | 4263bc52ace1595359e01bb0b8c70668bcd4a29d | |
| parent | 0421129e5663346a88d45b873b7bf093f17eeb5e [diff] |
Customize the builtins bzl environment This makes @builtins bzls able to load a new "_internal" module that will hold features not accessible to ordinary bzls. In particular, this will include the "original" native module field values before they get optionally replaced by builtins injection, as well as a view of the current StarlarkSemantics flags. This changes also makes @builtins bzls unable to access the top-level "native" object; we will soon also prohibit direct access to other top-level rule logic symbols like CcInfo. (Rationale: These are the very symbols that @builtins bzls are helping to define for ordinary users. It would be confusing if regular bzls and @builtins bzls attached different meanings to the same names.) To enable this change, ASTFileLookupFunction now retrieves the predeclared environment from PackageFactory using similar methods as BzlLoadFunction, instead of blindly applying the same environment to all bzls. As it turns out, ASTFileLookupFunction doesn't need access to the injected environment since builtins injection only changes the definitions of symbols, not whether or not the symbol exists at all. Therefore ASTFileLookupFunction doesn't need to request StarlarkBuiltinsValue from Skyframe. A new builtins ASTFileLookupValue key type is created, and it is wired into the corresponding key type for BzlLoadValue (getASTKey()). BuiltinsInjectionTest: - Renamed some test cases to eliminate boilerplate prefix - Split the test that @builtins bzls can't access stuff into two cases: "native", and rule logic symbols like CcInfo. The latter isn't implemented yet, so its assertions will be flipped. - Rename "builtins_dummy.bzl" in test case for consistency with other test cases; simplify exports.bzl to remove irrelevant setup in a test case - Add tests that @builtins bzls can access _internal and ordinary bzls can't Drive-bys: Rename a test case in BzlLoadFunctionTest for clarity. Add @Nullable to an override in Module.java where the parent method already has it. Word toward #11437. RELNOTES: None PiperOrigin-RevId: 328146383
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
See CONTRIBUTING.md