From 7604f1da1a129167bc7f608b7763466ea5295d29 Mon Sep 17 00:00:00 2001 From: alichinese Date: Thu, 9 May 2024 17:18:18 +0800 Subject: [PATCH] generate: optimize generate operation * adapted to run the command line menu even with versions of yocto-meta-openeuler that do not have a cross-compilation chain or nativesdk Signed-off-by: alichinese --- src/oebuild/app/plugins/generate/generate.py | 43 +++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index 42fbe7f..7d82682 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -522,25 +522,21 @@ Wrong platform, please run `oebuild generate -l` to view support feature""") platform_data = self.choice_platform(yocto_oebuild_dir) feature_data = self.add_feature(yocto_oebuild_dir) toolchain_data = self.add_toolchain(yocto_oebuild_dir) + nativesdk_data = self.add_nativesdk(yocto_oebuild_dir) if not os.path.exists( pathlib.Path(self.oebuild_kconfig_path).absolute()): os.makedirs(pathlib.Path(self.oebuild_kconfig_path).absolute()) kconfig_path = pathlib.Path(self.oebuild_kconfig_path, str(int(time.time()))) info = textwrap.dedent(""" - config NATIVE_SDK - bool "Build Nativesdk" - depends on !TOOLCHAIN - config AUTO_BUILD - bool "Auto Build" - depends on NATIVE_SDK config IMAGE bool "Build OS" depends on !NATIVE_SDK && !TOOLCHAIN default y if IMAGE """) - write_data = toolchain_data + info + platform_data + feature_data + basic_data + "\nendif" + write_data = toolchain_data + nativesdk_data + info + platform_data + feature_data \ + + basic_data + "\nendif" with open(kconfig_path, 'w', encoding='utf-8') as kconfig_file: kconfig_file.write(write_data) @@ -628,9 +624,10 @@ Wrong platform, please run `oebuild generate -l` to view support feature""") """ cross_path = os.path.join(yocto_oebuild_dir, "cross-tools") if not os.path.exists(cross_path): - logger.error('Build dependency not downloaded, not supported for build. Please ' - 'download the latest yocto meta openeuler repository') - sys.exit(-1) + # logger.error('Build dependency not downloaded, not supported for build. Please ' + # 'download the latest yocto meta openeuler repository') + # sys.exit(-1) + return "" toolchain_list = os.listdir(os.path.join(cross_path, 'configs')) toolchain_start = """ config TOOLCHAIN @@ -648,6 +645,32 @@ Wrong platform, please run `oebuild generate -l` to view support feature""") return toolchain_start + def add_nativesdk(self, yocto_oebuild_dir): + """ + add nativesdk to kconfig + Args: + yocto_oebuild_dir: yocto_oebuild_dir + + Returns: + + """ + cross_path = os.path.join(yocto_oebuild_dir, "nativesdk") + if not os.path.exists(cross_path): + # logger.error('Build dependency not downloaded, not supported for build. Please ' + # 'download the latest yocto meta openeuler repository') + # sys.exit(-1) + return "" + nativesdk_start = """ + config NATIVE_SDK + bool "Build Nativesdk" + depends on !TOOLCHAIN + config AUTO_BUILD + bool "Auto Build" + depends on NATIVE_SDK + """ + + return nativesdk_start + def generate_command(self, config_path): """ generate_command to oebuild generate -- Gitee