pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
moduledir = pkgdatadir / 'roster'
gnome = import('gnome')

gnome.compile_resources('roster',
  'roster.gresource.xml',
  gresource_bundle: true,
  install: true,
  install_dir: pkgdatadir,
)

python = import('python')

conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').full_path())
conf.set('VERSION', meson.project_version())
conf.set('localedir', get_option('prefix') / get_option('localedir'))
conf.set('pkgdatadir', pkgdatadir)

configure_file(
  input: 'roster.in',
  output: 'roster',
  configuration: conf,
  install: true,
  install_dir: get_option('bindir'),
  install_mode: 'rwxr-xr-x'
)

roster_sources = [
  '__init__.py',
  'main.py',
  'window.py',
  'models.py',
  'variable_substitution.py',
  'http_client.py',
  'history_manager.py',
  'migration.py',
  'project_manager.py',
  'secret_manager.py',
  'tab_manager.py',
  'constants.py',
  'icon_picker_dialog.py',
  'environments_dialog.py',
  'export_dialog.py',
  'preferences_dialog.py',
  'request_tab_widget.py',
  'script_executor.py',
  'wsdl_importer.py',
  'wsdl_import_dialog.py',
  'openapi_importer.py',
  'openapi_import_dialog.py',
  'http_file_importer.py',
  'http_file_import_dialog.py',
]

install_data(roster_sources, install_dir: moduledir)

# Install exporters submodule
exporters_sources = [
  'exporters/__init__.py',
  'exporters/base_exporter.py',
  'exporters/curl_exporter.py',
  'exporters/registry.py',
]

install_data(exporters_sources, install_dir: moduledir / 'exporters')

# Install widgets submodule
widgets_sources = [
  'widgets/__init__.py',
  'widgets/header_row.py',
  'widgets/history_item.py',
  'widgets/project_item.py',
  'widgets/request_item.py',
  'widgets/variable_row.py',
  'widgets/environment_row.py',
  'widgets/environment_column_header.py',
  'widgets/environment_header_row.py',
  'widgets/variable_data_row.py',
]

install_data(widgets_sources, install_dir: moduledir / 'widgets')
