summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2022-12-29 11:43:12 +0530
committerSebastian Dröge <slomo@coaxion.net>2023-01-12 21:57:08 +0000
commitc92700a19c5558455e14327f9c5920b6d07f18aa (patch)
tree4f3b21250340d6a2e68b662f6f43a1029b7f818b
parent68eb3414df2af3eb05ed8f272640009571d2be59 (diff)
android.config: Use f-strings for all string formatting
This makes it much easier to read Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/864>
-rw-r--r--config/android.config46
1 files changed, 23 insertions, 23 deletions
diff --git a/config/android.config b/config/android.config
index 335bebca..85cd332c 100644
--- a/config/android.config
+++ b/config/android.config
@@ -49,7 +49,7 @@ if target_arch == Architecture.ARMv7:
tools_dir = tools_prefix
arch_include = tools_prefix
host = 'arm-linux-androideabi'
- llvm_triple = 'armv7-none-linux-androideabi' + str(v)
+ llvm_triple = f'armv7-none-linux-androideabi{v}'
_android_arch = 'arm'
_cerbero_arch = 'armv7'
_cxx_arch = 'armeabi-v7a'
@@ -87,22 +87,22 @@ elif target_arch == Architecture.UNIVERSAL:
_cerbero_arch = 'x86_64'
_cxx_arch = 'x86_64'
else:
- raise FatalError("Arch %s not supported" % target_arch)
+ raise FatalError(f'Arch {target_arch} not supported')
if platform == Platform.DARWIN:
tc_arch = 'darwin-x86_64'
elif platform == Platform.LINUX:
tc_arch = 'linux-x86_64'
else:
- raise FatalError("Platform %s is not supported" % platform)
-llvm_toolchain_path = '%s/toolchains/llvm/prebuilt/%s/bin' % (toolchain_prefix, tc_arch)
-gcc_toolchain_root = '%s/toolchains/%s-4.9/prebuilt/%s' % (toolchain_prefix, tools_dir, tc_arch)
-spirv_toolchain_path = '%s/shader-tools/%s' % (toolchain_prefix, tc_arch)
+ raise FatalError(f'Platform {platform} is not supported')
+llvm_toolchain_path = f'{toolchain_prefix}/toolchains/llvm/prebuilt/{tc_arch}/bin'
+gcc_toolchain_root = f'{toolchain_prefix}/toolchains/{tools_dir}-4.9/prebuilt/{tc_arch}'
+spirv_toolchain_path = f'{toolchain_prefix}/shader-tools/{tc_arch}'
gcc_toolchain_path = os.path.join (gcc_toolchain_root, 'bin')
-isysroot = "%s/sysroot" % (toolchain_prefix)
-sysroot = "%s/platforms/android-%d/arch-%s" % (toolchain_prefix, v, _android_arch)
+isysroot = f'{toolchain_prefix}/sysroot'
+sysroot = f'{toolchain_prefix}/platforms/android-{v}/arch-{_android_arch}'
# Default compiler flags
env['CFLAGS'] = ''
@@ -130,20 +130,20 @@ if target_arch != Architecture.UNIVERSAL and not os.path.exists(lib_dir):
# Most of the compiler/linker specific flags are taken from
# from android-ndk-r16/build/core/toolchains/$NAME-$VERSION/setup.mk
ccache = use_ccache and 'ccache ' or ''
-defines = '-DANDROID -DPIC -D__ANDROID_API__=%s ' % (v)
+defines = f'-DANDROID -DPIC -D__ANDROID_API__={v} '
# -fno-integrated-as cause some libraries (e.g. pixman) fail to build with
# clang's assembler
# -target is being duplicated here and in CC variable to workaround cmake
# ignoring arguments in CC while other build systems may ignore CFLAGS for
# certain checks.
-cflags = '-target %s --sysroot %s -gcc-toolchain %s -isysroot %s -isystem %s -isystem %s/usr/include -isystem %s/usr/include/%s -fno-integrated-as -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -Wno-invalid-command-line-argument -Wno-unused-command-line-argument ' % (llvm_triple, sysroot, gcc_toolchain_root, isysroot, incl_dir, isysroot, isysroot, tools_prefix)
+cflags = f'-target {llvm_triple} --sysroot {sysroot} -gcc-toolchain {gcc_toolchain_root} -isysroot {isysroot} -isystem {incl_dir} -isystem {isysroot}/usr/include -isystem {isysroot}/usr/include/{tools_prefix} -fno-integrated-as -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -Wno-invalid-command-line-argument -Wno-unused-command-line-argument '
# http://b.android.com/220159 http://b.android.com/222239
if target_arch == Architecture.X86:
if v < 24:
cflags += ' -mstackrealign'
-ldflags = '-gcc-toolchain %s -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--warn-shared-textrel -Wl,--exclude-libs,libatomic.a -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libunwind.a' % (gcc_toolchain_root,)
+ldflags = f'-gcc-toolchain {gcc_toolchain_root} -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--warn-shared-textrel -Wl,--exclude-libs,libatomic.a -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libunwind.a'
if target_arch == Architecture.ARMv7:
defines += ' -D__ARM_ARCH_7A__ '
@@ -152,17 +152,17 @@ if target_arch == Architecture.ARMv7:
elif target_arch == Architecture.X86:
cflags += ' -march=i686 '
-ldflags += ' -L%s' % (lib_dir,)
+ldflags += ' -L' + lib_dir
if not target_arch in [Architecture.ARM64, Architecture.X86_64]:
# nocopyreloc causes broken linking on arm64
ldflags += ' -Wl,-z,nocopyreloc '
if target_arch in [Architecture.X86_64]:
- ldflags += ' -L%s/usr/lib64 ' % sysroot
+ ldflags += f' -L{sysroot}/usr/lib64 '
else:
- ldflags += ' -L%s/usr/lib ' % sysroot
+ ldflags += f' -L{sysroot}/usr/lib '
ldvariant = 'gold'
-ldflags += ' -fuse-ld=%s ' % ldvariant
+ldflags += f' -fuse-ld={ldvariant} '
# this C++ stl setup is closely tied to the gnustl recipe which sets up the
# necessary environment and files for this
@@ -174,18 +174,18 @@ stl_cxxflags = '-nostdlib++ -isystem ' + os.path.join (stl_prefix, 'include') +
# Toolchain environment
env['CPPFLAGS'] = defines
-env['CFLAGS'] += "%s %s -Wa,--noexecstack" % (cflags, defines)
+env['CFLAGS'] += f'{cflags} {defines} -Wa,--noexecstack'
env['CXXFLAGS'] = stl_cxxflags + ' ' + env['CFLAGS'] + ' -fno-rtti -fno-exceptions '
env['LDFLAGS'] = ldflags + ' -nostdlib++'
def cmd(command):
- return '%s-%s' % (tools_prefix, command)
+ return f'{tools_prefix}-{command}'
# clang requires the full path otherwise it does stupid things and can't
# find it's own binary
-env['CC']= ccache + os.path.join(llvm_toolchain_path, 'clang') + ' -target %s' % (llvm_triple) + ' --sysroot %s' % (sysroot)
-env['CXX']= ccache + os.path.join(llvm_toolchain_path, 'clang++') + ' -target %s' % (llvm_triple) + ' --sysroot %s' % (sysroot)
-env['LD']= cmd('ld.%s' % ldvariant)
+env['CC']= ccache + os.path.join(llvm_toolchain_path, 'clang') + f' -target {llvm_triple}' + f' --sysroot {sysroot}'
+env['CXX']= ccache + os.path.join(llvm_toolchain_path, 'clang++') + f' -target {llvm_triple}' + f' --sysroot {sysroot}'
+env['LD']= cmd(f'ld.{ldvariant}')
env['CPP']= os.path.join(llvm_toolchain_path, 'clang') + ' -E'
env['RANLIB']= cmd('ranlib')
env['AR']= cmd('ar')
@@ -194,12 +194,12 @@ env['NM']= cmd('nm')
env['STRIP']= cmd('strip')
env['OBJCOPY']= cmd('objcopy')
-env['PATH'] = '%s:%s:%s:%s:%s' % (toolchain_prefix, llvm_toolchain_path, gcc_toolchain_path, spirv_toolchain_path, env['PATH'])
+env['PATH'] = f'{toolchain_prefix}:{llvm_toolchain_path}:{gcc_toolchain_path}:{spirv_toolchain_path}:{env["PATH"]}'
# For the libc.so dependency in i686-linux-android-as
if target_arch == Architecture.X86:
- extra_lib_path = '%s/usr/lib' % (sysroot)
+ extra_lib_path = f'{sysroot}/usr/lib'
elif target_arch == Architecture.X86_64:
- extra_lib_path = '%s/usr/lib64' % (sysroot)
+ extra_lib_path = f'{sysroot}/usr/lib64'
# For GLib
meson_properties['growing_stack'] = 'true'