Skip to content

Commit 8f8ce57

Browse files
committed
Move simpleperf_report_lib to the scripts folder
When soong packages python files into a zip file, it will take their path relative to the Android.bp file and preserve that relative path in the zip file. Then the root directory of the zip file is added to the PYTHONPATH. Currently, all subdirectories of the top level zip directory are also added to the PYTHONPATH, but we want to remove this. Since simpleperf_report_lib was being added to the zip file under scripts/simpleperf_report_lib, "import simpleperf_report_lib" works currectly, but won't work after the PYTHONPATH changes (you'd have to say "import scripts.simpleperf_report_lib"). To fix this, move the Android.bp file for simpleperf_report_lib into the scripts folder, so the relative paths don't contain scripts/. Soong python modules do have a pkg_path attribute, which essentially adds more folders to the relative path, but we would need an attribute that removes them, which doesn't exist. This could also be done with a filegroup with the "path" attribute, but bp2build doesn't support that, so I opted to go with this option instead. Bug: 245583294 Test: Presubmits Change-Id: Icd13fecc249033cdf1a12c97c7e4bd7db207191f
1 parent 05933fa commit 8f8ce57

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

simpleperf/Android.bp

-13
Original file line numberDiff line numberDiff line change
@@ -709,19 +709,6 @@ cc_test {
709709
},
710710
}
711711

712-
python_library_host {
713-
name: "simpleperf_report_lib",
714-
srcs: [
715-
"scripts/simpleperf_report_lib.py",
716-
"scripts/simpleperf_utils.py",
717-
],
718-
data: [
719-
"scripts/bin/darwin/x86_64/libsimpleperf_report.dylib",
720-
"scripts/bin/linux/x86_64/libsimpleperf_report.so",
721-
"scripts/bin/windows/**/*.dll",
722-
],
723-
}
724-
725712
filegroup {
726713
name: "system-extras-simpleperf-testdata",
727714
srcs: ["CtsSimpleperfTestCases_testdata/**/*"],

simpleperf/scripts/Android.bp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright (C) 2022 The Android Open Source Project
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
python_library_host {
18+
name: "simpleperf_report_lib",
19+
srcs: [
20+
"simpleperf_report_lib.py",
21+
"simpleperf_utils.py",
22+
],
23+
data: [
24+
"bin/darwin/x86_64/libsimpleperf_report.dylib",
25+
"bin/linux/x86_64/libsimpleperf_report.so",
26+
"bin/windows/**/*.dll",
27+
],
28+
}

0 commit comments

Comments
 (0)