Created
July 15, 2017 02:41
-
-
Save jmhodges/4eebc6145a480f73a3b20756f49fa4dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
I do have one question that I haven't answered yet which is: are OutputGroups applied to dependencies or do they only apply the target being run and its dependencies aren't changed? I think it's the latter which is going to make this a lil annoying because of all of the `transitive_$WHATEVER` variables kicking around. | |
Anyway, here's as far as a I got: | |
I thought I could use OutputGroups and DefaultInfo at the very top of the stack, such that _go_binary_impl, etc. would look something like: | |
``` | |
def _go_binary_impl(ctx): | |
"""go_binary_impl emits actions for compiling and linking a go executable.""" | |
default = _go_binary_impl_more(ctx) | |
race =_go_binary_impl_more(ctx, "_race", addl_gc_goopts=["-race"], addl_gc_linkopt=["-race"]) | |
return [DefaultInfo(files = depset([default])), OutputGroupInfo(race = depset([race]))] | |
``` | |
That `_go_binary_impl_more` function (and the others like it) makes some changes to the labels and output file paths. It returns structs with the same fields that the original version of those `_impl` functions did. | |
However, DefaultInfo and OutputGroupInfo don't work in those cases because `depset` requires immutable objects and those structs returned by the `_more` functions are not immutable. | |
Further, from the limited documentation and my understanding of skylark, it seems you can only set the 4 fields `files`, `runfiles`, `data_runfiles`, and `default_runfiles`. Which means we couldn't return DefaultInfo and OutputGroupInfo from the `_impl` functions anyway, because we need additional providers like `cgo_object` and many more. | |
It's not yet clear to me if you can do things like this (supposing we're returning this from `_go_binary_impl`): | |
``` | |
return struct( | |
files = depset([DefaultInfo(files=depset[output_executable]), OutputGroup(files=depset([output_executable_race]))]) | |
runfiles = depset([DefaultInfo(files=depset[lib_result.runfiles]), OutputGroup(files=depset([lib_result_race.runfiles]))]) | |
# cgo_object would have similar DefaultInfo, OutputGroups code in its files and runfiles, etc. | |
cgo_object = lib_result.cgo_object, | |
) | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment