Skip to content

Commit

Permalink
rutabaga_gfx/ffi: add meson build
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gurchetansingh authored and crosvm LUCI committed Jun 5, 2024
1 parent 642f964 commit 704bec9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 76 deletions.
76 changes: 0 additions & 76 deletions rutabaga_gfx/ffi/Makefile

This file was deleted.

46 changes: 46 additions & 0 deletions rutabaga_gfx/ffi/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

project('rutabaga_gfx_ffi', ['rust', 'c'],
version: '0.1.3')

target_os = host_machine.system()

# By default cargo would generate rutabaga_gfx_ffi.dll (without the lib
# prefix) for a Windows cdylib
if target_os == 'windows'
shared_lib = 'rutabaga_gfx_ffi.dll'
endif
if target_os == 'darwin'
shared_lib = 'librutabaga_gfx_ffi.dylib'
endif
if target_os == 'linux'
shared_lib = 'librutabaga_gfx_ffi.so'
endif

cargo = find_program('cargo')
cmd = [cargo, 'build']
with_gfxstream = get_option('gfxstream')
if with_gfxstream
cmd += '--features=gfxstream'
endif

rutabaga_gfx_ffi_ct = custom_target(
'rutabaga_gfx_ffi_build',
output: shared_lib,
input: ['src/lib.rs', 'Cargo.toml', 'build.rs'],
command: cmd,
)

rutabaga_gfx_ffi_h = files('src/include/rutabaga_gfx_ffi.h')

rutabaga_gfx_ffi = library(
'rutabaga_gfx_ffi',
sources: [rutabaga_gfx_ffi_h, rutabaga_gfx_ffi_ct],
version: '0.1.3',
install: true,
)

install_headers(rutabaga_gfx_ffi_h,
subdir: 'rutabaga_gfx')
8 changes: 8 additions & 0 deletions rutabaga_gfx/ffi/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 2024 Android Open Source Project
# SPDX-License-Identifier: MIT
option(
'gfxstream',
type : 'boolean',
value : false,
description : 'Build gfxstream in rutabaga_gfx_ffi',
)

0 comments on commit 704bec9

Please sign in to comment.