Refactor documentation build rules to expose attributes
The gerrit-review build runs on something similar to Buck, but
doesn't use the BUCK file. Extract the attribute configuration that
used to be in the shared asciidoc.conf file into a .defs file that
can be imported by both build systems.
Hoist the git_version() up into the BUCK file, allowing either build
system to supply the Git revision and keep the definition shared.
Change-Id: I3429f966d0d8debb7b23a3b5142763c3ca4ba8e2
diff --git a/Documentation/BUCK b/Documentation/BUCK
index 4dc1f3a..9b8a5b8 100644
--- a/Documentation/BUCK
+++ b/Documentation/BUCK
@@ -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'])
@@ -34,16 +36,7 @@
srcs = SRCS + [genfile('licenses.txt')],
outs = HTML + ['licenses.html'],
deps = [':licenses.txt'],
- attributes = [
- 'toc',
- 'newline="\\n"',
- 'asterisk="*"',
- 'plus="+"',
- 'caret="^"',
- 'startsb="["',
- 'endsb="]"',
- 'tilde="~"',
- ],
+ attributes = documentation_attributes(git_describe()),
backend = 'xhtml11',
)
diff --git a/Documentation/asciidoc.defs b/Documentation/asciidoc.defs
index 97bf287..889ce0b 100644
--- a/Documentation/asciidoc.defs
+++ b/Documentation/asciidoc.defs
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-include_defs('//tools/git.defs')
-
def genasciidoc(
name,
srcs = [],
@@ -29,7 +27,6 @@
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):
diff --git a/Documentation/config.defs b/Documentation/config.defs
new file mode 100644
index 0000000..c3904cb
--- /dev/null
+++ b/Documentation/config.defs
@@ -0,0 +1,12 @@
+def documentation_attributes(revision):
+ return [
+ 'toc',
+ 'newline="\\n"',
+ 'asterisk="*"',
+ 'plus="+"',
+ 'caret="^"',
+ 'startsb="["',
+ 'endsb="]"',
+ 'tilde="~"',
+ 'revision="%s"' % revision,
+ ]