aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorNan Zhang <nanzhang@google.com>2018-05-31 12:49:33 -0700
committerNan Zhang <nanzhang@google.com>2018-06-04 12:32:55 -0700
commitbea0975f1882a8741dc3e9abe2bd69f7067953db (patch)
treec561f9cb883ba11a31a69e5a02f735d4d9a926d9 /python
parent1d2318d6cd9b7f64178afb4e3a8ce481dd603bbf (diff)
downloadbuild_soong-bea0975f1882a8741dc3e9abe2bd69f7067953db.tar.gz
build_soong-bea0975f1882a8741dc3e9abe2bd69f7067953db.tar.bz2
build_soong-bea0975f1882a8741dc3e9abe2bd69f7067953db.zip
Fix embedded_launcher can't find files
The problem came from Python libraries doesn't know the information that we enabled embedded_launcher (only Python binary knows about that). And we can't simply remove runfiles dir for Python libraries since host Python mode need this. Bug: b/80441699 Test: m perf_profo_flames Change-Id: I73ffc4d7504f95a708ae7cca47bc6c15a673aa31
Diffstat (limited to 'python')
-rw-r--r--python/builder.go7
-rw-r--r--python/python.go18
-rw-r--r--python/python_test.go18
-rw-r--r--python/scripts/stub_template_host.txt5
4 files changed, 15 insertions, 33 deletions
diff --git a/python/builder.go b/python/builder.go
index 969f9efd..ec4cb4ea 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -96,11 +96,8 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embeddedLauncher b
Output: binFile,
Implicits: implicits,
Args: map[string]string{
- "interp": strings.Replace(interpreter, "/", `\/`, -1),
- // we need remove "runfiles/" suffix since stub script starts
- // searching for main file in each sub-dir of "runfiles" directory tree.
- "main": strings.Replace(strings.TrimPrefix(main, runFiles+"/"),
- "/", `\/`, -1),
+ "interp": strings.Replace(interpreter, "/", `\/`, -1),
+ "main": strings.Replace(main, "/", `\/`, -1),
"template": template.String(),
"stub": stub,
"mergedZip": mergedZip.String(),
diff --git a/python/python.go b/python/python.go
index 6d6ac27b..4b9111f3 100644
--- a/python/python.go
+++ b/python/python.go
@@ -63,8 +63,7 @@ type BaseProperties struct {
// files of the current module.
// eg. Pkg_path = "a/b/c"; Other packages can reference this module by using
// (from a.b.c import ...) statement.
- // if left unspecified, all the source/data files of current module are copied to
- // "runfiles/" tree directory directly.
+ // if left unspecified, all the source/data files path is unchanged within zip file.
Pkg_path *string `android:"arch_variant"`
// true, if the Python module is used internally, eg, Python std libs.
@@ -215,7 +214,6 @@ var (
mainFileName = "__main__.py"
entryPointFile = "entry_point.txt"
parFileExt = ".zip"
- runFiles = "runfiles"
internal = "internal"
)
@@ -417,23 +415,11 @@ func (p *Module) GeneratePythonBuildActions(ctx android.ModuleContext) {
return
}
if p.properties.Is_internal != nil && *p.properties.Is_internal {
- // pkg_path starts from "internal/" implicitly.
pkgPath = filepath.Join(internal, pkgPath)
- } else {
- if !p.isEmbeddedLauncherEnabled(p.properties.Actual_version) {
- // pkg_path starts from "runfiles/" implicitly.
- pkgPath = filepath.Join(runFiles, pkgPath)
- }
}
} else {
if p.properties.Is_internal != nil && *p.properties.Is_internal {
- // pkg_path starts from "runfiles/" implicitly.
pkgPath = internal
- } else {
- if !p.isEmbeddedLauncherEnabled(p.properties.Actual_version) {
- // pkg_path starts from "runfiles/" implicitly.
- pkgPath = runFiles
- }
}
}
@@ -620,7 +606,7 @@ func (p *Module) walkTransitiveDeps(ctx android.ModuleContext) {
func fillInMap(ctx android.ModuleContext, m map[string]string,
key, value, curModule, otherModule string) bool {
if oldValue, found := m[key]; found {
- ctx.ModuleErrorf("found two files to be placed at the same runfiles location %q."+
+ ctx.ModuleErrorf("found two files to be placed at the same location within zip %q."+
" First file: in module %s at path %q."+
" Second file: in module %s at path %q.",
key, curModule, oldValue, otherModule, value)
diff --git a/python/python_test.go b/python/python_test.go
index 60a1c82a..e5fe126c 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -44,7 +44,7 @@ var (
badIdentifierErrTemplate = moduleVariantErrTemplate +
"srcs: the path %q contains invalid token %q."
dupRunfileErrTemplate = moduleVariantErrTemplate +
- "found two files to be placed at the same runfiles location %q." +
+ "found two files to be placed at the same location within zip %q." +
" First file: in module %s at path %q." +
" Second file: in module %s at path %q."
noSrcFileErr = moduleVariantErrTemplate + "doesn't have any source files!"
@@ -175,11 +175,11 @@ var (
},
errors: []string{
fmt.Sprintf(badIdentifierErrTemplate, "dir/Blueprints:4:11",
- "lib1", "PY3", "runfiles/a/b/c/-e/f/file1.py", "-e"),
+ "lib1", "PY3", "a/b/c/-e/f/file1.py", "-e"),
fmt.Sprintf(badIdentifierErrTemplate, "dir/Blueprints:4:11",
- "lib1", "PY3", "runfiles/a/b/c/.file1.py", ".file1"),
+ "lib1", "PY3", "a/b/c/.file1.py", ".file1"),
fmt.Sprintf(badIdentifierErrTemplate, "dir/Blueprints:4:11",
- "lib1", "PY3", "runfiles/a/b/c/123/file1.py", "123"),
+ "lib1", "PY3", "a/b/c/123/file1.py", "123"),
},
},
{
@@ -212,7 +212,7 @@ var (
},
errors: []string{
fmt.Sprintf(dupRunfileErrTemplate, "dir/Blueprints:9:6",
- "lib2", "PY3", "runfiles/a/b/c/file1.py", "lib2", "dir/file1.py",
+ "lib2", "PY3", "a/b/c/file1.py", "lib2", "dir/file1.py",
"lib1", "dir/c/file1.py"),
},
},
@@ -307,10 +307,10 @@ var (
name: "bin",
actualVersion: "PY3",
pyRunfiles: []string{
- "runfiles/e/default.py",
- "runfiles/e/bin.py",
- "runfiles/e/default_py3.py",
- "runfiles/e/file4.py",
+ "e/default.py",
+ "e/bin.py",
+ "e/default_py3.py",
+ "e/file4.py",
},
srcsZip: "@prefix@/.intermediates/dir/bin/PY3/bin.py.srcszip",
depsSrcsZips: []string{
diff --git a/python/scripts/stub_template_host.txt b/python/scripts/stub_template_host.txt
index 386298eb..e6862114 100644
--- a/python/scripts/stub_template_host.txt
+++ b/python/scripts/stub_template_host.txt
@@ -11,7 +11,6 @@ import zipfile
PYTHON_BINARY = '%interpreter%'
MAIN_FILE = '%main%'
PYTHON_PATH = 'PYTHONPATH'
-ZIP_RUNFILES_DIRECTORY_NAME = 'runfiles'
def SearchPathEnv(name):
search_path = os.getenv('PATH', os.defpath).split(os.pathsep)
@@ -36,7 +35,7 @@ def ExtractRunfiles():
temp_dir = tempfile.mkdtemp("", "Soong.python_")
zf = zipfile.ZipFile(os.path.dirname(__file__))
zf.extractall(temp_dir)
- return os.path.join(temp_dir, ZIP_RUNFILES_DIRECTORY_NAME)
+ return temp_dir
def Main():
args = sys.argv[1:]
@@ -83,7 +82,7 @@ def Main():
except:
raise
finally:
- shutil.rmtree(os.path.dirname(runfiles_path), True)
+ shutil.rmtree(runfiles_path, True)
if __name__ == '__main__':
Main()