xref: /aosp_15_r20/external/crosvm/rutabaga_gfx/ffi/meson.build (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1# Copyright 2024 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5project('rutabaga_gfx_ffi', ['rust', 'c'],
6         version: '0.1.3')
7
8target_os = host_machine.system()
9
10# By default cargo would generate rutabaga_gfx_ffi.dll (without the lib
11# prefix) for a Windows cdylib
12if target_os == 'windows'
13  shared_lib = 'rutabaga_gfx_ffi.dll'
14endif
15if target_os == 'darwin'
16  shared_lib = 'librutabaga_gfx_ffi.dylib'
17endif
18if target_os == 'linux'
19  shared_lib = 'librutabaga_gfx_ffi.so'
20endif
21
22shared_lib_major = '@[email protected]'.format(shared_lib)
23shared_lib_full_ver = '@0@.@1@'.format(shared_lib, meson.project_version())
24
25build_script = find_program('build.sh')
26with_gfxstream = get_option('gfxstream')
27features = ''
28if with_gfxstream
29  features += 'gfxstream'
30endif
31
32buildtype = 'debug'
33cargo_release = ''
34if get_option('buildtype') == 'release'
35  buildtype = 'release'
36  cargo_release = '--release'
37endif
38
39rutabaga_gfx_ffi_ct = custom_target(
40  'rutabaga_gfx_ffi_build',
41  output: [shared_lib, shared_lib_major, shared_lib_full_ver],
42  input: ['src/lib.rs', 'Cargo.toml', 'build.rs', 'build.sh'],
43  command: [build_script, features, meson.current_build_dir(),
44            shared_lib, meson.project_version(), buildtype, cargo_release],
45  install: true,
46  install_dir: get_option('libdir'),
47)
48
49pkg = import('pkgconfig')
50pkg.generate(
51  libraries: '-L${libdir} -lrutabaga_gfx_ffi',
52  name: 'rutabaga_gfx_ffi',
53  version: meson.project_version(),
54  description: 'C FFI bindings to Rutabaga VGI',
55)
56
57rutabaga_gfx_ffi_h = files('src/include/rutabaga_gfx_ffi.h')
58install_headers(rutabaga_gfx_ffi_h,
59                subdir: 'rutabaga_gfx')
60