Skip to content
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

Add scrooge support #29

Merged
merged 3 commits into from
Apr 27, 2016
Merged

Add scrooge support #29

merged 3 commits into from
Apr 27, 2016

Conversation

jcoveney
Copy link
Contributor

Ok, there is a LOT to be desired here... there are a ton of TODOS

BUT IT WORKS

I currently have a project which has two thrift files which depend on each other, BUILDS for them, and then a scala_library which depends on that and the thrifts...it builds. My guess is right now transitive stuff will not work.

So my immediate first goal is to make a test directory with some thrifts and some stuff that depends on them, to make sure that transitive stuff works properly.

After that is just...making it less crazy. I really, really need the guidance of people who have done this... I will put a microscope to everything I did, but I'm finding the "throw structs around with attributes! oh some attributes are missing!" to really resist abstraction and promote hacks...

But it works :) so I will do the above, hopefully refactor with guidance and time, and then will try it on one of our internal repositories.

One thing that I would like to put off, though, is moving it into different files etc. Right now I want to just make sure that we get the flow of everything down properly.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@johnynek
Copy link
Member

note stripe has signed the CLA.

# TODO the FileType.filter also seemed to get rid of it...??
for srcjar in srcjars:
srcjar_cmd += """
mkdir -p {{out}}_tmp/expand_srcjars/{srcjar}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should delete this first to make sure we don't keep old ones around. edit, I should read more before I comment. I see it is a subdir, so it should be clean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we rm -rf {out}_tmp so it should be removed as part of that

implementation = _scrooge_library_impl,
attrs = {
"srcs": attr.label_list(allow_files=_thrift_filetype),
"deps": attr.label_list(allow_files=_scroogelib_tar_filetype),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only want other scrooge libraries here, not the tars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you are right. this is 100% cargo culted from: https://github.com/wt/bazel_thrift/blob/master/tools/thrift.bzl#L95

Though that raises the question: what are they trying to express?

@johnynek
Copy link
Member

This is super great! I would like two things:

  1. let's break into two PRs (we can serialize, since one depends on the next): srcjar add support for src jars #2 and then add support for scrooge thrift generator #6
  2. let's add tests for srcjar support in a few cases: srcjar only, srcjar + src, multiple srcjars (with and without src).

@jcoveney
Copy link
Contributor Author

Ok, CI passes, though I need to add real tests.

Definitely agree with 2), 1) I agree with but I want to do after I have a couple of passes to answer some of the issues. Without the scrooge stuff, there is no use case that will properly ensure that the srcjars are being used as intended, and that transitive information is passed along properly. Though I have a feeling that if I answer some of your comments above, the decoupling of the 2 PRs will be a lot cleaner.

fail('scrooge_srcjar target must depend on scrooge_srcjar targets sufficient to ' +
'cover the transitive graph of thrift files. Uncovered sources: ' + missing)

def _content_newline(data):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we say _path_newline or something to reflect that we are calling .path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#namingthingsishard

@jcoveney
Copy link
Contributor Author

Lots of cleanup just pushed

@jcoveney
Copy link
Contributor Author

So it sounds like you're ok with absolute_prefix, and we should at least get a POC that new_git_repository can eliminate the need for remote_jars

"_pluck_scrooge": attr.label(
executable=True,
default=Label("//src/python/scripts:twitter_scrooge_pluck_cmd"),
#single_file=True,
allow_files=True),
} + implicit_deps(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the scala implicit deps, do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch...man, using the executable is a really nice way to simplify it!

@johnynek
Copy link
Member

One minor comment, then ready to go. Thanks for pushing this through!

@jcoveney
Copy link
Contributor Author

So what do we want to do about the remote_jars? Leave them for now, but comment that they may be removed soon? Or get the new_git_repository thing working?

@jcoveney
Copy link
Contributor Author

Oh, and re: _jdk, I'm gonna put it back... I totally forgot about #37 !

@jcoveney
Copy link
Contributor Author

so I guess _jdk is a dependency of _jar? hm, I guess we will see :)

@johnynek
Copy link
Member

crap, I merged your other one and now this won't merge cleanly

@jcoveney
Copy link
Contributor Author

I'll fix it now

@jcoveney
Copy link
Contributor Author

Fixing it was pretty easy actually... I kept the commits, though it was a rebase, so they'll get new sha's. But hopefully you still get the incremental view?

@johnynek johnynek added cla: yes and removed cla: no labels Apr 27, 2016
@johnynek
Copy link
Member

Awesome!

@johnynek johnynek merged commit ede87d1 into bazelbuild:master Apr 27, 2016
@jcoveney jcoveney deleted the jco/scrooge branch April 27, 2016 20:38
@damienmg
Copy link
Contributor

damienmg commented May 2, 2016

For your information this has broken ci.bazel.io build (missing dependency). See http://ci.bazel.io/job/rules_scala/105/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants