# Copyright (c) 2021 Huawei Device Co., Ltd. # 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. import("//build/ohos.gni") gni_filepath = "//foundation/graphic/graphic_2d/utils/lex_yacc" template("lex_yacc") { lex_name = invoker.lex yacc_name = invoker.yacc gen_flexlexer_name = "${target_name}_gen_flexlexer" gen_lex_name = "${target_name}_gen_lex" gen_yacc_name = "${target_name}_gen_yacc" gen_lex_yacc_name = "${target_name}_gen_lex_yacc" gen_config_name = "${target_name}_gen_config" flexlexer_filename = "$root_gen_dir/$target_name/FlexLexer.h" flexlexer_pathname = rebase_path(flexlexer_filename, root_build_dir) action(gen_flexlexer_name) { script = "$gni_filepath/gen_flexlexer_header.py" inputs = [ script ] outputs = [ flexlexer_filename ] args = [ "--output", flexlexer_pathname, ] } lex_filename = "$root_gen_dir/$target_name/lexer.yy.cc" lex_pathname = rebase_path(lex_filename, root_build_dir) action(gen_lex_name) { script = "$gni_filepath/gen_lex_cpp.py" lex_inputfile = rebase_path(lex_name, root_build_dir) inputs = [ script, lex_name, ] outputs = [ lex_filename ] args = [ "--input", lex_inputfile, "--output", lex_pathname, ] } yacc_filename = "$root_gen_dir/$target_name/parser.cpp" yacc_pathname = rebase_path(yacc_filename, root_build_dir) action(gen_yacc_name) { script = "$gni_filepath/gen_yacc_cpp.py" yacc_inputfile = rebase_path(yacc_name, root_build_dir) inputs = [ script, yacc_name, ] outputs = [ yacc_filename ] args = [ "--input", yacc_inputfile, "--output", yacc_pathname, ] } config(gen_config_name) { include_dirs = [ ".", "$root_gen_dir/$target_name", ] cflags = [ "-Wno-unused-private-field", "-Wno-header-hygiene", "-Wno-implicit-fallthrough", ] } ohos_static_library(gen_lex_yacc_name) { sources = [ "$lex_filename", "$yacc_filename", ] forward_variables_from(invoker, [ "cflags", "include_dirs", "public_configs", "deps", "public_deps", ]) if (!defined(configs)) { configs = [] } if (defined(invoker.configs)) { configs += invoker.configs } if (!defined(public_configs)) { public_configs = [] } public_configs += [ ":$gen_config_name", "//build/config/compiler:rtti", "//build/config/compiler:exceptions", ] deps = [ ":${gen_flexlexer_name}", ":${gen_lex_name}", ":${gen_yacc_name}", ] } group(target_name) { public_deps = [ ":${gen_lex_yacc_name}" ] } }