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" |
| 35 | KCONFIG_CONFIG_ROOTDIR ??= "${B}" |
| 36 | python do_menuconfig() { |
| 37 | import shutil |
| 38 | |
| 39 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") |
| 40 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") |
| 41 | |
| 42 | try: |
| 43 | mtime = os.path.getmtime(config) |
| 44 | shutil.copy(config, configorig) |
| 45 | except OSError: |
| 46 | mtime = 0 |
| 47 | |
| 48 | # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) |
| 49 | d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig") |
| 50 | d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig") |
| 51 | d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}") |
| 52 | d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1") |
| 53 | # ensure that environment variables are overwritten with this tasks 'd' values |
| 54 | d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") |
| 55 | |
| 56 | 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'), |
| 57 | d.getVar('PN') + ' Configuration', d) |
| 58 | |
| 59 | # FIXME this check can be removed when the minimum bitbake version has been bumped |
| 60 | if hasattr(bb.build, 'write_taint'): |
| 61 | try: |
| 62 | newmtime = os.path.getmtime(config) |
| 63 | except OSError: |
| 64 | newmtime = 0 |
| 65 | |
| 66 | if newmtime > mtime: |
| 67 | bb.note("Configuration changed, recompile will be forced") |
| 68 | bb.build.write_taint('do_compile', d) |
| 69 | } |
| 70 | do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" |
| 71 | do_menuconfig[nostamp] = "1" |
| 72 | do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" |
| 73 | addtask menuconfig after do_configure |
| 74 | |
| 75 | python do_diffconfig() { |
| 76 | import shutil |
| 77 | import subprocess |
| 78 | |
| 79 | workdir = d.getVar('WORKDIR') |
| 80 | fragment = workdir + '/fragment.cfg' |
| 81 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") |
| 82 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") |
| 83 | |
| 84 | try: |
| 85 | md5newconfig = bb.utils.md5_file(configorig) |
| 86 | md5config = bb.utils.md5_file(config) |
| 87 | isdiff = md5newconfig != md5config |
| 88 | except IOError as e: |
| 89 | bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e) |
| 90 | |
| 91 | if isdiff: |
| 92 | statement = 'diff --unchanged-line-format= --old-line-format= --new-line-format="%L" ' + configorig + ' ' + config + '>' + fragment |
| 93 | subprocess.call(statement, shell=True) |
| 94 | # No need to check the exit code as we know it's going to be |
| 95 | # non-zero, but that's what we expect. |
| 96 | shutil.copy(configorig, config) |
| 97 | |
| 98 | bb.plain("Config fragment has been dumped into:\n %s" % fragment) |
| 99 | else: |
| 100 | if os.path.exists(fragment): |
| 101 | os.unlink(fragment) |
| 102 | } |
| 103 | |
| 104 | do_diffconfig[nostamp] = "1" |
| 105 | do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" |
| 106 | addtask diffconfig |