BUILD 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. load(
  26. ":build_defs.bzl",
  27. "generated_file_staleness_test",
  28. )
  29. load(
  30. "//bazel:build_defs.bzl",
  31. "make_shell_script",
  32. )
  33. licenses(["notice"])
  34. exports_files(["staleness_test.py"])
  35. py_library(
  36. name = "staleness_test_lib",
  37. testonly = 1,
  38. srcs = ["staleness_test_lib.py"],
  39. )
  40. py_binary(
  41. name = "make_cmakelists",
  42. srcs = ["make_cmakelists.py"],
  43. )
  44. genrule(
  45. name = "gen_cmakelists",
  46. srcs = [
  47. "//:BUILD",
  48. "//:WORKSPACE",
  49. "//:cmake_files",
  50. ":cmake_files",
  51. ],
  52. outs = ["generated-in/CMakeLists.txt"],
  53. cmd = "$(location :make_cmakelists) $@",
  54. tools = [":make_cmakelists"],
  55. )
  56. genrule(
  57. name = "copy_protos",
  58. srcs = ["//:descriptor_upb_proto"],
  59. outs = [
  60. "generated-in/google/protobuf/descriptor.upb.c",
  61. "generated-in/google/protobuf/descriptor.upb.h",
  62. ],
  63. cmd = "cp $(SRCS) $(@D)/generated-in/google/protobuf",
  64. )
  65. generated_file_staleness_test(
  66. name = "test_generated_files",
  67. outs = [
  68. "CMakeLists.txt",
  69. "google/protobuf/descriptor.upb.c",
  70. "google/protobuf/descriptor.upb.h",
  71. ],
  72. generated_pattern = "generated-in/%s",
  73. )
  74. # Test the CMake build #########################################################
  75. filegroup(
  76. name = "cmake_files",
  77. srcs = glob([
  78. "**/*",
  79. ]),
  80. )
  81. make_shell_script(
  82. name = "gen_run_cmake_build",
  83. out = "run_cmake_build.sh",
  84. contents = "find . && mkdir build && cd build && cmake ../cmake && make -j8 && make test",
  85. )
  86. sh_test(
  87. name = "cmake_build",
  88. srcs = ["run_cmake_build.sh"],
  89. data = [
  90. ":cmake_files",
  91. "//:cmake_files",
  92. "//third_party/utf8_range:cmake_files",
  93. ],
  94. deps = ["@bazel_tools//tools/bash/runfiles"],
  95. )