Skip to content
Snippets Groups Projects
meson.build 8.34 KiB
Newer Older
# Copyright © 2019-2020 Collabora Ltd.
#
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

conf_data = configuration_data()
conf_data.set_quoted('VERSION', version)

configure_file(
  input : 'config.h.in',
  output : '_pressure-vessel-config.h',
  configuration : conf_data,
)

pv_dir = 'lib/pressure-vessel/relocatable'
pv_bindir = pv_dir + '/bin'
pv_c_args = ['-include', '_pressure-vessel-config.h']

# This trips some warnings in the libglnx subproject but not in
# pressure-vessel itself
pv_warning_cflags = [
    '-Wsign-compare',
]

scripts = [
  'pressure-vessel-locale-gen',
  'pressure-vessel-test-ui',
  'pressure-vessel-unruntime',
]

foreach script : scripts
  install_data(
    script,
    install_dir : pv_bindir,
# Headers to scan for enum/flags types.
headers = [
launcher1 = gnome.gdbus_codegen(
  'launcher1',
  sources : 'com.steampowered.PressureVessel.Launcher1.xml',
  interface_prefix : 'com.steampowered.PressureVessel.',
  namespace : 'Pv',
)

systemd_dbus = gnome.gdbus_codegen(
  'flatpak-systemd-dbus-generated',
  sources : 'org.freedesktop.systemd1.xml',
  interface_prefix : 'org.freedesktop.systemd1.',
  namespace : 'Systemd',
)

enums = gnome.mkenums_simple(
  'enumtypes',
  sources : headers,
)

pressure_vessel_utils = static_library(
  'pressure-vessel-utils',
  sources : [
    'bwrap-lock.c',
    'bwrap-lock.h',
    'flatpak-bwrap.c',
    'flatpak-bwrap-private.h',
    'flatpak-utils-base.c',
    'flatpak-utils-base-private.h',
    'flatpak-utils.c',
    'flatpak-utils-private.h',
    'tree-copy.c',
    'tree-copy.h',
    'utils.c',
    'utils.h',
  dependencies : [
    gio_unix,
  include_directories : pv_include_dirs,
  install: false,
)
pressure_vessel_utils_dep = declare_dependency(
  link_with : pressure_vessel_utils,
  sources : launcher1[1],
)
launcher_codegen = static_library(
  'pressure-vessel-launcher-codegen',
  sources : launcher1,
  dependencies : [
    gio_unix,
  ],
  c_args : silence_gdbus_codegen_warnings + pv_c_args,
  include_directories : pv_include_dirs,
launcher_codegen_dep = declare_dependency(
  link_with : launcher_codegen,
  sources : launcher1[1],
)
systemd_codegen = static_library(
  'pressure-vessel-systemd-codegen',
  sources : systemd_dbus,
  dependencies : [
    gio_unix,
  ],
  c_args : silence_gdbus_codegen_warnings + pv_c_args,
  include_directories : pv_include_dirs,
  install: false,
)
systemd_codegen_dep = declare_dependency(
  link_with : systemd_codegen,
  sources : systemd_dbus[1],
)

executable(
  'pressure-vessel-adverb',
  sources : [
    'supported-architectures.c',
    'supported-architectures.h',
    'wrap-interactive.c',
    'wrap-interactive.h',
  dependencies : [
    gio_unix,
  include_directories : pv_include_dirs,
  install : true,
  install_dir : pv_bindir,
  build_rpath : pv_rpath,
  install_rpath : pv_rpath,
)

executable(
  'pressure-vessel-launch',
  sources: [
    'launch.c',
  ],
  include_directories : pv_include_dirs,
  install_dir : pv_bindir,
  build_rpath : pv_rpath,
  install_rpath : pv_rpath,
)

executable(
  'pressure-vessel-launcher',
  sources: [
    'launcher.c',
    'portal-listener.c',
    'portal-listener.h',
    launcher_codegen_dep,
    pressure_vessel_utils_dep,
  include_directories : pv_include_dirs,
  install_dir : pv_bindir,
  build_rpath : pv_rpath,
  install_rpath : pv_rpath,
pressure_vessel_wrap_lib = static_library(
  'pressure-vessel-wrap-lib',
  sources : [
    'bwrap.c',
    'bwrap.h',
    'flatpak-common-types-private.h',
    'flatpak-context.c',
    'flatpak-context-private.h',
    'flatpak-exports.c',
    'flatpak-exports-private.h',
    'flatpak-run.c',
    'flatpak-run-private.h',
    'graphics-provider.c',
    'graphics-provider.h',
    'runtime.c',
    'runtime.h',
    'supported-architectures.c',
    'supported-architectures.h',
    'wrap-flatpak.c',
    'wrap-flatpak.h',
    'wrap-pipewire.c',
    'wrap-pipewire.h',
    'wrap-setup.c',
    'wrap-setup.h',
  dependencies : [
    gio_unix,
    xau,
  include_directories : pv_include_dirs,
)
pressure_vessel_wrap_lib_dep = declare_dependency(
  link_with : pressure_vessel_wrap_lib,
  sources : [launcher1[1], systemd_dbus[1]],
)

executable(
  'pressure-vessel-wrap',
  sources : [
    'wrap.c',
  ],
  c_args : pv_c_args,
  dependencies : [
    gio_unix,
    libglnx_dep,
    pressure_vessel_wrap_lib_dep,
  ],
  include_directories : pv_include_dirs,
  install : true,
  install_dir : pv_bindir,
  build_rpath : pv_rpath,
  install_rpath : pv_rpath,
)

executable(
  'pressure-vessel-try-setlocale',
  sources : [
    'try-setlocale.c',
  ],
  include_directories : pv_include_dirs,
  install : true,
  install_dir : pv_bindir,
# We'd like to use bubblewrap as a Meson subproject, but then we wouldn't
# be able to set its RPATH, which we need...
executable(
  'pv-bwrap',
  'bwrap-main.c',
  c_args : [
    '-DPACKAGE_STRING="modified bubblewrap from ' + meson.project_name() + ' ' + meson.project_version() + '"',
  ],
  dependencies: [libcap_dep, libselinux_dep],
  include_directories : project_include_dirs,
  install : true,
  install_dir : pv_bindir,
  build_rpath : pv_rpath,
  install_rpath : pv_rpath,
)

if get_option('srcdir') != ''
  conf_data = configuration_data()
  conf_data.set('prefix', get_option('prefix'))
  conf_data.set('pv_dir', pv_dir)
  conf_data.set('python', python.path())
  conf_data.set('sh', sh.path())
  conf_data.set('srcdir', get_option('srcdir'))
  conf_data.set('version', version)
  install_data(
    configure_file(
      input : 'build-relocatable-install.in',
      output : 'pressure-vessel-build-relocatable-install',
      configuration : conf_data,
    ),
    install_dir : pv_bindir,
    install_mode : 'rwxr-xr-x',
  )
  meson.add_install_script(
    python.path(),
    meson.current_source_dir() / 'copy-source-code.py',
    '--srcdir', meson.source_root(),
    '--pressure-vessel-dir', pv_dir,
    '--set-version', version,
    get_option('srcdir'),
  )
endif

if get_option('man')
  foreach tool : [
    'adverb',
    'launch',
    'launcher',
    'locale-gen',
    'test-ui',
    'try-setlocale',
    'unruntime',
    'wrap',
  ]
    custom_target(
      tool + '.1',
      build_by_default : true,
      command : [
        pandoc,
        '-s',
        '-o', '@OUTPUT@',
        '-f', pandoc_markdown_nosmart,
        '-t', 'man',
        '@INPUT@',
      ],
      input : tool + '.1.md',
      output : 'pressure-vessel-' + tool + '.1',
      install : true,
      install_dir : join_paths(
        get_option('prefix'),
        get_option('mandir'),
        'man1',
      ),
    )
  endforeach
endif

# vim:set sw=2 sts=2 et: