diff options
author | 2018-05-01 16:08:53 -0700 | |
---|---|---|
committer | 2018-05-01 16:10:45 -0700 | |
commit | 56fbc9998858bc2084a351576b20818bb9290a73 (patch) | |
tree | 5ef8709d4185d684c552e0d2c3dfb5cccdadb0db /src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java | |
parent | 6891ebbd7b9356b8ce5f6835e3eb7acd9cf988d7 (diff) |
Migrate struct and Provider to the skylark build api
RELNOTES: None.
PiperOrigin-RevId: 195013604
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java new file mode 100644 index 0000000000..306cf97f01 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/ProviderApi.java @@ -0,0 +1,43 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.skylarkbuildapi; + +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; + +/** Interface for provider objects (constructors for {@link StructApi} objects). */ +@SkylarkModule( + name = "Provider", + doc = + "A constructor for simple value objects, known as provider instances." + + "<br>" + + "This value has a dual purpose:" + + " <ul>" + + " <li>It is a function that can be called to construct 'struct'-like values:" + + "<pre class=\"language-python\">DataInfo = provider()\n" + + "d = DataInfo(x = 2, y = 3)\n" + + "print(d.x + d.y) # prints 5</pre>" + + " Note: Some providers, defined internally, do not allow instance creation" + + " </li>" + + " <li>It is a <i>key</i> to access a provider instance on a" + + " <a href=\"Target.html\">Target</a>" + + "<pre class=\"language-python\">DataInfo = provider()\n" + + "def _rule_impl(ctx)\n" + + " ... ctx.attr.dep[DataInfo]</pre>" + + " </li>" + + " </ul>" + + "Create a new <code>Provider</code> using the " + + "<a href=\"globals.html#provider\">provider</a> function." +) +public interface ProviderApi extends SkylarkValue {} |