mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 04:46:01 +01:00
pylibfdt: Convert to Python 3
Build this swig module with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5effab0549
commit
b4cf5f1df7
@ -21,7 +21,7 @@ quiet_cmd_pymod = PYMOD $@
|
|||||||
CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
|
CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
|
||||||
SOURCES="$(PYLIBFDT_srcs)" \
|
SOURCES="$(PYLIBFDT_srcs)" \
|
||||||
SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
|
SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
|
||||||
$(PYTHON2) $< --quiet build_ext --inplace
|
$(PYTHON3) $< --quiet build_ext --inplace
|
||||||
|
|
||||||
$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
|
$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
|
||||||
$(call if_changed,pymod)
|
$(call if_changed,pymod)
|
||||||
|
@ -624,7 +624,7 @@ class Fdt(FdtRo):
|
|||||||
Raises:
|
Raises:
|
||||||
FdtException if no parent found or other error occurs
|
FdtException if no parent found or other error occurs
|
||||||
"""
|
"""
|
||||||
val = val.encode('utf-8') + '\0'
|
val = val.encode('utf-8') + b'\0'
|
||||||
return check_err(fdt_setprop(self._fdt, nodeoffset, prop_name,
|
return check_err(fdt_setprop(self._fdt, nodeoffset, prop_name,
|
||||||
val, len(val)), quiet)
|
val, len(val)), quiet)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
setup.py file for SWIG libfdt
|
setup.py file for SWIG libfdt
|
||||||
|
@ -7,16 +7,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
import importlib
|
||||||
# importlib was introduced in Python 2.7 but there was a report of it not
|
|
||||||
# working in 2.7.12, so we work around this:
|
|
||||||
# http://lists.denx.de/pipermail/u-boot/2016-October/269729.html
|
|
||||||
try:
|
|
||||||
import importlib
|
|
||||||
have_importlib = True
|
|
||||||
except:
|
|
||||||
have_importlib = False
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -119,10 +110,7 @@ class Entry(object):
|
|||||||
old_path = sys.path
|
old_path = sys.path
|
||||||
sys.path.insert(0, os.path.join(our_path, 'etype'))
|
sys.path.insert(0, os.path.join(our_path, 'etype'))
|
||||||
try:
|
try:
|
||||||
if have_importlib:
|
module = importlib.import_module(module_name)
|
||||||
module = importlib.import_module(module_name)
|
|
||||||
else:
|
|
||||||
module = __import__(module_name)
|
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
|
raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
|
||||||
(etype, node_path, module_name, e))
|
(etype, node_path, module_name, e))
|
||||||
|
@ -39,21 +39,6 @@ class TestEntry(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
import entry
|
import entry
|
||||||
|
|
||||||
def test1EntryNoImportLib(self):
|
|
||||||
"""Test that we can import Entry subclassess successfully"""
|
|
||||||
sys.modules['importlib'] = None
|
|
||||||
global entry
|
|
||||||
self._ReloadEntry()
|
|
||||||
entry.Entry.Create(None, self.GetNode(), 'u-boot')
|
|
||||||
self.assertFalse(entry.have_importlib)
|
|
||||||
|
|
||||||
def test2EntryImportLib(self):
|
|
||||||
del sys.modules['importlib']
|
|
||||||
global entry
|
|
||||||
self._ReloadEntry()
|
|
||||||
entry.Entry.Create(None, self.GetNode(), 'u-boot-spl')
|
|
||||||
self.assertTrue(entry.have_importlib)
|
|
||||||
|
|
||||||
def testEntryContents(self):
|
def testEntryContents(self):
|
||||||
"""Test the Entry bass class"""
|
"""Test the Entry bass class"""
|
||||||
import entry
|
import entry
|
||||||
|
@ -27,6 +27,6 @@ class Entry_intel_fit(Entry_blob):
|
|||||||
self.align = 16
|
self.align = 16
|
||||||
|
|
||||||
def ObtainContents(self):
|
def ObtainContents(self):
|
||||||
data = struct.pack('<8sIHBB', '_FIT_ ', 1, 0x100, 0x80, 0x7d)
|
data = struct.pack('<8sIHBB', b'_FIT_ ', 1, 0x100, 0x80, 0x7d)
|
||||||
self.SetContents(data)
|
self.SetContents(data)
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user