| # 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. |
| |
| include_defs('//tools/git.defs') |
| |
| def genasciidoc( |
| name, |
| srcs = [], |
| outs = [], |
| deps = [], |
| attributes = [], |
| backend = None, |
| visibility = []): |
| MACRO_SUFFIX = '.expanded' |
| |
| cmd = ['asciidoc', '-o', '$OUT'] |
| if backend: |
| cmd.extend(['-b', backend]) |
| for attribute in attributes: |
| cmd.extend(['-a', attribute]) |
| cmd.extend(['-a', 'revision="%s"' % git_describe()]) |
| cmd.append('$SRCS') |
| |
| for p in zip(srcs, outs): |
| s, o = p |
| filename = s |
| if filename.startswith('BUCKGEN:') : |
| filename = s[8:] |
| genrule( |
| name = filename + MACRO_SUFFIX, |
| cmd = '$(exe :replace_macros) -s $SRCS -o $OUT --suffix=' + MACRO_SUFFIX, |
| srcs = [s], |
| deps = deps + [':replace_macros'], |
| out = filename + MACRO_SUFFIX, |
| ) |
| genrule( |
| name = o, |
| cmd = ' '.join(cmd), |
| srcs = [genfile(filename + MACRO_SUFFIX)], |
| deps = deps + [':' + filename + MACRO_SUFFIX], |
| out = o, |
| visibility = visibility, |
| ) |
| genrule( |
| name = name, |
| cmd = ':>$OUT', |
| deps = [':' + o for o in outs], |
| out = name + '__done', |
| visibility = visibility, |
| ) |