From e45fdd4dec11fcacabe61d4a49e2287764137c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] build-doc: exit 1 on error, add to release testing --- build | 5 +++++ build-doc | 40 ++++++++++++++++++++++++++++++++++++++-- common.py | 3 +++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/build b/build index 962b196..1800267 100755 --- a/build +++ b/build @@ -164,6 +164,7 @@ so looping over all of them would waste time. 'qemu-gem5-buildroot', 'all-baremetal', 'user-mode-qemu', + 'doc', ]), 'all-baremetal': _Component(dependencies=[ 'qemu-baremetal', @@ -220,6 +221,9 @@ so looping over all of them would waste time. }, submodules={'crosstool-ng'}, ), + 'doc': _Component( + self._build_file('build-doc'), + ), 'gem5': _Component( self._build_file('build-gem5'), **gem5_deps @@ -301,6 +305,7 @@ so looping over all of them would waste time. ), 'release': _Component(dependencies=[ 'qemu-buildroot', + 'doc', ]), 'test-gdb': _Component(dependencies=[ 'all-baremetal', diff --git a/build-doc b/build-doc index 5d514f8..8e958ab 100755 --- a/build-doc +++ b/build-doc @@ -1,2 +1,38 @@ -#!/usr/bin/env bash -asciidoctor -o out/README.html -v README.adoc +#!/usr/bin/env python3 + +import re + +import common +from shell_helpers import LF + +class Main(common.LkmcCliFunction): + def __init__(self): + super().__init__( + defaults = { + 'print_time': False, + }, + description='''\ +https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentation +''', + ) + + def timed_main(self): + self.sh.run_cmd( + [ + 'asciidoctor', LF, + '-o', self.env['readme_out'], LF, + '-v', self.env['readme'], LF, + ], + out_file=self.env['build_doc_log'], + ) + error_re = re.compile('^asciidoctor: WARNING: ') + exit_status = 0 + with open(self.env['build_doc_log']) as f: + for line in f: + if error_re.search(line): + exit_status = 1 + break + return exit_status + +if __name__ == '__main__': + Main().cli() diff --git a/common.py b/common.py index b37a9e1..b6efe6a 100644 --- a/common.py +++ b/common.py @@ -42,6 +42,9 @@ if consts['in_docker']: consts['out_dir'] = os.path.join(consts['root_dir'], 'out.docker') else: consts['out_dir'] = os.path.join(consts['root_dir'], 'out') +consts['readme'] = os.path.join(consts['root_dir'], 'README.adoc') +consts['readme_out'] = os.path.join(consts['out_dir'], 'README.html') +consts['build_doc_log'] = os.path.join(consts['out_dir'], 'build-doc.log') consts['gem5_out_dir'] = os.path.join(consts['out_dir'], 'gem5') consts['kernel_modules_build_base_dir'] = os.path.join(consts['out_dir'], 'kernel_modules') consts['buildroot_out_dir'] = os.path.join(consts['out_dir'], 'buildroot')