Merge changes I36184fee,I3429f966
* changes: Fix documentation dependencies for included files Refactor documentation build rules to expose attributes
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
include_defs('//Documentation/asciidoc.defs')
|
||||
include_defs('//Documentation/config.defs')
|
||||
include_defs('//tools/git.defs')
|
||||
|
||||
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
|
||||
SRCS = glob(['*.txt'], excludes = ['licenses.txt'])
|
||||
@@ -11,7 +13,7 @@ genrule(
|
||||
'for s in $SRCS;do ln -s $s Documentation;done;' +
|
||||
'mv Documentation/*.{jpg,png} Documentation/images;' +
|
||||
'rm Documentation/licenses.txt;' +
|
||||
'ln -s $SRCDIR/licenses.txt LICENSES.txt;' +
|
||||
'cp $SRCDIR/licenses.txt LICENSES.txt;' +
|
||||
'zip -qr $OUT *',
|
||||
srcs = [genfile(d) for d in HTML] +
|
||||
glob([
|
||||
@@ -30,20 +32,10 @@ genrule(
|
||||
)
|
||||
|
||||
genasciidoc(
|
||||
name = 'generate_html',
|
||||
srcs = SRCS + [genfile('licenses.txt')],
|
||||
outs = HTML + ['licenses.html'],
|
||||
deps = [':licenses.txt'],
|
||||
attributes = [
|
||||
'toc',
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
],
|
||||
deps = DOCUMENTATION_DEPS,
|
||||
attributes = documentation_attributes(git_describe()),
|
||||
backend = 'xhtml11',
|
||||
)
|
||||
|
||||
|
@@ -12,50 +12,47 @@
|
||||
# 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 = [],
|
||||
deps = {},
|
||||
attributes = [],
|
||||
backend = None,
|
||||
visibility = []):
|
||||
MACRO_SUFFIX = '.expanded'
|
||||
EXPN = '.expn'
|
||||
|
||||
cmd = ['asciidoc', '-o', '$OUT']
|
||||
asciidoc = ['asciidoc']
|
||||
if backend:
|
||||
cmd.extend(['-b', backend])
|
||||
asciidoc.extend(['-b', backend])
|
||||
for attribute in attributes:
|
||||
cmd.extend(['-a', attribute])
|
||||
cmd.extend(['-a', 'revision="%s"' % git_describe()])
|
||||
cmd.append('$SRCS')
|
||||
asciidoc.extend(['-a', attribute])
|
||||
asciidoc.extend(['-o', '$OUT'])
|
||||
|
||||
for p in zip(srcs, outs):
|
||||
s, o = p
|
||||
filename = s
|
||||
if filename.startswith('BUCKGEN:') :
|
||||
filename = s[8:]
|
||||
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 = filename + MACRO_SUFFIX,
|
||||
cmd = '$(exe :replace_macros) -s $SRCS -o $OUT --suffix=' + MACRO_SUFFIX,
|
||||
srcs = [s],
|
||||
deps = deps + [':replace_macros'],
|
||||
out = filename + MACRO_SUFFIX,
|
||||
name = ex,
|
||||
cmd = '$(exe :replace_macros) --suffix=' + EXPN +
|
||||
' -s $SRCDIR/%s' % fn +
|
||||
' -o $OUT',
|
||||
srcs = [src],
|
||||
deps = tx + [':replace_macros'],
|
||||
out = ex,
|
||||
)
|
||||
genrule(
|
||||
name = o,
|
||||
cmd = ' '.join(cmd),
|
||||
srcs = [genfile(filename + MACRO_SUFFIX)],
|
||||
deps = deps + [':' + filename + MACRO_SUFFIX],
|
||||
out = o,
|
||||
name = out,
|
||||
cmd = ' '.join(asciidoc + ['$SRCDIR/' + ex]),
|
||||
srcs = [genfile(ex)] + [genfile(n + EXPN) for n in dep],
|
||||
deps = [':' + ex] + [':' + n + EXPN for n in dep],
|
||||
out = out,
|
||||
visibility = visibility,
|
||||
)
|
||||
genrule(
|
||||
name = name,
|
||||
cmd = ':>$OUT',
|
||||
deps = [':' + o for o in outs],
|
||||
out = name + '__done',
|
||||
visibility = visibility,
|
||||
)
|
||||
|
17
Documentation/config.defs
Normal file
17
Documentation/config.defs
Normal file
@@ -0,0 +1,17 @@
|
||||
DOCUMENTATION_DEPS = {
|
||||
"install-quick.txt": ["config-login-register.txt"],
|
||||
"install.txt": ["database-setup.txt"],
|
||||
}
|
||||
|
||||
def documentation_attributes(revision):
|
||||
return [
|
||||
'toc',
|
||||
'newline="\\n"',
|
||||
'asterisk="*"',
|
||||
'plus="+"',
|
||||
'caret="^"',
|
||||
'startsb="["',
|
||||
'endsb="]"',
|
||||
'tilde="~"',
|
||||
'revision="%s"' % revision,
|
||||
]
|
Reference in New Issue
Block a user