summaryrefslogtreecommitdiff
path: root/docs/testplan/meson.build
blob: e838f2eb154050c9efbe286d5d878ab68648b802 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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')
kms_test_config = join_paths(source_root, 'tests', 'kms_test_config.json')
i915_test_config = join_paths(source_root, 'tests', 'i915', 'i915_test_config.json')

check_testlist = []
if build_tests
	doc_dependencies = testlist_files
	# Check if documentation matches the actual tests and tests can run
	if not meson.is_cross_build()
		build_info += 'Will Check if documentation is in sync with testlist'
		check_testlist = [ '--check-testlist', '--igt-build-path', build_root ]
	else
		warning('WARNING: Will not check if documentation is in sync with testlist')
	endif
else
	doc_dependencies = []
endif

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

if build_xe
	test_dict = {
		'i915_tests': { 'input': i915_test_config, 'extra_args': check_testlist },
		'kms_tests': { 'input': kms_test_config, 'extra_args': [] },
		'xe_tests': { 'input': xe_test_config, 'extra_args': check_testlist }
	    }
else
	test_dict = {
	      'i915_tests': { 'input': i915_test_config, 'extra_args': check_testlist },
	      'kms_tests': { 'input': kms_test_config, 'extra_args': [] }
	    }
endif

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('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 : '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())