From 52e76a998f602a2df97884878a320d8f33233a45 Mon Sep 17 00:00:00 2001 From: WangQiang Date: Fri, 17 Jul 2020 18:13:04 +0800 Subject: [PATCH] fixed scons --dist in IMXRT BSP --- bsp/imxrt/imxrt1052-atk-commander/rtconfig.py | 6 ++++-- bsp/imxrt/imxrt1052-fire-pro/rtconfig.py | 6 ++++-- bsp/imxrt/imxrt1052-nxp-evk/rtconfig.py | 5 +++-- bsp/imxrt/imxrt1064-nxp-evk/SConstruct | 19 +++++++++++++++++-- bsp/imxrt/imxrt1064-nxp-evk/rtconfig.py | 11 +++++++++++ bsp/imxrt/tools/sdk_dist.py | 12 ++++++++---- tools/mkdist.py | 2 +- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/bsp/imxrt/imxrt1052-atk-commander/rtconfig.py b/bsp/imxrt/imxrt1052-atk-commander/rtconfig.py index 9b0c3da87f..e89f349492 100644 --- a/bsp/imxrt/imxrt1052-atk-commander/rtconfig.py +++ b/bsp/imxrt/imxrt1052-atk-commander/rtconfig.py @@ -149,9 +149,11 @@ elif PLATFORM == 'iar': EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' -def dist_handle(BSP_ROOT): + +def dist_handle(BSP_ROOT, dist_dir): + 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) + dist_do_building(BSP_ROOT, dist_dir) \ No newline at end of file diff --git a/bsp/imxrt/imxrt1052-fire-pro/rtconfig.py b/bsp/imxrt/imxrt1052-fire-pro/rtconfig.py index 9b0c3da87f..e476f862ad 100644 --- a/bsp/imxrt/imxrt1052-fire-pro/rtconfig.py +++ b/bsp/imxrt/imxrt1052-fire-pro/rtconfig.py @@ -149,9 +149,11 @@ elif PLATFORM == 'iar': EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' -def dist_handle(BSP_ROOT): +def dist_handle(BSP_ROOT, dist_dir): + 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) + dist_do_building(BSP_ROOT, dist_dir) + \ No newline at end of file diff --git a/bsp/imxrt/imxrt1052-nxp-evk/rtconfig.py b/bsp/imxrt/imxrt1052-nxp-evk/rtconfig.py index 88fd75b5e6..26a162ff80 100644 --- a/bsp/imxrt/imxrt1052-nxp-evk/rtconfig.py +++ b/bsp/imxrt/imxrt1052-nxp-evk/rtconfig.py @@ -149,9 +149,10 @@ elif PLATFORM == 'iar': EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' -def dist_handle(BSP_ROOT): +def dist_handle(BSP_ROOT, dist_dir): + 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) + dist_do_building(BSP_ROOT, dist_dir) \ No newline at end of file diff --git a/bsp/imxrt/imxrt1064-nxp-evk/SConstruct b/bsp/imxrt/imxrt1064-nxp-evk/SConstruct index 71be0c13c6..2827f048f0 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/SConstruct +++ b/bsp/imxrt/imxrt1064-nxp-evk/SConstruct @@ -45,11 +45,26 @@ if rtconfig.PLATFORM == 'iar': Export('RTT_ROOT') Export('rtconfig') +SDK_ROOT = os.path.abspath('./') +if os.path.exists(SDK_ROOT + '/Libraries'): + libraries_path_prefix = SDK_ROOT + '/Libraries' +else: + libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/Libraries' + +SDK_LIB = libraries_path_prefix +Export('SDK_LIB') + # prepare building environment objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) -objs = objs + SConscript('../libraries/drivers/SConscript') -objs = objs + SConscript('../libraries/MIMXRT1064/SConscript') +imxrt_library = 'MIMXRT1064' +rtconfig.BSP_LIBRARY_TYPE = imxrt_library + +# include libraries +objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SConscript'))) + +# include drivers +objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript'))) # make a building DoBuilding(TARGET, objs) diff --git a/bsp/imxrt/imxrt1064-nxp-evk/rtconfig.py b/bsp/imxrt/imxrt1064-nxp-evk/rtconfig.py index 4eccbc92fd..4095eb0c82 100644 --- a/bsp/imxrt/imxrt1064-nxp-evk/rtconfig.py +++ b/bsp/imxrt/imxrt1064-nxp-evk/rtconfig.py @@ -5,6 +5,9 @@ ARCH='arm' CPU='cortex-m7' CROSS_TOOL='gcc' +# bsp lib config +BSP_LIBRARY_TYPE = None + if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') if os.getenv('RTT_ROOT'): @@ -150,3 +153,11 @@ elif PLATFORM == 'iar': EXEC_PATH = EXEC_PATH + '/arm/bin/' POST_ACTION = 'ielftool --bin $TARGET rtthread.bin' + + +def dist_handle(BSP_ROOT, dist_dir): + 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, dist_dir) \ No newline at end of file diff --git a/bsp/imxrt/tools/sdk_dist.py b/bsp/imxrt/tools/sdk_dist.py index ebf869b689..89b7da4356 100644 --- a/bsp/imxrt/tools/sdk_dist.py +++ b/bsp/imxrt/tools/sdk_dist.py @@ -5,15 +5,19 @@ 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=None): from mkdist import bsp_copy_files import rtconfig - dist_dir = os.path.join(BSP_ROOT, 'dist', os.path.basename(BSP_ROOT)) + if dist_dir is None: + dist_dir = os.path.join(BSP_ROOT, 'dist', os.path.basename(BSP_ROOT)) + + print("=> copy imxrt 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)) + print("=> copy bsp drivers") bsp_copy_files(os.path.join(library_path, 'drivers'), os.path.join(library_dir, '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 7e4b9a8bbe..ddcaf7b37a 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -349,7 +349,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')