Do all asciidoctor rendering in a single jvm

Previously for every html rendered, there's a separate jvm used, and buck's
parallel building will execute multiple jvm at once, burning the CPU and being
very slow.

Modified the asciidoctor-java-integrator CLI java wrapper interface to do that
all in a single jvm.

On a workstation tested, "buck build Documentation:html" took about 140s before,
and 60s after.

As a side-effect, we lose the build rules of the single html files (e.g.
"buck build Documentation:licenses.html")

Change-Id: Ifc70c63676b59571c6e240636752b7cba9270f04
diff --git a/Documentation/asciidoc.defs b/Documentation/asciidoc.defs
index 8279847..e2de785 100644
--- a/Documentation/asciidoc.defs
+++ b/Documentation/asciidoc.defs
@@ -13,25 +13,30 @@
 # limitations under the License.
 
 def genasciidoc(
+    name,
+    out,
     srcs = [],
-    outs = [],
-    deps = {},
+    deps = [],
     attributes = [],
     backend = None,
     visibility = []):
   EXPN = '.expn'
 
-  asciidoc = ['$(exe //lib/asciidoctor:asciidoc)']
+  asciidoc = [
+      '$(exe //lib/asciidoctor:asciidoc)',
+      '-z', '$OUT',
+      '--in-ext', '".txt%s"' % EXPN,
+      '--out-ext', '".html"',
+  ]
   if backend:
     asciidoc.extend(['-b', backend])
   for attribute in attributes:
     asciidoc.extend(['-a', attribute])
-  asciidoc.extend(['-o', '$OUT'])
+  asciidoc.append('$SRCS')
+  newsrcs = []
+  newdeps = deps + ['//lib/asciidoctor:asciidoc']
 
-  for p in zip(srcs, outs):
-    src, out = p
-    dep = deps.get(src) or []
-
+  for src in srcs:
     tx = []
     fn = src
     if fn.startswith('BUCKGEN:') :
@@ -48,14 +53,14 @@
       deps = tx + [':replace_macros'],
       out = ex,
     )
-    genrule(
-      name = out,
-      cmd = ' '.join(asciidoc + ['$SRCDIR/' + ex]),
-      srcs = [genfile(ex)] + [genfile(n + EXPN) for n in dep],
-      deps = [':' + n + EXPN for n in dep] + [
-        ':' + ex,
-        '//lib/asciidoctor:asciidoc',
-      ],
-      out = out,
-      visibility = visibility,
-    )
+    newdeps.append(':' + ex)
+    newsrcs.append(genfile(ex))
+
+  genrule(
+    name = name,
+    cmd = ' '.join(asciidoc),
+    srcs = newsrcs,
+    deps = newdeps,
+    out = out,
+    visibility = visibility,
+  )