From af5ee103ebfb6a546f2c334bf332015f7509bf19 Mon Sep 17 00:00:00 2001 From: panwentao Date: Thu, 28 Mar 2024 09:34:54 +0800 Subject: [PATCH 1/4] m_plugin: Check if the higher-level folder exists when adding it * Check if the higher-level folder exists when adding it Signed-off-by: panwentao --- src/oebuild/app/plugins/m_plugin/m_plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/oebuild/app/plugins/m_plugin/m_plugin.py b/src/oebuild/app/plugins/m_plugin/m_plugin.py index 83cdc6e..538f341 100644 --- a/src/oebuild/app/plugins/m_plugin/m_plugin.py +++ b/src/oebuild/app/plugins/m_plugin/m_plugin.py @@ -400,8 +400,10 @@ class MPlugin(OebuildCommand): file_split_info = install_plugin_object['file'].split('/') if len(file_split_info) > 1: file_name = pathlib.Path(file_split_info[-2], file_split_info[-1]) + file_name_dir = file_split_info[-2] else: file_name = pathlib.Path('plugin_info', file_split_info[-1]) + file_name_dir = "" file_path = pathlib.Path(self.oebuild_plugin_repository, install_plugin_object['plugin_name'], file_name) @@ -421,6 +423,9 @@ class MPlugin(OebuildCommand): if not os.path.exists(pathlib.Path(file_dir_path, 'plugin_info')): os.makedirs(pathlib.Path(file_dir_path, 'plugin_info')) + if file_name_dir and not os.path.exists(pathlib.Path(file_dir_path, file_name_dir)): + os.makedirs(pathlib.Path(file_dir_path, file_name_dir)) + if 'dir_path' not in install_plugin_object: subprocess.check_output( f"cp {install_plugin_object['file']} {file_path}", shell=True) -- Gitee From 276daa583830622363078d4fc226c8ff3144d73b Mon Sep 17 00:00:00 2001 From: panwentao Date: Thu, 28 Mar 2024 10:15:50 +0800 Subject: [PATCH 2/4] code: optimized program status code * Modify the partial return code Signed-off-by: panwentao --- src/oebuild/app/plugins/clear/clear.py | 2 +- src/oebuild/app/plugins/deploy/deploy_target.py | 4 ++-- src/oebuild/app/plugins/generate/generate.py | 2 +- src/oebuild/app/plugins/m_env/m_env.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/oebuild/app/plugins/clear/clear.py b/src/oebuild/app/plugins/clear/clear.py index 99640fd..fe19ac9 100644 --- a/src/oebuild/app/plugins/clear/clear.py +++ b/src/oebuild/app/plugins/clear/clear.py @@ -59,7 +59,7 @@ class Clear(OebuildCommand): def do_run(self, args: argparse.Namespace, unknown=None): # perpare parse help command if self.pre_parse_help(args, unknown): - sys.exit(1) + sys.exit(0) args = args.parse_args(unknown) diff --git a/src/oebuild/app/plugins/deploy/deploy_target.py b/src/oebuild/app/plugins/deploy/deploy_target.py index 4c051da..cd144c3 100644 --- a/src/oebuild/app/plugins/deploy/deploy_target.py +++ b/src/oebuild/app/plugins/deploy/deploy_target.py @@ -51,7 +51,7 @@ oebuild deploy-target [-h] [-c] [-s] [-n] [-p] [--no-check-space] [-e SSH_EXEC] def do_run(self, args: argparse.Namespace, unknown=None): if '-h' in unknown or '--help' in unknown: self.print_help_msg() - sys.exit(1) + sys.exit(0) str_args = ' '.join(unknown) com_target = ComTarget() com_target.exec(str_args=str_args, fun="deploy-target") @@ -116,7 +116,7 @@ oebuild undeploy-target [-h] [-c] [-s] [-a] [-n] [-e SSH_EXEC] def do_run(self, args: argparse.Namespace, unknown=None): if '-h' in unknown or '--help' in unknown: self.print_help_msg() - sys.exit(1) + sys.exit(0) str_args = ' '.join(unknown) com_target = ComTarget() com_target.exec(str_args=str_args, fun="undeploy-target") diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index 743d981..e5e5079 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -199,7 +199,7 @@ class Generate(OebuildCommand): def do_run(self, args: argparse.Namespace, unknown=None): # perpare parse help command if self.pre_parse_help(args, unknown): - sys.exit(1) + sys.exit(0) if not self.configure.is_oebuild_dir(): logger.error('Your current directory had not finished init') sys.exit(-1) diff --git a/src/oebuild/app/plugins/m_env/m_env.py b/src/oebuild/app/plugins/m_env/m_env.py index 15e656d..e4b381f 100644 --- a/src/oebuild/app/plugins/m_env/m_env.py +++ b/src/oebuild/app/plugins/m_env/m_env.py @@ -99,7 +99,7 @@ class Menv(OebuildCommand): unknown = unknown[1:] if self.pre_parse_help(args, unknown): - sys.exit(1) + sys.exit(0) args = args.parse_args(unknown) if command == 'create': -- Gitee From e87f50fe77d634358e5a3edfac45f488361d458a Mon Sep 17 00:00:00 2001 From: panwentao Date: Thu, 28 Mar 2024 15:33:36 +0800 Subject: [PATCH 3/4] generate: Modify the toolchain build function * Modify the toolchain build function Signed-off-by: panwentao --- .../app/plugins/bitbake/in_container.py | 2 +- src/oebuild/app/plugins/generate/generate.py | 48 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/oebuild/app/plugins/bitbake/in_container.py b/src/oebuild/app/plugins/bitbake/in_container.py index 0160377..4a0cb5f 100644 --- a/src/oebuild/app/plugins/bitbake/in_container.py +++ b/src/oebuild/app/plugins/bitbake/in_container.py @@ -38,6 +38,7 @@ def split_command(generate_command): command = """ ./cross-tools/update.sh ###!!!###\n cp config_aarch64 .config && ct-ng build ###!!!###\n + cp config_aarch64-musl .config && ct-ng build ###!!!###\n cp config_arm32 .config && ct-ng build ###!!!###\n cp config_x86_64 .config && ct-ng build ###!!!###\n cp config_riscv64 .config && ct-ng build ###!!!###\n""" @@ -45,7 +46,6 @@ def split_command(generate_command): command = "./cross-tools/update.sh ###!!!###\n" for command_info in generate_command.split(' ')[2:]: command = f"{command}cp {command_info} .config && ct-ng build ###!!!###\n" - return command diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index e5e5079..7968011 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -486,24 +486,13 @@ wrong platform, please run `oebuild generate -l` to view support feature""") basic_data = basic_config() platform_data = self.choice_platform(yocto_oebuild_dir) feature_data = self.add_feature(yocto_oebuild_dir) + toolchain_data = self.add_toolchain(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 TOOLCHAIN - bool "Build Toolchain" - if TOOLCHAIN - config TOOLCHAINS_CONFIG_AARCH64 - bool "AARCH64" - config TOOLCHAINS_CONFIG_ARM32 - bool "ARM32" - config TOOLCHAINS_CONFIG_X86-64 - bool "X86-64" - config TOOLCHAINS_CONFIG_RISCV64 - bool "RISCV64" - endif config NATIVE-SDK bool "Build Nativesdk" depends on !TOOLCHAIN @@ -513,7 +502,7 @@ wrong platform, please run `oebuild generate -l` to view support feature""") default y if IMAGE """) - write_data = info + platform_data + feature_data + basic_data + "\nendif" + write_data = toolchain_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) @@ -590,6 +579,36 @@ wrong platform, please run `oebuild generate -l` to view support feature""") return feature_start + def add_toolchain(self, yocto_oebuild_dir): + """ + add toolchain to kconfig + Args: + yocto_oebuild_dir: yocto_oebuild_dir + + Returns: + + """ + 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) + toolchain_list = os.listdir(os.path.join(cross_path, 'configs')) + toolchain_start = """ + config TOOLCHAIN + bool "Build Toolchain" + if TOOLCHAIN + """ + for config in toolchain_list: + if not re.search('xml', config): + toolchain_info = (f"""\nconfig TOOLCHAINS_{config.upper()}\n""" + f""" bool "{config.upper()}"\n""") + toolchain_start += toolchain_info + + toolchain_start += "endif\n" + return toolchain_start + + def generate_command(self, config_path): """ generate_command to oebuild generate @@ -689,12 +708,13 @@ wrong platform, please run `oebuild generate -l` to view support feature""") sys.exit(-1) toolchain_list = os.listdir(os.path.join(cross_path, 'configs')) for config in toolchain_list: - if re.search('[.-]', config): + if re.search('xml', config): toolchain_list.remove(config) if toolchain_name_list and not set(toolchain_name_list).issubset(toolchain_list): logger.error(f'toolchain name not exists, toolchain list is {toolchain_list}') sys.exit(-1) build_dir = os.path.join(self.configure.build_dir(), 'toolchain') + os.chdir(os.path.dirname(build_dir)) subprocess.run(f'rm -rf {build_dir}', shell=True, check=False) subprocess.run('oebuild generate -d toolchain', shell=True, check=False) subprocess.check_output(f'cp -r {cross_path} {build_dir}', shell=True) -- Gitee From f40e110505ab0cc23b1cc89be6de07ea983834b6 Mon Sep 17 00:00:00 2001 From: panwentao Date: Fri, 29 Mar 2024 17:35:11 +0800 Subject: [PATCH 4/4] menv: Modify sed to insert data * Modify sed to insert data Signed-off-by: panwentao --- src/oebuild/app/plugins/generate/generate.py | 1 - src/oebuild/app/plugins/m_env/m_env.py | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index 7968011..b6d2f65 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -608,7 +608,6 @@ wrong platform, please run `oebuild generate -l` to view support feature""") toolchain_start += "endif\n" return toolchain_start - def generate_command(self, config_path): """ generate_command to oebuild generate diff --git a/src/oebuild/app/plugins/m_env/m_env.py b/src/oebuild/app/plugins/m_env/m_env.py index e4b381f..996286b 100644 --- a/src/oebuild/app/plugins/m_env/m_env.py +++ b/src/oebuild/app/plugins/m_env/m_env.py @@ -168,6 +168,7 @@ Please enter the correct command: oebuild menv create [-d -f] Create an environm print('The path is invalid, please check the path ') sys.exit(-1) + # pylint: disable=R0914 def execute_setup_directory(self, setup_file_path, env_name): """ Prepare the environment using the parsed SDK folder provided @@ -214,13 +215,11 @@ Please enter the correct command: oebuild menv create [-d -f] Create an environm r"sed -i '$a\mv ~/.bashrc_back ~/.bashrc -f' ~/.bashrc", shell=True) # Add prompt words + separator = "====================================================" + prompt_one = "Your environment is ready" + prompt_two = "Please proceed with the subsequent operations here" wrap = '\\n###!###\\n' - prompt_words = f''' -===================================================={wrap} -Your environment is ready{wrap} -Please proceed with the subsequent operations here{wrap} -===================================================={wrap} -''' + prompt_words = separator + wrap + prompt_one + wrap + prompt_two + wrap + separator subprocess.check_output( rf'''sed -i '$a\echo "{prompt_words}"' ~/.bashrc''', shell=True) -- Gitee