IWYU in sapi code generator

PiperOrigin-RevId: 350134692
Change-Id: I5389df8a02f6679a3881b20b599ff5d9fc81650e
pull/75/head
Wiktor Garbacz 2021-01-05 07:18:13 -08:00 committed by Copybara-Service
parent 142c35898c
commit fe79c95a50
4 changed files with 21 additions and 2 deletions

View File

@ -31,6 +31,7 @@ def get_embed_dir():
return native.package_name()
def sort_deps(deps):
deps = depset(deps).to_list()
colon_deps = [x for x in deps if x.startswith(":")]
other_deps = [x for x in deps if not x.startswith(":")]
return sorted(colon_deps) + sorted(other_deps)
@ -192,7 +193,10 @@ def sapi_library(
data = [":" + name + ".bin"],
deps = sort_deps(
[
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
rprefix + "//sandboxed_api:sapi",
rprefix + "//sandboxed_api/util:status",
rprefix + "//sandboxed_api:vars",
] + deps +
([":" + name + "_embed"] if embed else []) +

View File

@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
licenses(["notice"])
load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
load("//sandboxed_api/bazel:sapi.bzl", "sapi_library")
licenses(["notice"])
py_library(
name = "code",
srcs = ["code.py"],
@ -81,6 +81,9 @@ cc_binary(
"//sandboxed_api:sapi",
"//sandboxed_api:vars",
"//sandboxed_api/sandbox2",
"//sandboxed_api/util:status",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)

View File

@ -906,7 +906,10 @@ class Generator(object):
result.append(Generator.GUARD_START.format(header_guard))
# Copybara transform results in the paths below.
result.append('#include "absl/status/status.h"')
result.append('#include "absl/status/statusor.h"')
result.append('#include "sandboxed_api/sandbox.h"')
result.append('#include "sandboxed_api/util/status_macros.h"')
result.append('#include "sandboxed_api/vars.h"')
if embed_name:

View File

@ -18,7 +18,10 @@
CODE_GOLD = """// AUTO-GENERATED by the Sandboxed API generator.
// Edits will be discarded when regenerating this file.
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/sandbox.h"
#include "sandboxed_api/util/status_macros.h"
#include "sandboxed_api/vars.h"
namespace sapi {
@ -119,7 +122,10 @@ class TestApi {
CODE_GOLD_MAPPED = """// AUTO-GENERATED by the Sandboxed API generator.
// Edits will be discarded when regenerating this file.
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/sandbox.h"
#include "sandboxed_api/util/status_macros.h"
#include "sandboxed_api/vars.h"
namespace sapi {
@ -154,7 +160,10 @@ class TestApi {
CODE_ENUM_GOLD = """// AUTO-GENERATED by the Sandboxed API generator.
// Edits will be discarded when regenerating this file.
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/sandbox.h"
#include "sandboxed_api/util/status_macros.h"
#include "sandboxed_api/vars.h"
namespace sapi {