blob: 22c06c24d2a3195bf44c39968b3e5519054627ec [file] [log] [blame]
Nan Zhang5323f8e2017-05-10 13:37:54 -07001// 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 "android/soong/android"
19)
20
21// This file handles installing python executables into their final location
22
Nan Zhangd9ec5e72017-12-01 20:00:31 +000023type installLocation int
24
25const (
26 InstallInData installLocation = iota
27)
28
Nan Zhang5323f8e2017-05-10 13:37:54 -070029type pythonInstaller struct {
Nan Zhangd9ec5e72017-12-01 20:00:31 +000030 dir string
31 dir64 string
32 relative string
Nan Zhang5323f8e2017-05-10 13:37:54 -070033
34 path android.OutputPath
Logan Chien02880e42018-11-06 17:30:35 +080035
36 androidMkSharedLibs []string
Nan Zhang5323f8e2017-05-10 13:37:54 -070037}
38
Nan Zhangd9ec5e72017-12-01 20:00:31 +000039func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
Nan Zhang5323f8e2017-05-10 13:37:54 -070040 return &pythonInstaller{
Nan Zhangd9ec5e72017-12-01 20:00:31 +000041 dir: dir,
42 dir64: dir64,
Nan Zhang5323f8e2017-05-10 13:37:54 -070043 }
44}
45
46var _ installer = (*pythonInstaller)(nil)
47
Nan Zhangd9ec5e72017-12-01 20:00:31 +000048func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.OutputPath {
49 dir := installer.dir
50 if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" {
51 dir = installer.dir64
52 }
Nan Zhangd9ec5e72017-12-01 20:00:31 +000053 return android.PathForModuleInstall(ctx, dir, installer.relative)
54}
55
Nan Zhang5323f8e2017-05-10 13:37:54 -070056func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
Nan Zhangd9ec5e72017-12-01 20:00:31 +000057 installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
Nan Zhang5323f8e2017-05-10 13:37:54 -070058}
Logan Chien02880e42018-11-06 17:30:35 +080059
60func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
61 installer.androidMkSharedLibs = sharedLibs
62}