• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load(
2    ":build_defs.bzl",
3    "generated_file_staleness_test",
4)
5load(
6    "//bazel:build_defs.bzl",
7    "make_shell_script",
8)
9
10licenses(["notice"])
11
12exports_files(["staleness_test.py"])
13
14py_library(
15    name = "staleness_test_lib",
16    testonly = 1,
17    srcs = ["staleness_test_lib.py"],
18)
19
20py_binary(
21    name = "make_cmakelists",
22    srcs = ["make_cmakelists.py"],
23)
24
25genrule(
26    name = "gen_cmakelists",
27    srcs = [
28        "//:BUILD",
29        "//:WORKSPACE",
30        "//:cmake_files",
31        "//third_party/wyhash:cmake_files",
32        ":cmake_files",
33    ],
34    outs = ["generated-in/CMakeLists.txt"],
35    cmd = "$(location :make_cmakelists) $@",
36    tools = [":make_cmakelists"],
37)
38
39genrule(
40    name = "copy_json_ragel",
41    srcs = ["//:upb/json/parser.c"],
42    outs = ["generated-in/upb/json/parser.c"],
43    cmd = "cp $< $@",
44)
45
46genrule(
47    name = "copy_protos",
48    srcs = ["//:descriptor_upb_proto"],
49    outs = [
50        "generated-in/google/protobuf/descriptor.upb.c",
51        "generated-in/google/protobuf/descriptor.upb.h",
52    ],
53    cmd = "cp $(SRCS) $(@D)/generated-in/google/protobuf",
54)
55
56generated_file_staleness_test(
57    name = "test_generated_files",
58    outs = [
59        "CMakeLists.txt",
60        "google/protobuf/descriptor.upb.c",
61        "google/protobuf/descriptor.upb.h",
62        "upb/json/parser.c",
63    ],
64    generated_pattern = "generated-in/%s",
65)
66
67# Test the CMake build #########################################################
68
69filegroup(
70    name = "cmake_files",
71    srcs = glob([
72        "**/*",
73    ]),
74)
75
76make_shell_script(
77    name = "gen_run_cmake_build",
78    out = "run_cmake_build.sh",
79    contents = "find . && mkdir build && cd build && cmake ../cmake && make -j8 && make test",
80)
81
82sh_test(
83    name = "cmake_build",
84    srcs = ["run_cmake_build.sh"],
85    data = [
86        ":cmake_files",
87        "//:cmake_files",
88        "//third_party/wyhash:cmake_files",
89    ],
90    deps = ["@bazel_tools//tools/bash/runfiles"],
91)
92