1 BB_DEFAULT_TASK ?= "build"
5 inherit packaged-staging
13 OE_IMPORTS += "oe.path oe.utils oe.packagegroup oe.data sys os time"
14 OE_IMPORTS[type] = "list"
17 if isinstance(e, bb.event.ConfigParsed):
20 bbpath = e.data.getVar("BBPATH", True).split(":")
21 sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
23 def inject(name, value):
24 """Make a python object accessible from the metadata"""
25 if hasattr(bb.utils, "_context"):
26 bb.utils._context[name] = value
28 __builtins__[name] = value
30 for toimport in e.data.getVar("OE_IMPORTS", True).split():
31 imported = __import__(toimport)
32 inject(toimport.split(".", 1)[0], imported)
55 oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
56 ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
60 # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
61 # we need that built is the responsibility of the patch function / class, not
63 if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
64 if (bb.data.getVar('HOST_SYS', d, 1) !=
65 bb.data.getVar('BUILD_SYS', d, 1)):
66 return "virtual/${TARGET_PREFIX}gcc virtual/libc"
67 elif bb.data.inherits_class('native', d) and \
68 bb.data.getVar('PN', d, True) not in \
69 ("linux-libc-headers-native", "quilt-native",
70 "unifdef-native", "shasum-native"):
71 return "linux-libc-headers-native"
74 DEPENDS_prepend = "${@base_deps(d)} "
75 DEPENDS_virtclass-native_prepend = "${@base_deps(d)} "
76 DEPENDS_virtclass-nativesdk_prepend = "${@base_deps(d)} "
79 SCENEFUNCS += "base_scenefunction"
80 SCENEFUNCS[type] = "list"
82 python base_scenefunction () {
83 stamp = bb.data.getVar('STAMP', d, 1) + ".needclean"
84 if os.path.exists(stamp):
85 bb.build.exec_func("do_clean", d)
88 python base_do_setscene () {
89 for func in oe.data.typed_value('SCENEFUNCS', d):
90 bb.build.exec_func(func, d)
91 if not os.path.exists(bb.data.getVar('STAMP', d, 1) + ".do_setscene"):
92 bb.build.make_stamp("do_setscene", d)
94 do_setscene[selfstamp] = "1"
95 addtask setscene before do_fetch
98 do_fetch[dirs] = "${DL_DIR}"
99 python base_do_fetch() {
102 localdata = bb.data.createCopy(d)
103 bb.data.update_data(localdata)
105 src_uri = oe.data.typed_value('SRC_URI', localdata)
109 bb.fetch.init(src_uri, d)
110 except bb.fetch.NoMethodError:
111 (type, value, traceback) = sys.exc_info()
112 raise bb.build.FuncFailed("No method: %s" % value)
113 except bb.MalformedUrl:
114 (type, value, traceback) = sys.exc_info()
115 raise bb.build.FuncFailed("Malformed URL: %s" % value)
118 bb.fetch.go(localdata)
119 except bb.fetch.MissingParameterError:
120 (type, value, traceback) = sys.exc_info()
121 raise bb.build.FuncFailed("Missing parameters: %s" % value)
122 except bb.fetch.FetchError:
123 (type, value, traceback) = sys.exc_info()
124 raise bb.build.FuncFailed("Fetch failed: %s" % value)
125 except bb.fetch.MD5SumError:
126 (type, value, traceback) = sys.exc_info()
127 raise bb.build.FuncFailed("MD5 failed: %s" % value)
129 (type, value, traceback) = sys.exc_info()
130 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
133 pv = bb.data.getVar('PV', d, True)
134 pn = bb.data.getVar('PN', d, True)
139 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
140 (type,host,path,_,_,params) = bb.decodeurl(url)
141 uri = "%s://%s%s" % (type,host,path)
143 if type in [ "http", "https", "ftp", "ftps" ]:
144 # We provide a default shortcut of plain [] for the first fetch uri
145 # Explicit names in any uri overrides this default.
146 if not "name" in params and first_uri:
149 if not base_chk_file(pn, pv, uri, localpath, params, d):
150 if not bb.data.getVar("OE_ALLOW_INSECURE_DOWNLOADS", d, True):
151 bb.fatal("%s-%s: %s cannot check archive integrity" % (pn,pv,uri))
153 bb.note("%s-%s: %s cannot check archive integrity" % (pn,pv,uri))
155 raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
158 def oe_unpack(d, local, urldata):
159 from oe.unpack import unpack_file, is_patch, UnpackError
160 if is_patch(local, urldata.parm):
164 if "subdir" in urldata.parm:
165 subdirs.append(urldata.parm["subdir"])
167 if urldata.type == "file":
169 urlpath = urldata.path
171 urlpath = "%s%s" % (urldata.host, urldata.path)
173 if not os.path.isabs(urlpath):
174 subdirs.append(os.path.dirname(urlpath))
176 workdir = d.getVar("WORKDIR", True)
178 destdir = oe.path.join(workdir, *subdirs)
179 bb.mkdirhier(destdir)
183 bb.note("Unpacking %s to %s/" % (base_path_out(local, d),
184 base_path_out(destdir, d)))
186 unpack_file(local, destdir, urldata.parm, env={"PATH": d.getVar("PATH", True)})
187 except UnpackError, exc:
190 addtask unpack after do_fetch
191 do_unpack[dirs] = "${WORKDIR}"
192 python base_do_unpack() {
193 from glob import glob
195 src_uri = oe.data.typed_value("SRC_URI", d)
198 srcurldata = bb.fetch.init(src_uri, d, True)
199 filespath = oe.data.typed_value("FILESPATH", d)
202 urldata = srcurldata[url]
203 if urldata.type == "file" and "*" in urldata.path:
204 # The fetch code doesn't know how to handle globs, so
205 # we need to handle the local bits ourselves
206 for path in filespath:
207 srcdir = oe.path.join(path, urldata.host,
208 os.path.dirname(urldata.path))
209 if os.path.exists(srcdir):
212 bb.fatal("Unable to locate files for %s" % url)
214 for filename in glob(oe.path.join(srcdir,
215 os.path.basename(urldata.path))):
216 oe_unpack(d, filename, urldata)
218 local = urldata.localpath
220 raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
222 oe_unpack(d, local, urldata)
225 python old_bitbake_messages () {
226 version = [int(c) for c in bb.__version__.split('.')]
227 if version >= [1, 9, 0]:
230 from bb.event import BuildBase, DepBase
231 from bb.build import TaskBase
233 name = bb.event.getName(e)
234 if isinstance(e, TaskBase):
235 pf = bb.data.getVar('PF', e.data, True)
236 msg = 'package %s: task %s: %s' % (pf, e.task, name[4:].lower())
237 elif isinstance(e, BuildBase):
238 msg = 'build %s: %s' % (e.name, name[5:].lower())
239 elif isinstance(e, DepBase):
240 msg = 'package %s: dependency %s %s' % (e.pkg, e.dep, name[:-3].lower())
246 addhandler old_bitbake_messages
248 python build_summary() {
249 from bb import note, error, data
250 from bb.event import getName
252 if isinstance(e, bb.event.BuildStarted):
253 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
254 statusvars = bb.data.getVar("BUILDCFG_VARS", e.data, 1).split()
255 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
256 statusmsg = "\n%s\n%s\n" % (bb.data.getVar("BUILDCFG_HEADER", e.data, 1), "\n".join(statuslines))
258 # bitbake 1.8.x has a broken bb.plain and that stops the BB_MIN_VERSION
259 # check from happening.
260 version = [int(c) for c in bb.__version__.split('.')]
261 if version >= [1, 9, 0]:
266 needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", e.data)
268 for v in needed_vars:
269 val = bb.data.getVar(v, e.data, 1)
270 if not val or val == 'INVALID':
273 bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser))
275 addhandler build_summary
277 addtask configure after do_unpack do_patch
278 do_configure[dirs] = "${S} ${B}"
279 do_configure[deptask] = "do_populate_sysroot"
280 base_do_configure() {
284 addtask compile after do_configure
285 do_compile[dirs] = "${S} ${B}"
287 if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then
288 oe_runmake || die "make failed"
290 oenote "nothing to compile"
294 addtask install after do_compile
295 do_install[dirs] = "${D} ${S} ${B}"
296 # Remove and re-create ${D} so that is it guaranteed to be empty
297 do_install[cleandirs] = "${D}"
314 def set_multimach_arch(d):
315 # 'multimachine' handling
316 mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
317 pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
320 # We always try to scan SRC_URI for urls with machine overrides
321 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
323 override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
324 if override != '0' and is_machine_specific(d):
325 bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
326 bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
331 for pkg in oe.data.typed_value('PACKAGES', d):
332 pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
334 # We could look for != PACKAGE_ARCH here but how to choose
335 # if multiple differences are present?
336 # Look through PACKAGE_ARCHS for the priority order?
337 if pkgarch and pkgarch == mach_arch:
338 multiarch = mach_arch
341 bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
346 source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
347 if not source_mirror_fetch:
348 need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
351 this_host = bb.data.getVar('HOST_SYS', d, 1)
352 if not re.match(need_host, this_host):
353 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
355 need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
358 this_machine = bb.data.getVar('MACHINE', d, 1)
359 if this_machine and not re.match(need_machine, this_machine):
360 this_soc_family = bb.data.getVar('SOC_FAMILY', d, 1)
361 if (this_soc_family and not re.match(need_machine, this_soc_family)) or not this_soc_family:
362 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
364 need_target = bb.data.getVar('COMPATIBLE_TARGET_SYS', d, 1)
367 this_target = bb.data.getVar('TARGET_SYS', d, 1)
368 if this_target and not re.match(need_target, this_target):
369 raise bb.parse.SkipPackage("incompatible with target system %s" % this_target)
371 pn = bb.data.getVar('PN', d, 1)
373 # OBSOLETE in bitbake 1.7.4
374 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
376 bb.data.setVar('SRCDATE', srcdate, d)
378 use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
380 bb.data.setVar('USE_NLS', use_nls, d)
382 setup_checksum_deps(d)
384 # Git packages should DEPEND on git-native
385 srcuri = bb.data.getVar('SRC_URI', d, 1)
386 if "git://" in srcuri:
387 depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
388 depends = depends + " git-native:do_populate_sysroot"
389 bb.data.setVarFlag('do_fetch', 'depends', depends, d)
391 if "hg://" in srcuri:
392 depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
393 depends = depends + " mercurial-native:do_populate_sysroot"
394 bb.data.setVarFlag('do_fetch', 'depends', depends, d)
396 # unzip-native should already be staged before unpacking ZIP recipes
397 need_unzip = bb.data.getVar('NEED_UNZIP_FOR_UNPACK', d, 1)
398 src_uri = bb.data.getVar('SRC_URI', d, 1)
400 if ".zip" in src_uri or need_unzip == "1":
401 depends = bb.data.getVarFlag('do_unpack', 'depends', d) or ""
402 depends = depends + " unzip-native:do_populate_sysroot"
403 bb.data.setVarFlag('do_unpack', 'depends', depends, d)
406 depends = bb.data.getVarFlag('do_unpack', 'depends', d) or ""
407 depends = depends + " lzip-native:do_populate_sysroot"
408 bb.data.setVarFlag('do_unpack', 'depends', depends, d)
410 # 'multimachine' handling
411 mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
412 pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
414 if (pkg_arch == mach_arch):
415 # Already machine specific - nothing further to do
418 set_multimach_arch(d)
421 EXPORT_FUNCTIONS do_setscene do_fetch do_unpack do_configure do_compile do_install do_package