1// Copyright 2017 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package python 16 17import ( 18 "path/filepath" 19 20 "android/soong/android" 21) 22 23// This file handles installing python executables into their final location 24 25type installLocation int 26 27const ( 28 InstallInData installLocation = iota 29) 30 31type pythonInstaller struct { 32 dir string 33 dir64 string 34 relative string 35 36 path android.InstallPath 37 38 androidMkSharedLibs []string 39} 40 41func NewPythonInstaller(dir, dir64 string) *pythonInstaller { 42 return &pythonInstaller{ 43 dir: dir, 44 dir64: dir64, 45 } 46} 47 48var _ installer = (*pythonInstaller)(nil) 49 50func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.InstallPath { 51 dir := installer.dir 52 if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" { 53 dir = installer.dir64 54 } 55 if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) { 56 dir = filepath.Join(dir, ctx.Arch().ArchType.String()) 57 } 58 return android.PathForModuleInstall(ctx, dir, installer.relative) 59} 60 61func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) { 62 installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file) 63} 64 65func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) { 66 installer.androidMkSharedLibs = sharedLibs 67} 68