| load("@rules_cc//cc:cc_binary.bzl", "cc_binary") | |
| load("@rules_java//java:java_binary.bzl", "java_binary") | |
| load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") | |
| load("@rules_ruby//ruby:defs.bzl", "rb_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, | |
| 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__"], | |
| ) | |
| rb_library( | |
| name = "protobuf_lib", | |
| srcs = glob([ | |
| "**/*.rb", | |
| ]), | |
| data = select({ | |
| # Platform native implementations | |
| "@ruby//engine: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": [], | |
| }), | |
| visibility = ["//ruby:__pkg__"], | |
| deps = [ | |
| "//ruby:well_known_ruby_protos", | |
| "@protobuf_bundle", | |
| ], | |
| ) | |
| pkg_files( | |
| name = "dist_files", | |
| srcs = glob([ | |
| "**/*.rb", | |
| "**/*.rake", | |
| ]), | |
| strip_prefix = strip_prefix.from_root(""), | |
| visibility = ["//ruby:__pkg__"], | |
| ) |