summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-02-19 22:39:02 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-21 09:32:43 +0000
commit524ee088b3ce354b4f29c0b18e92c532526f8909 (patch)
tree066fa4319f25410b7c8e0ae996497f39a5e69394 /scripts
parent7b6e5b025e2ba8a91be01d61f7b9093f4729e8cc (diff)
downloadpoky-524ee088b3ce354b4f29c0b18e92c532526f8909.tar.gz
recipetool: create: improve CMake package mapping
* Package names are actually case sensitive near as I can tell, so we shouldn't be lowercasing them everywhere. * Look for CMake packages in pkgdata and map those back to recipes, so we aren't dependent on the hardcoded mappings (though those are still preserved). * Avoid duplicates in the unmapped package list (From OE-Core rev: 2ddad52ccca07245eea43d9b844c6c7d4b667ca3) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/recipetool/create.py15
-rw-r--r--scripts/lib/recipetool/create_buildsys.py39
2 files changed, 40 insertions, 14 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 3e4bab8afe..7560cdf7cc 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -43,6 +43,7 @@ def tinfoil_init(instance):
43class RecipeHandler(object): 43class RecipeHandler(object):
44 recipelibmap = {} 44 recipelibmap = {}
45 recipeheadermap = {} 45 recipeheadermap = {}
46 recipecmakefilemap = {}
46 47
47 @staticmethod 48 @staticmethod
48 def load_libmap(d): 49 def load_libmap(d):
@@ -90,15 +91,18 @@ class RecipeHandler(object):
90 RecipeHandler.recipelibmap['GLESv2'] = 'virtual/libgles2' 91 RecipeHandler.recipelibmap['GLESv2'] = 'virtual/libgles2'
91 92
92 @staticmethod 93 @staticmethod
93 def load_headermap(d): 94 def load_devel_filemap(d):
94 '''Build up lib headerfile->recipe mapping''' 95 '''Build up development file->recipe mapping'''
95 if RecipeHandler.recipeheadermap: 96 if RecipeHandler.recipeheadermap:
96 return 97 return
98 pkgdata_dir = d.getVar('PKGDATA_DIR', True)
97 includedir = d.getVar('includedir', True) 99 includedir = d.getVar('includedir', True)
100 cmakedir = os.path.join(d.getVar('libdir', True), 'cmake')
98 for pkg in glob.glob(os.path.join(pkgdata_dir, 'runtime', '*-dev')): 101 for pkg in glob.glob(os.path.join(pkgdata_dir, 'runtime', '*-dev')):
99 with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f: 102 with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f:
100 pn = None 103 pn = None
101 headers = [] 104 headers = []
105 cmakefiles = []
102 for line in f: 106 for line in f:
103 if line.startswith('PN:'): 107 if line.startswith('PN:'):
104 pn = line.split(':', 1)[-1].strip() 108 pn = line.split(':', 1)[-1].strip()
@@ -108,9 +112,14 @@ class RecipeHandler(object):
108 for fullpth in sorted(dictval): 112 for fullpth in sorted(dictval):
109 if fullpth.startswith(includedir) and fullpth.endswith('.h'): 113 if fullpth.startswith(includedir) and fullpth.endswith('.h'):
110 headers.append(os.path.relpath(fullpth, includedir)) 114 headers.append(os.path.relpath(fullpth, includedir))
115 elif fullpth.startswith(cmakedir) and fullpth.endswith('.cmake'):
116 cmakefiles.append(os.path.relpath(fullpth, cmakedir))
111 if pn and headers: 117 if pn and headers:
112 for header in headers: 118 for header in headers:
113 RecipeHandler.recipeheadermap[header] = pn 119 RecipeHandler.recipeheadermap[header] = pn
120 if pn and cmakefiles:
121 for fn in cmakefiles:
122 RecipeHandler.recipecmakefilemap[fn] = pn
114 123
115 @staticmethod 124 @staticmethod
116 def checkfiles(path, speclist, recursive=False): 125 def checkfiles(path, speclist, recursive=False):
@@ -172,7 +181,7 @@ class RecipeHandler(object):
172 deps.append(recipe) 181 deps.append(recipe)
173 elif recipe is None: 182 elif recipe is None:
174 if header: 183 if header:
175 RecipeHandler.load_headermap(d) 184 RecipeHandler.load_devel_filemap(d)
176 recipe = RecipeHandler.recipeheadermap.get(header, None) 185 recipe = RecipeHandler.recipeheadermap.get(header, None)
177 if recipe: 186 if recipe:
178 deps.append(recipe) 187 deps.append(recipe)
diff --git a/scripts/lib/recipetool/create_buildsys.py b/scripts/lib/recipetool/create_buildsys.py
index 1a06cac8c5..43dcca3c5b 100644
--- a/scripts/lib/recipetool/create_buildsys.py
+++ b/scripts/lib/recipetool/create_buildsys.py
@@ -17,6 +17,7 @@
17 17
18import re 18import re
19import logging 19import logging
20import glob
20from recipetool.create import RecipeHandler, validate_pv 21from recipetool.create import RecipeHandler, validate_pv
21 22
22logger = logging.getLogger('recipetool') 23logger = logging.getLogger('recipetool')
@@ -156,6 +157,16 @@ class CmakeRecipeHandler(RecipeHandler):
156 subdir_re = re.compile('add_subdirectory\s*\(\s*([^)\s]*)\s*([^)\s]*)\s*\)', re.IGNORECASE) 157 subdir_re = re.compile('add_subdirectory\s*\(\s*([^)\s]*)\s*([^)\s]*)\s*\)', re.IGNORECASE)
157 dep_re = re.compile('([^ ><=]+)( *[<>=]+ *[^ ><=]+)?') 158 dep_re = re.compile('([^ ><=]+)( *[<>=]+ *[^ ><=]+)?')
158 159
160 def find_cmake_package(pkg):
161 RecipeHandler.load_devel_filemap(tinfoil.config_data)
162 for fn, pn in RecipeHandler.recipecmakefilemap.iteritems():
163 splitname = fn.split('/')
164 if len(splitname) > 1:
165 if splitname[0].lower().startswith(pkg.lower()):
166 if splitname[1] == '%s-config.cmake' % pkg.lower() or splitname[1] == '%sConfig.cmake' % pkg or splitname[1] == 'Find%s.cmake' % pkg:
167 return pn
168 return None
169
159 def interpret_value(value): 170 def interpret_value(value):
160 return value.strip('"') 171 return value.strip('"')
161 172
@@ -209,7 +220,7 @@ class CmakeRecipeHandler(RecipeHandler):
209 res = findpackage_re.match(line) 220 res = findpackage_re.match(line)
210 if res: 221 if res:
211 origpkg = res.group(1) 222 origpkg = res.group(1)
212 pkg = interpret_value(origpkg.lower()) 223 pkg = interpret_value(origpkg)
213 found = False 224 found = False
214 for handler in handlers: 225 for handler in handlers:
215 if handler.process_findpackage(srctree, fn, pkg, deps, outlines, inherits, values): 226 if handler.process_findpackage(srctree, fn, pkg, deps, outlines, inherits, values):
@@ -218,23 +229,29 @@ class CmakeRecipeHandler(RecipeHandler):
218 break 229 break
219 if found: 230 if found:
220 continue 231 continue
221 elif pkg == 'gettext': 232 elif pkg == 'Gettext':
222 inherits.append('gettext') 233 inherits.append('gettext')
223 elif pkg == 'perl': 234 elif pkg == 'Perl':
224 inherits.append('perlnative') 235 inherits.append('perlnative')
225 elif pkg == 'pkgconfig': 236 elif pkg == 'PkgConfig':
226 inherits.append('pkgconfig') 237 inherits.append('pkgconfig')
227 elif pkg == 'pythoninterp': 238 elif pkg == 'PythonInterp':
228 inherits.append('pythonnative') 239 inherits.append('pythonnative')
229 elif pkg == 'pythonlibs': 240 elif pkg == 'PythonLibs':
230 inherits.append('python-dir') 241 inherits.append('python-dir')
231 else: 242 else:
232 dep = cmake_pkgmap.get(pkg, None) 243 # Try to map via looking at installed CMake packages in pkgdata
244 dep = find_cmake_package(pkg)
233 if dep: 245 if dep:
234 logger.debug('Mapped CMake package %s to recipe %s via internal list' % (pkg, dep)) 246 logger.debug('Mapped CMake package %s to recipe %s via pkgdata' % (pkg, dep))
235 deps.append(dep) 247 deps.append(dep)
236 elif dep is None: 248 else:
237 unmappedpkgs.append(origpkg) 249 dep = cmake_pkgmap.get(pkg.lower(), None)
250 if dep:
251 logger.debug('Mapped CMake package %s to recipe %s via internal list' % (pkg, dep))
252 deps.append(dep)
253 elif dep is None:
254 unmappedpkgs.append(origpkg)
238 continue 255 continue
239 res = checklib_re.match(line) 256 res = checklib_re.match(line)
240 if res: 257 if res:
@@ -257,7 +274,7 @@ class CmakeRecipeHandler(RecipeHandler):
257 parse_cmake_file(srcfiles[0]) 274 parse_cmake_file(srcfiles[0])
258 275
259 if unmappedpkgs: 276 if unmappedpkgs:
260 outlines.append('# NOTE: unable to map the following CMake package dependencies: %s' % ' '.join(unmappedpkgs)) 277 outlines.append('# NOTE: unable to map the following CMake package dependencies: %s' % ' '.join(list(set(unmappedpkgs))))
261 278
262 RecipeHandler.handle_depends(libdeps, pcdeps, deps, outlines, values, tinfoil.config_data) 279 RecipeHandler.handle_depends(libdeps, pcdeps, deps, outlines, values, tinfoil.config_data)
263 280