summaryrefslogtreecommitdiffstats
path: root/import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py
diff options
context:
space:
mode:
Diffstat (limited to 'import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py')
-rw-r--r--import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py86
1 files changed, 58 insertions, 28 deletions
diff --git a/import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py b/import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py
index f84ec3dc6..e914e53aa 100644
--- a/import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py
+++ b/import-layers/yocto-poky/scripts/lib/recipetool/create_buildsys.py
@@ -44,7 +44,7 @@ class CmakeRecipeHandler(RecipeHandler):
classes.append('cmake')
values = CmakeRecipeHandler.extract_cmake_deps(lines_before, srctree, extravalues)
classes.extend(values.pop('inherit', '').split())
- for var, value in values.iteritems():
+ for var, value in values.items():
lines_before.append('%s = "%s"' % (var, value))
lines_after.append('# Specify any options you want to pass to cmake using EXTRA_OECMAKE:')
lines_after.append('EXTRA_OECMAKE = ""')
@@ -159,7 +159,7 @@ class CmakeRecipeHandler(RecipeHandler):
def find_cmake_package(pkg):
RecipeHandler.load_devel_filemap(tinfoil.config_data)
- for fn, pn in RecipeHandler.recipecmakefilemap.iteritems():
+ for fn, pn in RecipeHandler.recipecmakefilemap.items():
splitname = fn.split('/')
if len(splitname) > 1:
if splitname[0].lower().startswith(pkg.lower()):
@@ -173,7 +173,7 @@ class CmakeRecipeHandler(RecipeHandler):
def parse_cmake_file(fn, paths=None):
searchpaths = (paths or []) + [os.path.dirname(fn)]
logger.debug('Parsing file %s' % fn)
- with open(fn, 'r') as f:
+ with open(fn, 'r', errors='surrogateescape') as f:
for line in f:
line = line.strip()
for handler in handlers:
@@ -348,13 +348,13 @@ class AutotoolsRecipeHandler(RecipeHandler):
autoconf = True
values = AutotoolsRecipeHandler.extract_autotools_deps(lines_before, srctree, extravalues)
classes.extend(values.pop('inherit', '').split())
- for var, value in values.iteritems():
+ for var, value in values.items():
lines_before.append('%s = "%s"' % (var, value))
else:
conffile = RecipeHandler.checkfiles(srctree, ['configure'])
if conffile:
# Check if this is just a pre-generated autoconf configure script
- with open(conffile[0], 'r') as f:
+ with open(conffile[0], 'r', errors='surrogateescape') as f:
for i in range(1, 10):
if 'Generated by GNU Autoconf' in f.readline():
autoconf = True
@@ -364,7 +364,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
# Last resort
conffile = RecipeHandler.checkfiles(srctree, ['configure'])
if conffile:
- with open(conffile[0], 'r') as f:
+ with open(conffile[0], 'r', errors='surrogateescape') as f:
for line in f:
line = line.strip()
if line.startswith('VERSION=') or line.startswith('PACKAGE_VERSION='):
@@ -442,11 +442,12 @@ class AutotoolsRecipeHandler(RecipeHandler):
ac_init_re = re.compile('AC_INIT\(\s*([^,]+),\s*([^,]+)[,)].*')
am_init_re = re.compile('AM_INIT_AUTOMAKE\(\s*([^,]+),\s*([^,]+)[,)].*')
define_re = re.compile('\s*(m4_)?define\(\s*([^,]+),\s*([^,]+)\)')
+ version_re = re.compile('([0-9.]+)')
defines = {}
def subst_defines(value):
newvalue = value
- for define, defval in defines.iteritems():
+ for define, defval in defines.items():
newvalue = newvalue.replace(define, defval)
if newvalue != value:
return subst_defines(newvalue)
@@ -488,6 +489,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
for handler in handlers:
if handler.process_macro(srctree, keyword, value, process_value, libdeps, pcdeps, deps, outlines, inherits, values):
return
+ logger.debug('Found keyword %s with value "%s"' % (keyword, value))
if keyword == 'PKG_CHECK_MODULES':
res = pkg_re.search(value)
if res:
@@ -569,10 +571,21 @@ class AutotoolsRecipeHandler(RecipeHandler):
deps.append('sqlite3')
elif keyword == 'AX_LIB_TAGLIB':
deps.append('taglib')
- elif keyword == 'AX_PKG_SWIG':
- deps.append('swig')
+ elif keyword in ['AX_PKG_SWIG', 'AC_PROG_SWIG']:
+ deps.append('swig-native')
elif keyword == 'AX_PROG_XSLTPROC':
deps.append('libxslt-native')
+ elif keyword in ['AC_PYTHON_DEVEL', 'AX_PYTHON_DEVEL', 'AM_PATH_PYTHON']:
+ pythonclass = 'pythonnative'
+ res = version_re.search(value)
+ if res:
+ if res.group(1).startswith('3'):
+ pythonclass = 'python3native'
+ # Avoid replacing python3native with pythonnative
+ if not pythonclass in inherits and not 'python3native' in inherits:
+ if 'pythonnative' in inherits:
+ inherits.remove('pythonnative')
+ inherits.append(pythonclass)
elif keyword == 'AX_WITH_CURSES':
deps.append('ncurses')
elif keyword == 'AX_PATH_BDB':
@@ -638,7 +651,11 @@ class AutotoolsRecipeHandler(RecipeHandler):
'AX_LIB_SQLITE3',
'AX_LIB_TAGLIB',
'AX_PKG_SWIG',
+ 'AC_PROG_SWIG',
'AX_PROG_XSLTPROC',
+ 'AC_PYTHON_DEVEL',
+ 'AX_PYTHON_DEVEL',
+ 'AM_PATH_PYTHON',
'AX_WITH_CURSES',
'AX_PATH_BDB',
'AX_PATH_LIB_PCRE',
@@ -654,7 +671,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
nesting = 0
in_keyword = ''
partial = ''
- with open(srcfile, 'r') as f:
+ with open(srcfile, 'r', errors='surrogateescape') as f:
for line in f:
if in_keyword:
partial += ' ' + line.strip()
@@ -682,7 +699,7 @@ class AutotoolsRecipeHandler(RecipeHandler):
process_macro(in_keyword, partial)
if extravalues:
- for k,v in extravalues.items():
+ for k,v in list(extravalues.items()):
if v:
if v.startswith('$') or v.startswith('@') or v.startswith('%'):
del extravalues[k]
@@ -737,7 +754,7 @@ class MakefileRecipeHandler(RecipeHandler):
if 'buildsystem' in handled:
return False
- makefile = RecipeHandler.checkfiles(srctree, ['Makefile'])
+ makefile = RecipeHandler.checkfiles(srctree, ['Makefile', 'makefile', 'GNUmakefile'])
if makefile:
lines_after.append('# NOTE: this is a Makefile-only piece of software, so we cannot generate much of the')
lines_after.append('# recipe automatically - you will need to examine the Makefile yourself and ensure')
@@ -753,7 +770,7 @@ class MakefileRecipeHandler(RecipeHandler):
if scanfile and os.path.exists(scanfile):
values = AutotoolsRecipeHandler.extract_autotools_deps(lines_before, srctree, acfile=scanfile)
classes.extend(values.pop('inherit', '').split())
- for var, value in values.iteritems():
+ for var, value in values.items():
if var == 'DEPENDS':
lines_before.append('# NOTE: some of these dependencies may be optional, check the Makefile and/or upstream documentation')
lines_before.append('%s = "%s"' % (var, value))
@@ -780,7 +797,7 @@ class MakefileRecipeHandler(RecipeHandler):
if installtarget:
func.append('# This is a guess; additional arguments may be required')
makeargs = ''
- with open(makefile[0], 'r') as f:
+ with open(makefile[0], 'r', errors='surrogateescape') as f:
for i in range(1, 100):
if 'DESTDIR' in f.readline():
makeargs += " 'DESTDIR=${D}'"
@@ -809,7 +826,7 @@ class VersionFileRecipeHandler(RecipeHandler):
version = None
for fileitem in filelist:
linecount = 0
- with open(fileitem, 'r') as f:
+ with open(fileitem, 'r', errors='surrogateescape') as f:
for line in f:
line = line.rstrip().strip('"\'')
linecount += 1
@@ -830,22 +847,35 @@ class SpecFileRecipeHandler(RecipeHandler):
if 'PV' in extravalues and 'PN' in extravalues:
return
filelist = RecipeHandler.checkfiles(srctree, ['*.spec'], recursive=True)
- pn = None
- pv = None
+ valuemap = {'Name': 'PN',
+ 'Version': 'PV',
+ 'Summary': 'SUMMARY',
+ 'Url': 'HOMEPAGE',
+ 'License': 'LICENSE'}
+ foundvalues = {}
for fileitem in filelist:
linecount = 0
- with open(fileitem, 'r') as f:
+ with open(fileitem, 'r', errors='surrogateescape') as f:
for line in f:
- if line.startswith('Name:') and not pn:
- pn = line.split(':')[1].strip()
- if line.startswith('Version:') and not pv:
- pv = line.split(':')[1].strip()
- if pv or pn:
- if pv and not 'PV' in extravalues and validate_pv(pv):
- extravalues['PV'] = pv
- if pn and not 'PN' in extravalues:
- extravalues['PN'] = pn
- break
+ for value, varname in valuemap.items():
+ if line.startswith(value + ':') and not varname in foundvalues:
+ foundvalues[varname] = line.split(':', 1)[1].strip()
+ break
+ if len(foundvalues) == len(valuemap):
+ break
+ if 'PV' in foundvalues:
+ if not validate_pv(foundvalues['PV']):
+ del foundvalues['PV']
+ license = foundvalues.pop('LICENSE', None)
+ if license:
+ liccomment = '# NOTE: spec file indicates the license may be "%s"' % license
+ for i, line in enumerate(lines_before):
+ if line.startswith('LICENSE ='):
+ lines_before.insert(i, liccomment)
+ break
+ else:
+ lines_before.append(liccomment)
+ extravalues.update(foundvalues)
def register_recipe_handlers(handlers):
# Set priorities with some gaps so that other plugins can insert
OpenPOWER on IntegriCloud