proto_library.gni 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. # Compile a protocol buffer.
  5. #
  6. # Protobuf parameters:
  7. #
  8. # proto_in_dir (optional)
  9. # Specifies the path relative to the current BUILD.gn file where
  10. # proto files are located and the directory structure of
  11. # this proto library starts.
  12. #
  13. # This option can be calculated automatically but it will raise an
  14. # assertion error if any nested directories are found.
  15. #
  16. # proto_out_dir (optional)
  17. # Specifies the path suffix that output files are generated under.
  18. # This path will be appended to |root_gen_dir|, but for python stubs
  19. # it will be appended to |root_build_dir|/pyproto.
  20. #
  21. # generate_python (optional, default true)
  22. # Generate Python protobuf stubs.
  23. #
  24. # generate_cc (optional, default true)
  25. # Generate C++ protobuf stubs.
  26. #
  27. # generate_javascript (optional, default false)
  28. # Generate Javascript protobuf stubs.
  29. #
  30. # generate_library (optional, default true)
  31. # Generate a "static_library" target for linking with the generated code.
  32. #
  33. # generate_py_runtime (optional, default false)
  34. # Generates a "_py_runtime"-suffixed target for test targets that need the
  35. # Python stubs available at runtime.
  36. #
  37. # TODO(crbug.com/1237958): Remove allow_optional when proto rolls to 3.15.
  38. # allow_optional (optional, default false)
  39. # Enables experimental_allow_proto3_optional.
  40. #
  41. # cc_generator_options (optional)
  42. # List of extra flags passed to the protocol compiler. If you need to
  43. # add an EXPORT macro to a protobuf's C++ header, set the
  44. # 'cc_generator_options' variable with the value:
  45. # 'dllexport_decl=FOO_EXPORT:' (note trailing colon).
  46. #
  47. # It is likely you also need to #include a file for the above EXPORT
  48. # macro to work (see cc_include) and set
  49. # component_build_force_source_set = true.
  50. #
  51. # cc_include (optional)
  52. # String listing an extra include that should be passed.
  53. # Example: cc_include = "foo/bar.h"
  54. #
  55. # generator_plugin_label (optional)
  56. # GN label for plugin executable which generates custom cc stubs.
  57. # Don't specify a toolchain, host toolchain is assumed.
  58. #
  59. # generator_plugin_script (optional)
  60. # Path to plugin script. Mutually exclusive with |generator_plugin_label|.
  61. #
  62. # generator_plugin_script_deps (optional)
  63. # List of additional files required for generator plugin script.
  64. #
  65. # generator_plugin_suffix[es] (required if using a plugin)
  66. # Suffix (before extension) for generated .cc and .h files
  67. # or list of suffixes for all files (with extensions).
  68. #
  69. # generator_plugin_options (optional)
  70. # Extra flags passed to the plugin. See cc_generator_options.
  71. #
  72. # deps (optional)
  73. # DEPRECATED: use proto_deps or link_deps instead (crbug.com/938011).
  74. # Additional dependencies.
  75. #
  76. # link_deps (optional)
  77. # Additional dependencies linked to library.
  78. #
  79. # proto_deps (optional)
  80. # Additional dependencies required before running protoc.
  81. # e.g. proto file generating action.
  82. #
  83. # use_protobuf_full (optional)
  84. # If adding protobuf library would be required, adds protobuf_full to deps
  85. # instead of protobuf_lite.
  86. #
  87. # import_dirs (optional)
  88. # A list of extra import directories to be passed to protoc compiler.
  89. # WARNING: This circumvents proto checkdeps, and should only be used when
  90. # needed, typically when proto files cannot cleanly import through
  91. # absolute paths, such as for third_party or generated .proto files.
  92. # http://crbug.com/691451 tracks fixing this.
  93. #
  94. # Parameters for compiling the generated code:
  95. #
  96. # force_source_set (Default=false)
  97. # When set true the generated code will be compiled as a source set.
  98. # This can be useful if you need to export the generated symbols from a
  99. # shared library. You should use this carefully, as you probably only
  100. # want this if your dependencies are *always* shared libraries. Most
  101. # of the time, you probably want `component_build_force_source_set`
  102. # instead (see the next option).
  103. # component_build_force_source_set (Default=false)
  104. # When set true the generated code will be compiled as a source set in
  105. # the component build. This does not affect static builds. If you are
  106. # exporting symbols from a component, this is required to prevent those
  107. # symbols from being stripped. If you're not using dllexports in
  108. # cc_generator_options, it's usually best to leave this false.
  109. #
  110. # defines (optional)
  111. # Defines to supply to the source set that compiles the generated source
  112. # code.
  113. #
  114. # extra_configs (optional)
  115. # A list of config labels that will be appended to the configs applying
  116. # to the source set.
  117. #
  118. # remove_configs (optional)
  119. # A list of config labels that will be removed from the configs apllying
  120. # to the source set.
  121. #
  122. # propagate_imports_configs (optional)
  123. # A boolean value (defaults to true) that specifies whether the config
  124. # generated for the library's import directories will be propagated to
  125. # dependents as one of the library target's public_configs. See
  126. # crbug.com/1043279#c11 and crbug.com/gn/142 for why this option exists.
  127. # WARNING: If set to false, the embedder target is responsible for
  128. # propagating a suitable config, so that any dependent headers can resolve
  129. # includes generated by proto imports.
  130. #
  131. # Example:
  132. # proto_library("mylib") {
  133. # sources = [
  134. # "foo.proto",
  135. # ]
  136. # }
  137. import("//build/config/sanitizers/sanitizers.gni")
  138. import("//build/toolchain/kythe.gni")
  139. declare_args() {
  140. # Allows subprojects to omit javascript dependencies (e.g.) closure_compiler
  141. # and google-closure-library.
  142. enable_js_protobuf = true
  143. }
  144. if (enable_js_protobuf) {
  145. import("//third_party/closure_compiler/compile_js.gni")
  146. }
  147. if (host_os == "win") {
  148. _host_executable_suffix = ".exe"
  149. } else {
  150. _host_executable_suffix = ""
  151. }
  152. _protoc_label = "//third_party/protobuf:protoc($host_toolchain)"
  153. _protoc_path = get_label_info(_protoc_label, "root_out_dir") + "/protoc" +
  154. _host_executable_suffix
  155. template("proto_library") {
  156. assert(defined(invoker.sources), "Need sources for proto_library")
  157. proto_sources = invoker.sources
  158. if (defined(invoker.generate_cc)) {
  159. generate_cc = invoker.generate_cc
  160. } else {
  161. generate_cc = true
  162. }
  163. if (defined(invoker.generate_python)) {
  164. generate_python = invoker.generate_python
  165. } else {
  166. generate_python = true
  167. }
  168. if (defined(invoker.generate_javascript)) {
  169. generate_javascript = invoker.generate_javascript
  170. } else {
  171. generate_javascript = false
  172. }
  173. if (defined(invoker.generate_descriptor)) {
  174. generate_descriptor = invoker.generate_descriptor
  175. } else {
  176. generate_descriptor = ""
  177. }
  178. if (defined(invoker.generate_py_runtime)) {
  179. generate_py_runtime = invoker.generate_py_runtime
  180. } else {
  181. generate_py_runtime = false
  182. }
  183. if (generate_py_runtime) {
  184. generate_python = true
  185. }
  186. # exclude_imports is only used for generating the descriptor. Therefore, the
  187. # check needs to be here to avoid complaints from GN about the unused
  188. # variable.
  189. if (generate_descriptor != "") {
  190. if (defined(invoker.exclude_imports)) {
  191. exclude_imports = invoker.exclude_imports
  192. } else {
  193. exclude_imports = false
  194. }
  195. }
  196. if (defined(invoker.generator_plugin_label)) {
  197. # Straightforward way to get the name of executable doesn't work because
  198. # |root_out_dir| and |root_build_dir| may differ in cross-compilation and
  199. # also Windows executables have .exe at the end.
  200. plugin_host_label = invoker.generator_plugin_label + "($host_toolchain)"
  201. plugin_path =
  202. get_label_info(plugin_host_label, "root_out_dir") + "/" +
  203. get_label_info(plugin_host_label, "name") + _host_executable_suffix
  204. generate_with_plugin = true
  205. } else if (defined(invoker.generator_plugin_script)) {
  206. plugin_path = invoker.generator_plugin_script
  207. generate_with_plugin = true
  208. } else {
  209. generate_with_plugin = false
  210. }
  211. if (generate_with_plugin) {
  212. if (defined(invoker.generator_plugin_suffix)) {
  213. generator_plugin_suffixes = [
  214. "${invoker.generator_plugin_suffix}.h",
  215. "${invoker.generator_plugin_suffix}.cc",
  216. ]
  217. } else {
  218. generator_plugin_suffixes = invoker.generator_plugin_suffixes
  219. }
  220. }
  221. if (defined(invoker.proto_in_dir)) {
  222. proto_in_dir = invoker.proto_in_dir
  223. has_nested_dirs = false
  224. foreach(proto_source, proto_sources) {
  225. if (get_path_info(proto_source, "dir") != proto_in_dir) {
  226. has_nested_dirs = true
  227. }
  228. }
  229. } else {
  230. proto_in_dir = get_path_info(proto_sources[0], "dir")
  231. has_nested_dirs = false
  232. # Sanity check, |proto_in_dir| should be defined to allow sub-directories.
  233. foreach(proto_source, proto_sources) {
  234. assert(get_path_info(proto_source, "dir") == proto_in_dir,
  235. "Please define |proto_in_dir| to allow nested directories.")
  236. }
  237. }
  238. # Avoid absolute path because of the assumption that |proto_in_dir| is
  239. # relative to the directory of current BUILD.gn file.
  240. proto_in_dir = rebase_path(proto_in_dir, ".")
  241. if (defined(invoker.proto_out_dir)) {
  242. proto_out_dir = invoker.proto_out_dir
  243. } else {
  244. # Absolute path to the directory of current BUILD.gn file excluding "//".
  245. proto_out_dir = rebase_path(".", "//")
  246. if (proto_in_dir != ".") {
  247. proto_out_dir += "/$proto_in_dir"
  248. }
  249. }
  250. # We need both absolute path to use in GN statements and a relative one
  251. # to pass to external script.
  252. if (generate_cc || generate_with_plugin) {
  253. cc_out_dir = "$root_gen_dir/" + proto_out_dir
  254. rel_cc_out_dir = rebase_path(cc_out_dir, root_build_dir)
  255. }
  256. if (generate_python) {
  257. py_out_dir = "$root_out_dir/pyproto/" + proto_out_dir
  258. rel_py_out_dir = rebase_path(py_out_dir, root_build_dir)
  259. }
  260. if (generate_javascript) {
  261. js_out_dir = "$root_out_dir/jsproto/" + proto_out_dir
  262. rel_js_out_dir = rebase_path(js_out_dir, root_build_dir)
  263. }
  264. if (generate_descriptor != "") {
  265. descriptor_out =
  266. "$root_gen_dir/" + proto_out_dir + "/" + generate_descriptor
  267. rel_descriptor_out = rebase_path(descriptor_out, root_build_dir)
  268. }
  269. protos = rebase_path(invoker.sources, proto_in_dir)
  270. protogens = []
  271. protogens_py = []
  272. protogens_cc = []
  273. protogens_js = []
  274. # Whether source code bindings should be generated.
  275. generate_sources = generate_cc || generate_python || generate_with_plugin ||
  276. generate_javascript
  277. # Whether library should be generated.
  278. # Library is not needed when proto_library is used to generate binary descriptor, in which case
  279. # corresponding library target should be omitted entirely.
  280. if (defined(invoker.generate_library)) {
  281. generate_library = invoker.generate_library
  282. } else {
  283. generate_library = generate_sources
  284. }
  285. # List output files.
  286. if (generate_sources) {
  287. foreach(proto, protos) {
  288. proto_dir = get_path_info(proto, "dir")
  289. proto_name = get_path_info(proto, "name")
  290. proto_path = proto_dir + "/" + proto_name
  291. if (generate_cc) {
  292. protogens_cc += [
  293. "$cc_out_dir/$proto_path.pb.h",
  294. "$cc_out_dir/$proto_path.pb.cc",
  295. ]
  296. }
  297. if (generate_python) {
  298. protogens_py += [ "$py_out_dir/${proto_path}_pb2.py" ]
  299. }
  300. if (generate_with_plugin) {
  301. foreach(suffix, generator_plugin_suffixes) {
  302. protogens_cc += [ "$cc_out_dir/${proto_path}${suffix}" ]
  303. }
  304. }
  305. if (generate_javascript) {
  306. protogens_js += [ "$js_out_dir/${proto_path}.js" ]
  307. }
  308. }
  309. }
  310. # If descriptor needs to be generated, it should be added to list of outputs once.
  311. if (generate_descriptor != "") {
  312. protogens += [ descriptor_out ]
  313. }
  314. action_name = "${target_name}_gen"
  315. source_set_name = target_name
  316. javascript_name = "${target_name}_js"
  317. py_runtime_name = "${target_name}_py_runtime"
  318. # Generate protobuf stubs.
  319. action(action_name) {
  320. visibility = [
  321. ":$javascript_name",
  322. ":$py_runtime_name",
  323. ":$source_set_name",
  324. ]
  325. script = "//tools/protoc_wrapper/protoc_wrapper.py"
  326. args = protos
  327. sources = proto_sources
  328. outputs =
  329. get_path_info(protogens + protogens_cc + protogens_js + protogens_py,
  330. "abspath")
  331. if (defined(invoker.testonly)) {
  332. testonly = invoker.testonly
  333. }
  334. args += [
  335. # Wrapper should never pick a system protoc.
  336. # Path should be rebased because |root_build_dir| for current toolchain
  337. # may be different from |root_out_dir| of protoc built on host toolchain.
  338. "--protoc",
  339. "./" + rebase_path(_protoc_path, root_build_dir),
  340. "--proto-in-dir",
  341. rebase_path(proto_in_dir, root_build_dir),
  342. ]
  343. if (generate_cc) {
  344. args += [
  345. "--cc-out-dir",
  346. rel_cc_out_dir,
  347. ]
  348. if (enable_kythe_annotations) {
  349. args += [ "--enable-kythe-annotation" ]
  350. }
  351. if (defined(invoker.cc_generator_options)) {
  352. args += [
  353. "--cc-options",
  354. invoker.cc_generator_options,
  355. ]
  356. }
  357. if (defined(invoker.allow_optional) && invoker.allow_optional == true) {
  358. args += [ "--allow-optional" ]
  359. }
  360. if (defined(invoker.cc_include)) {
  361. args += [
  362. "--include",
  363. invoker.cc_include,
  364. ]
  365. }
  366. }
  367. if (generate_python) {
  368. args += [
  369. "--py-out-dir",
  370. rel_py_out_dir,
  371. ]
  372. }
  373. if (generate_javascript) {
  374. args += [
  375. "--js-out-dir",
  376. rel_js_out_dir,
  377. ]
  378. }
  379. if (generate_with_plugin) {
  380. args += [
  381. "--plugin",
  382. rebase_path(plugin_path, root_build_dir),
  383. "--plugin-out-dir",
  384. rel_cc_out_dir,
  385. ]
  386. if (defined(invoker.generator_plugin_options)) {
  387. args += [
  388. "--plugin-options",
  389. invoker.generator_plugin_options,
  390. ]
  391. }
  392. }
  393. if (generate_descriptor != "") {
  394. depfile =
  395. "$root_gen_dir/" + proto_out_dir + "/" + generate_descriptor + ".d"
  396. rel_depfile = rebase_path(depfile, root_build_dir)
  397. if (exclude_imports) {
  398. args += [ "--exclude-imports" ]
  399. }
  400. args += [
  401. "--descriptor-set-out",
  402. rel_descriptor_out,
  403. "--descriptor-set-dependency-file",
  404. rel_depfile,
  405. ]
  406. }
  407. if (defined(invoker.import_dirs)) {
  408. foreach(path, invoker.import_dirs) {
  409. args += [ "--import-dir=" + rebase_path(path, root_build_dir) ]
  410. }
  411. }
  412. # System protoc is not used so it's necessary to build a chromium one.
  413. inputs = [ _protoc_path ]
  414. deps = [ _protoc_label ]
  415. if (generate_with_plugin) {
  416. inputs += [ plugin_path ]
  417. if (defined(invoker.generator_plugin_script_deps)) {
  418. # Additional scripts for plugin.
  419. inputs += invoker.generator_plugin_script_deps
  420. }
  421. if (defined(plugin_host_label)) {
  422. # Action depends on native generator plugin but for host toolchain only.
  423. deps += [ plugin_host_label ]
  424. }
  425. }
  426. # The deps may have steps that have to run before running protoc.
  427. if (defined(invoker.proto_deps)) {
  428. deps += invoker.proto_deps
  429. }
  430. if (defined(invoker.deps)) {
  431. deps += invoker.deps
  432. }
  433. }
  434. if (!generate_library) {
  435. # If only descriptor is required, just generate a group wrapper for action output.
  436. link_target_type = "group"
  437. } else if ((defined(invoker.force_source_set) && invoker.force_source_set) ||
  438. (defined(invoker.component_build_force_source_set) &&
  439. invoker.component_build_force_source_set && is_component_build)) {
  440. # Option to disable building a library in component build.
  441. link_target_type = "source_set"
  442. } else {
  443. link_target_type = "static_library"
  444. }
  445. # Generated files may include other generated headers. These includes always
  446. # use relative paths starting at |cc_out_dir|.
  447. # However there is no necessity to add an additional directory, if all protos
  448. # are located in the same directory which is in the search path by default.
  449. config_name = "${target_name}_config"
  450. config(config_name) {
  451. include_dirs = []
  452. if (has_nested_dirs && generate_cc) {
  453. include_dirs += [ cc_out_dir ]
  454. }
  455. if (defined(invoker.import_dirs)) {
  456. foreach(path, invoker.import_dirs) {
  457. include_dirs += [ "$root_gen_dir/" + rebase_path(path, "//") ]
  458. }
  459. }
  460. }
  461. # Build generated javascript stubs.
  462. if (generate_javascript) {
  463. js_library(javascript_name) {
  464. forward_variables_from(invoker,
  465. [
  466. "testonly",
  467. "visibility",
  468. ])
  469. sources = protogens_js
  470. deps = [ "//third_party/protobuf:js_proto" ]
  471. extra_deps = [ ":$action_name" ]
  472. }
  473. }
  474. # Build generated protobuf stubs as libary or source set.
  475. target(link_target_type, target_name) {
  476. forward_variables_from(invoker,
  477. [
  478. "defines",
  479. "testonly",
  480. "visibility",
  481. ])
  482. if (generate_library) {
  483. sources = get_path_info(protogens_cc, "abspath")
  484. if (defined(invoker.remove_configs)) {
  485. configs -= invoker.remove_configs
  486. }
  487. if (defined(invoker.extra_configs)) {
  488. configs += invoker.extra_configs
  489. }
  490. # Remove Sanitizer and coverage instrumentation for a performance boost when
  491. # fuzzing, since the only fuzzers that use protobuf are libprotobuf-mutator
  492. # based fuzzers, and they don't actually target protobuf code.
  493. configs -= not_fuzzed_remove_configs
  494. configs += [ "//build/config/sanitizers:not_fuzzed" ]
  495. }
  496. public_configs = [
  497. "//third_party/protobuf:using_proto",
  498. "//third_party/protobuf:allow_deprecated_proto_fields",
  499. ]
  500. public_deps = []
  501. if (generate_cc || generate_with_plugin) {
  502. # Not necessary if all protos are located in the same directory.
  503. if (has_nested_dirs || defined(invoker.import_dirs)) {
  504. # By default, propagate the config for |include_dirs| to dependent
  505. # targets, so that public imports can be resolved to corresponding
  506. # header files. In some cases, the embedder target handles include
  507. # directory propagation itself, e.g. via a common config.
  508. propagate_imports_configs =
  509. !defined(invoker.propagate_imports_configs) ||
  510. invoker.propagate_imports_configs
  511. if (propagate_imports_configs) {
  512. public_configs += [ ":$config_name" ]
  513. } else {
  514. # Embedder handles include directory propagation to dependents.
  515. configs += [ ":$config_name" ]
  516. }
  517. }
  518. # If using built-in cc generator, the resulting headers reference headers
  519. # within protobuf_lite. Hence, dependencies require those headers too.
  520. # If using generator plugin, extra deps should be resolved by the invoker.
  521. if (generate_cc) {
  522. if (defined(invoker.use_protobuf_full) &&
  523. invoker.use_protobuf_full == true) {
  524. public_deps += [ "//third_party/protobuf:protobuf_full" ]
  525. } else {
  526. public_deps += [ "//third_party/protobuf:protobuf_lite" ]
  527. }
  528. if (is_win) {
  529. cflags = [
  530. # disable: C4125 decimal digit terminates octal escape sequence
  531. # Protoc generates such sequences frequently, there's no obvious
  532. # superior replacement behavior. Since this code is autogenerated,
  533. # the warning would never catch a legitimate bug.
  534. "/wd4125",
  535. ]
  536. }
  537. }
  538. }
  539. public_deps += [ ":$action_name" ]
  540. deps = []
  541. # This will link any libraries in the deps (the use of invoker.deps in the
  542. # action won't link it).
  543. if (defined(invoker.deps)) {
  544. deps += invoker.deps
  545. }
  546. if (defined(invoker.link_deps)) {
  547. deps += invoker.link_deps
  548. }
  549. }
  550. if (generate_py_runtime) {
  551. group(py_runtime_name) {
  552. data = protogens_py
  553. deps = [
  554. ":$action_name",
  555. "//third_party/protobuf:py_proto_runtime",
  556. ]
  557. }
  558. }
  559. }
  560. # Convert a protocol buffer between text and binary formats.
  561. # This can be used to run protoc with the --encode or --decode options.
  562. # Parameters:
  563. #
  564. # sources: list of string
  565. # The sources to loop over and run protoc on
  566. #
  567. # inputs: list of string
  568. # The file dependencies for the action. This should be the list of .proto
  569. # files involved in the conversion operation.
  570. #
  571. # output_pattern: string
  572. # A path pattern with source expansion variables (like source_name_part)
  573. # for where the result of conversion should be placed.
  574. #
  575. # deps: (optional) list of label
  576. # Additional dependencies for the target.
  577. #
  578. # args: list of string
  579. # Arguments to pass to the protoc tool. This could include -I for include
  580. # paths, as well as the name of the proto file.
  581. #
  582. #
  583. # Example to convert a .textproto to a .binarybp:
  584. # protoc_convert("convert_foo") {
  585. # sources = [
  586. # "test/data/example1.textproto",
  587. # "test/data/example2.textproto",
  588. # ]
  589. # inputs = [
  590. # "//component/core/foo.proto",
  591. # ]
  592. # output_pattern = "$target_gen_dir/foo_data/{{source_name_part}}.binarypb"
  593. # args = [
  594. # "--encode=foo.FooMessage",
  595. # "-I",
  596. # rebase_path("//"),
  597. # "component/core/foo.proto",
  598. # ]
  599. # }
  600. template("protoc_convert") {
  601. action_foreach(target_name) {
  602. script = "//tools/protoc_wrapper/protoc_convert.py"
  603. sources = invoker.sources
  604. inputs = invoker.inputs
  605. deps = [ _protoc_label ]
  606. if (defined(invoker.deps)) {
  607. deps += invoker.deps
  608. }
  609. if (defined(invoker.testonly)) {
  610. testonly = invoker.testonly
  611. }
  612. outputs = [ invoker.output_pattern ]
  613. args = [
  614. "--protoc",
  615. "./" + rebase_path(_protoc_path, root_build_dir),
  616. "--infile",
  617. "{{source}}",
  618. "--outfile",
  619. rebase_path(invoker.output_pattern),
  620. ] + invoker.args
  621. }
  622. }