// Copyright (C) 2017 The Android Open Source Project // // 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 wayland_protcool defines extension modules for the Soong build system // to make it easier to generate code from a list of Wayland protocol files. // // The primary extension module is "wayland_protocol_codegen", which applies a // code generation tool to a list of source protocol files. // // Note that the code generation done here is similar to what is done by the // base Soong "gensrcs" module, but there are two functional differences: // // 1) The output filenames are computed from the input filenames, rather // than needing to be specified explicitly. An optional prefix as well // as a suffix can be added to the protocol filename (without extension). // // 2) Code generation is done for each file independently by emitting // multiple Ninja build commands, rather than one build command which // does it all. package wayland_protocol import ( "fmt" "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" "android/soong/android" "android/soong/genrule" ) func init() { // Register out extension module type name with Soong. android.RegisterModuleType( "wayland_protocol_codegen", waylandCodegenModuleFactory) } var ( // Create a context for build rule output from this package pctx = android.NewPackageContext("android/soong/external/wayland-protocol") ) type hostToolDependencyTag struct { blueprint.BaseDependencyTag } var hostToolDepTag hostToolDependencyTag // waylandCodegenProperties defines the properties that will be read in from the // Android.bp file for each instantiation of the module. type waylandCodegenProperties struct { // This string gives the command line template to run on each protocol file // to wayland_protocol_codegen. // // The string can contain one or more "$" prefixed variable names for // values that can vary. At a minimum you need to use ${location}, ${out} // and ${in} // // $(location): the path to the first entry in tools or tool_files // $(location