aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-03-20 15:08:24 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-03-23 11:51:25 +0000
commitf02655fec3fdfe9a784d287fff53b886d91bae1c (patch)
tree7d6daa1bd5ac8b414692896ce553f0d073a6d923 /src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java
parentc4cf9130e83b731becb287e898faf758c753f40a (diff)
Initial checkin of Python rules into Bazel.
-- MOS_MIGRATED_REVID=89123900
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java
new file mode 100644
index 0000000000..863c3ee76d
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java
@@ -0,0 +1,62 @@
+// Copyright 2014 Google Inc. 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.python;
+
+import com.google.devtools.build.lib.analysis.RuleContext;
+import com.google.devtools.build.lib.analysis.Runfiles;
+import com.google.devtools.build.lib.analysis.RunfilesSupport;
+import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
+import com.google.devtools.build.lib.rules.test.InstrumentedFilesCollector.InstrumentationSpec;
+
+/**
+ * Pluggable semantics for Python rules.
+ *
+ * <p>A new instance of this class is created for each configured target, therefore, it is allowed
+ * to keep state.
+ */
+public interface PythonSemantics {
+ /**
+ * Called at the beginning of the analysis of {@code py_binary} rules to validate its attributes.
+ */
+ void validate(RuleContext ruleContext, PyCommon common);
+
+ /**
+ * Extends for the default and data runfiles of {@code py_binary} rules with custom elements.
+ */
+ void collectRunfilesForBinary(RuleContext ruleContext, Runfiles.Builder builder, PyCommon common);
+
+ /**
+ * Extends the default runfiles of {@code py_binary} rules with custom elements.
+ */
+ void collectDefaultRunfilesForBinary(RuleContext ruleContext, Runfiles.Builder builder);
+
+ /**
+ * Returns the coverage instrumentation specification to be used in Python rules.
+ */
+ InstrumentationSpec getCoverageInstrumentationSpec();
+
+ /**
+ * Create the actual executable artifact.
+ *
+ * <p>This should create a generating action for {@code common.getExecutable()}.
+ */
+ void createExecutable(RuleContext ruleContext, PyCommon common,
+ CcLinkParamsStore ccLinkParamsStore);
+
+ /**
+ * Called at the end of the analysis of {@code py_binary} rules.
+ */
+ void postInitBinary(RuleContext ruleContext, RunfilesSupport runfilesSupport,
+ PyCommon common);
+} \ No newline at end of file