diff options
Diffstat (limited to 'src/main/java/com')
3 files changed, 72 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index ceb0f5b6b9..b1dd9fdb81 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -653,6 +653,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/rules/objc", "//src/main/java/com/google/devtools/build/lib/rules/platform", "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", + "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android", "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/apple", "//src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp", "//src/main/java/com/google/devtools/build/lib/vfs", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java index ed94e47f78..da9a0f32b8 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java @@ -92,6 +92,7 @@ import com.google.devtools.build.lib.rules.repository.CoreWorkspaceRules; import com.google.devtools.build.lib.rules.repository.NewLocalRepositoryRule; import com.google.devtools.build.lib.rules.test.TestingSupportRules; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; +import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidBootstrap; import com.google.devtools.build.lib.util.OS; import com.google.devtools.build.lib.util.ResourceFileLoader; import com.google.devtools.build.lib.vfs.PathFragment; @@ -308,16 +309,15 @@ public class BazelRuleClassProvider { builder.addRuleDefinition(new AndroidDeviceScriptFixtureRule()); builder.addRuleDefinition(new AndroidHostServiceFixtureRule()); - builder.addSkylarkAccessibleTopLevels("android_common", new AndroidSkylarkCommon()); - builder.addSkylarkAccessibleTopLevels(ApkInfo.NAME, ApkInfo.PROVIDER); - builder.addSkylarkAccessibleTopLevels( - AndroidInstrumentationInfo.NAME, AndroidInstrumentationInfo.PROVIDER); - builder.addSkylarkAccessibleTopLevels( - AndroidDeviceBrokerInfo.NAME, AndroidDeviceBrokerInfo.PROVIDER); - builder.addSkylarkAccessibleTopLevels( - AndroidResourcesInfo.NAME, AndroidResourcesInfo.PROVIDER); - builder.addSkylarkAccessibleTopLevels( - AndroidNativeLibsInfo.NAME, AndroidNativeLibsInfo.PROVIDER); + AndroidBootstrap bootstrap = + new AndroidBootstrap( + new AndroidSkylarkCommon(), + ApkInfo.PROVIDER, + AndroidInstrumentationInfo.PROVIDER, + AndroidDeviceBrokerInfo.PROVIDER, + AndroidResourcesInfo.PROVIDER, + AndroidNativeLibsInfo.PROVIDER); + builder.addSkylarkBootstrap(bootstrap); try { builder.addWorkspaceFilePrefix( diff --git a/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidBootstrap.java b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidBootstrap.java new file mode 100644 index 0000000000..7eb708d3e7 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/android/AndroidBootstrap.java @@ -0,0 +1,61 @@ +// Copyright 2018 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.android; + +import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.skylarkbuildapi.Bootstrap; +import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidDeviceBrokerInfoApi.AndroidDeviceBrokerInfoApiProvider; +import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidInstrumentationInfoApi.AndroidInstrumentationInfoApiProvider; +import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidNativeLibsInfoApi.AndroidNativeLibsInfoApiProvider; +import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidResourcesInfoApi.AndroidResourcesInfoApiProvider; +import com.google.devtools.build.lib.skylarkbuildapi.android.ApkInfoApi.ApkInfoApiProvider; + +/** + * {@link Bootstrap} for skylark objects related to Android rules. + */ +public class AndroidBootstrap implements Bootstrap { + + private final AndroidSkylarkCommonApi<?> androidCommon; + private final ApkInfoApiProvider apkInfoProvider; + private final AndroidInstrumentationInfoApiProvider<?> androidInstrumentationInfoProvider; + private final AndroidDeviceBrokerInfoApiProvider androidDeviceBrokerInfoProvider; + private final AndroidResourcesInfoApiProvider androidResourcesInfoProvider; + private final AndroidNativeLibsInfoApiProvider androidNativeLibsInfoProvider; + + public AndroidBootstrap( + AndroidSkylarkCommonApi<?> androidCommon, + ApkInfoApiProvider apkInfoProvider, + AndroidInstrumentationInfoApiProvider<?> androidInstrumentationInfoProvider, + AndroidDeviceBrokerInfoApiProvider androidDeviceBrokerInfoProvider, + AndroidResourcesInfoApiProvider androidResourcesInfoProvider, + AndroidNativeLibsInfoApiProvider androidNativeLibsInfoProvider) { + this.androidCommon = androidCommon; + this.apkInfoProvider = apkInfoProvider; + this.androidInstrumentationInfoProvider = androidInstrumentationInfoProvider; + this.androidDeviceBrokerInfoProvider = androidDeviceBrokerInfoProvider; + this.androidResourcesInfoProvider = androidResourcesInfoProvider; + this.androidNativeLibsInfoProvider = androidNativeLibsInfoProvider; + } + + @Override + public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) { + builder.put("android_common", androidCommon); + builder.put(ApkInfoApi.NAME, apkInfoProvider); + builder.put(AndroidInstrumentationInfoApi.NAME, androidInstrumentationInfoProvider); + builder.put(AndroidDeviceBrokerInfoApi.NAME, androidDeviceBrokerInfoProvider); + builder.put(AndroidResourcesInfoApi.NAME, androidResourcesInfoProvider); + builder.put(AndroidNativeLibsInfoApi.NAME, androidNativeLibsInfoProvider); + } +} |