Skip to content

Fix issue with empty args and workers #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/scala/scripts/TwitterScroogeGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ class ScroogeGenerator extends Processor {
}

def processRequest(args: java.util.List[String]) {
def getIdx(i: Int): List[String] =
if (args.size > i) args.get(i).split(':').toList.filter(_.nonEmpty)
def getIdx(i: Int): List[String] = {
if (args.size > i) {
// bazel worker arguments cannot be empty so we pad to ensure non-empty
// and drop it off on the other side
// https://github.com/bazelbuild/bazel/issues/3329
val workerArgPadLen = 1 // workerArgPadLen == "_".length
args.get(i)
.drop(workerArgPadLen)
.split(':')
.toList
.filter(_.nonEmpty)
}
else Nil
}

val jarOutput = args.get(0)
// These are the files whose output we want
Expand Down
6 changes: 5 additions & 1 deletion twitter_scrooge/twitter_scrooge.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def _gen_scrooge_srcjar_impl(ctx):
# in order to generate code) have targets which will compile them.
_assert_set_is_subset(only_transitive_thrift_srcs, transitive_owned_srcs)

path_content = "\n".join([_colon_paths(ps) for ps in [immediate_thrift_srcs, only_transitive_thrift_srcs, remote_jars, external_jars]])
# bazel worker arguments cannot be empty so we pad to ensure non-empty
# and drop it off on the other side
# https://github.com/bazelbuild/bazel/issues/3329
worker_arg_pad = "_"
path_content = "\n".join([worker_arg_pad + _colon_paths(ps) for ps in [immediate_thrift_srcs, only_transitive_thrift_srcs, remote_jars, external_jars]])
worker_content = "{output}\n{paths}\n".format(output = ctx.outputs.srcjar.path, paths = path_content)

argfile = ctx.new_file(ctx.outputs.srcjar, "%s_worker_input" % ctx.label.name)
Expand Down