summaryrefslogtreecommitdiff
path: root/docs/testplan/meson.build
blob: 3347f61876efc388a7207c4025e71428786aca64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
testplan_title = 'IGT test plans'

sphinx = find_program('sphinx-build', required: build_sphinx)
rst2html = find_program('rst2html-3', 'rst2html', required : false)
rst2pdf = find_program('rst2pdf', required: false)

stylesheet = join_paths(meson.current_source_dir(), 'testplan.css')

xe_test_config = join_paths(source_root, 'tests', 'xe', 'xe_test_config.json')

check_testlist = []
if build_tests
	doc_dependencies = test_executables
	# Check if documentation matches the actual tests
	check_testlist = [ '--check-testlist', '--igt-build-path', build_root ]
else
	doc_dependencies = []
endif

test_dict = { 'xe_tests':
		{ 'input': xe_test_config, 'extra_args': check_testlist }
	    }

foreach testplan, fields: test_dict
	rst = custom_target(testplan + '.rst',
			    build_by_default : true,
			    command : [ igt_doc_script, '--config', '@INPUT@', '--rest', '@OUTPUT@' ] + fields['extra_args'],
			    depends : doc_dependencies,
			    input : fields['input'],
			    output : testplan + '.rst'
			   )

	if rst2html.found()
		custom_target(testplan + '.html',
			      build_by_default : true,
			      command : [ rst2html, '--stylesheet=' + stylesheet, '--field-name-limit=0', '@INPUT@', '@OUTPUT@' ],
			      input : rst,
			      output : testplan + '.html'
			     )
	endif
endforeach

if sphinx.found()
	if gen_rst_index.found()
		sphinx_out_dir = meson.current_build_dir()+ '/indexed_html'

		index_rst = custom_target('index.rst',
					  build_by_default : true,
					  command : [ gen_rst_index, testplan_title, test_dict.keys(), meson.current_build_dir()],
					  input : rst,
					  output : 'index.rst'
					 )

		custom_target('index.html',
			      build_by_default : true,
			      command : [ 'sphinx-build', '-c', meson.current_source_dir(),
					  meson.current_build_dir(), sphinx_out_dir],
			      input : index_rst,
			      output : 'index.html'
			     )
	endif

	if rst2pdf.found()
		sphinx_out_pdf = meson.current_build_dir() + '/pdf'

		custom_target('xe_tests.pdf',
			      build_by_default : true,
			      command : [ 'sphinx-build', '-c', meson.current_source_dir(),
					  '-b', 'pdf',
					  '-D', 'version=' + meson.project_version(),
					  meson.current_build_dir(), sphinx_out_pdf],
			      input : index_rst,
			      output : 'xe_tests.pdf'
			     )
	endif
endif

build_info += 'Build simple html testplan documentation: @0@'.format(rst2html.found())
build_info += 'Build indexed html testplan documentation: @0@'.format(sphinx.found())
build_info += 'Build pdf testplan documentation: @0@'.format(sphinx.found() and rst2pdf.found())