提交 5e03c2d8 编写于 作者: A Alex Bennée

docker: Add "cc" subcommand

Signed-off-by: NFam Zheng <famz@redhat.com>
[AJB: add if args.paths check]
Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
上级 13a5abe2
......@@ -412,6 +412,31 @@ class ProbeCommand(SubCommand):
return
class CcCommand(SubCommand):
"""Compile sources with cc in images"""
name = "cc"
def args(self, parser):
parser.add_argument("--image", "-i", required=True,
help="The docker image in which to run cc")
parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
help="""Extra paths to (ro) mount into container for
reading sources""")
def run(self, args, argv):
if argv and argv[0] == "--":
argv = argv[1:]
cwd = os.getcwd()
cmd = ["--rm", "-w", cwd,
"-v", "%s:%s:rw" % (cwd, cwd)]
if args.paths:
for p in args.paths:
cmd += ["-v", "%s:%s:ro,z" % (p, p)]
cmd += [args.image, "cc"]
cmd += argv
return Docker().command("run", cmd, args.quiet)
def main():
parser = argparse.ArgumentParser(description="A Docker helper",
usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册