diff options
author | Nan Zhang <nanzhang@google.com> | 2017-11-15 17:59:56 -0800 |
---|---|---|
committer | Nan Zhang <nanzhang@google.com> | 2017-11-30 13:55:49 -0800 |
commit | 3bba05962dc4329c6e3d28544775db591574ba7b (patch) | |
tree | 8ebc182125ea5934c824a583c07b123ffa1010f7 /python/installer.go | |
parent | e261615792dbe84250fea54c26ca7972293d23c6 (diff) | |
download | build_soong-3bba05962dc4329c6e3d28544775db591574ba7b.tar.gz build_soong-3bba05962dc4329c6e3d28544775db591574ba7b.tar.bz2 build_soong-3bba05962dc4329c6e3d28544775db591574ba7b.zip |
Change Python in Soong to support device side build.
Add python_test to generate executables for both host and device side.
And change python_library_host to python_library.
installation for python device test will be under
target/product/generic_arm[64]/data/nativetest[64].
Bug: b/69114465
Test: m clean && m -j
Device Test:
adb root; adb push nan_devicetest /data;
adb shell; ./nan_devicetest
print(sys.path)
['/data/nan_devicetest/runfiles', '/data/nan_devicetest', '/data/nan_devicetest/internal', '/data/nan_devicetest/internal/stdlib']
Change-Id: If8317070a3aa1b6dab2e84b8df2d037f495d7247
Diffstat (limited to 'python/installer.go')
-rw-r--r-- | python/installer.go | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/python/installer.go b/python/installer.go index 04698c55..ab3d9b4a 100644 --- a/python/installer.go +++ b/python/installer.go @@ -15,26 +15,47 @@ package python import ( + "path/filepath" + "android/soong/android" ) // This file handles installing python executables into their final location +type installLocation int + +const ( + InstallInData installLocation = iota +) + type pythonInstaller struct { - dir string + dir string + dir64 string + relative string path android.OutputPath } -func NewPythonInstaller(dir string) *pythonInstaller { +func NewPythonInstaller(dir, dir64 string) *pythonInstaller { return &pythonInstaller{ - dir: dir, + dir: dir, + dir64: dir64, } } var _ installer = (*pythonInstaller)(nil) +func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.OutputPath { + dir := installer.dir + if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" { + dir = installer.dir64 + } + if !ctx.Host() && !ctx.Arch().Native { + dir = filepath.Join(dir, ctx.Arch().ArchType.String()) + } + return android.PathForModuleInstall(ctx, dir, installer.relative) +} + func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) { - installer.path = ctx.InstallFile(android.PathForModuleInstall(ctx, installer.dir), - file.Base(), file) + installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file) } |