2017-06-27 16:01:03 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
2019-08-22 22:05:53 +01:00
|
|
|
import re
|
|
|
|
import subprocess
|
2017-06-27 16:01:03 +02:00
|
|
|
|
|
|
|
def get_sample(filename):
|
2017-07-18 13:43:20 +02:00
|
|
|
fullpath = os.path.join("@LIEF_SAMPLES_DIRECTORY@", filename)
|
2017-06-27 16:01:03 +02:00
|
|
|
|
|
|
|
assert os.path.exists(fullpath)
|
|
|
|
assert os.path.isfile(fullpath)
|
|
|
|
|
|
|
|
return fullpath
|
|
|
|
|
2019-08-22 22:05:53 +01:00
|
|
|
def get_compiler():
|
|
|
|
compiler = os.getenv("CC", "/usr/bin/cc")
|
|
|
|
if not os.path.exists(compiler):
|
|
|
|
raise RuntimeError("Unable to find a compiler")
|
|
|
|
return compiler
|
|
|
|
|
|
|
|
|
|
|
|
def has_recent_glibc():
|
|
|
|
"""Check if we have at least GLIBC 2.17"""
|
|
|
|
try:
|
|
|
|
out = subprocess.check_output(["ldd", "--version"]).decode("ascii")
|
|
|
|
version_str = re.search(" (\d\.\d+)\n", out).group(1)
|
|
|
|
major, minor = version_str.split(".")
|
|
|
|
except (OSError, AttributeError):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if int(major) == 2 and int(minor) >= 17:
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|