mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
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: https://github.com/mesonbuild/meson/issues/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 <dverkamp@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
642f9640b8
commit
704bec9aea
3 changed files with 54 additions and 76 deletions
|
@ -1,76 +0,0 @@
|
|||
# Copyright 2023 The ChromiumOS Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
prefix ?= /usr/local
|
||||
libdir = ${prefix}/lib
|
||||
includedir = ${prefix}/include/rutabaga_gfx
|
||||
|
||||
UNAME := $(shell uname -s)
|
||||
|
||||
GFXSTREAM_DEP = gfxstream_backend
|
||||
|
||||
ifdef debug
|
||||
release :=
|
||||
target :=debug
|
||||
extension :=debug
|
||||
OUT = target/debug
|
||||
else
|
||||
release :=--release
|
||||
target :=release
|
||||
extension :=
|
||||
OUT = target/release
|
||||
endif
|
||||
|
||||
# Remember to change ffi/build.rs if this changes.
|
||||
RUTABAGA_VERSION_MAJOR := 0
|
||||
SRC ?= src
|
||||
|
||||
ifeq ($(UNAME), Linux)
|
||||
LIB_NAME := librutabaga_gfx_ffi.so
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin)
|
||||
LIB_NAME := librutabaga_gfx_ffi.dylib
|
||||
endif
|
||||
|
||||
gfxstream_feature :=
|
||||
ifeq ($(shell pkg-config --exists $(GFXSTREAM_DEP) && echo 1),1)
|
||||
gfxstream_feature :=--features=gfxstream
|
||||
endif
|
||||
|
||||
RUTABAGA_VERSION := $(RUTABAGA_VERSION_MAJOR).1.3
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
cargo build $(gfxstream_feature) $(release)
|
||||
|
||||
install: build
|
||||
ifeq ($(UNAME), Linux)
|
||||
install -D -m 755 $(OUT)/$(LIB_NAME) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION)
|
||||
endif
|
||||
ifeq ($(UNAME), Darwin)
|
||||
install_name_tool -id $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
|
||||
endif
|
||||
|
||||
ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION_MAJOR)
|
||||
ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
|
||||
|
||||
ifeq ($(UNAME), Linux)
|
||||
install -D -m 0644 $(OUT)/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
|
||||
install -D -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
|
||||
endif
|
||||
ifeq ($(UNAME), Darwin)
|
||||
install -m 0644 $(OUT)/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
|
||||
install -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
|
||||
endif
|
||||
|
||||
clean:
|
||||
cargo clean $(release)
|
||||
|
||||
distclean:
|
||||
cargo clean $(release)
|
||||
|
||||
help:
|
||||
@echo "usage: make $(prog) [debug=1]"
|
46
rutabaga_gfx/ffi/meson.build
Normal file
46
rutabaga_gfx/ffi/meson.build
Normal file
|
@ -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
rutabaga_gfx/ffi/meson_options.txt
Normal file
8
rutabaga_gfx/ffi/meson_options.txt
Normal file
|
@ -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',
|
||||
)
|
Loading…
Reference in a new issue