blob: 8cbc194def3b0ed0e33cdea16d98b7ebaa7ac4de [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# 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.
config("css_parser_config") {
include_dirs = [ "$target_gen_dir" ]
}
# Generates header files from Bison grammar that are privately included
# by CSS scanner and parser.
action("css_grammar") {
script = "//starboard/build/run_bash.py"
# Define the platform specific Bison binary.
if (host_os == "win") {
bison_executable = "win_bison"
} else {
bison_executable = "bison"
}
inputs = [ "grammar.y" ]
outputs = [
# Tokens and types, included by scanner.
"$target_gen_dir/grammar_generated.h",
# LALR(1) parser tables and yy*() functions, included by parser.
"$target_gen_dir/grammar_impl_generated.h",
]
args = [
bison_executable,
"-Wall",
"-Werror",
"--defines=" + rebase_path(outputs[0], root_build_dir),
"--output=" + rebase_path(outputs[1], root_build_dir),
rebase_path(inputs[0], root_build_dir),
]
}
static_library("css_parser") {
has_pedantic_warnings = true
sources = [
"animation_shorthand_property_parse_structures.cc",
"animation_shorthand_property_parse_structures.h",
"background_shorthand_property_parse_structures.cc",
"background_shorthand_property_parse_structures.h",
"border_shorthand_property_parse_structures.cc",
"border_shorthand_property_parse_structures.h",
"flex_shorthand_property_parse_structures.cc",
"flex_shorthand_property_parse_structures.h",
"font_shorthand_property_parse_structures.cc",
"font_shorthand_property_parse_structures.h",
"grammar.h",
"margin_or_padding_shorthand.cc",
"margin_or_padding_shorthand.h",
"parser.cc",
"parser.h",
"position_parse_structures.cc",
"position_parse_structures.h",
"property_declaration.h",
"ref_counted_util.h",
"scanner.cc",
"scanner.h",
"shadow_property_parse_structures.cc",
"shadow_property_parse_structures.h",
"string_pool.h",
"switches.cc",
"switches.h",
"text_decoration_shorthand_property_parse_structures.cc",
"text_decoration_shorthand_property_parse_structures.h",
"transition_shorthand_property_parse_structures.cc",
"transition_shorthand_property_parse_structures.h",
"trivial_string_piece.h",
"trivial_type_pairs.h",
]
sources += get_target_outputs(":css_grammar")
public_configs = [ ":css_parser_config" ]
# Scanner exposes UChar32 in a header.
public_deps = [ "//third_party/icu:icuuc" ]
deps = [
":css_grammar",
"//base",
"//cobalt/base",
"//cobalt/cssom",
"//nb",
"//starboard/common",
]
if (is_clang_16) {
# grammar_impl_generated.h variable 'yynerrs' set but not used
cflags_cc = [ "-Wno-unused-but-set-variable" ]
}
}
target(gtest_target_type, "css_parser_test") {
testonly = true
has_pedantic_warnings = true
sources = [
"parser_test.cc",
"ref_counted_util_test.cc",
"scanner_test.cc",
"trivial_string_piece_test.cc",
]
deps = [
":css_grammar",
":css_parser",
"//base",
"//cobalt/browser:test_dependencies_on_browser",
"//cobalt/cssom",
"//cobalt/dom",
"//cobalt/test:run_all_unittests",
"//testing/gmock",
"//testing/gtest",
]
}