Get rid of //aos/prime
It's not a useful distinction to make any more.
Change-Id: Ieacfe8af4502108b8a5949234a1a3b6a6dd7b7e9
diff --git a/aos/downloader/downloader.bzl b/aos/downloader/downloader.bzl
new file mode 100644
index 0000000..dff198a
--- /dev/null
+++ b/aos/downloader/downloader.bzl
@@ -0,0 +1,62 @@
+def _aos_downloader_impl(ctx):
+ all_files = ctx.files.srcs + ctx.files.start_srcs + [ctx.outputs._startlist]
+ ctx.file_action(
+ output = ctx.outputs.executable,
+ executable = True,
+ content = '\n'.join([
+ '#!/bin/bash',
+ 'cd "${BASH_SOURCE[@]}.runfiles"',
+ 'exec %s %s -- %s "$@"' % (ctx.executable._downloader.short_path,
+ ' '.join([src.short_path for src in all_files]),
+ ctx.attr.default_target),
+ ]),
+ )
+
+ ctx.file_action(
+ output = ctx.outputs._startlist,
+ content = '\n'.join([f.basename for f in ctx.files.start_srcs]) + '\n',
+ )
+
+ return struct(
+ runfiles = ctx.runfiles(
+ files = all_files + ctx.files._downloader + [ctx.outputs._startlist],
+ collect_data = True,
+ collect_default = True,
+ ),
+ files = set([ctx.outputs.executable]),
+ )
+
+'''Creates a binary which downloads code to a robot.
+
+Running this with `bazel run` will actually download everything.
+
+Attrs:
+ srcs: The files to download. They currently all get shoved into one folder.
+ default_target: The default host to download to. If not specified, defaults to
+ roboRIO-971.local.
+'''
+aos_downloader = rule(
+ implementation = _aos_downloader_impl,
+ attrs = {
+ '_downloader': attr.label(
+ executable = True,
+ cfg = HOST_CFG,
+ default = Label('//aos/downloader'),
+ ),
+ 'start_srcs': attr.label_list(
+ mandatory = True,
+ allow_files = True,
+ ),
+ 'srcs': attr.label_list(
+ mandatory = True,
+ allow_files = True,
+ ),
+ 'default_target': attr.string(
+ default = 'roboRIO-971.local',
+ ),
+ },
+ executable = True,
+ outputs = {
+ '_startlist': '%{name}.start_list.dir/start_list.txt',
+ },
+)