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 (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-09-22 03:11:02 +08:00
|
|
|
|
|
|
|
"android/soong/android"
|
2017-05-11 04:37:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type subAndroidMkProvider interface {
|
2020-11-25 00:36:14 +08:00
|
|
|
AndroidMk(*Module, *android.AndroidMkEntries)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
func (p *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
|
2017-05-11 04:37:54 +08:00
|
|
|
if p.subAndroidMkOnce == nil {
|
|
|
|
p.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
|
|
|
|
}
|
|
|
|
if androidmk, ok := obj.(subAndroidMkProvider); ok {
|
|
|
|
if !p.subAndroidMkOnce[androidmk] {
|
|
|
|
p.subAndroidMkOnce[androidmk] = true
|
2020-11-25 00:36:14 +08:00
|
|
|
androidmk.AndroidMk(p, entries)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
func (p *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|
|
|
entries := android.AndroidMkEntries{OutputFile: p.installSource}
|
2017-08-11 08:00:19 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
p.subAndroidMk(&entries, p.installer)
|
2017-05-11 04:37:54 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
return []android.AndroidMkEntries{entries}
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
func (p *binaryDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
|
|
|
entries.Class = "EXECUTABLES"
|
2017-11-04 07:54:05 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
2020-11-25 04:42:58 +08:00
|
|
|
entries.AddCompatibilityTestSuites(p.binaryProperties.Test_suites...)
|
2017-11-04 07:54:05 +08:00
|
|
|
})
|
2020-11-25 00:36:14 +08:00
|
|
|
base.subAndroidMk(entries, p.pythonInstaller)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
func (p *testDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
|
|
|
entries.Class = "NATIVE_TESTS"
|
2017-11-04 07:54:05 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
2020-11-25 04:42:58 +08:00
|
|
|
entries.AddCompatibilityTestSuites(p.binaryDecorator.binaryProperties.Test_suites...)
|
2020-06-10 06:09:22 +08:00
|
|
|
if p.testConfig != nil {
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.SetString("LOCAL_FULL_TEST_CONFIG", p.testConfig.String())
|
2018-08-03 06:00:46 +08:00
|
|
|
}
|
2020-01-07 07:47:57 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
|
2020-09-22 03:11:02 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.AddStrings("LOCAL_TEST_DATA", android.AndroidMkDataPaths(p.data)...)
|
2020-11-14 06:33:46 +08:00
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(p.testProperties.Test_options.Unit_test))
|
2017-11-04 07:54:05 +08:00
|
|
|
})
|
2020-11-25 00:36:14 +08:00
|
|
|
base.subAndroidMk(entries, p.binaryDecorator.pythonInstaller)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
func (installer *pythonInstaller) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
2017-05-11 04:37:54 +08:00
|
|
|
// Soong installation is only supported for host modules. Have Make
|
|
|
|
// installation trigger Soong installation.
|
|
|
|
if base.Target().Os.Class == android.Host {
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.OutputFile = android.OptionalPathForPath(installer.path)
|
2017-05-11 04:37:54 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.Required = append(entries.Required, "libc++")
|
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
2019-10-03 07:01:35 +08:00
|
|
|
path, file := filepath.Split(installer.path.ToMakePath().String())
|
2017-05-11 04:37:54 +08:00
|
|
|
stem := strings.TrimSuffix(file, filepath.Ext(file))
|
|
|
|
|
2020-11-25 00:36:14 +08:00
|
|
|
entries.SetString("LOCAL_MODULE_SUFFIX", filepath.Ext(file))
|
|
|
|
entries.SetString("LOCAL_MODULE_PATH", path)
|
|
|
|
entries.SetString("LOCAL_MODULE_STEM", stem)
|
|
|
|
entries.AddStrings("LOCAL_SHARED_LIBRARIES", installer.androidMkSharedLibs...)
|
|
|
|
entries.SetBool("LOCAL_CHECK_ELF_FILES", false)
|
2017-05-11 04:37:54 +08:00
|
|
|
})
|
|
|
|
}
|