Skip to content

Commit

Permalink
Improve the JDK and JRE filegroups to include all the necessary parts…
Browse files Browse the repository at this point in the history
…. Then fix the Skylark rules and tests that so far failed to declare dependencies on the JVM.

--
MOS_MIGRATED_REVID=101215495
  • Loading branch information
philwo authored and hanwen committed Aug 24, 2015
1 parent f99bb1c commit c8db70c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ bind(
actual = "@local-jdk//:javac",
)

bind(
name = "jre-default",
actual = "@local-jdk//:jre-default",
)

bind(
name = "jdk-default",
actual = "@local-jdk//:jdk-default",
Expand Down
45 changes: 44 additions & 1 deletion src/main/tools/jdk.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,52 @@ filegroup(
srcs = glob(["jre/lib/ext/*.jar"]),
)

filegroup(
name = "jre-bin",
srcs = glob(["jre/bin/**"]),
)

filegroup(
name = "jre-lib",
srcs = glob(["jre/lib/**"]),
)

filegroup(
name = "jre-default",
srcs = [
":jre-bin",
":jre-lib",
],
)

filegroup(
name = "jdk-bin",
srcs = glob(["bin/**"]),
)

filegroup(
name = "jdk-include",
srcs = glob(["include/**"]),
)

filegroup(
name = "jdk-lib",
srcs = glob(
["lib/**"],
exclude= [
"lib/missioncontrol/**",
"lib/visualvm/**",
]),
)

filegroup(
name = "jdk-default",
srcs = glob(["bin/*"]),
srcs = [
":jdk-bin",
":jdk-include",
":jdk-lib",
":jre-default",
],
)

filegroup(
Expand Down
27 changes: 15 additions & 12 deletions tools/build_rules/genproto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,28 @@ def gensrcjar_impl(ctx):

ctx.action(
command=" && ".join(sub_commands),
inputs=[ctx.file.src, proto_compiler, ctx.file._jar],
inputs=[ctx.file.src, proto_compiler, ctx.file._jar] + ctx.files._jdk,
outputs=[out],
mnemonic="GenProtoSrcJar",
use_default_shell_env = True)

gensrcjar = rule(
gensrcjar_impl,
attrs={
"src": attr.label(allow_files=proto_filetype, single_file=True),
# TODO(bazel-team): this should be a hidden attribute with a default
# value, but Skylark needs to support select first.
"_proto_compiler": attr.label(
default=Label("//third_party:protoc"),
allow_files=True,
single_file=True),
"_jar": attr.label(
default=Label("//external:jar"),
allow_files=True,
single_file=True),
"src": attr.label(allow_files=proto_filetype, single_file=True),
# TODO(bazel-team): this should be a hidden attribute with a default
# value, but Skylark needs to support select first.
"_proto_compiler": attr.label(
default=Label("//third_party:protoc"),
allow_files=True,
single_file=True),
"_jar": attr.label(
default=Label("//tools/jdk:jar"),
allow_files=True,
single_file=True),
"_jdk": attr.label(
default=Label("//tools/jdk:jdk"),
allow_files=True),
},
outputs={"srcjar": "lib%{name}.srcjar"},
)
Expand Down
8 changes: 4 additions & 4 deletions tools/build_rules/java_rules_skylark.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def java_library_impl(ctx):
"touch " + build_output + "\n")
ctx.action(
inputs = (sources + compile_time_jars_list + [sources_param_file] +
ctx.files.resources + ctx.files.srcjars),
[ctx.file._jar] + ctx.files._jdk + ctx.files.resources + ctx.files.srcjars),
outputs = [class_jar],
mnemonic='Javac',
command=cmd,
Expand Down Expand Up @@ -116,7 +116,7 @@ def java_binary_impl(ctx):
"touch " + build_output + "\n")

ctx.action(
inputs=list(library_result.runtime_jars) + [manifest],
inputs=list(library_result.runtime_jars) + [manifest] + ctx.files._jdk,
outputs=[deploy_jar],
mnemonic='Deployjar',
command=cmd,
Expand Down Expand Up @@ -167,8 +167,7 @@ def java_binary_impl(ctx):
]),
executable = True)

runfiles = ctx.runfiles(files = [
deploy_jar, executable] + ctx.files.jvm, collect_data = True)
runfiles = ctx.runfiles(files = [deploy_jar, executable] + ctx.files._jdk, collect_data = True)
files_to_build = set([deploy_jar, manifest, executable])
files_to_build += library_result.files

Expand All @@ -191,6 +190,7 @@ java_library_attrs = {
"_java": attr.label(default=Label("//tools/jdk:java"), single_file=True),
"_javac": attr.label(default=Label("//tools/jdk:javac"), single_file=True),
"_jar": attr.label(default=Label("//tools/jdk:jar"), single_file=True),
"_jdk": attr.label(default=Label("//tools/jdk:jdk"), allow_files=True),
"data": attr.label_list(allow_files=True, cfg=DATA_CFG),
"resources": attr.label_list(allow_files=True),
"srcs": attr.label_list(allow_files=java_filetype),
Expand Down
11 changes: 11 additions & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ java_import(
neverlink = 1,
)

# This one is just needed because of how filegroup redirection works.
filegroup(name = "jre-null")

filegroup(
name = "jre",
srcs = [
":jre-null",
"//external:jre-default",
],
)

# This one is just needed because of how filegroup redirection works.
filegroup(name = "jdk-null")

Expand Down

0 comments on commit c8db70c

Please sign in to comment.