installer.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. package python
  15. import (
  16. "path/filepath"
  17. "android/soong/android"
  18. )
  19. // This file handles installing python executables into their final location
  20. type installLocation int
  21. const (
  22. InstallInData installLocation = iota
  23. )
  24. type pythonInstaller struct {
  25. dir string
  26. dir64 string
  27. relative string
  28. path android.InstallPath
  29. androidMkSharedLibs []string
  30. }
  31. func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
  32. return &pythonInstaller{
  33. dir: dir,
  34. dir64: dir64,
  35. }
  36. }
  37. var _ installer = (*pythonInstaller)(nil)
  38. func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.InstallPath {
  39. dir := installer.dir
  40. if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" {
  41. dir = installer.dir64
  42. }
  43. if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
  44. dir = filepath.Join(dir, ctx.Arch().ArchType.String())
  45. }
  46. return android.PathForModuleInstall(ctx, dir, installer.relative)
  47. }
  48. func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
  49. installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
  50. }
  51. func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
  52. installer.androidMkSharedLibs = sharedLibs
  53. }