Include Gold linker in requirements.

Updates #26.

PiperOrigin-RevId: 195303940
Change-Id: I833cee55b5df6196ed90c1f8987c3c9c07204678
This commit is contained in:
Christopher Koch
2018-05-03 13:44:05 -07:00
committed by Shentubot
parent 9739b8c21c
commit 18ebda3476
3 changed files with 89 additions and 112 deletions
+1
View File
@@ -171,6 +171,7 @@ and Docker.
* [Python 2.7][python] (See [bug #8](https://github.com/google/gvisor/issues/8)
for Python 3 support updates)
* [Docker version 17.09.0 or greater][docker]
* Gold linker (e.g. `binutils-gold` package on Ubuntu)
### Getting the source
+65 -81
View File
@@ -1,26 +1,26 @@
def _go_template_impl(ctx):
input = ctx.files.srcs
output = ctx.outputs.out
input = ctx.files.srcs
output = ctx.outputs.out
args = ["-o=%s" % output.path] + [f.path for f in input]
args = ["-o=%s" % output.path] + [f.path for f in input]
ctx.actions.run(
inputs = input,
outputs = [output],
mnemonic = "GoGenericsTemplate",
progress_message = "Building Go template %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
ctx.actions.run(
inputs = input,
outputs = [output],
mnemonic = "GoGenericsTemplate",
progress_message = "Building Go template %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
return struct(
types = ctx.attr.types,
opt_types = ctx.attr.opt_types,
consts = ctx.attr.consts,
opt_consts = ctx.attr.opt_consts,
deps = ctx.attr.deps,
file = output,
)
return struct(
types = ctx.attr.types,
opt_types = ctx.attr.opt_types,
consts = ctx.attr.consts,
opt_consts = ctx.attr.opt_consts,
deps = ctx.attr.deps,
file = output,
)
"""
Generates a Go template from a set of Go files.
@@ -39,81 +39,73 @@ Args:
opt_consts: the list of constants in the template that can but aren't required to be specified.
deps: the list of dependencies.
"""
go_template = rule(
implementation = _go_template_impl,
attrs = {
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
"srcs": attr.label_list(mandatory = True, allow_files = True),
"deps": attr.label_list(allow_files = True),
"types": attr.string_list(),
"opt_types": attr.string_list(),
"consts": attr.string_list(),
"opt_consts": attr.string_list(),
"_tool": attr.label(
executable = True,
cfg = "host",
default = Label("//tools/go_generics:go_merge"),
),
"_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_generics:go_merge")),
},
outputs = {
"out": "%{name}_template.go",
},
implementation = _go_template_impl,
)
def _go_template_instance_impl(ctx):
template = ctx.attr.template
output = ctx.outputs.out
template = ctx.attr.template
output = ctx.outputs.out
# Check that all required types are defined.
for t in template.types:
if t not in ctx.attr.types:
fail("Missing value for type %s in %s" % (t, ctx.attr.template.label))
# Check that all required types are defined.
for t in template.types:
if t not in ctx.attr.types:
fail("Missing value for type %s in %s" % (t, ctx.attr.template.label))
# Check that all defined types are expected by the template.
for t in ctx.attr.types:
if (t not in template.types) and (t not in template.opt_types):
fail("Type %s it not a parameter to %s" % (t, ctx.attr.template.label))
# Check that all defined types are expected by the template.
for t in ctx.attr.types:
if (t not in template.types) and (t not in template.opt_types):
fail("Type %s it not a parameter to %s" % (t, ctx.attr.template.label))
# Check that all required consts are defined.
for t in template.consts:
if t not in ctx.attr.consts:
fail("Missing value for constant %s in %s" % (t, ctx.attr.template.label))
# Check that all required consts are defined.
for t in template.consts:
if t not in ctx.attr.consts:
fail("Missing value for constant %s in %s" % (t, ctx.attr.template.label))
# Check that all defined consts are expected by the template.
for t in ctx.attr.consts:
if (t not in template.consts) and (t not in template.opt_consts):
fail("Const %s it not a parameter to %s" % (t, ctx.attr.template.label))
# Check that all defined consts are expected by the template.
for t in ctx.attr.consts:
if (t not in template.consts) and (t not in template.opt_consts):
fail("Const %s it not a parameter to %s" % (t, ctx.attr.template.label))
# Build the argument list.
args = ["-i=%s" % template.file.path, "-o=%s" % output.path]
args += ["-p=%s" % ctx.attr.package]
# Build the argument list.
args = ["-i=%s" % template.file.path, "-o=%s" % output.path]
args += ["-p=%s" % ctx.attr.package]
if len(ctx.attr.prefix) > 0:
args += ["-prefix=%s" % ctx.attr.prefix]
if len(ctx.attr.prefix) > 0:
args += ["-prefix=%s" % ctx.attr.prefix]
if len(ctx.attr.suffix) > 0:
args += ["-suffix=%s" % ctx.attr.suffix]
if len(ctx.attr.suffix) > 0:
args += ["-suffix=%s" % ctx.attr.suffix]
args += [("-t=%s=%s" % (p[0], p[1])) for p in ctx.attr.types.items()]
args += [("-c=%s=%s" % (p[0], p[1])) for p in ctx.attr.consts.items()]
args += [("-import=%s=%s" % (p[0], p[1])) for p in ctx.attr.imports.items()]
args += [("-t=%s=%s" % (p[0], p[1])) for p in ctx.attr.types.items()]
args += [("-c=%s=%s" % (p[0], p[1])) for p in ctx.attr.consts.items()]
args += [("-import=%s=%s" % (p[0], p[1])) for p in ctx.attr.imports.items()]
ctx.actions.run(
inputs = [template.file],
outputs = [output],
mnemonic = "GoGenericsInstance",
progress_message = "Building Go template instance %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
ctx.actions.run(
inputs = [template.file],
outputs = [output],
mnemonic = "GoGenericsInstance",
progress_message = "Building Go template instance %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
# TODO: How can we get the dependencies out?
return struct(
files = depset([output])
)
# TODO: How can we get the dependencies out?
return struct(
files = depset([output]),
)
"""
Instantiates a Go template by replacing all generic types with concrete ones.
@@ -128,13 +120,10 @@ Args:
imports: the map from imports used in types/consts to their import paths.
package: the name of the package the instantiated template will be compiled into.
"""
go_template_instance = rule(
implementation = _go_template_instance_impl,
attrs = {
"template": attr.label(
mandatory = True,
providers = ["types"],
),
"template": attr.label(mandatory = True, providers = ["types"]),
"prefix": attr.string(),
"suffix": attr.string(),
"types": attr.string_dict(),
@@ -142,11 +131,6 @@ go_template_instance = rule(
"imports": attr.string_dict(),
"package": attr.string(mandatory = True),
"out": attr.output(mandatory = True),
"_tool": attr.label(
executable = True,
cfg = "host",
default = Label("//tools/go_generics"),
),
"_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_generics")),
},
implementation = _go_template_instance_impl,
)
+23 -31
View File
@@ -23,27 +23,27 @@ go_library(
"""
def _go_stateify_impl(ctx):
"""Implementation for the stateify tool."""
output = ctx.outputs.out
"""Implementation for the stateify tool."""
output = ctx.outputs.out
# Run the stateify command.
args = ["-output=%s" % output.path]
args += ["-pkg=%s" % ctx.attr.package]
if ctx.attr._statepkg:
args += ["-statepkg=%s" % ctx.attr._statepkg]
if ctx.attr.imports:
args += ["-imports=%s" % ",".join(ctx.attr.imports)]
args += ["--"]
for src in ctx.attr.srcs:
args += [f.path for f in src.files]
ctx.actions.run(
inputs = ctx.files.srcs,
outputs = [output],
mnemonic = "GoStateify",
progress_message = "Generating state library %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
# Run the stateify command.
args = ["-output=%s" % output.path]
args += ["-pkg=%s" % ctx.attr.package]
if ctx.attr._statepkg:
args += ["-statepkg=%s" % ctx.attr._statepkg]
if ctx.attr.imports:
args += ["-imports=%s" % ",".join(ctx.attr.imports)]
args += ["--"]
for src in ctx.attr.srcs:
args += [f.path for f in src.files]
ctx.actions.run(
inputs = ctx.files.srcs,
outputs = [output],
mnemonic = "GoStateify",
progress_message = "Generating state library %s" % ctx.label,
arguments = args,
executable = ctx.executable._tool,
)
"""
Generates save and restore logic from a set of Go files.
@@ -56,22 +56,14 @@ Args:
out: the name of the generated file output. This must not conflict with any other files and must be added to the srcs of the relevant go_library.
package: the package name for the input sources.
"""
go_stateify = rule(
implementation = _go_stateify_impl,
attrs = {
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
"srcs": attr.label_list(mandatory = True, allow_files = True),
"imports": attr.string_list(mandatory = False),
"package": attr.string(mandatory = True),
"out": attr.output(mandatory = True),
"_tool": attr.label(
executable = True,
cfg = "host",
default = Label("//tools/go_stateify:stateify"),
),
"_tool": attr.label(executable = True, cfg = "host", default = Label("//tools/go_stateify:stateify")),
"_statepkg": attr.string(default = "gvisor.googlesource.com/gvisor/pkg/state"),
},
implementation = _go_stateify_impl,
)