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 (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
2020-09-21 21:11:02 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
2017-05-10 22:37:54 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type subAndroidMkProvider interface {
|
2020-11-24 17:36:14 +01:00
|
|
|
AndroidMk(*Module, *android.AndroidMkEntries)
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
func (p *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
|
2017-05-10 22:37:54 +02: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-24 17:36:14 +01:00
|
|
|
androidmk.AndroidMk(p, entries)
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
func (p *Module) AndroidMkEntries() []android.AndroidMkEntries {
|
|
|
|
entries := android.AndroidMkEntries{OutputFile: p.installSource}
|
2017-08-11 02:00:19 +02:00
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
p.subAndroidMk(&entries, p.installer)
|
2017-05-10 22:37:54 +02:00
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
return []android.AndroidMkEntries{entries}
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
func (p *binaryDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
|
|
|
entries.Class = "EXECUTABLES"
|
2017-11-04 00:54:05 +01:00
|
|
|
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries,
|
|
|
|
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
|
|
|
entries.AddCompatibilityTestSuites(p.binaryProperties.Test_suites...)
|
|
|
|
})
|
2020-11-24 17:36:14 +01:00
|
|
|
base.subAndroidMk(entries, p.pythonInstaller)
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
func (p *testDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
|
|
|
entries.Class = "NATIVE_TESTS"
|
2017-11-04 00:54:05 +01:00
|
|
|
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries,
|
|
|
|
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
|
|
|
entries.AddCompatibilityTestSuites(p.binaryDecorator.binaryProperties.Test_suites...)
|
|
|
|
if p.testConfig != nil {
|
|
|
|
entries.SetString("LOCAL_FULL_TEST_CONFIG", p.testConfig.String())
|
|
|
|
}
|
2020-01-07 00:47:57 +01:00
|
|
|
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
|
2020-09-21 21:11:02 +02:00
|
|
|
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.AddStrings("LOCAL_TEST_DATA", android.AndroidMkDataPaths(p.data)...)
|
2020-11-13 23:33:46 +01:00
|
|
|
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(p.testProperties.Test_options.Unit_test))
|
|
|
|
})
|
2020-11-24 17:36:14 +01:00
|
|
|
base.subAndroidMk(entries, p.binaryDecorator.pythonInstaller)
|
2017-05-10 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
2020-11-24 17:36:14 +01:00
|
|
|
func (installer *pythonInstaller) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
|
|
|
|
entries.Required = append(entries.Required, "libc++")
|
2020-07-03 22:18:24 +02:00
|
|
|
entries.ExtraEntries = append(entries.ExtraEntries,
|
|
|
|
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
2021-11-12 03:59:15 +01:00
|
|
|
path, file := filepath.Split(installer.path.String())
|
2020-07-03 22:18:24 +02:00
|
|
|
stem := strings.TrimSuffix(file, filepath.Ext(file))
|
|
|
|
|
|
|
|
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-10 22:37:54 +02:00
|
|
|
}
|