Skip to content

Commit

Permalink
♻️ Use single bazel workspace for validator (#37131)
Browse files Browse the repository at this point in the history
* Use a single worksapce file for validator

* Use hash in http archive url

* Sync copybara cl/414547365
  • Loading branch information
antiphoton committed Dec 13, 2021
1 parent 5d6d649 commit 9b8d9f4
Show file tree
Hide file tree
Showing 120 changed files with 484 additions and 551 deletions.
4 changes: 2 additions & 2 deletions build-system/tasks/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ async function validatorCpp() {
'--noshow_loading_progress',
'--test_summary=detailed',
'--verbose_failures',
'validator_test',
'cpp/engine:validator_test',
].join(' ');
execOrDie(bazelCmd, {
cwd: 'validator/cpp/engine',
cwd: 'validator',
stdio: 'inherit',
});
}
Expand Down
11 changes: 11 additions & 0 deletions validator/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Defaults to optimized build.
build -c opt

# Tested and compiles in llvm.
build --repo_env=CC=clang

# Contains c++17 features.
build --cxxopt='-std=c++17'

# Enabled operator new and operator delete for custom allocators.
build --cxxopt='-fsized-deallocation'
2 changes: 2 additions & 0 deletions validator/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules/
*.pyc
# These directories are generated by bazel
bazel-*
# These files are generated by copybara
*.orig
41 changes: 38 additions & 3 deletions validator/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,50 @@ workspace(name = "validator")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_google_absl",
sha256 = "368be019fc8d69a566ac2cf7a75262d5ba8f6409e3ef3cdbcf0106bdeb32e91c",
strip_prefix = "abseil-cpp-9336be04a242237cd41a525bedfcf3be1bb55377",
urls = ["https://github.com/abseil/abseil-cpp/archive/9336be04a242237cd41a525bedfcf3be1bb55377.zip"],
)

http_archive(
name = "com_github_glog",
sha256 = "9411249a033ff79b100d55111347cba886eebf4f0bb6394554b9c11a98eb837f",
strip_prefix = "glog-f4dd77ae6b8e5f8e1323c929e81dbc40ff58fc7b",
urls = ["https://github.com/google/glog/archive/f4dd77ae6b8e5f8e1323c929e81dbc40ff58fc7b.zip"],
)

http_archive(
name = "com_google_googletest",
sha256 = "002d540f947e5981f54ddaab476d87b113d2a14822f21a34dca30f24c9492a24",
strip_prefix = "googletest-16f637fbf4ffc3f7a01fa4eceb7906634565242f",
urls = ["https://github.com/google/googletest/archive/16f637fbf4ffc3f7a01fa4eceb7906634565242f.zip"], # 2019-01-07
)

http_archive(
name = "com_google_protobuf",
sha256 = "40825ef029f05038008b6217e34d00c09e506f99cb91fb97a2f2fd20143fb849",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
sha256 = "3f703847ef2f6b0e9c63a56b9ecc4f05cfc0c2e434555348130f37b03fb9d957",
strip_prefix = "protobuf-4812107b9d0fb9fdcca933766c237c38f2150379",
urls = ["https://github.com/protocolbuffers/protobuf/archive/4812107b9d0fb9fdcca933766c237c38f2150379.zip"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

http_archive(
name = "com_github_gflags_gflags",
sha256 = "cfdba0f2f17e8b1ff75c98113d5080d8ec016148426abcc19130864e2952d7bd",
strip_prefix = "gflags-827c769e5fc98e0f2a34c47cef953cc6328abced",
urls = ["https://github.com/gflags/gflags/archive/827c769e5fc98e0f2a34c47cef953cc6328abced.zip"],
)

http_archive(
name = "com_googlesource_code_re2",
sha256 = "892edf0e0df82740c50d2a624ded968b16ed331606e1c69dc3554b5449191601",
strip_prefix = "re2-d826d9fcb68c62996c1b7c0a45d604e22d814952",
urls = ["https://github.com/google/re2/archive/d826d9fcb68c62996c1b7c0a45d604e22d814952.zip"],
)

# rules_cc defines rules for generating C++ code from Protocol Buffers.
http_archive(
name = "rules_cc",
Expand Down
72 changes: 36 additions & 36 deletions validator/cpp/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cc_library(
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_googlesource_code_re2//:re2",
"@validator//:validator_cc_proto",
"//:validator_cc_proto",
],
)

Expand All @@ -68,7 +68,7 @@ cc_library(
deps = [
"@com_google_absl//absl/strings",
"@com_googlesource_code_re2//:re2",
"@htmlparser//:strings",
"//cpp/htmlparser:strings",
],
)

Expand All @@ -91,7 +91,7 @@ cc_library(
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_googlesource_code_re2//:re2",
"@validator//:validator_cc_proto",
"//:validator_cc_proto",
],
)

Expand All @@ -114,7 +114,7 @@ cc_library(
":utf8-util",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@htmlparser//:strings",
"//cpp/htmlparser:strings",
],
)

Expand All @@ -137,7 +137,7 @@ cc_library(
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:cord",
"@htmlparser//:strings",
"//cpp/htmlparser:strings",
],
)

Expand All @@ -148,7 +148,7 @@ cc_test(
deps = [
":utf8-util",
"@com_google_googletest//:gtest_main",
"@htmlparser//:strings",
"//cpp/htmlparser:strings",
],
)

Expand All @@ -161,7 +161,7 @@ cc_library(
"@com_google_absl//absl/base",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@htmlparser//css:parse-css",
"//cpp/htmlparser/css:parse-css",
],
)

Expand All @@ -172,8 +172,8 @@ cc_test(
":keyframes-parse-css",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
"@htmlparser//:strings",
"@htmlparser//css:parse-css",
"//cpp/htmlparser:strings",
"//cpp/htmlparser/css:parse-css",
],
)

Expand All @@ -184,7 +184,7 @@ cc_library(
copts = ["-std=c++17"],
deps = [
"@com_google_absl//absl/strings",
"@validator//:validator_cc_proto",
"//:validator_cc_proto",
],
)

Expand All @@ -194,7 +194,7 @@ cc_test(
deps = [
":type-identifier",
"@com_google_googletest//:gtest_main",
"@validator//:validator_cc_proto",
"//:validator_cc_proto",
],
)

Expand All @@ -207,8 +207,8 @@ cc_library(
":validator_pb",
"@com_github_glog//:glog",
"@com_googlesource_code_re2//:re2",
"@htmlparser//:strings",
"@validator//:validator_cc_proto",
"//cpp/htmlparser:strings",
"//:validator_cc_proto",
],
)

Expand All @@ -228,15 +228,15 @@ cc_binary(
copts = ["-std=c++17"],
deps = [
"@com_google_protobuf//:protobuf",
"@htmlparser//:defer",
"@htmlparser//:fileutil",
"@validator//:validator_cc_proto",
"//cpp/htmlparser:defer",
"//cpp/htmlparser:fileutil",
"//:validator_cc_proto",
],
)

genrule(
name = "validator-pb",
srcs = ["@validator//:validator.protoascii"],
srcs = ["//:validator.protoascii"],
outs = ["validator.pb"],
cmd = "$(location :validator-convert) " +
"$(SRCS) $@",
Expand Down Expand Up @@ -271,18 +271,18 @@ cc_library(
"@com_google_absl//absl/strings:cord",
"@com_google_absl//absl/synchronization",
"@com_googlesource_code_re2//:re2",
"@htmlparser//:atom",
"@htmlparser//:atomutil",
"@htmlparser//:defer",
"@htmlparser//:node",
"@htmlparser//:parser",
"@htmlparser//:strings",
"@htmlparser//:url",
"@htmlparser//css:amp4ads-parse-css",
"@htmlparser//css:parse-css",
"@htmlparser//css:parse_css_cc_proto",
"@htmlparser//json:parser",
"@validator//:validator_cc_proto",
"//cpp/htmlparser:atom",
"//cpp/htmlparser:atomutil",
"//cpp/htmlparser:defer",
"//cpp/htmlparser:node",
"//cpp/htmlparser:parser",
"//cpp/htmlparser:strings",
"//cpp/htmlparser:url",
"//cpp/htmlparser/css:amp4ads-parse-css",
"//cpp/htmlparser/css:parse-css",
"//cpp/htmlparser/css:parse_css_cc_proto",
"//cpp/htmlparser/json:parser",
"//:validator_cc_proto",
],
)

Expand All @@ -294,7 +294,7 @@ cc_library(
copts = ["-std=c++17"],
deps = [
":validator-internal",
"@validator//:validator_cc_proto",
"//:validator_cc_proto",
],
alwayslink = 1,
)
Expand All @@ -310,14 +310,14 @@ cc_library(
copts = ["-std=c++17"],
data = [
"@amphtml-extensions//:testdata_files",
"@validator//:testdata_files",
"//:testdata_files",
],
deps = [
":error-formatter",
"@com_google_absl//absl/strings",
"@htmlparser//:fileutil",
"@htmlparser//:strings",
"@validator//:validator_cc_proto",
"//cpp/htmlparser:fileutil",
"//cpp/htmlparser:strings",
"//:validator_cc_proto",
],
)

Expand All @@ -331,8 +331,8 @@ cc_test(
":validator_pb",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
"@htmlparser//css:parse_css_cc_proto",
"@validator//:validator_cc_proto",
"//cpp/htmlparser/css:parse_css_cc_proto",
"//:validator_cc_proto",
],
)

Expand Down
67 changes: 0 additions & 67 deletions validator/cpp/engine/WORKSPACE

This file was deleted.

2 changes: 1 addition & 1 deletion validator/cpp/engine/embed_data.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ embed_data = rule(
cfg = "host",
allow_files = True,
default = Label(
"//scripts:filecontents_to_cpp_header",
"//cpp/engine/scripts:filecontents_to_cpp_header",
),
),
},
Expand Down
6 changes: 3 additions & 3 deletions validator/cpp/engine/error-formatter.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// AMP Validator client library to validate if given html is a valid AMP
// document.
//
#include "error-formatter.h"
#include "cpp/engine/error-formatter.h"

#include "glog/logging.h"
#include "validator_pb.h"
#include "strings.h"
#include "cpp/engine/validator_pb.h"
#include "cpp/htmlparser/strings.h"
#include "validator.pb.h"
#include "re2/re2.h" // NOLINT(build/deprecated)

Expand Down
6 changes: 3 additions & 3 deletions validator/cpp/engine/error-formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// then call the ErrorFormatter::ApplyFormat function.
//
// A Java port is available: java/com/google/amp/validator/ErrorFormatter.java.
#ifndef AMPVALIDATOR__ERROR_FORMATTER_H_
#define AMPVALIDATOR__ERROR_FORMATTER_H_
#ifndef CPP_ENGINE_ERROR_FORMATTER_H_
#define CPP_ENGINE_ERROR_FORMATTER_H_

#include <string>

Expand Down Expand Up @@ -39,4 +39,4 @@ class ErrorFormatter {
};
} // namespace amp::validator

#endif // AMPVALIDATOR__ERROR_FORMATTER_H_
#endif // CPP_ENGINE_ERROR_FORMATTER_H_
2 changes: 1 addition & 1 deletion validator/cpp/engine/error-formatter_test.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// AMP Validator client library to validate if given html is a valid AMP
// document.

#include "error-formatter.h"
#include "cpp/engine/error-formatter.h"

#include "gtest/gtest.h"

Expand Down

0 comments on commit 9b8d9f4

Please sign in to comment.