Add infrastructure to support PythonBinary
Add a new request type with its own StarLark function
Hook it up via GetPythonBinary
Add to MockBazelContext a LabelToPythonBinary
Add a test for the new request type
Test: request_type_test.go:TestGetPythonBinaryParseResults
Change-Id: I05f6506adfbbdac8b3f40475509ed02ab8e844e5
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index b272daa..0e7c944 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -80,6 +80,9 @@
// Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order).
GetCcInfo(label string, archType ArchType) (cquery.CcInfo, bool, error)
+ // Returns the executable binary resultant from building together the python sources
+ GetPythonBinary(label string, archType ArchType) (string, bool)
+
// ** End cquery methods
// Issues commands to Bazel to receive results for all cquery requests
@@ -134,8 +137,9 @@
type MockBazelContext struct {
OutputBaseDir string
- LabelToOutputFiles map[string][]string
- LabelToCcInfo map[string]cquery.CcInfo
+ LabelToOutputFiles map[string][]string
+ LabelToCcInfo map[string]cquery.CcInfo
+ LabelToPythonBinary map[string]string
}
func (m MockBazelContext) GetOutputFiles(label string, archType ArchType) ([]string, bool) {
@@ -148,6 +152,11 @@
return result, ok, nil
}
+func (m MockBazelContext) GetPythonBinary(label string, archType ArchType) (string, bool) {
+ result, ok := m.LabelToPythonBinary[label]
+ return result, ok
+}
+
func (m MockBazelContext) InvokeBazel() error {
panic("unimplemented")
}
@@ -185,6 +194,16 @@
return ret, ok, err
}
+func (bazelCtx *bazelContext) GetPythonBinary(label string, archType ArchType) (string, bool) {
+ rawString, ok := bazelCtx.cquery(label, cquery.GetPythonBinary, archType)
+ var ret string
+ if ok {
+ bazelOutput := strings.TrimSpace(rawString)
+ ret = cquery.GetPythonBinary.ParseResult(bazelOutput)
+ }
+ return ret, ok
+}
+
func (n noopBazelContext) GetOutputFiles(label string, archType ArchType) ([]string, bool) {
panic("unimplemented")
}
@@ -193,6 +212,10 @@
panic("unimplemented")
}
+func (n noopBazelContext) GetPythonBinary(label string, archType ArchType) (string, bool) {
+ panic("unimplemented")
+}
+
func (n noopBazelContext) GetPrebuiltCcStaticLibraryFiles(label string, archType ArchType) ([]string, bool) {
panic("unimplemented")
}