Skip to content

Commit 704bec9

Browse files
gurchetansinghcrosvm LUCI
authored and
crosvm LUCI
committed
rutabaga_gfx/ffi: add meson build
This is somewhat more modern than the Makefile. Both just invoke cargo under the hood. The proper solution may come when Meson starts supporting external crates: mesonbuild/meson#2173 Right now, this is a just a minimal version for developers. A known issue is modifying dependent crates (rutabaga_gfx) doesn't cause a rebuild. A solution is just `touch src/lib.rs` in ffi. Also, `ninja -C build/ clean` isn't recommended. Just do cargo clean. BUG=344998548 TEST=meson setup build ninja -C build/ install Change-Id: Id5a142cc5cb5a8001198afc4d1cdbe800ec2ec23 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5599139 Reviewed-by: Daniel Verkamp <[email protected]> Commit-Queue: Gurchetan Singh <[email protected]>
1 parent 642f964 commit 704bec9

File tree

3 files changed

+54
-76
lines changed

3 files changed

+54
-76
lines changed

rutabaga_gfx/ffi/Makefile

Lines changed: 0 additions & 76 deletions
This file was deleted.

rutabaga_gfx/ffi/meson.build

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
5+
project('rutabaga_gfx_ffi', ['rust', 'c'],
6+
version: '0.1.3')
7+
8+
target_os = host_machine.system()
9+
10+
# By default cargo would generate rutabaga_gfx_ffi.dll (without the lib
11+
# prefix) for a Windows cdylib
12+
if target_os == 'windows'
13+
shared_lib = 'rutabaga_gfx_ffi.dll'
14+
endif
15+
if target_os == 'darwin'
16+
shared_lib = 'librutabaga_gfx_ffi.dylib'
17+
endif
18+
if target_os == 'linux'
19+
shared_lib = 'librutabaga_gfx_ffi.so'
20+
endif
21+
22+
cargo = find_program('cargo')
23+
cmd = [cargo, 'build']
24+
with_gfxstream = get_option('gfxstream')
25+
if with_gfxstream
26+
cmd += '--features=gfxstream'
27+
endif
28+
29+
rutabaga_gfx_ffi_ct = custom_target(
30+
'rutabaga_gfx_ffi_build',
31+
output: shared_lib,
32+
input: ['src/lib.rs', 'Cargo.toml', 'build.rs'],
33+
command: cmd,
34+
)
35+
36+
rutabaga_gfx_ffi_h = files('src/include/rutabaga_gfx_ffi.h')
37+
38+
rutabaga_gfx_ffi = library(
39+
'rutabaga_gfx_ffi',
40+
sources: [rutabaga_gfx_ffi_h, rutabaga_gfx_ffi_ct],
41+
version: '0.1.3',
42+
install: true,
43+
)
44+
45+
install_headers(rutabaga_gfx_ffi_h,
46+
subdir: 'rutabaga_gfx')

rutabaga_gfx/ffi/meson_options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 2024 Android Open Source Project
2+
# SPDX-License-Identifier: MIT
3+
option(
4+
'gfxstream',
5+
type : 'boolean',
6+
value : false,
7+
description : 'Build gfxstream in rutabaga_gfx_ffi',
8+
)

0 commit comments

Comments
 (0)