Debian Codegraph @

third_party/upb/cmake/BUILD.bazel

raw
1 # Copyright (c) 2009-2021, Google LLC
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
11 # * Neither the name of Google LLC nor the
12 # names of its contributors may be used to endorse or promote products
13 # derived from this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
19 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 load(
27 ":build_defs.bzl",
28 "generated_file_staleness_test",
29 )
30 load(
31 "//bazel:build_defs.bzl",
32 "make_shell_script",
33 )
34
35 licenses(["notice"])
36
37 exports_files(["staleness_test.py"])
38
39 py_library(
40 name = "staleness_test_lib",
41 testonly = 1,
42 srcs = ["staleness_test_lib.py"],
43 )
44
45 py_binary(
46 name = "make_cmakelists",
47 srcs = ["make_cmakelists.py"],
48 )
49
50 genrule(
51 name = "gen_cmakelists",
52 srcs = [
53 "//:BUILD",
54 "//:WORKSPACE",
55 ],
56 outs = ["generated-in/CMakeLists.txt"],
57 cmd = "$(location :make_cmakelists) $@",
58 tools = [":make_cmakelists"],
59 )
60
61 genrule(
62 name = "copy_protos",
63 srcs = ["//:descriptor_upb_proto"],
64 outs = [
65 "generated-in/google/protobuf/descriptor.upb.c",
66 "generated-in/google/protobuf/descriptor.upb.h",
67 ],
68 cmd = "cp $(SRCS) $(@D)/generated-in/google/protobuf",
69 )
70
71 generated_file_staleness_test(
72 name = "test_generated_files",
73 outs = [
74 "CMakeLists.txt",
75 "google/protobuf/descriptor.upb.c",
76 "google/protobuf/descriptor.upb.h",
77 ],
78 generated_pattern = "generated-in/%s",
79 tags = ["manual"],
80 )
81
82 # Test the CMake build #########################################################
83
84 make_shell_script(
85 name = "gen_run_cmake_build",
86 out = "run_cmake_build.sh",
87 contents = "set -ex\n" +
88 "(cd cmake/generated-in && rsync -avR . ..)\n" +
89 "mkdir build && cd build && cmake ../cmake && make -j8 && make test",
90 )
91
92 sh_test(
93 name = "cmake_build",
94 srcs = ["run_cmake_build.sh"],
95 data = [
96 ":copy_protos",
97 ":gen_cmakelists",
98 "//:cmake_files",
99 "//third_party/utf8_range:cmake_files",
100 ],
101 deps = ["@bazel_tools//tools/bash/runfiles"],
102 )