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