mirror of
https://github.com/tsukumijima/libmali-rockchip.git
synced 2026-01-24 00:10:50 +01:00
Support meson build system
meson build -Darch=aarch64 -Dgpu=bifrost-g31 -Dversion=rxp0 -Dplatform=only-cl Change-Id: I60bb14e16a9cbc9589b85279680c845f53ed0572 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
This commit is contained in:
parent
e74864b9bc
commit
f127d14e87
4 changed files with 211 additions and 0 deletions
20
grabber.sh
Executable file
20
grabber.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
ARCH=${1:-aarch64}
|
||||
GPU=${2:-midgard-t86x}
|
||||
VERSION=${3:-r18p0}
|
||||
SUBVERSION=${4:-none}
|
||||
PLATFORM=${5:-x11}
|
||||
|
||||
[ ${ARCH} = 'armv7l' -o ${ARCH} = 'armhf' -o ${ARCH} = 'arm32' ] && ARCH=arm
|
||||
[ ${ARCH} = 'armv8' -o ${ARCH} = 'arm64' ] && ARCH=aarch64
|
||||
|
||||
if [ ${SUBVERSION} = 'none' ]; then
|
||||
LIB="libmali-${GPU}-${VERSION}-${PLATFORM}.so"
|
||||
elif [ ${SUBVERSION} = 'all' ]; then
|
||||
LIB="libmali-${GPU}-${VERSION}*-${PLATFORM}.so"
|
||||
else
|
||||
LIB="libmali-${GPU}-${VERSION}-${SUBVERSION}-${PLATFORM}.so"
|
||||
fi
|
||||
|
||||
find lib/${ARCH}* -name ${LIB} 2>/dev/null
|
||||
169
meson.build
Normal file
169
meson.build
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
project(
|
||||
'libmali', 'c',
|
||||
version : '1.9.0',
|
||||
meson_version : '>=0.47.0',
|
||||
default_options: ['b_asneeded=false'],
|
||||
)
|
||||
|
||||
pkgconfig = import('pkgconfig')
|
||||
|
||||
if get_option('arch') != 'auto'
|
||||
arch = get_option('arch')
|
||||
else
|
||||
arch = host_machine.cpu_family()
|
||||
endif
|
||||
|
||||
gpu = get_option('gpu')
|
||||
version = get_option('version')
|
||||
subversion = get_option('subversion')
|
||||
platform = get_option('platform')
|
||||
|
||||
# Grab libraries with specified configs
|
||||
c = run_command('grabber.sh', arch, gpu, version, subversion, platform)
|
||||
libs = c.stdout().strip().split('\n')
|
||||
|
||||
# Use the first one as default library
|
||||
default_lib = libs[0]
|
||||
if default_lib == ''
|
||||
error('failed to find matched library.')
|
||||
endif
|
||||
|
||||
message('building for @0@'.format(libs))
|
||||
|
||||
# Wrap library name : version
|
||||
mali_wrappers = {'Mali' : '1'}
|
||||
gbm_wrappers = {'gbm' : '1'}
|
||||
egl_wrappers = {'EGL' : '1'}
|
||||
glesv1_wrappers = {'GLESv1_CM' : '1'}
|
||||
glesv2_wrappers = {'GLESv2' : '2'}
|
||||
wayland_wrappers = {'wayland-egl' : '1'}
|
||||
cl_wrappers = {'OpenCL' : '1', 'MaliOpenCL' : '1'}
|
||||
|
||||
# Subdir : headers
|
||||
mali_headers = {
|
||||
'KHR' : ['include/KHR/mali_khrplatform.h'],
|
||||
}
|
||||
egl_headers = {
|
||||
'EGL' : [
|
||||
'include/EGL/eglplatform.h',
|
||||
'include/EGL/eglext.h',
|
||||
'include/EGL/egl.h',
|
||||
],
|
||||
}
|
||||
glesv1_headers = {
|
||||
'GLES' : [
|
||||
'include/GLES/gl.h',
|
||||
'include/GLES/glplatform.h',
|
||||
'include/GLES/glext.h',
|
||||
'include/GLES/egl.h',
|
||||
],
|
||||
}
|
||||
glesv2_headers = {
|
||||
'GLES2' : [
|
||||
'include/GLES2/gl2ext.h',
|
||||
'include/GLES2/gl2.h',
|
||||
'include/GLES2/gl2platform.h',
|
||||
],
|
||||
'GLES3' : [
|
||||
'include/GLES3/gl3.h',
|
||||
'include/GLES3/gl32.h',
|
||||
'include/GLES3/gl3platform.h',
|
||||
'include/GLES3/gl31.h',
|
||||
],
|
||||
}
|
||||
cl_headers = {
|
||||
'CL': [
|
||||
'include/CL/cl_gl.h',
|
||||
'include/CL/cl.h',
|
||||
'include/CL/cl_dx9_media_sharing_intel.h',
|
||||
'include/CL/cl_ext_intel.h',
|
||||
'include/CL/cl_d3d10.h',
|
||||
'include/CL/opencl.h',
|
||||
'include/CL/cl_d3d11.h',
|
||||
'include/CL/cl_platform.h',
|
||||
'include/CL/cl_ext.h',
|
||||
'include/CL/cl_egl.h',
|
||||
'include/CL/cl_dx9_media_sharing.h',
|
||||
'include/CL/cl_va_api_media_sharing_intel.h',
|
||||
'include/CL/cl_gl_ext.h',
|
||||
],
|
||||
}
|
||||
|
||||
# Package name : required symbol, wrappers, headers, package version
|
||||
map = {
|
||||
'mali' : ['', mali_wrappers, mali_headers, meson.project_version()],
|
||||
'gbm' : ['gbm_create_device', gbm_wrappers, {'' : 'include/gbm.h'}, '10.4.0'],
|
||||
'egl' : ['eglCreateContext', egl_wrappers, egl_headers, '7.10'],
|
||||
'glesv1_cm' : ['eglCreateContext', glesv1_wrappers, glesv1_headers, '7.10'],
|
||||
'glesv2' : ['eglCreateContext', glesv2_wrappers, glesv2_headers, '7.10'],
|
||||
'wayland-egl' : ['wl_egl_window_create', wayland_wrappers, {}, '18.1.0'],
|
||||
'OpenCL' : ['clCreateContext', cl_wrappers, cl_headers, '1.2'],
|
||||
}
|
||||
|
||||
mali_cflags = []
|
||||
if platform != 'x11'
|
||||
mali_cflags += '-DMESA_EGL_NO_X11_HEADERS'
|
||||
endif
|
||||
|
||||
# Create dummy source for building libraries
|
||||
run_command('touch', join_paths(meson.current_build_dir(), 'dummy.c'))
|
||||
|
||||
# Create a dummy library for building wrappers
|
||||
libmali = shared_library(
|
||||
'mali',
|
||||
join_paths(meson.current_build_dir(), 'dummy.c'),
|
||||
install : true,
|
||||
version : meson.project_version())
|
||||
|
||||
foreach name, values : map
|
||||
symbol = values[0]
|
||||
wrappers = values[1]
|
||||
headers = values[2]
|
||||
pkg_version = values[3]
|
||||
|
||||
# TODO: Use readelf -s ?
|
||||
if run_command('grep', '-q', symbol, default_lib).returncode() != 0
|
||||
continue
|
||||
endif
|
||||
|
||||
foreach wrapper, version : wrappers
|
||||
shared_library(
|
||||
wrapper,
|
||||
join_paths(meson.current_build_dir(), 'dummy.c'),
|
||||
link_with : libmali,
|
||||
install : true,
|
||||
version : version)
|
||||
endforeach
|
||||
|
||||
foreach dir, files : headers
|
||||
install_headers(files, subdir : dir)
|
||||
endforeach
|
||||
|
||||
pkgconfig.generate(
|
||||
libraries : ['-L${libdir} -lmali'],
|
||||
extra_cflags : mali_cflags,
|
||||
version : pkg_version,
|
||||
name : name,
|
||||
description : 'Mali GPU User-Space Binary Drivers'
|
||||
)
|
||||
|
||||
if name == 'OpenCL'
|
||||
install_data('include/mali.icd', install_dir : get_option('sysconfdir') / 'OpenCL' / 'vendors')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
# Install optional overlay
|
||||
if get_option('with-overlay')
|
||||
if gpu == 'utgard-400' and subversion == 'r3p0'
|
||||
install_data('overlay/S10libmali_px3se', install_dir : get_option('sysconfdir') / 'init.d')
|
||||
install_data('overlay/px3seBase', install_dir : get_option('bindir'))
|
||||
endif
|
||||
|
||||
if gpu == 'midgard-t76x' and subversion == 'all'
|
||||
install_data('overlay/S10libmali_rk3288', install_dir : get_option('sysconfdir') / 'init.d')
|
||||
endif
|
||||
endif
|
||||
|
||||
# Install target libraries and replace the dummy one
|
||||
install_data(libs, install_dir : get_option('libdir'))
|
||||
meson.add_install_script('postinst.sh', get_option('libdir'), default_lib)
|
||||
12
meson_options.txt
Normal file
12
meson_options.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
option('arch', type: 'combo', choices: ['auto', 'arm', 'armv7l', 'armhf', 'arm32', 'armv8', 'arm64', 'aarch64'],
|
||||
description: 'arch (default: auto)')
|
||||
option('gpu', type: 'string', value: 'midgard-t86x',
|
||||
description: 'GPU name (default: midgard-t86x)')
|
||||
option('version', type: 'string', value: 'r18p0',
|
||||
description: 'GPU version (default: r18p0)')
|
||||
option('subversion', type: 'string', value: 'none',
|
||||
description: 'subversion (default: none)')
|
||||
option('platform', type: 'combo', choices: ['x11', 'gbm', 'wayland', 'only-cl'],
|
||||
value: 'x11', description: 'platform (default: x11)')
|
||||
option('with-overlay', type: 'boolean', value: 'false',
|
||||
description: 'install overlay (default: false)')
|
||||
10
postinst.sh
Executable file
10
postinst.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ $# -lt 2 ] && exit
|
||||
|
||||
LIB_DIR="${MESON_INSTALL_DESTDIR_PREFIX:-/usr}/$1"
|
||||
LIBMALI="$(basename $2)"
|
||||
|
||||
cd $LIB_DIR && \
|
||||
cp "$LIBMALI" libmali.so && \
|
||||
ln -sf libmali.so "$LIBMALI"
|
||||
Loading…
Add table
Add a link
Reference in a new issue