From 6b49888a17d4d00ea539d62ceb9b940f2d487f5f Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Tue, 23 May 2023 17:55:47 +0000 Subject: [PATCH] Remove GetPythonBinary request type This has been dead code for over a year. Fixes: 232976601 Test: m nothing Change-Id: Ida305fc8fa61d8ac83d74ea2cf007073a0019cec --- android/bazel_handler.go | 25 ------------------------- bazel/cquery/request_type.go | 28 ---------------------------- bazel/cquery/request_type_test.go | 28 ---------------------------- 3 files changed, 81 deletions(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 10cf60a0a..3f645b234 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -183,10 +183,6 @@ type BazelContext interface { // Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order). GetCcInfo(label string, cfgKey configKey) (cquery.CcInfo, error) - // Returns the executable binary resultant from building together the python sources - // TODO(b/232976601): Remove. - GetPythonBinary(label string, cfgKey configKey) (string, error) - // Returns the results of the GetApexInfo query (including output files) GetApexInfo(label string, cfgkey configKey) (cquery.ApexInfo, error) @@ -315,14 +311,6 @@ func (m MockBazelContext) GetCcInfo(label string, cfgKey configKey) (cquery.CcIn return result, nil } -func (m MockBazelContext) GetPythonBinary(label string, _ configKey) (string, error) { - result, ok := m.LabelToPythonBinary[label] - if !ok { - return "", fmt.Errorf("no target with label %q in LabelToPythonBinary", label) - } - return result, nil -} - func (m MockBazelContext) GetApexInfo(label string, _ configKey) (cquery.ApexInfo, error) { result, ok := m.LabelToApexInfo[label] if !ok { @@ -431,15 +419,6 @@ func (bazelCtx *mixedBuildBazelContext) GetCcInfo(label string, cfgKey configKey return cquery.CcInfo{}, fmt.Errorf("no bazel response found for %v", key) } -func (bazelCtx *mixedBuildBazelContext) GetPythonBinary(label string, cfgKey configKey) (string, error) { - key := makeCqueryKey(label, cquery.GetPythonBinary, cfgKey) - if rawString, ok := bazelCtx.results[key]; ok { - bazelOutput := strings.TrimSpace(rawString) - return cquery.GetPythonBinary.ParseResult(bazelOutput), nil - } - return "", fmt.Errorf("no bazel response found for %v", key) -} - func (bazelCtx *mixedBuildBazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) { key := makeCqueryKey(label, cquery.GetApexInfo, cfgKey) if rawString, ok := bazelCtx.results[key]; ok { @@ -468,10 +447,6 @@ func (n noopBazelContext) GetCcInfo(_ string, _ configKey) (cquery.CcInfo, error panic("unimplemented") } -func (n noopBazelContext) GetPythonBinary(_ string, _ configKey) (string, error) { - panic("unimplemented") -} - func (n noopBazelContext) GetApexInfo(_ string, _ configKey) (cquery.ApexInfo, error) { panic("unimplemented") } diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go index 6a3b3c82c..ca96f2339 100644 --- a/bazel/cquery/request_type.go +++ b/bazel/cquery/request_type.go @@ -8,7 +8,6 @@ import ( var ( GetOutputFiles = &getOutputFilesRequestType{} - GetPythonBinary = &getPythonBinaryRequestType{} GetCcInfo = &getCcInfoType{} GetApexInfo = &getApexInfoType{} GetCcUnstrippedInfo = &getCcUnstrippedInfoType{} @@ -45,8 +44,6 @@ type CcInfo struct { type getOutputFilesRequestType struct{} -type getPythonBinaryRequestType struct{} - // Name returns a string name for this request type. Such request type names must be unique, // and must only consist of alphanumeric characters. func (g getOutputFilesRequestType) Name() string { @@ -72,31 +69,6 @@ func (g getOutputFilesRequestType) ParseResult(rawString string) []string { return splitOrEmpty(rawString, ", ") } -// Name returns a string name for this request type. Such request type names must be unique, -// and must only consist of alphanumeric characters. -func (g getPythonBinaryRequestType) Name() string { - return "getPythonBinary" -} - -// StarlarkFunctionBody returns a starlark function body to process this request type. -// The returned string is the body of a Starlark function which obtains -// all request-relevant information about a target and returns a string containing -// this information. -// The function should have the following properties: -// - The arguments are `target` (a configured target) and `id_string` (the label + configuration). -// - The return value must be a string. -// - The function body should not be indented outside of its own scope. -func (g getPythonBinaryRequestType) StarlarkFunctionBody() string { - return "return providers(target)['FilesToRunProvider'].executable.path" -} - -// ParseResult returns a value obtained by parsing the result of the request's Starlark function. -// The given rawString must correspond to the string output which was created by evaluating the -// Starlark given in StarlarkFunctionBody. -func (g getPythonBinaryRequestType) ParseResult(rawString string) string { - return rawString -} - type getCcInfoType struct{} // Name returns a string name for this request type. Such request type names must be unique, diff --git a/bazel/cquery/request_type_test.go b/bazel/cquery/request_type_test.go index 7003ce193..e772bb7d6 100644 --- a/bazel/cquery/request_type_test.go +++ b/bazel/cquery/request_type_test.go @@ -40,34 +40,6 @@ func TestGetOutputFilesParseResults(t *testing.T) { } } -func TestGetPythonBinaryParseResults(t *testing.T) { - t.Parallel() - testCases := []struct { - description string - input string - expectedOutput string - }{ - { - description: "no result", - input: "", - expectedOutput: "", - }, - { - description: "one result", - input: "test", - expectedOutput: "test", - }, - } - for _, tc := range testCases { - t.Run(tc.description, func(t *testing.T) { - actualOutput := GetPythonBinary.ParseResult(tc.input) - if !reflect.DeepEqual(tc.expectedOutput, actualOutput) { - t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput) - } - }) - } -} - func TestGetCcInfoParseResults(t *testing.T) { t.Parallel() testCases := []struct {