blob: c4e3c9ff7a3b9173dbfcc59817964763faa2de9e [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
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
8def 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
17cml1_do_configure() {
18 set -e
19 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
20 yes '' | oe_runmake oldconfig
21}
22
23EXPORT_FUNCTIONS do_configure
Patrick Williams92b42cb2022-09-03 06:53:57 -050024
25inherit terminal
26
27OE_TERMINAL_EXPORTS += "HOST_EXTRACFLAGS HOSTLDFLAGS TERMINFO CROSS_CURSES_LIB CROSS_CURSES_INC"
28HOST_EXTRACFLAGS = "${BUILD_CFLAGS} ${BUILD_LDFLAGS}"
29HOSTLDFLAGS = "${BUILD_LDFLAGS}"
30CROSS_CURSES_LIB = "-lncurses -ltinfo"
31CROSS_CURSES_INC = '-DCURSES_LOC="<curses.h>"'
32TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo"
33
34KCONFIG_CONFIG_COMMAND ??= "menuconfig"
Patrick Williams520786c2023-06-25 16:20:36 -050035KCONFIG_CONFIG_ENABLE_MENUCONFIG ??= "true"
Patrick Williams92b42cb2022-09-03 06:53:57 -050036KCONFIG_CONFIG_ROOTDIR ??= "${B}"
37python do_menuconfig() {
38 import shutil
39
Patrick Williams520786c2023-06-25 16:20:36 -050040 if not bb.utils.to_boolean(d.getVar("KCONFIG_CONFIG_ENABLE_MENUCONFIG")):
41 bb.fatal("do_menuconfig is disabled, please check KCONFIG_CONFIG_ENABLE_MENUCONFIG variable.")
42 return
43
Patrick Williams92b42cb2022-09-03 06:53:57 -050044 config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config")
45 configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig")
46
47 try:
48 mtime = os.path.getmtime(config)
49 shutil.copy(config, configorig)
50 except OSError:
51 mtime = 0
52
53 # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
54 d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig")
55 d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig")
56 d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}")
57 d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1")
58 # ensure that environment variables are overwritten with this tasks 'd' values
59 d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR")
60
Andrew Geissler5082cc72023-09-11 08:41:39 -040061 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'),
Patrick Williams92b42cb2022-09-03 06:53:57 -050062 d.getVar('PN') + ' Configuration', d)
63
64 # FIXME this check can be removed when the minimum bitbake version has been bumped
65 if hasattr(bb.build, 'write_taint'):
66 try:
67 newmtime = os.path.getmtime(config)
68 except OSError:
69 newmtime = 0
70
71 if newmtime > mtime:
72 bb.note("Configuration changed, recompile will be forced")
73 bb.build.write_taint('do_compile', d)
74}
75do_menuconfig[depends] += "ncurses-native:do_populate_sysroot"
76do_menuconfig[nostamp] = "1"
77do_menuconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
78addtask menuconfig after do_configure
79
80python do_diffconfig() {
81 import shutil
82 import subprocess
83
84 workdir = d.getVar('WORKDIR')
85 fragment = workdir + '/fragment.cfg'
86 configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig")
87 config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config")
88
89 try:
90 md5newconfig = bb.utils.md5_file(configorig)
91 md5config = bb.utils.md5_file(config)
92 isdiff = md5newconfig != md5config
93 except IOError as e:
94 bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e)
95
96 if isdiff:
97 statement = 'diff --unchanged-line-format= --old-line-format= --new-line-format="%L" ' + configorig + ' ' + config + '>' + fragment
98 subprocess.call(statement, shell=True)
99 # No need to check the exit code as we know it's going to be
100 # non-zero, but that's what we expect.
101 shutil.copy(configorig, config)
102
103 bb.plain("Config fragment has been dumped into:\n %s" % fragment)
104 else:
105 if os.path.exists(fragment):
106 os.unlink(fragment)
107}
108
109do_diffconfig[nostamp] = "1"
110do_diffconfig[dirs] = "${KCONFIG_CONFIG_ROOTDIR}"
111addtask diffconfig
Andrew Geissler8f840682023-07-21 09:09:43 -0500112
113do_showconfig() {
114 bbplain "Config file written to ${KCONFIG_CONFIG_ROOTDIR}/.config"
115}
116do_showconfig[nostamp] = "1"
117addtask showconfig after do_configure