Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. |
| 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 cc |
| 16 | |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 17 | import ( |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 18 | "path/filepath" |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 19 | "strings" |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 20 | |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 21 | "github.com/google/blueprint" |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 22 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 23 | "android/soong/android" |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | func init() { |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 27 | pctx.SourcePathVariable("lexCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/flex") |
Dan Willemsen | 613564e | 2020-07-23 21:37:35 +0000 | [diff] [blame] | 28 | pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4") |
| 29 | |
Dan Willemsen | e1240db | 2016-11-03 14:28:51 -0700 | [diff] [blame] | 30 | pctx.HostBinToolVariable("aidlCmd", "aidl-cpp") |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 31 | pctx.HostBinToolVariable("syspropCmd", "sysprop_cpp") |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | var ( |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 35 | lex = pctx.AndroidStaticRule("lex", |
| 36 | blueprint.RuleParams{ |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 37 | Command: "M4=$m4Cmd $lexCmd $flags -o$out $in", |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 38 | CommandDeps: []string{"$lexCmd", "$m4Cmd"}, |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 39 | }, "flags") |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 40 | |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 41 | sysprop = pctx.AndroidStaticRule("sysprop", |
| 42 | blueprint.RuleParams{ |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 43 | Command: "$syspropCmd --header-dir=$headerOutDir --public-header-dir=$publicOutDir " + |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 44 | "--source-dir=$srcOutDir --include-name=$includeName $in", |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 45 | CommandDeps: []string{"$syspropCmd"}, |
| 46 | }, |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 47 | "headerOutDir", "publicOutDir", "srcOutDir", "includeName") |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 48 | ) |
| 49 | |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 50 | type YaccProperties struct { |
| 51 | // list of module-specific flags that will be used for .y and .yy compiles |
| 52 | Flags []string |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 53 | |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 54 | // whether the yacc files will produce a location.hh file |
| 55 | Gen_location_hh *bool |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 56 | |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 57 | // whether the yacc files will product a position.hh file |
| 58 | Gen_position_hh *bool |
| 59 | } |
| 60 | |
| 61 | func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile android.Path, |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 62 | outFile android.ModuleGenPath, props *YaccProperties) (headerFiles android.Paths) { |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 63 | |
| 64 | outDir := android.PathForModuleGen(ctx, "yacc") |
| 65 | headerFile := android.GenPathWithExt(ctx, "yacc", yaccFile, "h") |
| 66 | ret := android.Paths{headerFile} |
| 67 | |
| 68 | cmd := rule.Command() |
| 69 | |
| 70 | // Fix up #line markers to not use the sbox temporary directory |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 71 | // android.sboxPathForOutput(outDir, outDir) returns the sbox placeholder for the out |
Colin Cross | 3d68051 | 2020-11-13 16:23:53 -0800 | [diff] [blame] | 72 | // directory itself, without any filename appended. |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 73 | sboxOutDir := cmd.PathForOutput(outDir) |
Colin Cross | 3d68051 | 2020-11-13 16:23:53 -0800 | [diff] [blame] | 74 | sedCmd := "sed -i.bak 's#" + sboxOutDir + "#" + outDir.String() + "#'" |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 75 | rule.Command().Text(sedCmd).Input(outFile) |
| 76 | rule.Command().Text(sedCmd).Input(headerFile) |
| 77 | |
| 78 | var flags []string |
| 79 | if props != nil { |
| 80 | flags = props.Flags |
| 81 | |
| 82 | if Bool(props.Gen_location_hh) { |
| 83 | locationHeader := outFile.InSameDir(ctx, "location.hh") |
| 84 | ret = append(ret, locationHeader) |
| 85 | cmd.ImplicitOutput(locationHeader) |
| 86 | rule.Command().Text(sedCmd).Input(locationHeader) |
| 87 | } |
| 88 | if Bool(props.Gen_position_hh) { |
| 89 | positionHeader := outFile.InSameDir(ctx, "position.hh") |
| 90 | ret = append(ret, positionHeader) |
| 91 | cmd.ImplicitOutput(positionHeader) |
| 92 | rule.Command().Text(sedCmd).Input(positionHeader) |
| 93 | } |
| 94 | } |
| 95 | |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 96 | cmd.Text("BISON_PKGDATADIR=prebuilts/build-tools/common/bison"). |
| 97 | FlagWithInput("M4=", ctx.Config().PrebuiltBuildTool(ctx, "m4")). |
| 98 | PrebuiltBuildTool(ctx, "bison"). |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 99 | Flag("-d"). |
| 100 | Flags(flags). |
| 101 | FlagWithOutput("--defines=", headerFile). |
| 102 | Flag("-o").Output(outFile).Input(yaccFile) |
| 103 | |
| 104 | return ret |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 107 | func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path, aidlFlags string) (cppFile android.OutputPath, headerFiles android.Paths) { |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 108 | aidlPackage := strings.TrimSuffix(aidlFile.Rel(), aidlFile.Base()) |
| 109 | baseName := strings.TrimSuffix(aidlFile.Base(), aidlFile.Ext()) |
Daniel Norman | 10b7435 | 2019-09-24 17:39:58 -0700 | [diff] [blame] | 110 | shortName := baseName |
| 111 | // TODO(b/111362593): aidl_to_cpp_common.cpp uses heuristics to figure out if |
| 112 | // an interface name has a leading I. Those same heuristics have been |
| 113 | // moved here. |
| 114 | if len(baseName) >= 2 && baseName[0] == 'I' && |
| 115 | strings.ToUpper(baseName)[1] == baseName[1] { |
| 116 | shortName = strings.TrimPrefix(baseName, "I") |
| 117 | } |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 118 | |
| 119 | outDir := android.PathForModuleGen(ctx, "aidl") |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 120 | cppFile = outDir.Join(ctx, aidlPackage, baseName+".cpp") |
| 121 | depFile := outDir.Join(ctx, aidlPackage, baseName+".cpp.d") |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 122 | headerI := outDir.Join(ctx, aidlPackage, baseName+".h") |
| 123 | headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h") |
| 124 | headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h") |
| 125 | |
Jiyong Park | 2907459 | 2019-07-07 16:27:47 +0900 | [diff] [blame] | 126 | baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel()) |
| 127 | if baseDir != "" { |
| 128 | aidlFlags += " -I" + baseDir |
| 129 | } |
| 130 | |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 131 | cmd := rule.Command() |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 132 | cmd.BuiltTool("aidl-cpp"). |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 133 | FlagWithDepFile("-d", depFile). |
| 134 | Flag("--ninja"). |
| 135 | Flag(aidlFlags). |
| 136 | Input(aidlFile). |
| 137 | OutputDir(). |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 138 | Output(cppFile). |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 139 | ImplicitOutputs(android.WritablePaths{ |
| 140 | headerI, |
| 141 | headerBn, |
| 142 | headerBp, |
| 143 | }) |
| 144 | |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 145 | return cppFile, android.Paths{ |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 146 | headerI, |
| 147 | headerBn, |
| 148 | headerBp, |
| 149 | } |
Dan Willemsen | e1240db | 2016-11-03 14:28:51 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 152 | type LexProperties struct { |
| 153 | // list of module-specific flags that will be used for .l and .ll compiles |
| 154 | Flags []string |
| 155 | } |
| 156 | |
| 157 | func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath, props *LexProperties) { |
| 158 | var flags []string |
| 159 | if props != nil { |
| 160 | flags = props.Flags |
| 161 | } |
| 162 | flagsString := strings.Join(flags[:], " ") |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 163 | ctx.Build(pctx, android.BuildParams{ |
| 164 | Rule: lex, |
| 165 | Description: "lex " + lexFile.Rel(), |
| 166 | Output: outFile, |
| 167 | Input: lexFile, |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 168 | Args: map[string]string{"flags": flagsString}, |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 169 | }) |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 170 | } |
| 171 | |
Inseob Kim | ed2641f | 2020-02-19 10:42:41 +0900 | [diff] [blame] | 172 | func genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Paths) { |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 173 | headerFile := android.PathForModuleGen(ctx, "sysprop", "include", syspropFile.Rel()+".h") |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 174 | publicHeaderFile := android.PathForModuleGen(ctx, "sysprop/public", "include", syspropFile.Rel()+".h") |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 175 | cppFile := android.PathForModuleGen(ctx, "sysprop", syspropFile.Rel()+".cpp") |
| 176 | |
Inseob Kim | ed2641f | 2020-02-19 10:42:41 +0900 | [diff] [blame] | 177 | headers := android.WritablePaths{headerFile, publicHeaderFile} |
| 178 | |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 179 | ctx.Build(pctx, android.BuildParams{ |
Inseob Kim | ed2641f | 2020-02-19 10:42:41 +0900 | [diff] [blame] | 180 | Rule: sysprop, |
| 181 | Description: "sysprop " + syspropFile.Rel(), |
| 182 | Output: cppFile, |
| 183 | ImplicitOutputs: headers, |
| 184 | Input: syspropFile, |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 185 | Args: map[string]string{ |
| 186 | "headerOutDir": filepath.Dir(headerFile.String()), |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 187 | "publicOutDir": filepath.Dir(publicHeaderFile.String()), |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 188 | "srcOutDir": filepath.Dir(cppFile.String()), |
| 189 | "includeName": syspropFile.Rel() + ".h", |
| 190 | }, |
| 191 | }) |
| 192 | |
Inseob Kim | ed2641f | 2020-02-19 10:42:41 +0900 | [diff] [blame] | 193 | return cppFile, headers.Paths() |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 194 | } |
| 195 | |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 196 | // Used to communicate information from the genSources method back to the library code that uses |
| 197 | // it. |
| 198 | type generatedSourceInfo struct { |
| 199 | // The headers created from .proto files |
| 200 | protoHeaders android.Paths |
| 201 | |
| 202 | // The files that can be used as order only dependencies in order to ensure that the proto header |
| 203 | // files are up to date. |
| 204 | protoOrderOnlyDeps android.Paths |
| 205 | |
| 206 | // The headers created from .aidl files |
| 207 | aidlHeaders android.Paths |
| 208 | |
| 209 | // The files that can be used as order only dependencies in order to ensure that the aidl header |
| 210 | // files are up to date. |
| 211 | aidlOrderOnlyDeps android.Paths |
| 212 | |
| 213 | // The headers created from .sysprop files |
| 214 | syspropHeaders android.Paths |
| 215 | |
| 216 | // The files that can be used as order only dependencies in order to ensure that the sysprop |
| 217 | // header files are up to date. |
| 218 | syspropOrderOnlyDeps android.Paths |
| 219 | } |
| 220 | |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 221 | func genSources(ctx android.ModuleContext, srcFiles android.Paths, |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 222 | buildFlags builderFlags) (android.Paths, android.Paths, generatedSourceInfo) { |
| 223 | |
| 224 | var info generatedSourceInfo |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 225 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 226 | var deps android.Paths |
Colin Cross | 2a252be | 2017-05-01 17:37:24 -0700 | [diff] [blame] | 227 | var rsFiles android.Paths |
| 228 | |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 229 | var aidlRule *android.RuleBuilder |
| 230 | |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 231 | var yaccRule_ *android.RuleBuilder |
| 232 | yaccRule := func() *android.RuleBuilder { |
| 233 | if yaccRule_ == nil { |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 234 | yaccRule_ = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "yacc"), |
Colin Cross | e16ce36 | 2020-11-12 08:29:30 -0800 | [diff] [blame] | 235 | android.PathForModuleGen(ctx, "yacc.sbox.textproto")) |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 236 | } |
| 237 | return yaccRule_ |
| 238 | } |
| 239 | |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 240 | for i, srcFile := range srcFiles { |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 241 | switch srcFile.Ext() { |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 242 | case ".y": |
Dan Willemsen | 21ec490 | 2016-11-02 20:43:13 -0700 | [diff] [blame] | 243 | cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c") |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 244 | srcFiles[i] = cFile |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 245 | deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc)...) |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 246 | case ".yy": |
Dan Willemsen | 21ec490 | 2016-11-02 20:43:13 -0700 | [diff] [blame] | 247 | cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp") |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 248 | srcFiles[i] = cppFile |
David Su | dd18efd | 2020-07-24 17:19:23 +0000 | [diff] [blame] | 249 | deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc)...) |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 250 | case ".l": |
Dan Willemsen | 21ec490 | 2016-11-02 20:43:13 -0700 | [diff] [blame] | 251 | cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c") |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 252 | srcFiles[i] = cFile |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 253 | genLex(ctx, srcFile, cFile, buildFlags.lex) |
Dan Willemsen | f0c73e0 | 2016-03-01 15:15:26 -0800 | [diff] [blame] | 254 | case ".ll": |
Dan Willemsen | 21ec490 | 2016-11-02 20:43:13 -0700 | [diff] [blame] | 255 | cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp") |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 256 | srcFiles[i] = cppFile |
Matthias Maennich | 22fd4d1 | 2020-07-15 10:58:56 +0200 | [diff] [blame] | 257 | genLex(ctx, srcFile, cppFile, buildFlags.lex) |
Colin Cross | 0c461f1 | 2016-10-20 16:11:43 -0700 | [diff] [blame] | 258 | case ".proto": |
Dan Willemsen | 60e62f0 | 2018-11-16 21:05:32 -0800 | [diff] [blame] | 259 | ccFile, headerFile := genProto(ctx, srcFile, buildFlags) |
Colin Cross | 6af17aa | 2017-09-20 12:59:05 -0700 | [diff] [blame] | 260 | srcFiles[i] = ccFile |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 261 | info.protoHeaders = append(info.protoHeaders, headerFile) |
| 262 | // Use the generated header as an order only dep to ensure that it is up to date when needed. |
| 263 | info.protoOrderOnlyDeps = append(info.protoOrderOnlyDeps, headerFile) |
Dan Willemsen | e1240db | 2016-11-03 14:28:51 -0700 | [diff] [blame] | 264 | case ".aidl": |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 265 | if aidlRule == nil { |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 266 | aidlRule = android.NewRuleBuilder(pctx, ctx).Sbox(android.PathForModuleGen(ctx, "aidl"), |
Colin Cross | e16ce36 | 2020-11-12 08:29:30 -0800 | [diff] [blame] | 267 | android.PathForModuleGen(ctx, "aidl.sbox.textproto")) |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 268 | } |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 269 | cppFile, aidlHeaders := genAidl(ctx, aidlRule, srcFile, buildFlags.aidlFlags) |
Dan Willemsen | e1240db | 2016-11-03 14:28:51 -0700 | [diff] [blame] | 270 | srcFiles[i] = cppFile |
Jiyong Park | c7e592c | 2021-04-07 21:49:34 +0900 | [diff] [blame] | 271 | |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 272 | info.aidlHeaders = append(info.aidlHeaders, aidlHeaders...) |
| 273 | // Use the generated headers as order only deps to ensure that they are up to date when |
| 274 | // needed. |
| 275 | // TODO: Reduce the size of the ninja file by using one order only dep for the whole rule |
| 276 | info.aidlOrderOnlyDeps = append(info.aidlOrderOnlyDeps, aidlHeaders...) |
Jeff Vander Stoep | d612627 | 2019-07-15 19:08:37 -0700 | [diff] [blame] | 277 | case ".rscript", ".fs": |
Colin Cross | 2a252be | 2017-05-01 17:37:24 -0700 | [diff] [blame] | 278 | cppFile := rsGeneratedCppFile(ctx, srcFile) |
| 279 | rsFiles = append(rsFiles, srcFiles[i]) |
| 280 | srcFiles[i] = cppFile |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 281 | case ".sysprop": |
Inseob Kim | ed2641f | 2020-02-19 10:42:41 +0900 | [diff] [blame] | 282 | cppFile, headerFiles := genSysprop(ctx, srcFile) |
Inseob Kim | 21f2690 | 2018-09-06 00:55:20 +0900 | [diff] [blame] | 283 | srcFiles[i] = cppFile |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 284 | info.syspropHeaders = append(info.syspropHeaders, headerFiles...) |
| 285 | // Use the generated headers as order only deps to ensure that they are up to date when |
| 286 | // needed. |
| 287 | info.syspropOrderOnlyDeps = append(info.syspropOrderOnlyDeps, headerFiles...) |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 291 | if aidlRule != nil { |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 292 | aidlRule.Build("aidl", "gen aidl") |
Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 295 | if yaccRule_ != nil { |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 296 | yaccRule_.Build("yacc", "gen yacc") |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 299 | deps = append(deps, info.protoOrderOnlyDeps...) |
| 300 | deps = append(deps, info.aidlOrderOnlyDeps...) |
| 301 | deps = append(deps, info.syspropOrderOnlyDeps...) |
| 302 | |
Colin Cross | 2a252be | 2017-05-01 17:37:24 -0700 | [diff] [blame] | 303 | if len(rsFiles) > 0 { |
| 304 | deps = append(deps, rsGenerateCpp(ctx, rsFiles, buildFlags.rsFlags)...) |
| 305 | } |
| 306 | |
Paul Duffin | 33056e8 | 2021-02-19 13:49:08 +0000 | [diff] [blame] | 307 | return srcFiles, deps, info |
Colin Cross | 581c189 | 2015-04-07 16:50:10 -0700 | [diff] [blame] | 308 | } |