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