Home | History | Annotate | Download | only in build
      1 // Copyright (C) 2017 The Android Open Source Project
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package hidl
     16 
     17 import (
     18 	"sync"
     19 
     20 	"android/soong/android"
     21 )
     22 
     23 func init() {
     24 	android.RegisterModuleType("hidl_package_root", hidlPackageRootFactory)
     25 }
     26 
     27 type hidlPackageRoot struct {
     28 	android.ModuleBase
     29 
     30 	properties struct {
     31 		// path to this module from root
     32 		Path string
     33 	}
     34 }
     35 
     36 func (r *hidlPackageRoot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
     37 }
     38 func (r *hidlPackageRoot) DepsMutator(ctx android.BottomUpMutatorContext) {
     39 }
     40 
     41 var packageRootsMutex sync.Mutex
     42 var packageRoots []*hidlPackageRoot
     43 
     44 func hidlPackageRootFactory() android.Module {
     45 	r := &hidlPackageRoot{}
     46 	r.AddProperties(&r.properties)
     47 	android.InitAndroidModule(r)
     48 
     49 	packageRootsMutex.Lock()
     50 	packageRoots = append(packageRoots, r)
     51 	packageRootsMutex.Unlock()
     52 
     53 	return r
     54 }
     55 
     56 func lookupPackageRoot(name string) *hidlPackageRoot {
     57 	for _, i := range packageRoots {
     58 		if i.ModuleBase.Name() == name {
     59 			return i
     60 		}
     61 	}
     62 	return nil
     63 }
     64