17ec681f3Smrg# Copyright © 2020 Google, Inc
27ec681f3Smrg
37ec681f3Smrg# Permission is hereby granted, free of charge, to any person obtaining a copy
47ec681f3Smrg# of this software and associated documentation files (the "Software"), to deal
57ec681f3Smrg# in the Software without restriction, including without limitation the rights
67ec681f3Smrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77ec681f3Smrg# copies of the Software, and to permit persons to whom the Software is
87ec681f3Smrg# furnished to do so, subject to the following conditions:
97ec681f3Smrg
107ec681f3Smrg# The above copyright notice and this permission notice shall be included in
117ec681f3Smrg# all copies or substantial portions of the Software.
127ec681f3Smrg
137ec681f3Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
147ec681f3Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
157ec681f3Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
167ec681f3Smrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
177ec681f3Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
187ec681f3Smrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
197ec681f3Smrg# SOFTWARE.
207ec681f3Smrg
217ec681f3Smrgif with_tests
227ec681f3Smrg  diff = find_program('diff')
237ec681f3Smrgendif
247ec681f3Smrg
257ec681f3Smrgafuc_parser = custom_target(
267ec681f3Smrg  'parser.[ch]',
277ec681f3Smrg  input: 'parser.y',
287ec681f3Smrg  output: ['parser.c', 'parser.h'],
297ec681f3Smrg  command: [
307ec681f3Smrg    prog_bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'
317ec681f3Smrg  ]
327ec681f3Smrg)
337ec681f3Smrg
347ec681f3Smrgafuc_lexer = custom_target(
357ec681f3Smrg  'lexer.c',
367ec681f3Smrg  input: 'lexer.l',
377ec681f3Smrg  output: 'lexer.c',
387ec681f3Smrg  command: [
397ec681f3Smrg    prog_flex, '-o', '@OUTPUT@', '@INPUT@'
407ec681f3Smrg  ]
417ec681f3Smrg)
427ec681f3Smrg
437ec681f3Smrgasm = executable(
447ec681f3Smrg  'afuc-asm',
457ec681f3Smrg  [
467ec681f3Smrg    'asm.c',
477ec681f3Smrg    'util.c',
487ec681f3Smrg    'util.h',
497ec681f3Smrg    afuc_lexer,
507ec681f3Smrg    afuc_parser,
517ec681f3Smrg  ],
527ec681f3Smrg  include_directories: [
537ec681f3Smrg    inc_freedreno_rnn, inc_include, inc_src, inc_util,
547ec681f3Smrg  ],
557ec681f3Smrg  link_with: [
567ec681f3Smrg    libfreedreno_rnn,
577ec681f3Smrg  ],
587ec681f3Smrg  dependencies: [],
597ec681f3Smrg  build_by_default : with_tools.contains('freedreno'),
607ec681f3Smrg  install: install_fd_decode_tools,
617ec681f3Smrg)
627ec681f3Smrgif with_tests
637ec681f3Smrg  asm_fw = custom_target('afuc_test.fw',
647ec681f3Smrg    output: 'afuc_test.fw',
657ec681f3Smrg    command: [asm, '-g', '6', files('../.gitlab-ci/traces/afuc_test.asm'), '@OUTPUT@'],
667ec681f3Smrg  )
677ec681f3Smrg  test('afuc-asm',
687ec681f3Smrg    diff,
697ec681f3Smrg    args: ['-u', files('../.gitlab-ci/reference/afuc_test.fw'), asm_fw],
707ec681f3Smrg    suite: 'freedreno',
717ec681f3Smrg    workdir: meson.source_root()
727ec681f3Smrg  )
737ec681f3Smrgendif
747ec681f3Smrg
757ec681f3Smrg# Disasm requires mmaping >4GB
767ec681f3Smrgif cc.sizeof('size_t') > 4
777ec681f3Smrg  disasm = executable(
787ec681f3Smrg    'afuc-disasm',
797ec681f3Smrg    [
807ec681f3Smrg      'disasm.c',
817ec681f3Smrg      'emu.c',
827ec681f3Smrg      'emu.h',
837ec681f3Smrg      'emu-ds.c',
847ec681f3Smrg      'emu-regs.c',
857ec681f3Smrg      'emu-ui.c',
867ec681f3Smrg      'util.c',
877ec681f3Smrg      'util.h',
887ec681f3Smrg    ],
897ec681f3Smrg    include_directories: [
907ec681f3Smrg      inc_freedreno,
917ec681f3Smrg      inc_freedreno_rnn,
927ec681f3Smrg      inc_include,
937ec681f3Smrg      inc_src,
947ec681f3Smrg      inc_util,
957ec681f3Smrg    ],
967ec681f3Smrg    link_with: [
977ec681f3Smrg      libfreedreno_rnn,
987ec681f3Smrg    ],
997ec681f3Smrg    dependencies: [
1007ec681f3Smrg    ],
1017ec681f3Smrg    build_by_default : with_tools.contains('freedreno'),
1027ec681f3Smrg    install: install_fd_decode_tools,
1037ec681f3Smrg  )
1047ec681f3Smrg
1057ec681f3Smrg  if with_tests
1067ec681f3Smrg    disasm_fw = custom_target('afuc_test.asm',
1077ec681f3Smrg      output: 'afuc_test.asm',
1087ec681f3Smrg      command: [disasm, '-u', files('../.gitlab-ci/reference/afuc_test.fw'), '-g', '630'],
1097ec681f3Smrg      capture: true
1107ec681f3Smrg    )
1117ec681f3Smrg    test('afuc-disasm',
1127ec681f3Smrg      diff,
1137ec681f3Smrg      args: ['-u', files('../.gitlab-ci/reference/afuc_test.asm'), disasm_fw],
1147ec681f3Smrg      suite: 'freedreno',
1157ec681f3Smrg      workdir: meson.source_root()
1167ec681f3Smrg    )
1177ec681f3Smrg  endif
1187ec681f3Smrgendif
119