| Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 1 | # returns all the elements from the src uri that are .cfg files | 
|  | 2 | def find_cfgs(d): | 
|  | 3 | sources=src_patches(d, True) | 
|  | 4 | sources_list=[] | 
|  | 5 | for s in sources: | 
|  | 6 | if s.endswith('.cfg'): | 
|  | 7 | sources_list.append(s) | 
|  | 8 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame^] | 9 | return sources_list | 
| Andrew Geissler | b7d2861 | 2020-07-24 16:15:54 -0500 | [diff] [blame] | 10 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | cml1_do_configure() { | 
|  | 12 | set -e | 
|  | 13 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS | 
| Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 14 | yes '' | oe_runmake oldconfig | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | } | 
|  | 16 |  | 
|  | 17 | EXPORT_FUNCTIONS do_configure | 
|  | 18 | addtask configure after do_unpack do_patch before do_compile | 
|  | 19 |  | 
|  | 20 | inherit terminal | 
|  | 21 |  | 
|  | 22 | OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC" | 
|  | 23 | HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}" | 
|  | 24 | HOSTLDFLAGS = "${BUILD_LDFLAGS}" | 
|  | 25 | CROSS_CURSES_LIB = "-lncurses -ltinfo" | 
|  | 26 | CROSS_CURSES_INC = '-DCURSES_LOC="<curses.h>"' | 
|  | 27 | TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo" | 
|  | 28 |  | 
|  | 29 | KCONFIG_CONFIG_COMMAND ??= "menuconfig" | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 30 | KCONFIG_CONFIG_ROOTDIR ??= "${B}" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | python do_menuconfig() { | 
|  | 32 | import shutil | 
|  | 33 |  | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 34 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") | 
|  | 35 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") | 
|  | 36 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | try: | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 38 | mtime = os.path.getmtime(config) | 
|  | 39 | shutil.copy(config, configorig) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | except OSError: | 
|  | 41 | mtime = 0 | 
|  | 42 |  | 
| Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 43 | # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) | 
|  | 44 | d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig") | 
|  | 45 | d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig") | 
|  | 46 | d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}") | 
|  | 47 | d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1") | 
|  | 48 | # ensure that environment variables are overwritten with this tasks 'd' values | 
|  | 49 | d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") | 
|  | 50 |  | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 51 | 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'), | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | d.getVar('PN') + ' Configuration', d) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 |  | 
|  | 54 | # FIXME this check can be removed when the minimum bitbake version has been bumped | 
|  | 55 | if hasattr(bb.build, 'write_taint'): | 
|  | 56 | try: | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 57 | newmtime = os.path.getmtime(config) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | except OSError: | 
|  | 59 | newmtime = 0 | 
|  | 60 |  | 
|  | 61 | if newmtime > mtime: | 
|  | 62 | bb.note("Configuration changed, recompile will be forced") | 
|  | 63 | bb.build.write_taint('do_compile', d) | 
|  | 64 | } | 
|  | 65 | do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" | 
|  | 66 | do_menuconfig[nostamp] = "1" | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 67 | do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | addtask menuconfig after do_configure | 
|  | 69 |  | 
|  | 70 | python do_diffconfig() { | 
|  | 71 | import shutil | 
|  | 72 | import subprocess | 
|  | 73 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 74 | workdir = d.getVar('WORKDIR') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | fragment = workdir + '/fragment.cfg' | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 76 | configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") | 
|  | 77 | config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 |  | 
|  | 79 | try: | 
|  | 80 | md5newconfig = bb.utils.md5_file(configorig) | 
|  | 81 | md5config = bb.utils.md5_file(config) | 
|  | 82 | isdiff = md5newconfig != md5config | 
|  | 83 | except IOError as e: | 
|  | 84 | bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e) | 
|  | 85 |  | 
|  | 86 | if isdiff: | 
|  | 87 | statement = 'diff --unchanged-line-format= --old-line-format= --new-line-format="%L" ' + configorig + ' ' + config + '>' + fragment | 
|  | 88 | subprocess.call(statement, shell=True) | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 89 | # No need to check the exit code as we know it's going to be | 
|  | 90 | # non-zero, but that's what we expect. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 91 | shutil.copy(configorig, config) | 
|  | 92 |  | 
|  | 93 | bb.plain("Config fragment has been dumped into:\n %s" % fragment) | 
|  | 94 | else: | 
|  | 95 | if os.path.exists(fragment): | 
|  | 96 | os.unlink(fragment) | 
|  | 97 | } | 
|  | 98 |  | 
|  | 99 | do_diffconfig[nostamp] = "1" | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 100 | do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | addtask diffconfig |