aboutsummaryrefslogtreecommitdiff
path: root/examples/src/BUILD
blob: cd5e985dcedb2ed89b9bd387fd1a5c41ec34589e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 2022 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# 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.
# Examples of applications and interactions with licenses

load("@rules_license//rules:compliance.bzl", "check_license", "licenses_used")
load("@rules_license//examples/vndor/constant_gen:defs.bzl", "constant_gen")

package(
    default_package_metadata = ["//:license", "//:package_info"],
    default_visibility = ["//examples:__subpackages__"],
)

cc_binary(
    name = "my_server",
    srcs = ["server.cc"],
    deps = [":message"],
)

# Sample
constant_gen(
    name = "message",
    text = "Hello, world.",
    var = "server_message",
)

# TODO(aiuto): Turn this strictly into a compliance test.
check_license(
    name = "check_server",
    check_conditions = False,
    license_texts = "server_licenses.txt",
    report = "server_report.txt",
    deps = [
        ":my_server",
    ],
)

#
# Verify the licenses are what we expect. The golden output shows that
# :my_server only uses the unencumbered license type.

licenses_used(
    name = "server_licenses",
    out = "server_licenses.json",
    deps = [":my_server"],
)

py_test(
    name = "server_licenses_test",
    srcs = ["server_licenses_test.py"],
    data = [":server_licenses.json"],
    python_version = "PY3",
    deps = [
        "@rules_license//tests:license_test_utils",
    ],
)

# This server uses something under a restricted license
cc_binary(
    name = "my_violating_server",
    srcs = ["server.cc"],
    deps = [
        ":message",
        "@rules_license//examples/vndor/acme",
        "@rules_license//examples/vndor/libhhgttg",
    ],
)