aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2016-02-24 22:20:34 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-02-25 14:13:28 +0000
commit029dcc7929493f9a2c72daa8720c9ff06e003483 (patch)
treea0f48b90c0c1c1b3c9839bc83d742b802bc0e16d /src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java
parentd188735707db1d1ec969ca84d959fb8c6e716b06 (diff)
Expose Android resources in Skylark API.
Also expose functionality to calculate resource source directory from Android resource artifact. -- MOS_MIGRATED_REVID=115492705
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java
new file mode 100644
index 0000000000..1724cfa4f8
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java
@@ -0,0 +1,41 @@
+// Copyright 2016 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.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
+import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
+import com.google.devtools.build.lib.vfs.PathFragment;
+
+/**
+ * Common utilities for Skylark rules related to Android.
+ */
+@SkylarkModule(
+ name = "android_common",
+ doc = "Common utilities and fucntionality related to Android rules."
+)
+public class AndroidSkylarkCommon {
+ @SkylarkCallable(
+ name = "resource_source_directory",
+ allowReturnNones = true,
+ doc =
+ "Returns a source directory for Android resource file. "
+ + "The source directory is a prefix of resource's relative path up to "
+ + "a directory that designates resource kind (cf. "
+ + "http://developer.android.com/guide/topics/resources/providing-resources.html)."
+ )
+ public static PathFragment getSourceDirectoryRelativePathFromResource(Artifact resource) {
+ return AndroidCommon.getSourceDirectoryRelativePathFromResource(resource);
+ }
+}