From c861959ac5667d05eb0418b608f9be7e6f6ff082 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 19 Aug 2021 14:58:59 +0800 Subject: [PATCH] meson: Support optimize-level option The default optimize level is O3, there're more to come. Change-Id: I4671d9664a565c43300ec46a0aa6ac91661bd607 Signed-off-by: Jeffy Chen --- grabber.sh | 12 ++++++++++-- meson.build | 5 +++-- meson_options.txt | 2 ++ optimize_3 | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) create mode 120000 optimize_3 diff --git a/grabber.sh b/grabber.sh index 9d8c308..4034078 100755 --- a/grabber.sh +++ b/grabber.sh @@ -1,10 +1,11 @@ -#!/bin/sh +#!/bin/bash ARCH=${1:-aarch64} GPU=${2:-midgard-t86x} VERSION=${3:-r18p0} SUBVERSION=${4:-none} PLATFORM=${5:-x11} +OPTIMIZE=${6:-O3} [ ${ARCH} = 'armv7l' -o ${ARCH} = 'armhf' -o ${ARCH} = 'arm32' ] && ARCH=arm [ ${ARCH} = 'armv8' -o ${ARCH} = 'arm64' ] && ARCH=aarch64 @@ -17,4 +18,11 @@ else LIB="libmali-${GPU}-${VERSION}-${SUBVERSION}-${PLATFORM}.so" fi -find lib/${ARCH}* -name ${LIB} 2>/dev/null +DIR=lib +case ${OPTIMIZE} in + O*) + DIR=optimize_${OPTIMIZE#O} + ;; +esac + +find ${DIR}/${ARCH}* -name ${LIB} diff --git a/meson.build b/meson.build index 3f3a6e1..3752a08 100644 --- a/meson.build +++ b/meson.build @@ -21,11 +21,12 @@ platform = get_option('platform') opencl_icd = get_option('opencl-icd') vendor_package = get_option('vendor-package') wrappers_opts = get_option('wrappers') +optimize = get_option('optimize-level') -message('Building for ' + '|'.join([arch, gpu, version, subversion, platform])) +message('Building for ' + '|'.join([arch, gpu, version, subversion, platform, optimize])) # Grab libraries with specified configs -cmd = run_command('grabber.sh', arch, gpu, version, subversion, platform) +cmd = run_command('grabber.sh', arch, gpu, version, subversion, platform, optimize) libs = cmd.stdout().strip().split('\n') # Use the first one as default library diff --git a/meson_options.txt b/meson_options.txt index bb53eeb..6468b54 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -18,3 +18,5 @@ option('vendor-package', type: 'boolean', value: 'false', description: 'Install as vendor package (default: false)') option('wrappers', type: 'feature', value: 'auto', description: 'Install with wrappers (default: auto)') +option('optimize-level', type: 'combo', choices: ['O0', 'O1', 'O2', 'O3', 'Os', 'Ofast', 'Og'], value: 'O3', + description: 'Optimize level (default: O3)') diff --git a/optimize_3 b/optimize_3 new file mode 120000 index 0000000..7951405 --- /dev/null +++ b/optimize_3 @@ -0,0 +1 @@ +lib \ No newline at end of file