blob: 9a435fc68bce778ff593fe42b4f6de45bb619da5 [file] [log] [blame]
Brian Silvermanaf485d62015-10-12 00:37:14 -04001def _aos_downloader_impl(ctx):
2 ctx.file_action(
3 output = ctx.outputs.executable,
4 executable = True,
5 content = '\n'.join([
6 '#!/bin/bash',
7 'exec %s %s -- %s "$@"' % (ctx.executable._downloader.short_path,
8 ' '.join([src.short_path for src in ctx.files.srcs]),
9 ctx.attr.default_target),
10 ]),
11 )
12
13 return struct(
14 runfiles = ctx.runfiles(
15 files = ctx.files.srcs + ctx.files._downloader,
16 collect_data = True,
17 collect_default = True,
18 ),
19 files = set([ctx.outputs.executable]),
20 )
21
22'''Creates a binary which downloads code to a robot.
23
24Running this with `bazel run` will actually download everything.
25
26Attrs:
27 srcs: The files to download. They currently all get shoved into one folder.
28 default_target: The default host to download to. If not specified, defaults to
29 roboRIO-971.local.
30'''
31aos_downloader = rule(
32 implementation = _aos_downloader_impl,
33 attrs = {
34 '_downloader': attr.label(
35 executable = True,
36 cfg = HOST_CFG,
37 default = Label('//aos/prime/downloader'),
38 ),
39 'srcs': attr.label_list(
40 mandatory = True,
41 allow_files = True,
42 ),
43 'default_target': attr.string(
44 default = 'roboRIO-971.local',
45 ),
46 },
47 executable = True,
48)