2017-02-05 02:47:46 +01: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 00:24:31 +02:00
|
|
|
android.RegisterModuleType("phony", PhonyFactory)
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type phony struct {
|
|
|
|
android.ModuleBase
|
2019-04-02 03:37:36 +02:00
|
|
|
requiredModuleNames []string
|
|
|
|
hostRequiredModuleNames []string
|
|
|
|
targetRequiredModuleNames []string
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
|
2018-07-12 00:24:31 +02:00
|
|
|
func PhonyFactory() android.Module {
|
2017-02-05 02:47:46 +01:00
|
|
|
module := &phony{}
|
|
|
|
|
2019-04-03 02:04:18 +02:00
|
|
|
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *phony) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
p.requiredModuleNames = ctx.RequiredModuleNames()
|
2019-04-02 03:37:36 +02:00
|
|
|
p.hostRequiredModuleNames = ctx.HostRequiredModuleNames()
|
|
|
|
p.targetRequiredModuleNames = ctx.TargetRequiredModuleNames()
|
|
|
|
if len(p.requiredModuleNames) == 0 &&
|
|
|
|
len(p.hostRequiredModuleNames) == 0 && len(p.targetRequiredModuleNames) == 0 {
|
|
|
|
ctx.PropertyErrorf("required", "phony must not have empty required dependencies "+
|
|
|
|
"in order to be useful(and therefore permitted).")
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-11 02:00:19 +02:00
|
|
|
func (p *phony) AndroidMk() android.AndroidMkData {
|
|
|
|
return android.AndroidMkData{
|
2017-08-11 02:07:28 +02:00
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
2017-08-11 02:00:19 +02:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
|
2019-04-03 02:04:18 +02:00
|
|
|
if p.Host() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
|
|
|
}
|
2019-04-02 03:37:36 +02: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 02:00:19 +02:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
|
|
|
},
|
2017-02-05 02:47:46 +01:00
|
|
|
}
|
|
|
|
}
|