from os import getenv, path from subprocess import Popen, PIPE from re import sub import shlex
cc = getenv("CC") assert cc, "Environment variable CC not set"
# Check if CC has options, as is the case in yocto, where it uses CC="cc --sysroot..."
cc_tokens = cc.split() if len(cc_tokens) > 1:
cc = cc_tokens[0]
cc_options = " ".join([str(e) for e in cc_tokens[1:]]) + " " else:
cc_options = ""
# ignore optional stderr could be None as it is set to PIPE to avoid that. # mypy: disable-error-code="union-attr"
cc_is_clang = b"clang version"in Popen([cc, "-v"], stderr=PIPE).stderr.readline()
srctree = getenv('srctree') assert srctree, "Environment variable srctree, for the Linux sources, not set"
src_feature_tests = f'{srctree}/tools/build/feature'
def clang_has_option(option):
cmd = shlex.split(f"{cc} {cc_options} {option}")
cmd.append(path.join(src_feature_tests, "test-hello.c"))
cc_output = Popen(cmd, stderr=PIPE).stderr.readlines() return [o for o in cc_output if ((b"unknown argument"in o) or (b"is not supported"in o) or (b"unknown warning option"in o))] == [ ]
class install_lib(_install_lib): def finalize_options(self):
_install_lib.finalize_options(self)
self.build_dir = build_lib
cflags = getenv('CFLAGS', '').split() # switch off several checks (need to be at the end of cflags list)
cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ] if cc_is_clang:
cflags += ["-Wno-unused-command-line-argument" ] if clang_has_option("-Wno-cast-function-type-mismatch"):
cflags += ["-Wno-cast-function-type-mismatch" ] else:
cflags += ['-Wno-cast-function-type' ]
# The python headers have mixed code with declarations (decls after asserts, for instance)
cflags += [ "-Wno-declaration-after-statement" ]
setup(name='perf',
version='0.1',
description='Interface with the Linux profiling infrastructure',
author='Arnaldo Carvalho de Melo',
author_email='acme@redhat.com',
license='GPLv2',
url='http://perf.wiki.kernel.org',
ext_modules=[perf],
cmdclass={'build_ext': build_ext, 'install_lib': install_lib})
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.