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