host_machine.system() == 'linux' or subdir_done()
libdrm_amdgpu.found() or subdir_done()

cargs = ['-DG_LOG_DOMAIN="FuPluginAmdGpu"']
plugins += {meson.current_source_dir().split('/')[-1]: true}

plugin_quirks += files('amd-gpu.quirk')
plugin_builtins += static_library('fu_plugin_amd_gpu',
  rustgen.process(
    'fu-amd-gpu-atom.rs',          # fuzzing
    'fu-amd-gpu-psp.rs',           # fuzzing
  ),
  sources: [
    'fu-amd-gpu-plugin.c',
    'fu-amd-gpu-device.c',
    'fu-amd-gpu-psp-firmware.c',
    'fu-amd-gpu-atom-firmware.c',
    'fu-amd-gpu-uma.c',
  ],
  include_directories: plugin_incdirs,
  link_with: plugin_libs,
  c_args: cargs,
  dependencies: plugin_deps,
)
enumeration_data += files('tests/amd-apu-rembrandt-setup.json',
                          'tests/amd-apu-strix-setup.json',
                          'tests/amd-dgpu-setup.json')
device_tests += files('tests/amd-apu-rembrandt.json',
                      'tests/amd-apu-strix.json',
                      'tests/amd-dgpu.json',
                      'tests/amd-dgpu-navi3x.json',
)

if get_option('tests')
  env = environment()
  env.set('G_TEST_SRCDIR', meson.current_source_dir())
  env.set('G_TEST_BUILDDIR', meson.current_build_dir())
  e = executable('fu-amd-gpu-uma-test',
    sources: 'fu-amd-gpu-uma-test.c',
    include_directories: plugin_incdirs,
    dependencies: plugin_deps,
    link_with: [plugin_libs, plugin_builtins],
    install: true,
    install_rpath: libdir_pkg,
    install_dir: installed_test_bindir,
    install_tag: 'tests',
    c_args: [
      '-DSRCDIR="' + meson.current_source_dir() + '"',
    ],
  )
  test('amd-gpu-uma-self-test', e, env: env)
endif
