File: BUILD.bazel

package info (click to toggle)
protobuf 3.25.4-4
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 45,992 kB
  • sloc: cpp: 204,199; java: 87,622; ansic: 81,204; objc: 58,434; cs: 27,303; python: 22,799; php: 11,340; ruby: 8,637; pascal: 3,324; xml: 2,333; sh: 1,331; makefile: 538; lisp: 86; awk: 17
file content (98 lines) | stat: -rw-r--r-- 2,534 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_ruby//ruby:defs.bzl", "ruby_library")

config_setting(
    name = "requires_bundle",
    constraint_values = ["@platforms//os:osx"],
)

cc_binary(
    name = "protobuf_c.so",
    linkshared = 1,
    tags = ["manual"],
    deps = ["//ruby/ext/google/protobuf_c"],
)

cc_binary(
    name = "libprotobuf_c_ffi.so",
    linkshared = 1,
    tags = ["manual"],
    deps = ["//ruby/ext/google/protobuf_c:protobuf_c_ffi"],
)

# Move the bundle to the location expected by our Ruby files.
genrule(
    name = "copy_bundle",
    srcs = ["//ruby/ext/google/protobuf_c:bundle"],
    outs = ["protobuf_c.bundle"],
    cmd = "cp $< $@",
    tags = ["manual"],
)

# Move the bundle to the location expected by our Ruby files.
genrule(
    name = "copy_ffi_bundle",
    srcs = ["//ruby/ext/google/protobuf_c:ffi_bundle"],
    outs = ["libprotobuf_c_ffi.bundle"],
    cmd = "cp $< $@",
    tags = ["manual"],
    visibility = [
        "//ruby:__subpackages__",
    ],
)

java_binary(
    name = "protobuf_java_bin",
    create_executable = False,
    deploy_env = ["@rules_ruby//ruby/runtime:jruby_binary"],
    runtime_deps = [
        "//ruby/src/main/java:protobuf_java",
    ],
)

# Move the jar to the location expected by our Ruby files.
genrule(
    name = "copy_jar",
    srcs = ["protobuf_java_bin_deploy.jar"],
    outs = ["protobuf_java.jar"],
    cmd = "cp $< $@",
    tags = ["manual"],
    visibility = ["//ruby:__subpackages__"],
)

ruby_library(
    name = "protobuf_lib",
    srcs = glob([
        "**/*.rb",
    ]),
    data = select({
        # Platform native implementations
        "@rules_ruby//ruby/runtime:config_jruby": ["protobuf_java.jar"],
        "@platforms//os:osx": ["protobuf_c.bundle"],
        "//conditions:default": ["protobuf_c.so"],
    }) + select({
        # FFI Implementations
        "//ruby:macos_ffi_enabled": ["libprotobuf_c_ffi.bundle"],
        "//ruby:linux_ffi_enabled": ["libprotobuf_c_ffi.so"],
        "//conditions:default": [],
    }),
    includes = ["ruby/lib"],
    visibility = ["//ruby:__pkg__"],
    deps = ["//:well_known_ruby_protos"] + select({
        "//ruby:ffi_enabled": [
            "@protobuf_bundle//:ffi",
            "@protobuf_bundle//:ffi-compiler",
        ],
        "//conditions:default": [],
    }),
)

pkg_files(
    name = "dist_files",
    srcs = glob([
        "**/*.rb",
        "**/*.rake",
    ]),
    strip_prefix = strip_prefix.from_root(""),
    visibility = ["//ruby:__pkg__"],
)