| # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # GN template to generate static library for the given yacc files. |
| # How to use: |
| # [platform2/pkg/BUILD.gn] |
| # generate_flex_parser("foo_flex_parser") { |
| # out_dir = "${platform2_root}" |
| # sources = [ |
| # "foo.ll", |
| # "bar.ll", |
| # ] |
| # } |
| # |
| # Then this generates the binding source code under ${root_gen_dir},. |
| # E.g. ${root_gen_dir}/${out_dir}/foo.cc, ${root_gen_dir}/${out_dir}/bar.cc etc. |
| # |
| # Parameters: |
| # out_dir |
| # The output source code and headers' path. |
| # sources |
| # The .ll / .l file paths. |
| # |
| |
| template("generate_flex_parser") { |
| h_dir = "${root_gen_dir}/" + invoker.out_dir |
| |
| action_foreach(target_name) { |
| sources = invoker.sources |
| script = "//common-mk/file_generator_wrapper.py" |
| outputs = [ |
| "${h_dir}/{{source_name_part}}.cc", |
| ] |
| args = [ |
| "flex", |
| "-o", |
| "${h_dir}/{{source_name_part}}.cc", |
| "{{source}}", |
| ] |
| } |
| } |