-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
includes
option to ruby_bundle
rule for per-gem load path cus…
…tomization (#102) * Add register_gem support for non-standard gemspecs * cleanup and workaround * debug * Add includes option to bundle_build * Add description about includes/excludes optional parameters for ruby_bundle * Trim extra whitespace characters * Add example usage of ruby_bundle.includes to README * Add a test for includes option of ruby_bundle rule * tidy up * Fix the default value of ruby_bundle rule * Bump up Ruby version of ruby_bundle includes sample code * Fix new test workspace * Fix bundle build rule path injection * Fix usage of ruby_bundle rule's includes option * More clarification in comments * Clarify that folders in spec.require_paths do not need to be listed in includes hash Co-authored-by: Konstantin Gredeskoul <[email protected]>
- Loading branch information
Showing
10 changed files
with
194 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
load( | ||
"@bazelruby_rules_ruby//ruby:defs.bzl", | ||
"ruby_binary", | ||
) | ||
|
||
package(default_visibility = ["//:__subpackages__"]) | ||
|
||
ruby_binary( | ||
name = "script", | ||
srcs = ["script.rb"], | ||
main = "script.rb", | ||
deps = [ | ||
"@gems//:grpc", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'grpc' |
18 changes: 18 additions & 0 deletions
18
ruby/tests/testdata/bundle_includes_workspace/Gemfile.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
google-protobuf (3.17.3) | ||
googleapis-common-protos-types (1.1.0) | ||
google-protobuf (~> 3.14) | ||
grpc (1.38.0) | ||
google-protobuf (~> 3.15) | ||
googleapis-common-protos-types (~> 1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
grpc | ||
|
||
BUNDLED WITH | ||
2.2.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
workspace(name = "bazelruby_rules_ruby_ruby_tests_testdata_bundle_includes_workspace") | ||
|
||
local_repository( | ||
name = "bazelruby_rules_ruby", | ||
path = "../../../..", | ||
) | ||
|
||
load( | ||
"@bazelruby_rules_ruby//ruby:deps.bzl", | ||
"rules_ruby_dependencies", | ||
"rules_ruby_select_sdk", | ||
) | ||
|
||
rules_ruby_dependencies() | ||
|
||
rules_ruby_select_sdk(version = "3.0.1") | ||
|
||
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_bundle") | ||
|
||
ruby_bundle( | ||
name = "gems", | ||
bundler_version = "2.2.21", | ||
gemfile = "//:Gemfile", | ||
gemfile_lock = "//:Gemfile.lock", | ||
includes = { | ||
# The gemspec of grpc gem lists ['src/ruby/bin', 'src/ruby/lib', 'src/ruby/pb'] as the `require_paths`. When installing | ||
# pre-built versions of the gem using a package downloaded from rubygems.org, these paths are sufficient since the file | ||
# `src/ruby/lib/grpc.rb` in the downloaded gem package does not `require` any file outside these directories. | ||
# However, when installing grpc gem from source using Bundler, `src/ruby/lib/grpc.rb` in the source package does | ||
# `require` 'etc/roots.pem', so the directory containing this `require`-d file also needs to be present in the `$LOAD_PATH`. | ||
# Thus users have to manually add the 'etc' directory to the `$LOAD_PATH` using the `includes` option of `ruby_bundle` rule. | ||
# The `includes` option of `ruby_bundle` rule is a means of workaround for such a peculiar situation. | ||
"grpc": ["etc"], | ||
}, | ||
) |
Oops, something went wrong.