diff options
Diffstat (limited to 'external/poky/meta/classes/kernel-yocto.bbclass')
-rw-r--r-- | external/poky/meta/classes/kernel-yocto.bbclass | 143 |
1 files changed, 108 insertions, 35 deletions
diff --git a/external/poky/meta/classes/kernel-yocto.bbclass b/external/poky/meta/classes/kernel-yocto.bbclass index 496c8a7f..3311f6e8 100644 --- a/external/poky/meta/classes/kernel-yocto.bbclass +++ b/external/poky/meta/classes/kernel-yocto.bbclass @@ -1,16 +1,41 @@ # remove tasks that modify the source tree in case externalsrc is inherited -SRCTREECOVEREDTASKS += "do_kernel_configme do_validate_branches do_kernel_configcheck do_kernel_checkout do_fetch do_unpack do_patch" +SRCTREECOVEREDTASKS += "do_validate_branches do_kernel_configcheck do_kernel_checkout do_fetch do_unpack do_patch" PATCH_GIT_USER_EMAIL ?= "kernel-yocto@oe" PATCH_GIT_USER_NAME ?= "OpenEmbedded" +# The distro or local.conf should set this, but if nobody cares... +LINUX_KERNEL_TYPE ??= "standard" + +# KMETA ?= "" +KBRANCH ?= "master" +KMACHINE ?= "${MACHINE}" +SRCREV_FORMAT ?= "meta_machine" + +# LEVELS: +# 0: no reporting +# 1: report options that are specified, but not in the final config +# 2: report options that are not hardware related, but set by a BSP +KCONF_AUDIT_LEVEL ?= "1" +KCONF_BSP_AUDIT_LEVEL ?= "0" +KMETA_AUDIT ?= "yes" + # returns local (absolute) path names for all valid patches in the # src_uri -def find_patches(d): +def find_patches(d,subdir): patches = src_patches(d) patch_list=[] for p in patches: - _, _, local, _, _, _ = bb.fetch.decodeurl(p) - patch_list.append(local) + _, _, local, _, _, parm = bb.fetch.decodeurl(p) + # if patchdir has been passed, we won't be able to apply it so skip + # the patch for now, and special processing happens later + patchdir = '' + if "patchdir" in parm: + patchdir = parm["patchdir"] + if subdir: + if subdir == patchdir: + patch_list.append(local) + else: + patch_list.append(local) return patch_list @@ -22,7 +47,7 @@ def find_sccs(d): base, ext = os.path.splitext(os.path.basename(s)) if ext and ext in [".scc", ".cfg"]: sources_list.append(s) - elif base and base in 'defconfig': + elif base and 'defconfig' in base: sources_list.append(s) return sources_list @@ -74,13 +99,6 @@ do_kernel_metadata() { fi fi - machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" - machine_srcrev="${SRCREV_machine}" - if [ -z "${machine_srcrev}" ]; then - # fallback to SRCREV if a non machine_meta tree is being built - machine_srcrev="${SRCREV}" - fi - # In a similar manner to the kernel itself: # # defconfig: $(obj)/conf @@ -113,24 +131,47 @@ do_kernel_metadata() { else cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig fi - sccs="${WORKDIR}/defconfig" + in_tree_defconfig="${WORKDIR}/defconfig" else bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree" fi fi + # was anyone trying to patch the kernel meta data ?, we need to do + # this here, since the scc commands migrate the .cfg fragments to the + # kernel source tree, where they'll be used later. + check_git_config + patches="${@" ".join(find_patches(d,'kernel-meta'))}" + for p in $patches; do + ( + cd ${WORKDIR}/kernel-meta + git am -s $p + ) + done + sccs_from_src_uri="${@" ".join(find_sccs(d))}" - patches="${@" ".join(find_patches(d))}" + patches="${@" ".join(find_patches(d,''))}" feat_dirs="${@" ".join(find_kernel_feature_dirs(d))}" - # a quick check to make sure we don't have duplicate defconfigs - # If there's a defconfig in the SRC_URI, did we also have one from - # the KBUILD_DEFCONFIG processing above ? - if [ -n "$sccs" ]; then - # we did have a defconfig from above. remove any that might be in the src_uri - sccs_from_src_uri=$(echo $sccs_from_src_uri | awk '{ if ($0!="defconfig") { print $0 } }' RS=' ') + # a quick check to make sure we don't have duplicate defconfigs If + # there's a defconfig in the SRC_URI, did we also have one from the + # KBUILD_DEFCONFIG processing above ? + src_uri_defconfig=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") != 0) { print $0 }' RS=' ') + # drop and defconfig's from the src_uri variable, we captured it just above here if it existed + sccs_from_src_uri=$(echo $sccs_from_src_uri | awk '(match($0, "defconfig") == 0) { print $0 }' RS=' ') + + if [ -n "$in_tree_defconfig" ]; then + sccs_defconfig=$in_tree_defconfig + if [ -n "$src_uri_defconfig" ]; then + bbwarn "[NOTE]: defconfig was supplied both via KBUILD_DEFCONFIG and SRC_URI. Dropping SRC_URI defconfig" + fi + else + # if we didn't have an in-tree one, make our defconfig the one + # from the src_uri. Note: there may not have been one from the + # src_uri, so this can be an empty variable. + sccs_defconfig=$src_uri_defconfig fi - sccs="$sccs $sccs_from_src_uri" + sccs="$sccs_from_src_uri" # check for feature directories/repos/branches that were part of the # SRC_URI. If they were supplied, we convert them into include directives @@ -138,10 +179,10 @@ do_kernel_metadata() { for f in ${feat_dirs}; do if [ -d "${WORKDIR}/$f/meta" ]; then includes="$includes -I${WORKDIR}/$f/kernel-meta" - elif [ -d "${WORKDIR}/$f" ]; then - includes="$includes -I${WORKDIR}/$f" elif [ -d "${WORKDIR}/../oe-local-files/$f" ]; then includes="$includes -I${WORKDIR}/../oe-local-files/$f" + elif [ -d "${WORKDIR}/$f" ]; then + includes="$includes -I${WORKDIR}/$f" fi done for s in ${sccs} ${patches}; do @@ -157,23 +198,37 @@ do_kernel_metadata() { # expand kernel features into their full path equivalents bsp_definition=$(spp ${includes} --find -DKMACHINE=${KMACHINE} -DKTYPE=${LINUX_KERNEL_TYPE}) if [ -z "$bsp_definition" ]; then - echo "$sccs" | grep -q defconfig - if [ $? -ne 0 ]; then + if [ -z "$sccs_defconfig" ]; then bbfatal_log "Could not locate BSP definition for ${KMACHINE}/${LINUX_KERNEL_TYPE} and no defconfig was provided" fi + else + # if the bsp definition has "define KMETA_EXTERNAL_BSP t", + # then we need to set a flag that will instruct the next + # steps to use the BSP as both configuration and patches. + grep -q KMETA_EXTERNAL_BSP $bsp_definition + if [ $? -eq 0 ]; then + KMETA_EXTERNAL_BSPS="t" + fi fi meta_dir=$(kgit --meta) # run1: pull all the configuration fragments, no matter where they come from - elements="`echo -n ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES}`" + elements="`echo -n ${bsp_definition} $sccs_defconfig ${sccs} ${patches} ${KERNEL_FEATURES}`" if [ -n "${elements}" ]; then echo "${bsp_definition}" > ${S}/${meta_dir}/bsp_definition - scc --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} ${bsp_definition} ${sccs} ${patches} ${KERNEL_FEATURES} + scc --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} $sccs_defconfig $bsp_definition $sccs $patches ${KERNEL_FEATURES} if [ $? -ne 0 ]; then bbfatal_log "Could not generate configuration queue for ${KMACHINE}." fi fi + # if KMETA_EXTERNAL_BSPS has been set, or it has been detected from + # the bsp definition, then we inject the bsp_definition into the + # patch phase below. we'll piggy back on the sccs variable. + if [ -n "${KMETA_EXTERNAL_BSPS}" ]; then + sccs="${bsp_definition} ${sccs}" + fi + # run2: only generate patches for elements that have been passed on the SRC_URI elements="`echo -n ${sccs} ${patches} ${KERNEL_FEATURES}`" if [ -n "${elements}" ]; then @@ -272,7 +327,7 @@ do_kernel_checkout() { } do_kernel_checkout[dirs] = "${S}" -addtask kernel_checkout before do_kernel_metadata after do_unpack +addtask kernel_checkout before do_kernel_metadata after do_symlink_kernsrc addtask kernel_metadata after do_validate_branches do_unpack before do_patch do_kernel_metadata[depends] = "kern-tools-native:do_populate_sysroot" do_validate_branches[depends] = "kern-tools-native:do_populate_sysroot" @@ -280,10 +335,9 @@ do_validate_branches[depends] = "kern-tools-native:do_populate_sysroot" do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}binutils:do_populate_sysroot" do_kernel_configme[depends] += "virtual/${TARGET_PREFIX}gcc:do_populate_sysroot" do_kernel_configme[depends] += "bc-native:do_populate_sysroot bison-native:do_populate_sysroot" +do_kernel_configme[depends] += "kern-tools-native:do_populate_sysroot" do_kernel_configme[dirs] += "${S} ${B}" do_kernel_configme() { - set +e - # translate the kconfig_mode into something that merge_config.sh # understands case ${KCONFIG_MODE} in @@ -309,13 +363,20 @@ do_kernel_configme() { bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)" fi - CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1 - if [ $? -ne 0 ]; then - bbfatal_log "Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}" + CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" LD="${KERNEL_LD}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1 + if [ $? -ne 0 -o ! -f ${B}/.config ]; then + bberror "Could not generate a .config for ${KMACHINE}-${LINUX_KERNEL_TYPE}" + if [ ${KCONF_AUDIT_LEVEL} -gt 1 ]; then + bbfatal_log "`cat ${meta_dir}/cfg/merge_config_build.log`" + else + bbfatal_log "Details can be found at: ${S}/${meta_dir}/cfg/merge_config_build.log" + fi fi - echo "# Global settings from linux recipe" >> ${B}/.config - echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config + if [ ! -z "${LINUX_VERSION_EXTENSION}" ]; then + echo "# Global settings from linux recipe" >> ${B}/.config + echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config + fi } addtask kernel_configme before do_configure after do_patch @@ -334,6 +395,7 @@ python do_kernel_configcheck() { env = os.environ.copy() env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") + env['LD'] = "${KERNEL_LD}" try: configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8') @@ -437,4 +499,15 @@ python () { # If diffconfig is available, ensure it runs after kernel_configme if 'do_diffconfig' in d: bb.build.addtask('do_diffconfig', None, 'do_kernel_configme', d) + + externalsrc = d.getVar('EXTERNALSRC') + if externalsrc: + # If we deltask do_patch, do_kernel_configme is left without + # dependencies and runs too early + d.setVarFlag('do_kernel_configme', 'deps', (d.getVarFlag('do_kernel_configme', 'deps', False) or []) + ['do_unpack']) } + +# extra tasks +addtask kernel_version_sanity_check after do_kernel_metadata do_kernel_checkout before do_compile +addtask validate_branches before do_patch after do_kernel_checkout +addtask kernel_configcheck after do_configure before do_compile |