Skip to content

Commit

Permalink
Sync for validator cpp engine and cpp htmlparser (#36271)
Browse files Browse the repository at this point in the history
* Add glog/logging.h for LOG(FATAL) and LOG_IF(FATAL, ...)

PiperOrigin-RevId: 400277046

* Fix build rules to regenerate states.h

PiperOrigin-RevId: 400280277

* Fix missing flag declaration in htmldataset_test.cc

PiperOrigin-RevId: 400288157

* Use com_googlesource_re2 instead of com_github_re2

PiperOrigin-RevId: 400295263

* Add sha256 in WORKSPACE files and other clean up.
Moved com_google_protobuf to first in WORKSPACEs.
Removed unused com_github_re2 http_archive.

PiperOrigin-RevId: 400304559
  • Loading branch information
honeybadgerdontcare committed Oct 7, 2021
1 parent e51d33d commit 70bbf7f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
34 changes: 19 additions & 15 deletions validator/cpp/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ load("embed_data.bzl", "embed_data")
# Usage:
# To build the library, use the following bazel command:
#
# bazel build --repo_env=CC=clang --cxxopt='-std=c++17' <build_target>
# bazel build --repo_env=CC=clang --cxxopt='-std=c++17' validator
#
# To run the tests, use the following bazel command:
#
# bazel test --cxxopt='-std=c++17' validator_test

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -36,13 +40,13 @@ cc_library(
name = "parse-layout",
srcs = ["parse-layout.cc"],
hdrs = ["parse-layout.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_googlesource_code_re2//:re2",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -60,12 +64,12 @@ cc_library(
name = "parse-layout-sizes",
srcs = ["parse-layout-sizes.cc"],
hdrs = ["parse-layout-sizes.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/strings",
"@com_googlesource_code_re2//:re2",
"@htmlparser//:strings",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -82,13 +86,13 @@ cc_library(
name = "parse-srcset",
srcs = ["parse-srcset.cc"],
hdrs = ["parse-srcset.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_googlesource_code_re2//:re2",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -105,13 +109,13 @@ cc_library(
name = "parse-viewport",
srcs = ["parse-viewport.cc"],
hdrs = ["parse-viewport.h"],
copts = ["-std=c++17"],
deps = [
":utf8-util",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@htmlparser//:strings",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -128,13 +132,13 @@ cc_library(
name = "utf8-util",
srcs = ["utf8-util.cc"],
hdrs = ["utf8-util.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@htmlparser//:strings",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -152,13 +156,13 @@ cc_library(
name = "keyframes-parse-css",
srcs = ["keyframes-parse-css.cc"],
hdrs = ["keyframes-parse-css.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/base",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@htmlparser//css:parse-css",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -177,11 +181,11 @@ cc_library(
name = "type-identifier",
srcs = ["type-identifier.cc"],
hdrs = ["type-identifier.h"],
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/strings",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -198,14 +202,14 @@ cc_library(
name = "error-formatter",
srcs = ["error-formatter.cc"],
hdrs = ["error-formatter.h"],
copts = ["-std=c++17"],
deps = [
":validator_pb",
"@com_googlesource_code_re2//:re2",
"@com_github_glog//:glog",
"@com_googlesource_code_re2//:re2",
"@htmlparser//:strings",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_test(
Expand All @@ -221,13 +225,13 @@ cc_test(
cc_binary(
name = "validator-convert",
srcs = ["validator-convert.cc"],
copts = ["-std=c++17"],
deps = [
"@com_google_protobuf//:protobuf",
"@htmlparser//:defer",
"@htmlparser//:fileutil",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

genrule(
Expand All @@ -244,6 +248,7 @@ cc_library(
srcs = [
"validator-internal.cc",
],
copts = ["-std=c++17"],
visibility = ["//visibility:private"],
deps = [
":keyframes-parse-css",
Expand Down Expand Up @@ -279,20 +284,19 @@ cc_library(
"@htmlparser//json:parser",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_library(
name = "validator",
hdrs = [
"validator.h",
],
copts = ["-std=c++17"],
deps = [
":validator-internal",
"@validator//:validator_cc_proto",
],
alwayslink = 1,
copts = ["-std=c++17"],
)

cc_library(
Expand All @@ -303,9 +307,10 @@ cc_library(
hdrs = [
"testing-utils.h",
],
copts = ["-std=c++17"],
data = [
"@validator//:testdata_files",
"@amphtml-extensions//:testdata_files",
"@validator//:testdata_files",
],
deps = [
":error-formatter",
Expand All @@ -314,7 +319,6 @@ cc_library(
"@htmlparser//:strings",
"@validator//:validator_cc_proto",
],
copts = ["-std=c++17"],
)

cc_test(
Expand Down
4 changes: 2 additions & 2 deletions validator/cpp/engine/scripts/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
licenses(["notice"])

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

cc_binary(
name = "filecontents_to_cpp_header",
srcs = [
Expand Down
6 changes: 4 additions & 2 deletions validator/cpp/htmlparser/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ cc_binary(
)

cc_binary(
name = "jsongrammargen",
name = "statetablegen",
srcs = [
"jsongrammargen.cc",
"statetablegen.cc",
],
data = [
"@htmlparser//data:jsongrammar.txt",
"@htmlparser//json:states.h",
],
deps = [
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@htmlparser//grammar:tablebuilder",
],
)
2 changes: 1 addition & 1 deletion validator/cpp/htmlparser/css/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ cc_library(
hdrs = ["amp4ads-parse-css.h"],
deps = [
":parse-css",
"@com_github_re2//:re2",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_googlesource_code_re2//:re2",
],
)

Expand Down
1 change: 1 addition & 0 deletions validator/cpp/htmlparser/css/parse-css-urls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "absl/strings/numbers.h"
#include "absl/strings/str_join.h"
#include "absl/types/variant.h"
#include "glog/logging.h"
#include "logging.h"
#include "strings.h"

Expand Down
2 changes: 1 addition & 1 deletion validator/cpp/htmlparser/grammar/tablebuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ bool TableBuilder::OutputHeaderFile(
fd << "// -*- C++ -*-\n";

fd << "\n// AUTO GENERATED; DO NOT EDIT.\n";
fd << "// To regenerate this file, see comments in bin/jsongrammargen\n\n";
fd << "// To regenerate this file, see comments in bin/statetablegen\n\n";
if (!header_options_.ifdef_guard.empty()) {
fd << "#ifndef " << header_options_.ifdef_guard << "\n";
fd << "#define " << header_options_.ifdef_guard << "\n\n";
Expand Down
2 changes: 2 additions & 0 deletions validator/cpp/htmlparser/htmldataset_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "testconstants.h"
#include "tokenizer.h"

ABSL_FLAG(std::string, test_srcdir, "", "Testdata directory");

using namespace htmlparser;

// Represents a single test case.
Expand Down
2 changes: 1 addition & 1 deletion validator/cpp/htmlparser/json/states.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- C++ -*-

// AUTO GENERATED; DO NOT EDIT.
// To regenerate this file, see comments in bin/jsongrammargen
// To regenerate this file, see comments in bin/statestablegen

#ifndef HTMLPARSER__JSON_STATES_H_
#define HTMLPARSER__JSON_STATES_H_
Expand Down

0 comments on commit 70bbf7f

Please sign in to comment.