# Copyright 2026, Jiri Eischmann <jiri@eischmann.cz> and the meshy contributors
# SPDX-License-Identifier: GPL-3.0-or-later

meshy_sources = [
  '__init__.py',
  'main.py',
  'application.py',
  'window.py',
  'protocol.py',
  'ble.py',
  'location.py',
  'camera.py',
  'notification.py',
  'models.py',
  'storage.py',
  'meshcore_packets.py',
  'mesh_crypto.py',
  'transport_base.py',
  'usb_serial.py',
  'tcp.py',
  'utils.py',
  'backup.py',
  'frame_handler.py',
  'message_controller.py',
  'path_history.py',
  'connection_controller.py',
  'host_integration.py',
  'theme_manager.py',
  'theme_chooser_dialog.py',
  'background_portal.py',
  'smaz.py',
  'repeater_helpers.py',
]

if get_option('qr_scanner')
  meshy_sources += ['qr_scanner.py']
endif

views_sources = [
  'views/__init__.py',
  'views/chat_helpers.py',
  'views/chat_mixin.py',
  'views/chat_view.py',
  'views/contact_detail_dialog.py',
  'views/contacts_view.py',
  'views/channels_view.py',
  'views/settings_view.py',
  'views/device_view.py',
  'views/connection_view.py',
  'views/repeater_view.py',
  'views/sensor_view.py',
  'views/map_view.py',
]

# Platform abstraction layer
platforms_sources = [
  'platforms/__init__.py',
  'platforms/ble_base.py',
  'platforms/notification_base.py',
]

platforms_linux_sources = [
  'platforms/linux/__init__.py',
  'platforms/linux/ble_bluez.py',
  'platforms/linux/location_geoclue.py',
  'platforms/linux/notification_gio.py',
]

platforms_macos_sources = [
  'platforms/macos/__init__.py',
  'platforms/macos/ble_corebluetooth.py',
  'platforms/macos/app_activation.py',
  'platforms/macos/location_corelocation.py',
  'platforms/macos/camera_avfoundation.py',
  'platforms/macos/login_items.py',
  'platforms/macos/notification_native.py',
]

py_installation.install_sources(meshy_sources, subdir: 'meshy')
py_installation.install_sources(views_sources, subdir: 'meshy' / 'views')
py_installation.install_sources(platforms_sources, subdir: 'meshy' / 'platforms')
if host_machine.system() == 'darwin'
  py_installation.install_sources(platforms_macos_sources, subdir: 'meshy' / 'platforms' / 'macos')
else
  # Linux and other Unix-like systems (BSD) share the GIO/GeoClue backends
  py_installation.install_sources(platforms_linux_sources, subdir: 'meshy' / 'platforms' / 'linux')
endif

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