Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # returns all the elements from the src uri that are .cfg files |
| 8 | def find_cfgs(d): |
| 9 | sources=src_patches(d, True) |
| 10 | sources_list=[] |
| 11 | for s in sources: |
| 12 | if s.endswith('.cfg'): |
| 13 | sources_list.append(s) |
| 14 | |
| 15 | return sources_list |
| 16 | |
| 17 | cml1_do_configure() { |
| 18 | set -e |
| 19 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
| 20 | yes '' | oe_runmake oldconfig |
| 21 | } |
| 22 | |
| 23 | EXPORT_FUNCTIONS do_configure |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 24 | |
| 25 | inherit terminal |
| 26 | |
| 27 | OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC" |
| 28 | HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}" |
| 29 | HOSTLDFLAGS = "${BUILD_LDFLAGS}" |
| 30 | CROSS_CURSES_LIB = "-lncurses -ltinfo" |
| 31 | CROSS_CURSES_INC = '-DCURSES_LOC="<curses.h>"' |
| 32 | TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo" |
| 33 | |
| 34 | KCONFIG_CONFIG_COMMAND ??= "menuconfig" |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 35 | KCONFIG_CONFIG_ENABLE_MENUCONFIG ??= "true" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 36 | KCONFIG_CONFIG_ROOTDIR ??= "${B}" |
| 37 | python do_menuconfig() { |
| 38 | import shutil |
| 39 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 40 | if not bb.utils.to_boolean(d.getVar("KCONFIG_CONFIG_ENABLE_MENUCONFIG")): |
| 41 | bb.fatal("do_menuconfig is disabled, please check KCONFIG_CONFIG_ENABLE_MENUCONFIG variable.") |
| 42 | return |
| 43 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 44 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") |
| 45 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") |
| 46 | |
| 47 | try: |
| 48 | mtime = os.path.getmtime(config) |
| 49 | shutil.copy(config, configorig) |
| 50 | except OSError: |
| 51 | mtime = 0 |
| 52 | |
| 53 | # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) |
| 54 | d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig") |
| 55 | d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig") |
| 56 | d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}") |
| 57 | d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1") |
| 58 | # ensure that environment variables are overwritten with this tasks 'd' values |
| 59 | d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") |
| 60 | |
Andrew Geissler | 5082cc7 | 2023-09-11 08:41:39 -0400 | [diff] [blame] | 61 | oe_terminal("sh -c 'make %s; if [ \\$? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi'" % d.getVar('KCONFIG_CONFIG_COMMAND'), |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 62 | d.getVar('PN') + ' Configuration', d) |
| 63 | |
| 64 | # FIXME this check can be removed when the minimum bitbake version has been bumped |
| 65 | if hasattr(bb.build, 'write_taint'): |
| 66 | try: |
| 67 | newmtime = os.path.getmtime(config) |
| 68 | except OSError: |
| 69 | newmtime = 0 |
| 70 | |
| 71 | if newmtime > mtime: |
| 72 | bb.note("Configuration changed, recompile will be forced") |
| 73 | bb.build.write_taint('do_compile', d) |
| 74 | } |
| 75 | do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" |
| 76 | do_menuconfig[nostamp] = "1" |
| 77 | do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" |
| 78 | addtask menuconfig after do_configure |
| 79 | |
| 80 | python do_diffconfig() { |
| 81 | import shutil |
| 82 | import subprocess |
| 83 | |
| 84 | workdir = d.getVar('WORKDIR') |
| 85 | fragment = workdir + '/fragment.cfg' |
| 86 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") |
| 87 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") |
| 88 | |
| 89 | try: |
| 90 | md5newconfig = bb.utils.md5_file(configorig) |
| 91 | md5config = bb.utils.md5_file(config) |
| 92 | isdiff = md5newconfig != md5config |
| 93 | except IOError as e: |
| 94 | bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e) |
| 95 | |
| 96 | if isdiff: |
| 97 | statement = 'diff --unchanged-line-format= --old-line-format= --new-line-format="%L" ' + configorig + ' ' + config + '>' + fragment |
| 98 | subprocess.call(statement, shell=True) |
| 99 | # No need to check the exit code as we know it's going to be |
| 100 | # non-zero, but that's what we expect. |
| 101 | shutil.copy(configorig, config) |
| 102 | |
| 103 | bb.plain("Config fragment has been dumped into:\n %s" % fragment) |
| 104 | else: |
| 105 | if os.path.exists(fragment): |
| 106 | os.unlink(fragment) |
| 107 | } |
| 108 | |
| 109 | do_diffconfig[nostamp] = "1" |
| 110 | do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" |
| 111 | addtask diffconfig |
Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 112 | |
| 113 | do_showconfig() { |
| 114 | bbplain "Config file written to ${KCONFIG_CONFIG_ROOTDIR}/.config" |
| 115 | } |
| 116 | do_showconfig[nostamp] = "1" |
| 117 | addtask showconfig after do_configure |