diff options
author | John Cater <jcater@google.com> | 2017-02-28 13:15:28 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2017-02-28 17:02:08 +0000 |
commit | 691fbc1a5fd3ab03ab6c21e6c04fa9c528bbf1ba (patch) | |
tree | 3235bb9c6a3382f40e0bf1a933a22b2967a23c69 /src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java | |
parent | 55e4c51ac76f1da3537f33536c1d2bfea15e5b93 (diff) |
Add constraint_setting and constraint_value rules, to enable defining
platform-related constraints and values.
Part of ongoing work on #2219.
--
Change-Id: Ice370ee26469f4992faf72c0c95a1a3e51a9f9e7
Reviewed-on: https://cr.bazel.build/9091
PiperOrigin-RevId: 148758190
MOS_MIGRATED_REVID=148758190
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java new file mode 100644 index 0000000000..c232c92212 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValue.java @@ -0,0 +1,48 @@ +// 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.platform; + +import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.FileProvider; +import com.google.devtools.build.lib.analysis.FilesToRunProvider; +import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; +import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; +import com.google.devtools.build.lib.analysis.RuleContext; +import com.google.devtools.build.lib.analysis.RunfilesProvider; +import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory; + +/** Defines a potential value of a constraint. */ +public class ConstraintValue implements RuleConfiguredTargetFactory { + + @Override + public ConfiguredTarget create(RuleContext ruleContext) + throws InterruptedException, RuleErrorException { + + ConstraintSettingProvider constraint = + ruleContext.getPrerequisite( + ConstraintValueRule.CONSTRAINT_SETTING_ATTR, + Mode.DONT_CHECK, + ConstraintSettingProvider.class); + + return new RuleConfiguredTargetBuilder(ruleContext) + .addProvider(RunfilesProvider.class, RunfilesProvider.EMPTY) + .addProvider(FileProvider.class, FileProvider.EMPTY) + .addProvider(FilesToRunProvider.class, FilesToRunProvider.EMPTY) + .addProvider( + ConstraintValueProvider.class, + ConstraintValueProvider.create(constraint, ruleContext.getLabel())) + .build(); + } +} |