diff --git a/install_dependencies.sh b/install_dependencies.sh index 7e8a8657..907aba7a 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -1,17 +1,31 @@ #!/bin/bash # Copyright 2021 Google LLC # -# 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 +# Please read carefully before adding new dependencies: +# +# System dependencies are disallowed by default, and the bar for exceptions is +# high. +# +# pins-infra strives for a hermetic build, i.e. one that is insensitive to the +# libraries and other software installed on your machine, other than Bazel and +# the compilers. This ensure the build is reproducible and portable. +# +# Before adding a new system dependency, consider the following: # -# http://www.apache.org/licenses/LICENSE-2.0 +# 1. Please read the note on dependencies in pins_infra_deps.bzl. # -# 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. +# 2. Can the dependency be avoided altogether? Consider that there is a +# non-trival cost to maintaining dependencies over time. +# +# 3. Can the dependency be built with Bazel instead? +# - For many libraries, there are existing Bazel BUILD files. Try a quick +# Google search. +# - If there is no existing BUILD file, can you write your own BUILD file? +# See the bazel/ folder for examples. Ideally, we strive to upstream such +# BUILD files so everyone can benefit and share the maintenance burden. +# - If it's too hard to write a native BUILD file, try writing a BUILD file +# using rules_foreign_cc (https://github.com/bazelbuild/rules_foreign_cc). +#. See the bazel/ folder for examples. # Please read carefully before adding new dependencies: # diff --git a/p4_symbolic/BUILD.bazel b/p4_symbolic/BUILD.bazel index 753fa143..2fb1ac2d 100644 --- a/p4_symbolic/BUILD.bazel +++ b/p4_symbolic/BUILD.bazel @@ -14,11 +14,6 @@ # This file contains build rules for the main binary of p4_symbolic. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") - package( default_visibility = ["//visibility:public"], licenses = ["notice"], @@ -29,8 +24,6 @@ cc_binary( srcs = [ "main.cc", ], - # linkopts = ["-lz3"], - visibility = ["//p4_symbolic/symbolic:__pkg__"], deps = [ ":parser", "//gutil:status", @@ -49,15 +42,10 @@ cc_binary( cc_library( name = "parser", - srcs = [ - "parser.cc", - ], - hdrs = [ - "parser.h", - ], - visibility = ["//visibility:public"], + srcs = ["parser.cc"], + hdrs = ["parser.h"], deps = [ - "//gutil:proto", + "//gutil:proto", "//gutil:status", "//p4_pdpi:ir_cc_proto", "//p4_symbolic/bmv2", @@ -74,7 +62,6 @@ cc_library( name = "z3_util", srcs = ["z3_util.cc"], hdrs = ["z3_util.h"], - visibility = ["//visibility:public"], deps = [ "//gutil:status", "//p4_pdpi/string_encodings:hex_string", diff --git a/p4_symbolic/bmv2/BUILD.bazel b/p4_symbolic/bmv2/BUILD.bazel index bfe70047..f80130ff 100644 --- a/p4_symbolic/bmv2/BUILD.bazel +++ b/p4_symbolic/bmv2/BUILD.bazel @@ -12,10 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") load("//p4_symbolic/bmv2:test.bzl", "bmv2_protobuf_parsing_test") package( @@ -25,7 +21,6 @@ package( cc_proto_library( name = "bmv2_cc_proto", - visibility = ["//p4_symbolic:__subpackages__"], deps = [":bmv2_proto"], ) @@ -34,7 +29,6 @@ proto_library( srcs = [ "bmv2.proto", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ "@com_google_protobuf//:struct_proto", ], @@ -48,7 +42,6 @@ cc_library( hdrs = [ "bmv2.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ ":bmv2_cc_proto", "//gutil:status", diff --git a/p4_symbolic/ir/BUILD.bazel b/p4_symbolic/ir/BUILD.bazel index 26f11de1..be4ec3e5 100644 --- a/p4_symbolic/ir/BUILD.bazel +++ b/p4_symbolic/ir/BUILD.bazel @@ -12,10 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") load("//p4_symbolic/ir:test.bzl", "ir_parsing_test") package( @@ -23,6 +19,20 @@ package( licenses = ["notice"], ) +cc_proto_library( + name = "ir_cc_proto", + deps = [":ir_proto"], +) + +proto_library( + name = "ir_proto", + srcs = ["ir.proto"], + deps = [ + "//p4_pdpi:ir_proto", + "//p4_symbolic/bmv2:bmv2_proto", + ], +) + cc_library( name = "pdpi_driver", srcs = [ @@ -31,7 +41,6 @@ cc_library( hdrs = [ "pdpi_driver.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ "//gutil:proto", "//gutil:status", @@ -40,21 +49,6 @@ cc_library( ], ) -cc_proto_library( - name = "ir_cc_proto", - visibility = ["//p4_symbolic:__subpackages__"], - deps = [":ir_proto"], -) - -proto_library( - name = "ir_proto", - srcs = ["ir.proto"], - deps = [ - "//p4_pdpi:ir_proto", - "//p4_symbolic/bmv2:bmv2_proto", - ], -) - cc_library( name = "table_entries", srcs = [ @@ -63,7 +57,6 @@ cc_library( hdrs = [ "table_entries.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ ":ir_cc_proto", "//gutil:status", @@ -85,7 +78,6 @@ cc_library( hdrs = [ "ir.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ ":ir_cc_proto", ":table_entries", diff --git a/p4_symbolic/sai/BUILD.bazel b/p4_symbolic/sai/BUILD.bazel index 93d15ead..f6bbff33 100644 --- a/p4_symbolic/sai/BUILD.bazel +++ b/p4_symbolic/sai/BUILD.bazel @@ -12,12 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") - -package(licenses = ["notice"]) +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], +) cc_library( name = "fields", @@ -36,7 +34,6 @@ cc_library( name = "parser", srcs = ["parser.cc"], hdrs = ["parser.h"], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ ":fields", "//gutil:status", diff --git a/p4_symbolic/symbolic/BUILD.bazel b/p4_symbolic/symbolic/BUILD.bazel index 7dbad4ae..ca48e2b2 100644 --- a/p4_symbolic/symbolic/BUILD.bazel +++ b/p4_symbolic/symbolic/BUILD.bazel @@ -12,10 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") load("//p4_symbolic/symbolic:test.bzl", "end_to_end_test") package( @@ -49,7 +45,6 @@ cc_library( "util.h", "values.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ "//gutil:status", "//p4_pdpi:ir_cc_proto", diff --git a/p4_symbolic/testdata/BUILD.bazel b/p4_symbolic/testdata/BUILD.bazel index 7ec79468..52e61f67 100644 --- a/p4_symbolic/testdata/BUILD.bazel +++ b/p4_symbolic/testdata/BUILD.bazel @@ -12,11 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") - package(default_visibility = ["//visibility:public"]) # Make sure programs under p4-samples are visible to other @@ -27,5 +22,4 @@ exports_files( "**/*.txt", ]), licenses = ["notice"], - visibility = ["//p4_symbolic:__subpackages__"], ) diff --git a/p4_symbolic/tests/BUILD.bazel b/p4_symbolic/tests/BUILD.bazel index 87daf147..013dcdcc 100644 --- a/p4_symbolic/tests/BUILD.bazel +++ b/p4_symbolic/tests/BUILD.bazel @@ -1,8 +1,3 @@ -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") - package( default_visibility = ["//visibility:public"], licenses = ["notice"], diff --git a/p4_symbolic/tests/sai_p4_component_test.cc b/p4_symbolic/tests/sai_p4_component_test.cc index e6cbe62f..14944e0c 100644 --- a/p4_symbolic/tests/sai_p4_component_test.cc +++ b/p4_symbolic/tests/sai_p4_component_test.cc @@ -28,7 +28,7 @@ using ::p4::config::v1::P4Info; using ::testing::Eq; using ::testing::Not; -constexpr absl::string_view kTableEntries = R"PB( +constexpr absl::string_view kTableEntries = R"pb( entries { acl_pre_ingress_table_entry { match { @@ -73,7 +73,7 @@ constexpr absl::string_view kTableEntries = R"PB( action { set_dst_mac { dst_mac: "cc:bb:aa:99:88:77" } } } } -)PB"; +)pb"; class P4SymbolicComponentTest : public testing::Test { public: diff --git a/p4_symbolic/util/BUILD.bazel b/p4_symbolic/util/BUILD.bazel index b8070667..d9f9a016 100644 --- a/p4_symbolic/util/BUILD.bazel +++ b/p4_symbolic/util/BUILD.bazel @@ -12,11 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//p4_pdpi/testing:diff_test.bzl", "cmd_diff_test", "diff_test") -load("//p4_pdpi:pdgen.bzl", "p4_pd_proto") -load("@com_github_p4lang_p4c//:bazel/p4_library.bzl", "p4_library") - package( default_visibility = ["//visibility:public"], licenses = ["notice"], @@ -33,7 +28,6 @@ cc_library( # TODO: clean up. # "status.h", ], - visibility = ["//p4_symbolic:__subpackages__"], deps = [ "//gutil:status", "@com_google_absl//absl/status",