// 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.rules.android;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.AliasProvider;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.BuiltinProvider;
import com.google.devtools.build.lib.packages.NativeInfo;
import com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper;
import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import com.google.devtools.build.lib.rules.config.ConfigFeatureFlag;
import com.google.devtools.build.lib.skylarkbuildapi.android.AndroidFeatureFlagSetProviderApi;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import java.util.Map;
/**
* Provider for checking the set of feature flags used by an android_binary.
*
*
Because the feature flags are completely replaced by android_binary, android_test uses this
* provider to ensure that the test sets the same flags as the binary. Otherwise, the dependencies
* of the android_test will be compiled with different flags from the android_binary code which runs
* in the same Android virtual machine, which may cause compatibility issues at runtime.
*/
@Immutable
public final class AndroidFeatureFlagSetProvider extends NativeInfo
implements AndroidFeatureFlagSetProviderApi {
public static final String PROVIDER_NAME = "AndroidFeatureFlagSetProvider";
public static final Provider PROVIDER = new Provider();
/** The name of the attribute used by Android rules to set config_feature_flags. */
public static final String FEATURE_FLAG_ATTR = "feature_flags";
private final Optional> flags;
AndroidFeatureFlagSetProvider(Optional extends Map