浏览代码

[add] scons --dist-ide function

SummerGift 5 年之前
父节点
当前提交
5c78ab740f
共有 2 个文件被更改,包括 30 次插入5 次删除
  1. 11 0
      tools/building.py
  2. 19 5
      tools/mkdist.py

+ 11 - 0
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)

+ 19 - 5
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!')