blob: 82798471bffe3dd5915808345900d219aa1ba3be [file] [log] [blame]
# Copyright (C) 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def genasciidoc(
srcs = [],
outs = [],
deps = {},
attributes = [],
backend = None,
visibility = []):
EXPN = '.expn'
asciidoc = ['$(exe //lib/asciidoctor:asciidoc)']
if backend:
asciidoc.extend(['-b', backend])
for attribute in attributes:
asciidoc.extend(['-a', attribute])
asciidoc.extend(['-o', '$OUT'])
for p in zip(srcs, outs):
src, out = p
dep = deps.get(src) or []
tx = []
fn = src
if fn.startswith('BUCKGEN:') :
fn = src[8:]
tx = [':' + fn]
ex = fn + EXPN
genrule(
name = ex,
cmd = '$(exe :replace_macros) --suffix=' + EXPN +
' -s $SRCDIR/%s' % fn +
' -o $OUT',
srcs = [src],
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,
)