blob: d319d66ab2229717467d8ce3029218a7334639fe [file] [log] [blame]
Andrew Geisslerb7d28612020-07-24 16:15:54 -05001# returns all the elements from the src uri that are .cfg files
2def 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 IIIac69b482021-06-02 12:28:27 -07009 return sources_list
Andrew Geisslerb7d28612020-07-24 16:15:54 -050010
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011cml1_do_configure() {
12 set -e
13 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
Brad Bishopc342db32019-05-15 21:57:59 -040014 yes '' | oe_runmake oldconfig
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015}
16
17EXPORT_FUNCTIONS do_configure
18addtask configure after do_unpack do_patch before do_compile
19
20inherit terminal
21
22OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC"
23HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}"
24HOSTLDFLAGS = "${BUILD_LDFLAGS}"
25CROSS_CURSES_LIB = "-lncurses -ltinfo"
26CROSS_CURSES_INC = '-DCURSES_LOC="<curses.h>"'
27TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo"
28
29KCONFIG_CONFIG_COMMAND ??= "menuconfig"
Andrew Geissler635e0e42020-08-21 15:58:33 -050030KCONFIG_CONFIG_ROOTDIR ??= "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031python do_menuconfig() {
32 import shutil
33
Andrew Geissler635e0e42020-08-21 15:58:33 -050034 config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config")
35 configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig")
36
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 try:
Andrew Geissler635e0e42020-08-21 15:58:33 -050038 mtime = os.path.getmtime(config)
39 shutil.copy(config, configorig)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 except OSError:
41 mtime = 0
42
Andrew Geissler6ce62a22020-11-30 19:58:47 -060043 # 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 Bishop19323692019-04-05 15:28:33 -040051 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 Bishop6e60e8b2018-02-01 10:27:11 -050052 d.getVar('PN') + ' Configuration', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053
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 Geissler635e0e42020-08-21 15:58:33 -050057 newmtime = os.path.getmtime(config)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058 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}
65do_menuconfig[depends] += "ncurses-native:do_populate_sysroot"
66do_menuconfig[nostamp] = "1"
Andrew Geissler635e0e42020-08-21 15:58:33 -050067do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068addtask menuconfig after do_configure
69
70python do_diffconfig() {
71 import shutil
72 import subprocess
73
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 workdir = d.getVar('WORKDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 fragment = workdir + '/fragment.cfg'
Andrew Geissler635e0e42020-08-21 15:58:33 -050076 configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig")
77 config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078
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 Bishopd7bf8c12018-02-25 22:55:05 -050089 # 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 Williamsc124f4f2015-09-15 14:41:29 -050091 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
99do_diffconfig[nostamp] = "1"
Andrew Geissler635e0e42020-08-21 15:58:33 -0500100do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101addtask diffconfig