protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Add ruby release targets

Open deannagarcia opened this issue 3 years ago • 3 comments

Add bazel targets to create ruby release artifacts.

Should be run with:

bazel run ruby:release
bazel run ruby:jruby_release 

deannagarcia avatar Jan 05 '23 17:01 deannagarcia

bazel run ruby:release --define=ruby_platform=c bazel run ruby:jruby_release --define=ruby_platform=java

These defines aren't necessary anymore, and don't actually do anything. The new pattern is to use target_compatible_with (e.g. https://github.com/protocolbuffers/protobuf/blob/ade256e153ea7bfff85987a7f1bf2e9c9632cb10/ruby/BUILD.bazel#L54) and just allow the toolchain resolution to pick the appropriate target

mkruskal-google avatar Jan 05 '23 20:01 mkruskal-google

bazel run ruby:release --define=ruby_platform=c bazel run ruby:jruby_release --define=ruby_platform=java

These defines aren't necessary anymore, and don't actually do anything. The new pattern is to use target_compatible_with (e.g.

https://github.com/protocolbuffers/protobuf/blob/ade256e153ea7bfff85987a7f1bf2e9c9632cb10/ruby/BUILD.bazel#L54

) and just allow the toolchain resolution to pick the appropriate target

I implemented that but now when I test I get:

Dependency chain:
    //ruby:jruby_release (06aa77)   <-- target platform (@local_config_platform//:host) didn't satisfy constraint @platforms//:incompatible

How can I use this and test locally?

deannagarcia avatar Jan 05 '23 22:01 deannagarcia

Our current configuration is to use the system ruby version. So if you're using c-ruby and you run a bazel target only compatible with jruby, you'll see those constraint errors. You'll need to switch to jruby with rvm before running the target.

Alternatively, I came up with a strategy that I liked for this kind of thing. If you have cruby and jruby targets that build the same "kind" of thing, you can add a third target with a conditional dependency on both. I did this with the protobuf runtime, where //lib/google/protobuf:protobuf_lib will always compile, but sometimes refer to the jruby jar and sometimes to the cruby library.

mkruskal-google avatar Jan 09 '23 17:01 mkruskal-google

bazel run ruby:release --define=ruby_platform=c bazel run ruby:jruby_release --define=ruby_platform=java

These defines aren't necessary anymore, and don't actually do anything. The new pattern is to use target_compatible_with (e.g.

https://github.com/protocolbuffers/protobuf/blob/ade256e153ea7bfff85987a7f1bf2e9c9632cb10/ruby/BUILD.bazel#L54

) and just allow the toolchain resolution to pick the appropriate target

Used this and deleted comments about using the other flags.

deannagarcia avatar Jan 18 '23 18:01 deannagarcia