Files
poky/meta/recipes-devtools/cmake/cmake/cmake-setup.py
Jagadeesh Krishnanjanappa ee5f9d9fdd cmake: support to create per-toolchain cmake file in SDK
The patch creates ${MULTIMACH_TARGET_SYS}-toolchain.cmake file
at ${SDK_INSTALL_DIR}/sysroots/${SDK_SYS}/usr/share/cmake/, which is
per-toolchain CMake toolchain file containing arch-specific values
and independent of OE environment variables.
The file gets created after installing SDK toolchain installer
ined by running "bitbake -c populate_sdk <image>".

The changes are similar to meson-setup.py which is used to
create arch-specific
${SDK_INSTALL_DIR}/sysroots/${SDK_SYS}/usr/share/meson/*-meson.cross

[YOCTO #14644]

Tested-by: Jan Dorniak <jaskij@gmail.com>
(From OE-Core rev: 42e68397ec74b3cd8ae5df45355c8f6254b48cd8)

Signed-off-by: Jagadeesh Krishnanjanappa <workjagadeesh@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-03-31 17:52:59 +01:00

34 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import string
import sys
class Template(string.Template):
delimiter = "@"
class Environ():
def __getitem__(self, name):
if name == "OECORE_SDK_SYS":
return os.path.basename(os.environ["OECORE_NATIVE_SYSROOT"])
elif name == "OECORE_TARGET_SYS":
return os.path.basename(os.environ["OECORE_TARGET_SYSROOT"])
elif name == "OECORE_TARGET_ALIAS":
return os.path.basename(os.environ["TARGET_PREFIX"].strip("-"))
else:
return os.environ[name]
try:
sysroot = os.environ['OECORE_NATIVE_SYSROOT']
except KeyError:
print("Not in environment setup, bailing")
sys.exit(1)
template_file = os.path.join(sysroot, 'usr/share/cmake/SDKToolchainConfig.cmake.template')
cross_file = os.path.join(sysroot, 'usr/share/cmake/%s-toolchain.cmake' % (os.path.basename(os.environ["OECORE_TARGET_SYSROOT"])))
with open(template_file) as in_file:
template = in_file.read()
output = Template(template).substitute(Environ())
with open(cross_file, "w") as out_file:
out_file.write(output)