blob: 9b9866f4c375edb02021546cd19a2f72954133a1 [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
9 return sources_list
10
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
Brad Bishop19323692019-04-05 15:28:33 -040043 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 -050044 d.getVar('PN') + ' Configuration', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045
46 # FIXME this check can be removed when the minimum bitbake version has been bumped
47 if hasattr(bb.build, 'write_taint'):
48 try:
Andrew Geissler635e0e42020-08-21 15:58:33 -050049 newmtime = os.path.getmtime(config)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 except OSError:
51 newmtime = 0
52
53 if newmtime > mtime:
54 bb.note("Configuration changed, recompile will be forced")
55 bb.build.write_taint('do_compile', d)
56}
57do_menuconfig[depends] += "ncurses-native:do_populate_sysroot"
58do_menuconfig[nostamp] = "1"
Andrew Geissler635e0e42020-08-21 15:58:33 -050059do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060addtask menuconfig after do_configure
61
62python do_diffconfig() {
63 import shutil
64 import subprocess
65
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 workdir = d.getVar('WORKDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 fragment = workdir + '/fragment.cfg'
Andrew Geissler635e0e42020-08-21 15:58:33 -050068 configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig")
69 config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070
71 try:
72 md5newconfig = bb.utils.md5_file(configorig)
73 md5config = bb.utils.md5_file(config)
74 isdiff = md5newconfig != md5config
75 except IOError as e:
76 bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e)
77
78 if isdiff:
79 statement = 'diff --unchanged-line-format= --old-line-format= --new-line-format="%L" ' + configorig + ' ' + config + '>' + fragment
80 subprocess.call(statement, shell=True)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050081 # No need to check the exit code as we know it's going to be
82 # non-zero, but that's what we expect.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 shutil.copy(configorig, config)
84
85 bb.plain("Config fragment has been dumped into:\n %s" % fragment)
86 else:
87 if os.path.exists(fragment):
88 os.unlink(fragment)
89}
90
91do_diffconfig[nostamp] = "1"
Andrew Geissler635e0e42020-08-21 15:58:33 -050092do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093addtask diffconfig