Skip to content

Commit a7fcdaf

Browse files
author
Konstantin Gredeskoul
committed
Merge remote-tracking branch 'origin/graham/styles' into develop
2 parents 63f78ce + fa7c2ea commit a7fcdaf

File tree

19 files changed

+445
-349
lines changed

19 files changed

+445
-349
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ before_install:
3131
- bazel $BAZEL_OPTS info
3232
- bazel $BAZEL_OPTS fetch --curses=no -- "//ruby/..."
3333
- (cd examples && bazel $BAZEL_OPTS fetch --curses=no -- "//...")
34+
- bundle install
3435
install:
3536
- bazel $BAZEL_OPTS build $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 -- //...
3637
- (cd examples && bazel $BAZEL_OPTS build $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 -- //...)
3738
script:
3839
- bazel $BAZEL_OPTS test $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 --test_output=streamed -- //...
3940
- (cd examples && bazel $BAZEL_OPTS test $BAZEL_BUILD_OPTS --show_progress_rate_limit 0 --test_output=streamed -- //...)
41+
# If this fails run `bazel run :buildifier`
42+
- bazel run :buildifier-check
43+
# If this fails run `bundle exec rubocop -a`
44+
- bundle exec rubocop
4045

4146
env:
4247
global:

BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
2+
3+
buildifier(name = "buildifier")
4+
5+
buildifier(
6+
name = "buildifier-check",
7+
mode = "check",
8+
)

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gem 'rubocop', '~> 0.76.0', require: false

Gemfile.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.4.0)
5+
jaro_winkler (1.5.2)
6+
parallel (1.14.0)
7+
parser (2.6.0.0)
8+
ast (~> 2.4.0)
9+
rainbow (3.0.0)
10+
rubocop (0.76.0)
11+
jaro_winkler (~> 1.5.1)
12+
parallel (~> 1.10)
13+
parser (>= 2.6)
14+
rainbow (>= 2.2.2, < 4.0)
15+
ruby-progressbar (~> 1.7)
16+
unicode-display_width (>= 1.4.0, < 1.7)
17+
ruby-progressbar (1.10.0)
18+
unicode-display_width (1.5.0)
19+
20+
PLATFORMS
21+
ruby
22+
23+
DEPENDENCIES
24+
rubocop (~> 0.76.0)
25+
26+
BUNDLED WITH
27+
1.9

WORKSPACE

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,43 @@ local_repository(
1414
name = "bazelruby_ruby_rules_ruby_tests_testdata_another_workspace",
1515
path = "ruby/tests/testdata/another_workspace",
1616
)
17+
18+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
19+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
20+
21+
# installing go for buildifier
22+
http_archive(
23+
name = "io_bazel_rules_go",
24+
sha256 = "842ec0e6b4fbfdd3de6150b61af92901eeb73681fd4d185746644c338f51d4c0",
25+
urls = [
26+
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.1/rules_go-v0.20.1.tar.gz",
27+
"https://github.com/bazelbuild/rules_go/releases/download/v0.20.1/rules_go-v0.20.1.tar.gz",
28+
],
29+
)
30+
31+
git_repository(
32+
name = "bazel_gazelle",
33+
commit = "11a9ed24876401ee8b570c04de3a132e62415304",
34+
remote = "https://github.com/bazelbuild/bazel-gazelle",
35+
)
36+
37+
git_repository(
38+
name = "com_google_protobuf",
39+
commit = "09745575a923640154bcf307fba8aedff47f240a",
40+
remote = "https://github.com/protocolbuffers/protobuf",
41+
shallow_since = "1558721209 -0700",
42+
)
43+
44+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
45+
46+
go_rules_dependencies()
47+
48+
go_register_toolchains(go_version = "1.12.9")
49+
50+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
51+
52+
gazelle_dependencies()
53+
54+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
55+
56+
protobuf_deps()

examples/bin/show_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
require 'foo'
55

66
bar = Foo::Bar.new
7-
7+
Foo::Bar.new
88
puts Foo::VERSION
99
puts bar.inspect

ruby/def.bzl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ load(
22
"@bazelruby_ruby_rules//ruby/private:library.bzl",
33
_library = "ruby_library",
44
)
5-
65
load(
76
"@bazelruby_ruby_rules//ruby/private:binary.bzl",
87
_binary = "ruby_binary",
98
_test = "ruby_test",
109
)
1110

1211
def ruby_library(**attrs):
13-
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
14-
_library(**attrs)
12+
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
13+
_library(**attrs)
1514

1615
def ruby_binary(**attrs):
17-
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
18-
_binary(**attrs)
16+
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
17+
_binary(**attrs)
1918

2019
def ruby_test(**attrs):
21-
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
22-
_test(**attrs)
20+
print("//ruby:def.bzl was deprecated and will be removed soon. Use //ruby:defs.bzl instead")
21+
_test(**attrs)

ruby/defs.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ load(
22
"@bazelruby_ruby_rules//ruby/private:toolchain.bzl",
33
_toolchain = "ruby_toolchain",
44
)
5-
65
load(
76
"@bazelruby_ruby_rules//ruby/private:library.bzl",
87
_library = "ruby_library",
98
)
10-
119
load(
1210
"@bazelruby_ruby_rules//ruby/private:binary.bzl",
1311
_binary = "ruby_binary",
1412
_test = "ruby_test",
1513
)
16-
1714
load(
1815
"@bazelruby_ruby_rules//ruby/private:bundle.bzl",
1916
_bundle_install = "bundle_install",

ruby/private/binary.bzl

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,60 @@ load(
55
_transitive_deps = "transitive_deps",
66
)
77

8-
98
def _ruby_binary_impl(ctx):
10-
sdk = ctx.toolchains[TOOLCHAIN_TYPE_NAME].ruby_runtime
11-
interpreter = sdk.interpreter[DefaultInfo].files_to_run.executable
12-
init_files = [f for t in sdk.init_files for f in t.files.to_list()]
13-
init_flags = " ".join(["-r${PATH_PREFIX}%s" % f.short_path for f in init_files])
9+
sdk = ctx.toolchains[TOOLCHAIN_TYPE_NAME].ruby_runtime
10+
interpreter = sdk.interpreter[DefaultInfo].files_to_run.executable
11+
init_files = [f for t in sdk.init_files for f in t.files.to_list()]
12+
init_flags = " ".join(["-r${PATH_PREFIX}%s" % f.short_path for f in init_files])
1413

15-
main = ctx.file.main
16-
if not main:
17-
expected_name = "%s.rb" % ctx.attr.name
18-
for f in ctx.attr.srcs:
19-
if f.label.name == expected_name:
20-
main = f.files.to_list()[0]
21-
break
22-
if not main:
23-
fail(
24-
("main must be present unless the name of the rule matches to one " +
25-
"of the srcs"),
26-
"main",
27-
)
14+
main = ctx.file.main
15+
if not main:
16+
expected_name = "%s.rb" % ctx.attr.name
17+
for f in ctx.attr.srcs:
18+
if f.label.name == expected_name:
19+
main = f.files.to_list()[0]
20+
break
21+
if not main:
22+
fail(
23+
("main must be present unless the name of the rule matches to one " +
24+
"of the srcs"),
25+
"main",
26+
)
2827

29-
executable = ctx.actions.declare_file(ctx.attr.name)
30-
deps = _transitive_deps(
31-
ctx,
32-
extra_files = init_files + [interpreter, executable],
33-
extra_deps = sdk.init_files + [sdk.interpreter],
34-
)
28+
executable = ctx.actions.declare_file(ctx.attr.name)
29+
deps = _transitive_deps(
30+
ctx,
31+
extra_files = init_files + [interpreter, executable],
32+
extra_deps = sdk.init_files + [sdk.interpreter],
33+
)
3534

36-
rubyopt = reversed(deps.rubyopt.to_list())
37-
rubyopt += ["-I${PATH_PREFIX}%s" % inc for inc in deps.incpaths.to_list()]
35+
rubyopt = reversed(deps.rubyopt.to_list())
36+
rubyopt += ["-I${PATH_PREFIX}%s" % inc for inc in deps.incpaths.to_list()]
3837

39-
ctx.actions.expand_template(
40-
template = ctx.file._wrapper_template,
41-
output = executable,
42-
substitutions = {
43-
"{interpreter}": interpreter.short_path,
44-
"{init_flags}": init_flags,
45-
"{rubyopt}": " ".join(rubyopt),
46-
"{main}": main.short_path,
47-
"{workspace_name}": ctx.label.workspace_name or ctx.workspace_name,
48-
},
49-
is_executable = True,
50-
)
51-
return [DefaultInfo(
52-
executable = executable,
53-
default_runfiles = deps.default_files,
54-
data_runfiles = deps.data_files,
55-
)]
38+
ctx.actions.expand_template(
39+
template = ctx.file._wrapper_template,
40+
output = executable,
41+
substitutions = {
42+
"{interpreter}": interpreter.short_path,
43+
"{init_flags}": init_flags,
44+
"{rubyopt}": " ".join(rubyopt),
45+
"{main}": main.short_path,
46+
"{workspace_name}": ctx.label.workspace_name or ctx.workspace_name,
47+
},
48+
is_executable = True,
49+
)
50+
return [DefaultInfo(
51+
executable = executable,
52+
default_runfiles = deps.default_files,
53+
data_runfiles = deps.data_files,
54+
)]
5655

5756
_ATTRS = {
5857
"srcs": attr.label_list(
5958
allow_files = True,
6059
),
6160
"deps": attr.label_list(
62-
providers = [RubyLibrary]
61+
providers = [RubyLibrary],
6362
),
6463
"includes": attr.string_list(),
6564
"rubyopt": attr.string_list(),
@@ -69,10 +68,9 @@ _ATTRS = {
6968
"main": attr.label(
7069
allow_single_file = True,
7170
),
72-
7371
"_wrapper_template": attr.label(
74-
allow_single_file = True,
75-
default = "binary_wrapper.tpl",
72+
allow_single_file = True,
73+
default = "binary_wrapper.tpl",
7674
),
7775
}
7876

ruby/private/bundle.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load(
22
"//ruby/private/bundle:bundle.bzl",
3-
_bundle_install="bundle_install",
3+
_bundle_install = "bundle_install",
44
)
55

66
bundle_install = _bundle_install

0 commit comments

Comments
 (0)