xref: /aosp_15_r20/external/sandboxed-api/sandboxed_api/tools/generator2/BUILD.bazel (revision ec63e07ab9515d95e79c211197c445ef84cefa6a)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
16load("//sandboxed_api/bazel:sapi.bzl", "sapi_library")
17
18licenses(["notice"])
19
20py_library(
21    name = "code",
22    srcs = ["code.py"],
23)
24
25py_test(
26    name = "code_test",
27    size = "small",
28    srcs = [
29        "code_test.py",
30        "code_test_util.py",
31    ],
32    deps = [
33        ":code",
34        "@com_google_absl_py//absl/testing:absltest",
35        "@com_google_absl_py//absl/testing:parameterized",
36    ],
37)
38
39py_binary(
40    name = "sapi_generator",
41    srcs = ["sapi_generator.py"],
42    visibility = ["//visibility:public"],
43    deps = [
44        ":code",
45        "@com_google_absl_py//absl:app",
46        "@com_google_absl_py//absl/flags",
47        "@com_google_absl_py//absl/logging",
48    ],
49)
50
51cc_library(
52    name = "tests",
53    srcs = [
54        "testdata/tests.cc",
55        "testdata/tests.h",
56        "testdata/tests2.cc",
57    ],
58    copts = sapi_platform_copts(),
59    alwayslink = 1,
60)
61
62# Targets for testing if generated code compiles
63sapi_library(
64    name = "tests_sapi_generator",
65    generator_version = 1,
66    input_files = [
67        "testdata/tests.cc",
68        "testdata/tests2.cc",
69    ],
70    lib = ":tests",
71    lib_name = "Tests",
72    namespace = "sapi::tests",
73)
74
75cc_binary(
76    name = "build_test_bin",
77    srcs = [
78        "testdata/main.cc",
79        ":tests_sapi_generator.sapi.h",
80        ":tests_sapi_generator_embed.h",
81    ],
82    copts = sapi_platform_copts(),
83    deps = [
84        ":tests_sapi_generator",
85        "//sandboxed_api:sapi",
86        "//sandboxed_api:vars",
87        "//sandboxed_api/util:status",
88        "@com_google_absl//absl/status",
89        "@com_google_absl//absl/status:statusor",
90    ],
91)
92
93# Compilation test - always passes if dependency builds properly
94sh_test(
95    name = "build_test",
96    srcs = ["build_test.sh"],
97    data = [":build_test_bin"],
98    tags = ["nobuilder"],
99)
100