2017-05-10 22:37:54 +02:00
|
|
|
// Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package python
|
|
|
|
|
|
|
|
import (
|
2019-09-18 23:12:18 +02:00
|
|
|
"path/filepath"
|
|
|
|
|
2017-05-10 22:37:54 +02:00
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This file handles installing python executables into their final location
|
|
|
|
|
2017-12-01 21:00:31 +01:00
|
|
|
type installLocation int
|
|
|
|
|
|
|
|
const (
|
|
|
|
InstallInData installLocation = iota
|
|
|
|
)
|
|
|
|
|
2017-05-10 22:37:54 +02:00
|
|
|
type pythonInstaller struct {
|
2017-12-01 21:00:31 +01:00
|
|
|
dir string
|
|
|
|
dir64 string
|
|
|
|
relative string
|
2017-05-10 22:37:54 +02:00
|
|
|
|
2019-10-02 07:05:35 +02:00
|
|
|
path android.InstallPath
|
2018-11-06 10:30:35 +01:00
|
|
|
|
|
|
|
androidMkSharedLibs []string
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 21:00:31 +01:00
|
|
|
func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
|
2017-05-10 22:37:54 +02:00
|
|
|
return &pythonInstaller{
|
2017-12-01 21:00:31 +01:00
|
|
|
dir: dir,
|
|
|
|
dir64: dir64,
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ installer = (*pythonInstaller)(nil)
|
|
|
|
|
2019-10-02 07:05:35 +02:00
|
|
|
func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.InstallPath {
|
2017-12-01 21:00:31 +01:00
|
|
|
dir := installer.dir
|
|
|
|
if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" {
|
|
|
|
dir = installer.dir64
|
|
|
|
}
|
2019-09-17 23:45:31 +02:00
|
|
|
if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
|
2019-09-18 23:12:18 +02:00
|
|
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
|
|
|
}
|
2017-12-01 21:00:31 +01:00
|
|
|
return android.PathForModuleInstall(ctx, dir, installer.relative)
|
|
|
|
}
|
|
|
|
|
2017-05-10 22:37:54 +02:00
|
|
|
func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
|
2017-12-01 21:00:31 +01:00
|
|
|
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
2018-11-06 10:30:35 +01:00
|
|
|
|
|
|
|
func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
|
|
|
|
installer.androidMkSharedLibs = sharedLibs
|
|
|
|
}
|