Deprecate DATA_CFG and HOST_CFG, use string 'data' and 'host' instead.

--
MOS_MIGRATED_REVID=126572660
diff --git a/site/docs/skylark/cookbook.md b/site/docs/skylark/cookbook.md
index 3a5430a..e243396 100644
--- a/site/docs/skylark/cookbook.md
+++ b/site/docs/skylark/cookbook.md
@@ -438,7 +438,7 @@
 execute = rule(
   implementation=_impl,
   attrs={
-      "binary": attr.label(cfg=HOST_CFG, mandatory=True, allow_files=True,
+      "binary": attr.label(cfg="host", mandatory=True, allow_files=True,
                            executable=True),
       "input_content": attr.string(),
       "out": attr.output(mandatory=True),
@@ -497,7 +497,7 @@
   executable=True,
   attrs={
       "command": attr.string(),
-      "data": attr.label_list(cfg=DATA_CFG, allow_files=True),
+      "data": attr.label_list(cfg="data", allow_files=True),
       },
 )
 ```
diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md
index 860dce7..34c9cda 100644
--- a/site/docs/skylark/rules.md
+++ b/site/docs/skylark/rules.md
@@ -260,11 +260,11 @@
 runtime can use the same configuration.
 
 Tools that are executed as part of the build (e.g., compilers, code generators)
-should be built for the host configuration. In this case, specify `cfg=HOST_CFG`
+should be built for the host configuration. In this case, specify `cfg="host"`
 in the attribute.
 
-`DATA_CFG` is present for legacy reasons and should be used for `data`
-attributes.
+The configuration `"data"` is present for legacy reasons and should be used for
+the `data` attributes.
 
 
 ## <a name="fragments"></a> Configuration Fragments
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkAttr.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkAttr.java
index 5b0fd57..b1e627d 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkAttr.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkAttr.java
@@ -87,7 +87,7 @@
 
   private static final String CONFIGURATION_ARG = "cfg";
   private static final String CONFIGURATION_DOC =
-      "configuration of the attribute. For example, use DATA_CFG or HOST_CFG.";
+      "configuration of the attribute. It can be either \"data\" or \"host\".";
 
   private static final String DEFAULT_ARG = "default";
   private static final String DEFAULT_DOC = "the default value of the attribute.";
@@ -219,7 +219,17 @@
     }
 
     if (containsNonNoneKey(arguments, CONFIGURATION_ARG)) {
-      builder.cfg((ConfigurationTransition) arguments.get(CONFIGURATION_ARG));
+      Object trans = arguments.get(CONFIGURATION_ARG);
+      if (trans instanceof ConfigurationTransition) {
+        // TODO(laurentlb): Deprecated, to be removed in August 2016.
+        builder.cfg((ConfigurationTransition) trans);
+      } else if (trans.equals("data")) {
+        builder.cfg(ConfigurationTransition.DATA);
+      } else if (trans.equals("host")) {
+        builder.cfg(ConfigurationTransition.HOST);
+      } else {
+        throw new EvalException(ast.getLocation(), "cfg must be either 'data' or 'host'.");
+      }
     }
     return builder;
   }
@@ -474,7 +484,7 @@
       ),
       @Param(
         name = CONFIGURATION_ARG,
-        type = ConfigurationTransition.class,
+        type = Object.class,
         noneable = true,
         defaultValue = "None",
         named = true,
@@ -691,7 +701,7 @@
       ),
       @Param(
         name = CONFIGURATION_ARG,
-        type = ConfigurationTransition.class,
+        type = Object.class,
         noneable = true,
         defaultValue = "None",
         named = true,
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
index 400af91..c7c8b01 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java
@@ -99,13 +99,22 @@
  */
 public class SkylarkRuleClassFunctions {
 
-  //TODO(bazel-team): proper enum support
-  @SkylarkSignature(name = "DATA_CFG", returnType = ConfigurationTransition.class,
-      doc = "Experimental. Specifies a transition to the data configuration.")
+  @SkylarkSignature(
+    name = "DATA_CFG",
+    returnType = ConfigurationTransition.class,
+    doc =
+        "Deprecated. Use string \"data\" instead. "
+            + "Specifies a transition to the data configuration."
+  )
   private static final Object dataTransition = ConfigurationTransition.DATA;
 
-  @SkylarkSignature(name = "HOST_CFG", returnType = ConfigurationTransition.class,
-      doc = "Specifies a transition to the host configuration.")
+  @SkylarkSignature(
+    name = "HOST_CFG",
+    returnType = ConfigurationTransition.class,
+    doc =
+        "Deprecated. Use string \"host\" instead. "
+            + "Specifies a transition to the host configuration."
+  )
   private static final Object hostTransition = ConfigurationTransition.HOST;
 
   // TODO(bazel-team): Copied from ConfiguredRuleClassProvider for the transition from built-in
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index 78ced6c..0716654 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -375,13 +375,27 @@
   }
 
   @Test
-  public void testAttrCfg() throws Exception {
+  public void testAttrCfg_deprecated() throws Exception {
     Attribute attr = evalAttributeDefinition("attr.label(cfg = HOST_CFG, allow_files = True)")
         .build("a1");
     assertEquals(ConfigurationTransition.HOST, attr.getConfigurationTransition());
   }
 
   @Test
+  public void testAttrCfg() throws Exception {
+    Attribute attr = evalAttributeDefinition("attr.label(cfg = 'host', allow_files = True)")
+        .build("a1");
+    assertEquals(ConfigurationTransition.HOST, attr.getConfigurationTransition());
+  }
+
+  @Test
+  public void testAttrCfgData() throws Exception {
+    Attribute attr = evalAttributeDefinition("attr.label(cfg = 'data', allow_files = True)")
+        .build("a1");
+    assertEquals(ConfigurationTransition.DATA, attr.getConfigurationTransition());
+  }
+
+  @Test
   public void testAttrValues() throws Exception {
     Attribute attr = evalAttributeDefinition("attr.string(values = ['ab', 'cd'])").build("a1");
     PredicateWithMessage<Object> predicate = attr.getAllowedValues();