2017-05-11 04:37:54 +08: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-19 05:12:18 +08:00
|
|
|
"path/filepath"
|
|
|
|
|
2017-05-11 04:37:54 +08:00
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This file handles installing python executables into their final location
|
|
|
|
|
2017-12-02 04:00:31 +08:00
|
|
|
type installLocation int
|
|
|
|
|
|
|
|
const (
|
|
|
|
InstallInData installLocation = iota
|
|
|
|
)
|
|
|
|
|
2017-05-11 04:37:54 +08:00
|
|
|
type pythonInstaller struct {
|
2017-12-02 04:00:31 +08:00
|
|
|
dir string
|
|
|
|
dir64 string
|
|
|
|
relative string
|
2017-05-11 04:37:54 +08:00
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
path android.InstallPath
|
2018-11-06 17:30:35 +08:00
|
|
|
|
|
|
|
androidMkSharedLibs []string
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2017-12-02 04:00:31 +08:00
|
|
|
func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
|
2017-05-11 04:37:54 +08:00
|
|
|
return &pythonInstaller{
|
2017-12-02 04:00:31 +08:00
|
|
|
dir: dir,
|
|
|
|
dir64: dir64,
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ installer = (*pythonInstaller)(nil)
|
|
|
|
|
2019-10-02 13:05:35 +08:00
|
|
|
func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.InstallPath {
|
2017-12-02 04:00:31 +08:00
|
|
|
dir := installer.dir
|
|
|
|
if ctx.Arch().ArchType.Multilib == "lib64" && installer.dir64 != "" {
|
|
|
|
dir = installer.dir64
|
|
|
|
}
|
2019-09-18 05:45:31 +08:00
|
|
|
if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
|
2019-09-19 05:12:18 +08:00
|
|
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
|
|
|
}
|
2017-12-02 04:00:31 +08:00
|
|
|
return android.PathForModuleInstall(ctx, dir, installer.relative)
|
|
|
|
}
|
|
|
|
|
2017-05-11 04:37:54 +08:00
|
|
|
func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
|
2017-12-02 04:00:31 +08:00
|
|
|
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
2018-11-06 17:30:35 +08:00
|
|
|
|
|
|
|
func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
|
|
|
|
installer.androidMkSharedLibs = sharedLibs
|
|
|
|
}
|