rockbox/tools/thumb-cc.py
Solomon Peachy af9b65485b build: move '-mthumb-interwork' into the configure script
When we request a thumb build on a non-thumb-only target, we hand
compilation to a script that tries to build everything as thumb, falling
back to non-thumb arm mode if the thumb build fails.  In order for
this to work, the compiler flag -mthumb-interwork is required.

Move this definition out of the thumb-cc script, and into the configure
script (ie along with the other target-specific definitions)

Change-Id: Idc1f8caa088dbbf710b169b272de61cc0b7c9ca6
2026-09-19 21:18:30 -04:00

46 lines
1.7 KiB
Python
Executable file

#!/usr/bin/env python3
# -*- coding: utf8 -*-
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
#
# Copyright © 2010-2011 Rafaël Carré <rafael.carre@gmail>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
from sys import argv, stderr, stdout
from subprocess import Popen, PIPE
from os import execv
args = argv[1:] # remove script path
for opt in ['-E', '-MM', '-v', '--version']:
if opt in args:
execv(args[0], args) # not actually compiling
if '-o' in args and args.index('-o') < len(args) - 1:
if len(args[args.index('-o') + 1].rsplit('.o', 1)) == 1:
execv(args[0], args) # output doesn't end in .o
# thumb-interwork is required; add if not present
if '-mthumb-interwork' not in args:
args += ['-mthumb-interwork'];
# Try to compile in thumb mode first
gcc = Popen(args + ['-mthumb'], stdout=PIPE, stderr=PIPE)
(out, err) = gcc.communicate()
if gcc.returncode != 0: # thumb failed, try outputting arm
execv(args[0], args)
stdout.write(out.decode("utf-8"))
stderr.write(err.decode("utf-8"))