From ee4cabe69f90cd2bde042d7d8d114e420b09319f Mon Sep 17 00:00:00 2001 From: Huaqi Fang <578567190@qq.com> Date: Fri, 17 Apr 2020 21:07:29 +0800 Subject: [BSP][Nuclei] Add Nuclei RISC-V Processor support * Nuclei RISC-V Processor support is added both RV32 and RV64 * Nuclei RVSTAR BSP is added, UART driver is added * MSH works well in RVSTAR board --------------------------- Squashed commit of the following: commit b7368bc2ed725c42f9adc297d0e9cf3ed706a520 Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 17 14:38:54 2020 +0800 [BSP][Nuclei] Pretty source code Signed-off-by: Huaqi Fang <578567190@qq.com> commit 2c42a997f7b5d8aa53bdaf19ccb30596091a112d Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 16 15:51:03 2020 +0800 [libcpu] Remove ARCH_NUCLEI in libcpu kconfig Signed-off-by: Huaqi Fang <578567190@qq.com> commit 915ad4c076ff3d7cebda896537605e7f7939b7af Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 16 15:50:00 2020 +0800 [BSP][Nuclei] Remove ARCH_NUCLEI in bsp KConfig Signed-off-by: Huaqi Fang <578567190@qq.com> commit fe43869c79675a25669447d57ea5d77385e07ca5 Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 15 12:43:20 2020 +0800 [BSP][NUCLEI] Simply application main.c Remove previous complicated application of gd32vf103_rvstar Signed-off-by: Huaqi Fang <578567190@qq.com> commit 8fd31727bc7ff51c83a3c47840cff1bfb100c0ba Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 15 12:38:04 2020 +0800 [BSP][NUCLEI] Format application and board source code Signed-off-by: Huaqi Fang <578567190@qq.com> commit b432308b20cdf24dfcc1398511d1d83bce6a9df2 Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 15 11:58:28 2020 +0800 [BSP][Nuclei] Format source code of drivers of gd32vf103 Signed-off-by: Huaqi Fang <578567190@qq.com> commit 7366173d749d8a51ed8d48eca09007d27aee8ad8 Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 15 11:54:02 2020 +0800 [LIBCPU][NUCLEI] Optimize nuclei cpu portable code Signed-off-by: Huaqi Fang <578567190@qq.com> commit 8c2cd4745b7279a6721946d119441bbf7fd1a9c2 Author: Huaqi Fang <578567190@qq.com> Date: Tue Apr 14 15:45:42 2020 +0800 nuclei: Update README.md Signed-off-by: Huaqi Fang <578567190@qq.com> commit fa8a2f24ea5e4dbce714ffda16c1ce558e5b5ddb Author: Huaqi Fang <578567190@qq.com> Date: Tue Apr 14 14:06:54 2020 +0800 nuclei: Add gpio driver not tested Signed-off-by: Huaqi Fang <578567190@qq.com> commit 1be40bc50be43dfcdd105291bd24355498f9fef3 Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 9 14:55:22 2020 +0800 Nuclei: Update README.md Signed-off-by: Huaqi Fang <578567190@qq.com> commit 4c8beb204b7ee3e38c04e1f23a1f7e4ce48aa196 Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 9 10:20:25 2020 +0800 Nuclei: Change idle stack size from 256 to 396 bytes If changed to 396 bytes, then debug optimization level changed from O2 to O0, and the application can run successfully without stack overflow issue of tidle0 task warning: tidle0 stack is close to end of stack address. Signed-off-by: Huaqi Fang <578567190@qq.com> commit da2bcf5c56ef32b611405a8e591ecd3f1e598b11 Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 9 10:11:40 2020 +0800 nuclei: Remove unused kconfig Signed-off-by: Huaqi Fang <578567190@qq.com> commit 0b932c677a7934d60e70da141744790aec202ef6 Author: Huaqi Fang <578567190@qq.com> Date: Thu Apr 9 09:32:22 2020 +0800 nuclei: optimize drivers support Signed-off-by: Huaqi Fang <578567190@qq.com> commit 0431f6f01f6efab2900de552abede83639415431 Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 8 19:28:02 2020 +0800 tools: Update mkdist.py for nuclei bsp Signed-off-by: Huaqi Fang <578567190@qq.com> commit 0e1f502edfddff93a4a66c041be68560ef4828eb Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 8 18:46:58 2020 +0800 nuclei: optimize rvstar support directory Signed-off-by: Huaqi Fang <578567190@qq.com> commit 1131f6e6483d8f2fbafe07f4e598fc8f802ee85d Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 8 18:37:24 2020 +0800 nuclei: update kconfig Signed-off-by: Huaqi Fang <578567190@qq.com> commit ad81c1d3bf9d80d2b561c94e903e7ce4ca2c68c6 Author: Huaqi Fang <578567190@qq.com> Date: Wed Apr 8 15:43:00 2020 +0800 nuclei: Rename board name Signed-off-by: Huaqi Fang <578567190@qq.com> commit d780138a1abf5da5097cc89e6a428ebeae06f284 Author: Huaqi Fang <578567190@qq.com> Date: Tue Apr 7 09:36:19 2020 +0800 libcpu: Add Nuclei arch option in KConfig Signed-off-by: Huaqi Fang <578567190@qq.com> commit 60320d34b1d88315efe1b566fd6bc75c69851f06 Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 3 16:51:01 2020 +0800 nuclei: Update nuclei sdk of rt-thread support Signed-off-by: Huaqi Fang <578567190@qq.com> commit a042b806efe0ea3bc9dba80ebc7696e5941ba35f Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 3 11:34:09 2020 +0800 nuclei: modify application for not print anything Signed-off-by: Huaqi Fang <578567190@qq.com> commit 2a9603adcb584b29886a2b93ded2473f4e8bffb1 Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 3 11:31:01 2020 +0800 nuclei: Add .gitignore for nuclei bsp Signed-off-by: Huaqi Fang <578567190@qq.com> commit 34aaf6aebae75c3ee9d38cc17e6bdb826ed9e357 Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 3 11:28:06 2020 +0800 nuclei_sdk: update link script of rvstar to contain rt-thread needed sections /* section information for finsh shell */ . = ALIGN(4); __fsymtab_start = .; KEEP(*(FSymTab)) __fsymtab_end = .; . = ALIGN(4); __vsymtab_start = .; KEEP(*(VSymTab)) __vsymtab_end = .; /* section information for initial. */ . = ALIGN(4); __rt_init_start = .; KEEP(*(SORT(.rti_fn*))) __rt_init_end = .; The above code placed in rodata section Signed-off-by: Huaqi Fang <578567190@qq.com> commit 3451466e9d8da3c3c8a631be69f3c7a5e6220c21 Author: Huaqi Fang <578567190@qq.com> Date: Fri Apr 3 10:04:42 2020 +0800 bsp: Add initial commit of nuclei rvstar board bsp Signed-off-by: Huaqi Fang <578567190@qq.com> Signed-off-by: Huaqi Fang <578567190@qq.com> --- tools/mkdist.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools') diff --git a/tools/mkdist.py b/tools/mkdist.py index 7e4b9a8bbe..ec527d87e1 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -345,6 +345,13 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # copy nuclei bsp libiary files + if os.path.basename(os.path.dirname(BSP_ROOT)) == 'nuclei': + print("=> copy nuclei bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') + library_dir = os.path.join(dist_dir, 'libraries') + bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) + # do bsp special dist handle if 'dist_handle' in Env: print("=> start dist handle") -- cgit v1.3.1 From 3b2fa472096d41287ee8cb542e8c1d119a5a8b76 Mon Sep 17 00:00:00 2001 From: luhuadong Date: Fri, 17 Apr 2020 22:14:37 +0800 Subject: [BSP] add Libraries when scons --dist --- bsp/at32/at32f403a-start/rtconfig.py | 6 +++--- tools/mkdist.py | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/bsp/at32/at32f403a-start/rtconfig.py b/bsp/at32/at32f403a-start/rtconfig.py index 1d63cabb96..4800f9a871 100644 --- a/bsp/at32/at32f403a-start/rtconfig.py +++ b/bsp/at32/at32f403a-start/rtconfig.py @@ -57,7 +57,7 @@ if PLATFORM == 'gcc': else: CFLAGS += ' -O2' - CXXFLAGS = CFLAGS + CXXFLAGS = CFLAGS POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' @@ -88,7 +88,7 @@ elif PLATFORM == 'armcc': else: CFLAGS += ' -O2' - CXXFLAGS = CFLAGS + CXXFLAGS = CFLAGS CFLAGS += ' -std=c99' POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' @@ -136,7 +136,7 @@ elif PLATFORM == 'iar': LFLAGS = ' --config "board/linker_scripts/link.icf"' LFLAGS += ' --entry __iar_program_start' - + CXXFLAGS = CFLAGS EXEC_PATH = EXEC_PATH + '/arm/bin/' diff --git a/tools/mkdist.py b/tools/mkdist.py index 7e4b9a8bbe..e71d767446 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -122,7 +122,7 @@ def bsp_update_kconfig(dist_dir): line = line[0:position] + 'default "rt-thread"\n' found = 0 f.write(line) - + def bsp_update_kconfig_library(dist_dir): # change RTT_ROOT in Kconfig if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')): @@ -141,7 +141,7 @@ def bsp_update_kconfig_library(dist_dir): found = 0 f.write(line) - # change board/kconfig path + # change board/kconfig path if not os.path.isfile(os.path.join(dist_dir, 'board/Kconfig')): return @@ -214,12 +214,21 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # copy at32 bsp libiary files + if os.path.basename(os.path.dirname(BSP_ROOT)) == 'at32': + print("=> copy at32 bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') + library_dir = os.path.join(dist_dir, 'Libraries') + bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) + bsp_copy_files(os.path.join(library_path, 'AT32_Std_Driver'), os.path.join(library_dir, 'AT32_Std_Driver')) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # do bsp special dist handle - if 'dist_handle' in Env: + if 'dist_handle' in Env: print("=> start dist handle") dist_handle = Env['dist_handle'] dist_handle(BSP_ROOT) - + # get all source files from program for item in program: walk_children(item) @@ -345,6 +354,15 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # copy at32 bsp libiary files + if os.path.basename(os.path.dirname(BSP_ROOT)) == 'at32': + print("=> copy at32 bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') + library_dir = os.path.join(dist_dir, 'Libraries') + bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) + bsp_copy_files(os.path.join(library_path, 'AT32_Std_Driver'), os.path.join(library_dir, 'AT32_Std_Driver')) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) + # do bsp special dist handle if 'dist_handle' in Env: print("=> start dist handle") -- cgit v1.3.1 From e1bd3673fd428ffbfd04d2f51a1a9be6fbfe832d Mon Sep 17 00:00:00 2001 From: luhuadong Date: Wed, 22 Apr 2020 16:58:10 +0800 Subject: [AT32 BSP] do bsp special dist handle --- bsp/at32/at32f403a-start/Kconfig | 3 +-- bsp/at32/at32f403a-start/rtconfig.py | 7 +++++++ bsp/at32/tools/sdk_dist.py | 19 +++++++++++++++++++ tools/mkdist.py | 18 ------------------ 4 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 bsp/at32/tools/sdk_dist.py (limited to 'tools') diff --git a/bsp/at32/at32f403a-start/Kconfig b/bsp/at32/at32f403a-start/Kconfig index 7a400db91f..1a3b4b75bc 100644 --- a/bsp/at32/at32f403a-start/Kconfig +++ b/bsp/at32/at32f403a-start/Kconfig @@ -17,6 +17,5 @@ config PKGS_DIR source "$RTT_DIR/Kconfig" source "$PKGS_DIR/Kconfig" -source "../libraries/Kconfig" +source "../Libraries/Kconfig" source "board/Kconfig" - diff --git a/bsp/at32/at32f403a-start/rtconfig.py b/bsp/at32/at32f403a-start/rtconfig.py index 4800f9a871..5f2f01ca76 100644 --- a/bsp/at32/at32f403a-start/rtconfig.py +++ b/bsp/at32/at32f403a-start/rtconfig.py @@ -1,4 +1,5 @@ import os +import sys # toolchains options ARCH='arm' @@ -141,3 +142,9 @@ elif PLATFORM == 'iar': EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' + +def dist_handle(BSP_ROOT): + cwd_path = os.getcwd() + sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools')) + from sdk_dist import dist_do_building + dist_do_building(BSP_ROOT) diff --git a/bsp/at32/tools/sdk_dist.py b/bsp/at32/tools/sdk_dist.py new file mode 100644 index 0000000000..01ff930b20 --- /dev/null +++ b/bsp/at32/tools/sdk_dist.py @@ -0,0 +1,19 @@ +import os +import sys +import shutil +cwd_path = os.getcwd() +sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + +# BSP dist function +def dist_do_building(BSP_ROOT): + from mkdist import bsp_copy_files + import rtconfig + + dist_dir = os.path.join(BSP_ROOT, 'dist', os.path.basename(BSP_ROOT)) + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') + library_dir = os.path.join(dist_dir, 'Libraries') + print("=> copy bsp drivers") + bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) + print("=> copy bsp library") + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) diff --git a/tools/mkdist.py b/tools/mkdist.py index 2f12ad8f12..d83020f755 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -214,15 +214,6 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, Env): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - # copy at32 bsp libiary files - if os.path.basename(os.path.dirname(BSP_ROOT)) == 'at32': - print("=> copy at32 bsp library") - library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - library_dir = os.path.join(dist_dir, 'Libraries') - bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) - bsp_copy_files(os.path.join(library_path, 'AT32_Std_Driver'), os.path.join(library_dir, 'AT32_Std_Driver')) - shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - # do bsp special dist handle if 'dist_handle' in Env: print("=> start dist handle") @@ -354,15 +345,6 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - # copy at32 bsp libiary files - if os.path.basename(os.path.dirname(BSP_ROOT)) == 'at32': - print("=> copy at32 bsp library") - library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries') - library_dir = os.path.join(dist_dir, 'Libraries') - bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers')) - bsp_copy_files(os.path.join(library_path, 'AT32_Std_Driver'), os.path.join(library_dir, 'AT32_Std_Driver')) - shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - # copy nuclei bsp libiary files if os.path.basename(os.path.dirname(BSP_ROOT)) == 'nuclei': print("=> copy nuclei bsp library") -- cgit v1.3.1 From 03eb616ff6f5227efd6bb786f33294283bf96246 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 24 Apr 2020 08:46:56 +0800 Subject: [tools] fix c99/siginfo_t issue caused by gcc_version --- tools/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/utils.py b/tools/utils.py index 9459396544..67ce098ccd 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -273,7 +273,7 @@ def VersionCmp(ver1, ver2): def GCCC99Patch(cflags): import building - gcc_version = building.GetDepend('GCC_VERSION') + gcc_version = building.GetDepend('GCC_VERSION_STR') if gcc_version: gcc_version = gcc_version.replace('"', '') if VersionCmp(gcc_version, "4.8.0") == 1: -- cgit v1.3.1 From 783cf540873297ba6b78161dee4a6dc545abcd54 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Wed, 6 May 2020 14:53:15 +0800 Subject: [del] stm32 dist handle in mkdist.py --- tools/mkdist.py | 9 --------- 1 file changed, 9 deletions(-) (limited to 'tools') diff --git a/tools/mkdist.py b/tools/mkdist.py index d83020f755..e190123e6c 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -336,15 +336,6 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): print('=> %s' % os.path.basename(BSP_ROOT)) bsp_copy_files(BSP_ROOT, dist_dir) - # copy stm32 bsp libiary files - if os.path.basename(os.path.dirname(BSP_ROOT)) == 'stm32': - print("=> copy stm32 bsp library") - library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') - library_dir = os.path.join(dist_dir, 'libraries') - bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers')) - bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) - shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) - # copy nuclei bsp libiary files if os.path.basename(os.path.dirname(BSP_ROOT)) == 'nuclei': print("=> copy nuclei bsp library") -- cgit v1.3.1 From 36755af0be6b92f095702afa2fae6e0376a27681 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Wed, 6 May 2020 15:32:53 +0800 Subject: [update] nuclei dist handle --- bsp/nuclei/gd32vf103_rvstar/rtconfig.py | 12 ++++++++++++ bsp/nuclei/tools/sdk_dist.py | 18 ++++++++++++++++++ tools/mkdist.py | 7 ------- 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 bsp/nuclei/tools/sdk_dist.py (limited to 'tools') diff --git a/bsp/nuclei/gd32vf103_rvstar/rtconfig.py b/bsp/nuclei/gd32vf103_rvstar/rtconfig.py index 8136b392f8..bf74338e8a 100644 --- a/bsp/nuclei/gd32vf103_rvstar/rtconfig.py +++ b/bsp/nuclei/gd32vf103_rvstar/rtconfig.py @@ -5,6 +5,9 @@ ARCH='risc-v' CPU='nuclei' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') @@ -18,7 +21,9 @@ else: # EXEC_PATH = os.getenv('RTT_EXEC_PATH') BUILD = 'debug' + # Fixed configurations below +NUCLEI_SDK_OPENOCD_CFG = "type in your config" NUCLEI_SDK_SOC = "gd32vf103" NUCLEI_SDK_BOARD = "gd32vf103v_rvstar" NUCLEI_SDK_DOWNLOAD = "flashxip" @@ -56,3 +61,10 @@ if PLATFORM == 'gcc': DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n' POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' + +def dist_handle(BSP_ROOT): + import sys + cwd_path = os.getcwd() + sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools')) + from sdk_dist import dist_do_building + dist_do_building(BSP_ROOT) diff --git a/bsp/nuclei/tools/sdk_dist.py b/bsp/nuclei/tools/sdk_dist.py new file mode 100644 index 0000000000..f802e92730 --- /dev/null +++ b/bsp/nuclei/tools/sdk_dist.py @@ -0,0 +1,18 @@ +import os +import sys +import shutil +cwd_path = os.getcwd() +sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + +# BSP dist function +def dist_do_building(BSP_ROOT): + from mkdist import bsp_copy_files + import rtconfig + + dist_dir = os.path.join(BSP_ROOT, 'dist', os.path.basename(BSP_ROOT)) + library_dir = os.path.join(dist_dir, 'libraries') + + print("=> copy nuclei bsp library") + library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') + library_dir = os.path.join(dist_dir, 'libraries') + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) diff --git a/tools/mkdist.py b/tools/mkdist.py index e190123e6c..a6c744b470 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -336,13 +336,6 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): print('=> %s' % os.path.basename(BSP_ROOT)) bsp_copy_files(BSP_ROOT, dist_dir) - # copy nuclei bsp libiary files - if os.path.basename(os.path.dirname(BSP_ROOT)) == 'nuclei': - print("=> copy nuclei bsp library") - library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') - library_dir = os.path.join(dist_dir, 'libraries') - bsp_copy_files(os.path.join(library_path, Env['bsp_lib_type']), os.path.join(library_dir, Env['bsp_lib_type'])) - # do bsp special dist handle if 'dist_handle' in Env: print("=> start dist handle") -- cgit v1.3.1 From 53977c1fb4f92b3c5e2420b674d7764eeda187fc Mon Sep 17 00:00:00 2001 From: thread-liu Date: Mon, 11 May 2020 14:10:48 +0800 Subject: [update] tools/eclipse.py --- tools/eclipse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/eclipse.py b/tools/eclipse.py index 699ecef4d1..48b38c8f0a 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -109,12 +109,12 @@ def ExcludeFiles(infiles, files): def ExcludePaths(rootpath, paths): ret = [] - files = os.listdir(rootpath) + files = os.listdir(OSPath(rootpath)) for file in files: if file.startswith('.'): continue - fullname = os.path.join(rootpath, file) + fullname = os.path.join(OSPath(rootpath), file) if os.path.isdir(fullname): # print(fullname) -- cgit v1.3.1 From f8992996996b27834aafaf9b3deffb734d4edb49 Mon Sep 17 00:00:00 2001 From: thread-liu Date: Mon, 18 May 2020 17:41:16 +0800 Subject: [update] eclipse.py --- tools/eclipse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/eclipse.py b/tools/eclipse.py index 48b38c8f0a..ef546fb15a 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 2 +MODULE_VER_NUM = 3 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] -- cgit v1.3.1 From 01873a56873ab0da2a981030e362c214075e9746 Mon Sep 17 00:00:00 2001 From: SummerGift Date: Mon, 25 May 2020 14:30:22 +0800 Subject: [add] rt-thread ide project dist feature --- bsp/stm32/tools/sdk_dist.py | 14 ++++++++------ tools/mkdist.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/bsp/stm32/tools/sdk_dist.py b/bsp/stm32/tools/sdk_dist.py index cd04eb6900..8da926c521 100644 --- a/bsp/stm32/tools/sdk_dist.py +++ b/bsp/stm32/tools/sdk_dist.py @@ -1,20 +1,22 @@ import os import sys import shutil + cwd_path = os.getcwd() sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools')) + # BSP dist function -def dist_do_building(BSP_ROOT): +def dist_do_building(BSP_ROOT, dist_dir): from mkdist import bsp_copy_files import rtconfig - dist_dir = os.path.join(BSP_ROOT, 'dist', os.path.basename(BSP_ROOT)) - library_dir = os.path.join(dist_dir, 'libraries') - print("=> copy stm32 bsp library") + library_dir = os.path.join(dist_dir, 'libraries') library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries') - bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), + os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE)) + print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'HAL_Drivers'), os.path.join(library_dir, 'HAL_Drivers')) - shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) \ No newline at end of file + shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig')) diff --git a/tools/mkdist.py b/tools/mkdist.py index a6c744b470..a1dafd25cb 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -340,7 +340,7 @@ def MkDist(program, BSP_ROOT, RTT_ROOT, Env, rttide = None): if 'dist_handle' in Env: print("=> start dist handle") dist_handle = Env['dist_handle'] - dist_handle(BSP_ROOT) + dist_handle(BSP_ROOT, dist_dir) # copy tools directory print('=> components') -- cgit v1.3.1 From ba32394a00fee9b749ae0a7c690828bb38b028a7 Mon Sep 17 00:00:00 2001 From: xieyangrun Date: Mon, 8 Jun 2020 18:07:04 +0800 Subject: Optimize project group sort by name --- tools/building.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/building.py b/tools/building.py index 65af794434..de49c14a63 100644 --- a/tools/building.py +++ b/tools/building.py @@ -675,8 +675,17 @@ def DefineGroup(name, src, depend, **parameters): MergeGroup(g, group) return objs + def PriorityInsertGroup(groups, group): + length = len(groups) + for i in range(0, length): + if cmp(groups[i]['name'].lower(), group['name'].lower()) > 0: + groups.insert(i, group) + return + groups.append(group) + # add a new group - Projects.append(group) + #Projects.append(group) + PriorityInsertGroup(Projects, group) return objs -- cgit v1.3.1 From d46f914da45c63635fef8a4a131797cfc6df6b2c Mon Sep 17 00:00:00 2001 From: xieyangrun Date: Thu, 11 Jun 2020 09:17:16 +0800 Subject: [tools] fixed python 2.x `cmp` --- tools/building.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/building.py b/tools/building.py index de49c14a63..2ddeb9669b 100644 --- a/tools/building.py +++ b/tools/building.py @@ -28,6 +28,7 @@ import os import sys import string import utils +import operator from SCons.Script import * from utils import _make_path_relative @@ -678,13 +679,12 @@ def DefineGroup(name, src, depend, **parameters): def PriorityInsertGroup(groups, group): length = len(groups) for i in range(0, length): - if cmp(groups[i]['name'].lower(), group['name'].lower()) > 0: + if operator.gt(groups[i]['name'].lower(), group['name'].lower()): groups.insert(i, group) return groups.append(group) # add a new group - #Projects.append(group) PriorityInsertGroup(Projects, group) return objs -- cgit v1.3.1 From 07519cf020f6d50cffa2fef849d0013e51076d5b Mon Sep 17 00:00:00 2001 From: 来日方长 <1125934312@qq.com> Date: Sun, 21 Jun 2020 22:11:13 +0800 Subject: update tools/building.py. 添加stackanalysis选项 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tools') diff --git a/tools/building.py b/tools/building.py index 2ddeb9669b..1de54e236b 100644 --- a/tools/building.py +++ b/tools/building.py @@ -209,6 +209,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ dest = 'target', type = 'string', help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse') + AddOption('--stackanalysis', + dest = 'stackanalysis', + action = 'store_true', + default = False, + help = 'thread stack static analysis') AddOption('--genconfig', dest = 'genconfig', action = 'store_true', @@ -363,6 +368,11 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ genconfig() exit(0) + if GetOption('stackanalysis'): + from WCS import ThreadStackStaticAnalysis + ThreadStackStaticAnalysis(Env) + exit(0) + if env['PLATFORM'] != 'win32': AddOption('--menuconfig', dest = 'menuconfig', -- cgit v1.3.1 From 4b8d446b58433f67f8c28e86a35525bbcf1bc986 Mon Sep 17 00:00:00 2001 From: 来日方长 <1125934312@qq.com> Date: Sun, 21 Jun 2020 22:14:30 +0800 Subject: update tools/WCS.py. 添加 WCS.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/WCS.py | 440 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 tools/WCS.py (limited to 'tools') diff --git a/tools/WCS.py b/tools/WCS.py new file mode 100644 index 0000000000..8625d6fff5 --- /dev/null +++ b/tools/WCS.py @@ -0,0 +1,440 @@ +import re +import pprint +import os +from subprocess import check_output +from optparse import OptionParser + +# Constants +rtl_ext_end = ".dfinish" +rtl_ext = None # e.g. '.c.270r.dfinish'. The number '270' will change with gcc version and is auto-detected by the + # function find_rtl_ext +dir = r'.' # Working directory +su_ext = '.su' +obj_ext = '.o' +manual_ext = '.msu' +read_elf_path = "arm-none-eabi-readelf.exe" # You may need to enter the full path here +stdout_encoding = "utf-8" # System dependant + + +class Printable: + def __repr__(self): + return "<" + type(self).__name__ + "> " + pprint.pformat(vars(self), indent=4, width=1) + + +class Symbol(Printable): + pass + + +def read_symbols(file): + from subprocess import check_output + + def to_symbol(read_elf_line): + v = read_elf_line.split() + + s2 = Symbol() + s2.value = int(v[1], 16) + s2.size = int(v[2]) + s2.type = v[3] + s2.binding = v[4] + if len(v) >= 8: + s2.name = v[7] + else: + s2.name = "" + + return s2 + + output = check_output([read_elf_path, "-s", "-W", file]).decode(stdout_encoding) + lines = output.splitlines()[3:] + return [to_symbol(line) for line in lines] + + +def read_obj(tu, call_graph): + """ + Reads the file tu.o and gets the binding (global or local) for each function + :param tu: name of the translation unit (e.g. for main.c, this would be 'main') + :param call_graph: a object used to store information about each function, results go here + """ + symbols = read_symbols(tu[0:tu.rindex(".")] + obj_ext) + + for s in symbols: + + if s.type == 'FUNC': + if s.binding == 'GLOBAL': + # Check for multiple declarations + if s.name in call_graph['globals'] or s.name in call_graph['locals']: + raise Exception('Multiple declarations of {}'.format(s.name)) + call_graph['globals'][s.name] = {'tu': tu, 'name': s.name, 'binding': s.binding} + elif s.binding == 'LOCAL': + # Check for multiple declarations + if s.name in call_graph['locals'] and tu in call_graph['locals'][s.name]: + raise Exception('Multiple declarations of {}'.format(s.name)) + + if s.name not in call_graph['locals']: + call_graph['locals'][s.name] = {} + + call_graph['locals'][s.name][tu] = {'tu': tu, 'name': s.name, 'binding': s.binding} + elif s.binding == 'WEAK': + if s.name in call_graph['weak']: + raise Exception('Multiple declarations of {}'.format(s.name)) + call_graph['weak'][s.name] = {'tu': tu, 'name': s.name, 'binding': s.binding} + else: + raise Exception('Error Unknown Binding "{}" for symbol: {}'.format(s.binding, s.name)) + + +def find_fxn(tu, fxn, call_graph): + """ + Looks up the dictionary associated with the function. + :param tu: The translation unit in which to look for locals functions + :param fxn: The function name + :param call_graph: a object used to store information about each function + :return: the dictionary for the given function or None + """ + + if fxn in call_graph['globals']: + return call_graph['globals'][fxn] + else: + try: + return call_graph['locals'][fxn][tu] + except KeyError: + return None + + +def find_demangled_fxn(tu, fxn, call_graph): + """ + Looks up the dictionary associated with the function. + :param tu: The translation unit in which to look for locals functions + :param fxn: The function name + :param call_graph: a object used to store information about each function + :return: the dictionary for the given function or None + """ + for f in call_graph['globals'].values(): + if 'demangledName' in f: + if f['demangledName'] == fxn: + return f + for f in call_graph['locals'].values(): + if tu in f: + if 'demangledName' in f[tu]: + if f[tu]['demangledName'] == fxn: + return f[tu] + return None + + +def read_rtl(tu, call_graph): + """ + Read an RTL file and finds callees for each function and if there are calls via function pointer. + :param tu: the translation unit + :param call_graph: a object used to store information about each function, results go here + """ + + # Construct A Call Graph + function = re.compile(r'^;; Function (.*) \((\S+), funcdef_no=\d+(, [a-z_]+=\d+)*\)( \([a-z ]+\))?$') + static_call = re.compile(r'^.*\(call.*"(.*)".*$') + other_call = re.compile(r'^.*call .*$') + + for line_ in open(tu + rtl_ext).readlines(): + m = function.match(line_) + if m: + fxn_name = m.group(2) + fxn_dict2 = find_fxn(tu, fxn_name, call_graph) + if not fxn_dict2: + pprint.pprint(call_graph) + raise Exception("Error locating function {} in {}".format(fxn_name, tu)) + + fxn_dict2['demangledName'] = m.group(1) + fxn_dict2['calls'] = set() + fxn_dict2['has_ptr_call'] = False + continue + + m = static_call.match(line_) + if m: + fxn_dict2['calls'].add(m.group(1)) + # print("Call: {0} -> {1}".format(current_fxn, m.group(1))) + continue + + m = other_call.match(line_) + if m: + fxn_dict2['has_ptr_call'] = True + continue + + +def read_su(tu, call_graph): + """ + Reads the 'local_stack' for each function. Local stack ignores stack used by callees. + :param tu: the translation unit + :param call_graph: a object used to store information about each function, results go here + :return: + """ + + su_line = re.compile(r'^([^ :]+):([\d]+):([\d]+):(.+)\t(\d+)\t(\S+)$') + i = 1 + + for line in open(tu[0:tu.rindex(".")] + su_ext).readlines(): + m = su_line.match(line) + if m: + fxn = m.group(4) + fxn_dict2 = find_demangled_fxn(tu, fxn, call_graph) + fxn_dict2['local_stack'] = int(m.group(5)) + else: + print("error parsing line {} in file {}".format(i, tu)) + i += 1 + + +def read_manual(file, call_graph): + """ + reads the manual stack useage files. + :param file: the file name + :param call_graph: a object used to store information about each function, results go here + """ + + for line in open(file).readlines(): + fxn, stack_sz = line.split() + if fxn in call_graph: + raise Exception("Redeclared Function {}".format(fxn)) + call_graph['globals'][fxn] = {'wcs': int(stack_sz), + 'calls': set(), + 'has_ptr_call': False, + 'local_stack': int(stack_sz), + 'is_manual': True, + 'name': fxn, + 'tu': '#MANUAL', + 'binding': 'GLOBAL'} + + +def validate_all_data(call_graph): + """ + Check that every entry in the call graph has the following fields: + .calls, .has_ptr_call, .local_stack, .scope, .src_line + """ + + def validate_dict(d): + if not ('calls' in d and 'has_ptr_call' in d and 'local_stack' in d + and 'name' in d and 'tu' in d): + print("Error data is missing in fxn dictionary {}".format(d)) + + # Loop through every global and local function + # and resolve each call, save results in r_calls + for fxn_dict2 in call_graph['globals'].values(): + validate_dict(fxn_dict2) + + for l_dict in call_graph['locals'].values(): + for fxn_dict2 in l_dict.values(): + validate_dict(fxn_dict2) + +def resolve_all_calls(call_graph): + def resolve_calls(fxn_dict2): + fxn_dict2['r_calls'] = [] + fxn_dict2['unresolved_calls'] = set() + + for call in fxn_dict2['calls']: + call_dict = find_fxn(fxn_dict2['tu'], call, call_graph) + if call_dict: + fxn_dict2['r_calls'].append(call_dict) + else: + fxn_dict2['unresolved_calls'].add(call) + + # Loop through every global and local function + # and resolve each call, save results in r_calls + for fxn_dict in call_graph['globals'].values(): + resolve_calls(fxn_dict) + + for l_dict in call_graph['locals'].values(): + for fxn_dict in l_dict.values(): + resolve_calls(fxn_dict) + + +def calc_all_wcs(call_graph): + def calc_wcs(fxn_dict2, call_graph1, parents): + """ + Calculates the worst case stack for a fxn that is declared (or called from) in a given file. + :param parents: This function gets called recursively through the call graph. If a function has recursion the + tuple file, fxn will be in the parents stack and everything between the top of the stack and the matching entry + has recursion. + :return: + """ + + # If the wcs is already known, then nothing to do + if 'wcs' in fxn_dict2: + return + + # Check for pointer calls + if fxn_dict2['has_ptr_call']: + fxn_dict2['wcs'] = 'unbounded' + return + + # Check for recursion + if fxn_dict2 in parents: + fxn_dict2['wcs'] = 'unbounded' + return + + # Calculate WCS + call_max = 0 + for call_dict in fxn_dict2['r_calls']: + + # Calculate the WCS for the called function + parents.append(fxn_dict2) + calc_wcs(call_dict, call_graph1, parents) + parents.pop() + + # If the called function is unbounded, so is this function + if call_dict['wcs'] == 'unbounded': + fxn_dict2['wcs'] = 'unbounded' + return + + # Keep track of the call with the largest stack use + call_max = max(call_max, call_dict['wcs']) + + # Propagate Unresolved Calls + for unresolved_call in call_dict['unresolved_calls']: + fxn_dict2['unresolved_calls'].add(unresolved_call) + + fxn_dict2['wcs'] = call_max + fxn_dict2['local_stack'] + + # Loop through every global and local function + # and resolve each call, save results in r_calls + for fxn_dict in call_graph['globals'].values(): + calc_wcs(fxn_dict, call_graph, []) + + for l_dict in call_graph['locals'].values(): + for fxn_dict in l_dict.values(): + calc_wcs(fxn_dict, call_graph, []) + + +def print_all_fxns(call_graph): + + def print_fxn(row_format, fxn_dict2): + unresolved = fxn_dict2['unresolved_calls'] + stack = str(fxn_dict2['wcs']) + if unresolved: + unresolved_str = '({})'.format(' ,'.join(unresolved)) + if stack != 'unbounded': + stack = "unbounded:" + stack + else: + unresolved_str = '' + + print(row_format.format(fxn_dict2['tu'], fxn_dict2['demangledName'], stack, unresolved_str)) + + def get_order(val): + if val == 'unbounded': + return 1 + else: + return -val + + # Loop through every global and local function + # and resolve each call, save results in r_calls + d_list = [] + for fxn_dict in call_graph['globals'].values(): + d_list.append(fxn_dict) + + for l_dict in call_graph['locals'].values(): + for fxn_dict in l_dict.values(): + d_list.append(fxn_dict) + + d_list.sort(key=lambda item: get_order(item['wcs'])) + + # Calculate table width + tu_width = max(max([len(d['tu']) for d in d_list]), 16) + name_width = max(max([len(d['name']) for d in d_list]), 13) + row_format = "{:<" + str(tu_width + 2) + "} {:<" + str(name_width + 2) + "} {:>14} {:<17}" + + # Print out the table + print("") + print(row_format.format('Translation Unit', 'Function Name', 'Stack', 'Unresolved Dependencies')) + for d in d_list: + print_fxn(row_format, d) + + +def find_rtl_ext(): + # Find the rtl_extension + global rtl_ext + + for root, directories, filenames in os.walk('.'): + for f in filenames: + if (f.endswith(rtl_ext_end)): + rtl_ext = f[f[:-len(rtl_ext_end)].rindex("."):] + print("rtl_ext = " + rtl_ext) + return + + print("Could not find any files ending with '.dfinish'. Check that the script is being run from the correct " + "directory. Check that the code was compiled with the correct flags") + exit(-1) + + +def find_files(): + tu = [] + manual = [] + all_files = [] + for root, directories, filenames in os.walk(dir): + for filename in filenames: + all_files.append(os.path.join(root,filename)) + + files = [f for f in all_files if os.path.isfile(f) and f.endswith(rtl_ext)] + for f in files: + base = f[0:-len(rtl_ext)] + short_base = base[0:base.rindex(".")] + if short_base + su_ext in all_files and short_base + obj_ext in all_files: + tu.append(base) + print('Reading: {}{}, {}{}, {}{}'.format(base, rtl_ext, short_base, su_ext, short_base, obj_ext)) + + files = [f for f in all_files if os.path.isfile(f) and f.endswith(manual_ext)] + for f in files: + manual.append(f) + print('Reading: {}'.format(f)) + + # Print some diagnostic messages + if not tu: + print("Could not find any translation units to analyse") + exit(-1) + + return tu, manual + + +def main(): + + # Find the appropriate RTL extension + find_rtl_ext() + + # Find all input files + call_graph = {'locals': {}, 'globals': {}, 'weak': {}} + tu_list, manual_list = find_files() + + # Read the input files + for tu in tu_list: + read_obj(tu, call_graph) # This must be first + + for fxn in call_graph['weak'].values(): + if fxn['name'] not in call_graph['globals'].keys(): + call_graph['globals'][fxn['name']] = fxn + + for tu in tu_list: + read_rtl(tu, call_graph) + for tu in tu_list: + read_su(tu, call_graph) + + # Read manual files + for m in manual_list: + read_manual(m, call_graph) + + # Validate Data + validate_all_data(call_graph) + + # Resolve All Function Calls + resolve_all_calls(call_graph) + + # Calculate Worst Case Stack For Each Function + calc_all_wcs(call_graph) + + # Print A Nice Message With Each Function and the WCS + print_all_fxns(call_graph) + + + + +def ThreadStackStaticAnalysis(env): + print('Start thread stack static analysis...') + + import rtconfig + read_elf_path = rtconfig.EXEC_PATH + r'\readelf.exe' + main() + + print('\nThread stack static analysis done!') + return \ No newline at end of file -- cgit v1.3.1 From abfbd9a79a693c574cae303c404d3fa223b51be8 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Thu, 9 Jul 2020 16:05:09 +0800 Subject: fixbug:eclipse.py do not remove all unused path from list --- tools/eclipse.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/eclipse.py b/tools/eclipse.py index ef546fb15a..fb2e604bdc 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 3 +MODULE_VER_NUM = 4 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -348,12 +348,13 @@ def GenExcluding(env, project): rtt_root = os.path.abspath(env['RTT_ROOT']) bsp_root = os.path.abspath(env['BSP_ROOT']) coll_dirs = CollectPaths(project['DIRS']) - all_paths = [OSPath(path) for path in coll_dirs] + all_paths_temp = [OSPath(path) for path in coll_dirs] + all_paths = [] - # remove unused path - for path in all_paths: - if not path.startswith(rtt_root) and not path.startswith(bsp_root): - all_paths.remove(path) + # add used path + for path in all_paths_temp: + if path.startswith(rtt_root) or path.startswith(bsp_root): + all_paths.append(path) if bsp_root.startswith(rtt_root): # bsp folder is in the RT-Thread root folder, such as the RT-Thread source code on GitHub -- cgit v1.3.1 From aa411a25ad8a6108dce6477db2299b1ecdef1274 Mon Sep 17 00:00:00 2001 From: "yaxing.chen" Date: Fri, 24 Jul 2020 16:04:02 +0800 Subject: fixbug:keep user's lib configuration while running --target=eclipse --- tools/eclipse.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/eclipse.py b/tools/eclipse.py index fb2e604bdc..154bffb754 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import SubElement from building import * -MODULE_VER_NUM = 4 +MODULE_VER_NUM = 5 source_pattern = ['*.c', '*.cpp', '*.cxx', '*.s', '*.S', '*.asm'] @@ -138,6 +138,20 @@ def IsRttEclipsePathFormat(path): return True else : return False + +# all libs added by scons should be ends with five whitespace as a flag +rtt_lib_flag = 5 * " " + + +def ConverToRttEclipseLibFormat(lib): + return str(lib) + str(rtt_lib_flag) + + +def IsRttEclipseLibFormat(path): + if path.endswith(rtt_lib_flag): + return True + else: + return False def IsCppProject(): @@ -189,7 +203,7 @@ def HandleToolOption(tools, env, project, reset): linker_script_option = option elif option.get('id').find('linker.nostart') != -1: linker_nostart_option = option - elif option.get('id').find('linker.libs') != -1 and env.has_key('LIBS'): + elif option.get('id').find('linker.libs') != -1: linker_libs_option = option elif option.get('id').find('linker.paths') != -1 and env.has_key('LIBPATH'): linker_paths_option = option @@ -288,16 +302,22 @@ def HandleToolOption(tools, env, project, reset): else: option.set('value', 'false') # update libs - if linker_libs_option is not None : + if linker_libs_option is not None: option = linker_libs_option # remove old libs for item in option.findall('listOptionValue'): - option.remove(item) + if IsRttEclipseLibFormat(item.get("value")): + option.remove(item) + # add new libs - for lib in env['LIBS']: - SubElement(option, 'listOptionValue', {'builtIn': 'false', 'value': lib}) + if env.has_key('LIBS'): + for lib in env['LIBS']: + formatedLib = ConverToRttEclipseLibFormat(lib) + SubElement(option, 'listOptionValue', { + 'builtIn': 'false', 'value': formatedLib}) + # update lib paths - if linker_paths_option is not None : + if linker_paths_option is not None: option = linker_paths_option # remove old lib paths for item in option.findall('listOptionValue'): -- cgit v1.3.1