Update SConstruct to python3

This commit is contained in:
Ingo Ruhnke 2019-11-24 18:16:16 +01:00
parent ac6ebb1228
commit 39a334fbc0

View file

@ -15,7 +15,7 @@ def build_dbus_glue(target, source, env):
"--mode=glib-server",
"--prefix=" + env['DBUS_PREFIX'], source[0].get_path()],
stdout=subprocess.PIPE).communicate()[0]
xml = xml.decode()
xml = re.sub(r"callback = \(([A-Za-z_]+)\) \(marshal_data \? marshal_data : cc->callback\);",
r"union { \1 fn; void* obj; } conv;\n "
"conv.obj = (marshal_data ? marshal_data : cc->callback);\n "
@ -29,14 +29,14 @@ def build_bin2h(target, source, env):
Takes a list of files and converts them into a C source that can be included
"""
def c_escape(str):
return str.translate(string.maketrans("/.-", "___"))
return str.translate(str.maketrans("/.-", "___"))
print target
print source
print(target)
print(source)
with open(target[0].get_path(), "w") as fout:
fout.write("// autogenerated by scons Bin2H builder, do not edit by hand!\n\n")
if env.has_key("BIN2H_NAMESPACE"):
if "BIN2H_NAMESPACE" in env:
fout.write("namespace %s {\n\n" % env["BIN2H_NAMESPACE"])
# write down data
@ -45,8 +45,8 @@ def build_bin2h(target, source, env):
data = fin.read()
fout.write("// \"%s\"\n" % src.get_path())
fout.write("const char %s[] = {" % c_escape(src.get_path()))
bytes_arr = ["0x%02x" % ord(c) for c in data]
for i in xrange(len(bytes_arr)):
bytes_arr = ["0x%02x" % c for c in data]
for i in range(len(bytes_arr)):
if i % 13 == 0:
fout.write("\n ")
fout.write(bytes_arr[i])
@ -62,7 +62,7 @@ def build_bin2h(target, source, env):
for src in source], ",\n"))
fout.write("\n}\n\n")
if env.has_key("BIN2H_NAMESPACE"):
if "BIN2H_NAMESPACE" in env:
fout.write("} // namespace %s\n\n" % env["BIN2H_NAMESPACE"])
fout.write("/* EOF */\n")
@ -131,12 +131,12 @@ env.Append(CPPDEFINES = { 'PACKAGE_VERSION': "'\"%s\"'" % package_version })
conf = Configure(env)
if not conf.env['CXX']:
print "g++ must be installed!"
print("g++ must be installed!")
Exit(1)
# X11 checks
if not conf.CheckLibWithHeader('X11', 'X11/Xlib.h', 'C++'):
print 'libx11-dev must be installed!'
print('libx11-dev must be installed!')
Exit(1)
env = conf.Finish()