2017-02-05 09:47:46 +08:00
|
|
|
// Copyright 2016 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 phony
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-07-12 06:24:31 +08:00
|
|
|
android.RegisterModuleType("phony", PhonyFactory)
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type phony struct {
|
|
|
|
android.ModuleBase
|
2019-04-02 09:37:36 +08:00
|
|
|
requiredModuleNames []string
|
|
|
|
hostRequiredModuleNames []string
|
|
|
|
targetRequiredModuleNames []string
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
|
2018-07-12 06:24:31 +08:00
|
|
|
func PhonyFactory() android.Module {
|
2017-02-05 09:47:46 +08:00
|
|
|
module := &phony{}
|
|
|
|
|
2019-04-03 08:04:18 +08:00
|
|
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
2017-06-24 06:06:31 +08:00
|
|
|
return module
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
p.requiredModuleNames = ctx.RequiredModuleNames()
|
2019-04-02 09:37:36 +08:00
|
|
|
p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
|
|
|
|
p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
|
2017-08-11 08:00:19 +08:00
|
|
|
func (p *phony) AndroidMk() android.AndroidMkData {
|
|
|
|
return android.AndroidMkData{
|
2017-08-11 08:07:28 +08:00
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
2017-08-11 08:00:19 +08:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
2019-04-03 08:04:18 +08:00
|
|
|
if p.Host() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
|
|
|
}
|
2019-04-02 09:37:36 +08:00
|
|
|
if len(p.requiredModuleNames) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=",
|
|
|
|
strings.Join(p.requiredModuleNames, " "))
|
|
|
|
}
|
|
|
|
if len(p.hostRequiredModuleNames) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=",
|
|
|
|
strings.Join(p.hostRequiredModuleNames, " "))
|
|
|
|
}
|
|
|
|
if len(p.targetRequiredModuleNames) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=",
|
|
|
|
strings.Join(p.targetRequiredModuleNames, " "))
|
|
|
|
}
|
2017-08-11 08:00:19 +08:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
|
|
|
},
|
2017-02-05 09:47:46 +08:00
|
|
|
}
|
|
|
|
}
|