From 5c78ab740f5e7bf1ce8341c2bad01b54153abad9 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Mon, 17 Jun 2019 20:34:05 +0800 Subject: [PATCH 1/6] [add] scons --dist-ide function --- tools/building.py | 11 +++++++++++ tools/mkdist.py | 24 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tools/building.py b/tools/building.py index c037c2d068..142c5eccc2 100644 --- a/tools/building.py +++ b/tools/building.py @@ -161,6 +161,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ action = 'store_true', default = False, help = 'make distribution and strip useless files') + AddOption('--dist-ide', + dest = 'make-dist-ide', + type = 'string', + default = False, + help = 'make distribution for rt-thread eclipse ide') AddOption('--cscope', dest = 'cscope', action = 'store_true', @@ -865,6 +870,12 @@ def EndBuilding(target, program = None): from mkdist import MkDist_Strip MkDist_Strip(program, BSP_ROOT, Rtt_Root, Env) need_exit = True + if GetOption('make-dist-ide') and program != None: + from mkdist import MkDist + output_path = GetOption('make-dist-ide')[5:] + rtt_ide = {'output_path': output_path} + MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide) + need_exit = True if GetOption('cscope'): from cscope import CscopeDatabase CscopeDatabase(Projects) diff --git a/tools/mkdist.py b/tools/mkdist.py index 9d90e95e55..39c7b65afd 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -141,7 +141,7 @@ def bsp_update_kconfig_library(dist_dir): found = 0 f.write(line) -def bs_update_ide_project(bsp_root, rtt_root): +def bs_update_ide_project(bsp_root, rtt_root, rttide = None): import subprocess # default update the projects which have template file tgt_dict = {'mdk4':('keil', 'armcc'), @@ -151,6 +151,11 @@ def bs_update_ide_project(bsp_root, rtt_root): 'vs2012':('msvc', 'cl'), 'cdk':('gcc', 'gcc')} + ide_dict = {'eclipse':('gcc', 'gcc')} + + if rttide != None: + tgt_dict = ide_dict + scons_env = os.environ.copy() scons_env['RTT_ROOT'] = rtt_root @@ -302,11 +307,15 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): print('done!') -def MkDist(program, BSP_ROOT, RTT_ROOT, Env): +def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): print('make distribution....') dist_name = os.path.basename(BSP_ROOT) - dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name) + + if isinstance(rttide, dict): + dist_dir = rttide['output_path'] + else: + dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name) target_path = os.path.join(dist_dir, 'rt-thread') @@ -366,11 +375,16 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env): # change RTT_ROOT in Kconfig bsp_update_kconfig(dist_dir) bsp_update_kconfig_library(dist_dir) + # update all project files - bs_update_ide_project(dist_dir, target_path) + if rttide != None: + bs_update_ide_project(dist_dir, target_path, rttide) + else: + bs_update_ide_project(dist_dir, target_path) # make zip package - zip_dist(dist_dir, dist_name) + if rttide != None: + zip_dist(dist_dir, dist_name) print('done!') From 8329c29f84c4cb8f16fe245f87fda2760d3e3b81 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Tue, 18 Jun 2019 10:29:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E4=BF=AE=E6=94=B9]=20=E5=B0=86=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9=E4=B8=BA=20scons?= =?UTF-8?q?=20--dist-ide=20--target-path=3Dyour=5F=5Fprj=5Fpath=20--target?= =?UTF-8?q?-name=3Dyour=5Fprj=5Fname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 17 ++++++++++++++--- tools/mkdist.py | 18 +++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tools/building.py b/tools/building.py index 142c5eccc2..9e12b81204 100644 --- a/tools/building.py +++ b/tools/building.py @@ -163,9 +163,19 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ help = 'make distribution and strip useless files') AddOption('--dist-ide', dest = 'make-dist-ide', - type = 'string', + action = 'store_true', default = False, help = 'make distribution for rt-thread eclipse ide') + AddOption('--project-path', + dest = 'make-project-path', + type = 'string', + default = False, + help = 'set dist-ide project output path') + AddOption('--project-name', + dest = 'make-project-name', + type = 'string', + default = False, + help = 'set dist-ide project name') AddOption('--cscope', dest = 'cscope', action = 'store_true', @@ -872,8 +882,9 @@ def EndBuilding(target, program = None): need_exit = True if GetOption('make-dist-ide') and program != None: from mkdist import MkDist - output_path = GetOption('make-dist-ide')[5:] - rtt_ide = {'output_path': output_path} + project_path = GetOption('make-project-path') + project_name = GetOption('make-project-name') + rtt_ide = {'project_path' : project_path, 'project_name' : project_name} MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide) need_exit = True if GetOption('cscope'): diff --git a/tools/mkdist.py b/tools/mkdist.py index 39c7b65afd..96d0e63ef9 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -312,10 +312,14 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): dist_name = os.path.basename(BSP_ROOT) - if isinstance(rttide, dict): - dist_dir = rttide['output_path'] - else: + if rttide == None: dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name) + else: + dist_dir = rttide['project_path'] + if not isinstance(dist_dir, str): + print("\n--target-path=your_project_path parameter is required.") + print("\nstop!") + return target_path = os.path.join(dist_dir, 'rt-thread') @@ -377,13 +381,13 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): bsp_update_kconfig_library(dist_dir) # update all project files - if rttide != None: - bs_update_ide_project(dist_dir, target_path, rttide) - else: + if rttide == None: bs_update_ide_project(dist_dir, target_path) + else: + bs_update_ide_project(dist_dir, target_path, rttide) # make zip package - if rttide != None: + if rttide == None: zip_dist(dist_dir, dist_name) print('done!') From 1dbbedbc2fe2ccfec3fa2b2a1305753020f1d0a8 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Tue, 18 Jun 2019 10:34:43 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E3=80=90=E5=AE=8C=E5=96=84=E3=80=91dist-id?= =?UTF-8?q?e=20=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mkdist.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/mkdist.py b/tools/mkdist.py index 96d0e63ef9..219fa35150 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -144,17 +144,16 @@ def bsp_update_kconfig_library(dist_dir): def bs_update_ide_project(bsp_root, rtt_root, rttide = None): import subprocess # default update the projects which have template file - tgt_dict = {'mdk4':('keil', 'armcc'), - 'mdk5':('keil', 'armcc'), - 'iar':('iar', 'iar'), - 'vs':('msvc', 'cl'), - 'vs2012':('msvc', 'cl'), - 'cdk':('gcc', 'gcc')} - ide_dict = {'eclipse':('gcc', 'gcc')} - - if rttide != None: - tgt_dict = ide_dict + if rttide == None: + tgt_dict = {'mdk4':('keil', 'armcc'), + 'mdk5':('keil', 'armcc'), + 'iar':('iar', 'iar'), + 'vs':('msvc', 'cl'), + 'vs2012':('msvc', 'cl'), + 'cdk':('gcc', 'gcc')} + else: + tgt_dict = {'eclipse':('gcc', 'gcc')} scons_env = os.environ.copy() scons_env['RTT_ROOT'] = rtt_root From bd220bcda6dbd0066abaffee5a70cc1d1c354e49 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Tue, 18 Jun 2019 12:01:52 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/mkdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mkdist.py b/tools/mkdist.py index 219fa35150..8784dac7c9 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -316,7 +316,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): else: dist_dir = rttide['project_path'] if not isinstance(dist_dir, str): - print("\n--target-path=your_project_path parameter is required.") + print("\n--project-path=your_project_path parameter is required.") print("\nstop!") return From 4ca30835c1fee29f83f5e60dcf10be99a6e20529 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Tue, 18 Jun 2019 14:27:23 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E3=80=90=E5=AE=8C=E5=96=84=E3=80=91?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20eclipse=20=E7=94=9F=E6=88=90=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E7=9B=B8=E5=85=B3=E5=A4=84=E7=90=86=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8F=82=E6=95=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 11 +++++++++++ tools/mkdist.py | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/building.py b/tools/building.py index 9e12b81204..b05a4d5c67 100644 --- a/tools/building.py +++ b/tools/building.py @@ -884,6 +884,17 @@ def EndBuilding(target, program = None): from mkdist import MkDist project_path = GetOption('make-project-path') project_name = GetOption('make-project-name') + + if not isinstance(project_path, str) or len(project_path) == 0 : + print("\nwarning : --project-path=your_project_path parameter is required.") + print("\nstop!") + exit(0) + + if not isinstance(project_name, str) or len(project_name) == 0: + print("\nwarning : --project-name=your_project_name parameter is required.") + print("\nstop!") + exit(0) + rtt_ide = {'project_path' : project_path, 'project_name' : project_name} MkDist(program, BSP_ROOT, Rtt_Root, Env, rtt_ide) need_exit = True diff --git a/tools/mkdist.py b/tools/mkdist.py index 8784dac7c9..3b77739282 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -153,7 +153,8 @@ def bs_update_ide_project(bsp_root, rtt_root, rttide = None): 'vs2012':('msvc', 'cl'), 'cdk':('gcc', 'gcc')} else: - tgt_dict = {'eclipse':('gcc', 'gcc')} + item = 'eclipse --project-name=' + rttide['project_name'] + tgt_dict = {item:('gcc', 'gcc')} scons_env = os.environ.copy() scons_env['RTT_ROOT'] = rtt_root @@ -315,10 +316,6 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): dist_dir = os.path.join(BSP_ROOT, 'dist', dist_name) else: dist_dir = rttide['project_path'] - if not isinstance(dist_dir, str): - print("\n--project-path=your_project_path parameter is required.") - print("\nstop!") - return target_path = os.path.join(dist_dir, 'rt-thread') From 1a32d47a79b5fbfb71a1762cade64ec03fd72283 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Tue, 18 Jun 2019 14:42:08 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E3=80=90=E5=AE=8C=E5=96=84=E3=80=91?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=91=BD=E4=BB=A4=E8=AF=B4=E6=98=8E=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/building.py b/tools/building.py index b05a4d5c67..edb95fdda5 100644 --- a/tools/building.py +++ b/tools/building.py @@ -165,7 +165,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ dest = 'make-dist-ide', action = 'store_true', default = False, - help = 'make distribution for rt-thread eclipse ide') + help = 'make distribution for RT-Thread Studio IDE') AddOption('--project-path', dest = 'make-project-path', type = 'string', @@ -175,7 +175,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ dest = 'make-project-name', type = 'string', default = False, - help = 'set dist-ide project name') + help = 'set project name') AddOption('--cscope', dest = 'cscope', action = 'store_true',