1# Copyright © 2020 Google, Inc
2
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21if with_tests
22  diff = find_program('diff')
23endif
24
25afuc_parser = custom_target(
26  'parser.[ch]',
27  input: 'parser.y',
28  output: ['parser.c', 'parser.h'],
29  command: [
30    prog_bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'
31  ]
32)
33
34afuc_lexer = custom_target(
35  'lexer.c',
36  input: 'lexer.l',
37  output: 'lexer.c',
38  command: [
39    prog_flex, '-o', '@OUTPUT@', '@INPUT@'
40  ]
41)
42
43asm = executable(
44  'afuc-asm',
45  [
46    'asm.c',
47    'util.c',
48    'util.h',
49    afuc_lexer,
50    afuc_parser,
51  ],
52  include_directories: [
53    inc_freedreno_rnn, inc_include, inc_src, inc_util,
54  ],
55  link_with: [
56    libfreedreno_rnn,
57  ],
58  dependencies: [],
59  build_by_default : with_tools.contains('freedreno'),
60  install: install_fd_decode_tools,
61)
62if with_tests
63  asm_fw = custom_target('afuc_test.fw',
64    output: 'afuc_test.fw',
65    command: [asm, '-g', '6', files('../.gitlab-ci/traces/afuc_test.asm'), '@OUTPUT@'],
66  )
67  test('afuc-asm',
68    diff,
69    args: ['-u', files('../.gitlab-ci/reference/afuc_test.fw'), asm_fw],
70    suite: 'freedreno',
71    workdir: meson.source_root()
72  )
73endif
74
75# Disasm requires mmaping >4GB
76if cc.sizeof('size_t') > 4
77  disasm = executable(
78    'afuc-disasm',
79    [
80      'disasm.c',
81      'emu.c',
82      'emu.h',
83      'emu-ds.c',
84      'emu-regs.c',
85      'emu-ui.c',
86      'util.c',
87      'util.h',
88    ],
89    include_directories: [
90      inc_freedreno,
91      inc_freedreno_rnn,
92      inc_include,
93      inc_src,
94      inc_util,
95    ],
96    link_with: [
97      libfreedreno_rnn,
98    ],
99    dependencies: [
100    ],
101    build_by_default : with_tools.contains('freedreno'),
102    install: install_fd_decode_tools,
103  )
104
105  if with_tests
106    disasm_fw = custom_target('afuc_test.asm',
107      output: 'afuc_test.asm',
108      command: [disasm, '-u', files('../.gitlab-ci/reference/afuc_test.fw'), '-g', '630'],
109      capture: true
110    )
111    test('afuc-disasm',
112      diff,
113      args: ['-u', files('../.gitlab-ci/reference/afuc_test.asm'), disasm_fw],
114      suite: 'freedreno',
115      workdir: meson.source_root()
116    )
117  endif
118endif
119