瀏覽代碼

mkdist和sdk_dist支持kconfiglib语法

latercomer 10 月之前
父節點
當前提交
f0e6d772f3

+ 10 - 10
bsp/at32/tools/sdk_dist.py

@@ -1,9 +1,11 @@
 import os
 import sys
 import shutil
+
 cwd_path = os.getcwd()
 sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
 
+
 def bsp_update_kconfig_library(dist_dir):
     # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
@@ -12,16 +14,12 @@ def bsp_update_kconfig_library(dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../libraries') != -1 and found:
-                position = line.find('../libraries')
-                line = line[0:position] + 'libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)
 
+
 # BSP dist function
 def dist_do_building(BSP_ROOT, dist_dir):
     from mkdist import bsp_copy_files
@@ -30,12 +28,14 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy at32 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, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers'))
     bsp_copy_files(os.path.join(library_path, 'usbd_library'), os.path.join(library_dir, 'usbd_library'))
     bsp_copy_files(os.path.join(library_path, 'usbotg_library'), os.path.join(library_dir, 'usbotg_library'))
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
-    bsp_update_kconfig_library(dist_dir)
+    bsp_update_kconfig_library(dist_dir)

+ 8 - 11
bsp/bouffalo_lab/bl808/tools/sdk_dist.py

@@ -1,18 +1,20 @@
 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, dist_dir):
     from mkdist import bsp_copy_files
     import rtconfig
 
     library_path = os.path.join(os.path.dirname(BSP_ROOT), '../libraries')
-    print("library_path   ",library_path)
-    library_dir  = os.path.join(dist_dir, 'libraries')
-    print("library_dir   ",library_dir)
+    print("library_path   ", library_path)
+    library_dir = os.path.join(dist_dir, 'libraries')
+    print("library_dir   ", library_dir)
     print("=> copy bsp drivers")
     bsp_copy_files(os.path.join(library_path, 'rt_drivers'), os.path.join(library_dir, 'rt_drivers'))
     print("=> copy bsp CMSIS")
@@ -20,7 +22,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy bsp library")
 
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
-    
+
     # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
         return
@@ -28,12 +30,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../../libraries') != -1 and found:
-                position = line.find('../../libraries')
-                line = line[0:position] + 'libraries"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)

+ 8 - 12
bsp/core-v-mcu/tools/sdk_dist.py

@@ -1,10 +1,12 @@
 import os
 import sys
 import shutil
+
 cwd_path = os.getcwd()
-#cwd_path = E:\rt-thread\bsp\core-v-mcu\tools
+# cwd_path = E:\rt-thread\bsp\core-v-mcu\tools
 sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
 
+
 # BSP dist function
 def dist_do_building(BSP_ROOT, dist_dir):
     from mkdist import bsp_copy_files
@@ -13,25 +15,19 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy core-v 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))
-    #library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries
+    bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE), os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
+    # library_dir = E:\rt-thread\bsp\core-v-mcu\Libraries
     print("=> copy bsp drivers")
     bsp_copy_files(os.path.join(library_path, 'core_v_drivers'), os.path.join(library_dir, 'core_v_drivers'))
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
-# change RTT_ROOT in Kconfig
+    # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
         return
 
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../Libraries') != -1 and found:
-                position = line.find('../Libraries')
-                line = line[0:position] + 'Libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)

+ 11 - 13
bsp/ht32/tools/sdk_dist.py

@@ -2,9 +2,11 @@ import os
 import re
 import sys
 import shutil
+
 cwd_path = os.getcwd()
 sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
 
+
 def bsp_update_kconfig_library(dist_dir):
     # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
@@ -13,16 +15,12 @@ def bsp_update_kconfig_library(dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../libraries') != -1 and found:
-                position = line.find('../libraries')
-                line = line[0:position] + 'libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)
 
+
 # BSP dist function
 def dist_do_building(BSP_ROOT, dist_dir):
     from mkdist import bsp_copy_files
@@ -31,14 +29,14 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy ht32 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, 'ht32_drivers'), os.path.join(library_dir, 'ht32_drivers'))
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
     bsp_update_kconfig_library(dist_dir)
-  
+
+
 def get_source(ic_model, file_path, system_path, base_path):
     source_path = []
     files_list = []
@@ -47,7 +45,7 @@ def get_source(ic_model, file_path, system_path, base_path):
         return
 
     with open(file_path, 'r') as file:
-        #content = file.read()
+        # content = file.read()
         for line in file:
             if readafter == 2 and line.find('>') != -1:
                 break
@@ -56,10 +54,10 @@ def get_source(ic_model, file_path, system_path, base_path):
             if line.find(ic_model) != -1:
                 readafter = 1
             if readafter == 1 and line.find('<') != -1:
-                readafter = 2  
+                readafter = 2
     for line in files_list:
         if line.find('system') != -1:
             source_path.append(os.path.join(system_path, line.strip()))
         else:
             source_path.append(os.path.join(base_path, line.strip()))
-    return source_path  
+    return source_path

+ 6 - 9
bsp/nxp/lpc/lpc55sxx/tools/sdk_dist.py

@@ -1,16 +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, dist_dir):
     from mkdist import bsp_copy_files
     import rtconfig
 
     library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
-    library_dir  = os.path.join(dist_dir, 'Libraries')
+    library_dir = os.path.join(dist_dir, 'Libraries')
     print("=> copy bsp drivers")
     bsp_copy_files(os.path.join(library_path, 'drivers'), os.path.join(library_dir, 'drivers'))
     print("=> copy bsp CMSIS")
@@ -18,7 +20,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
     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'))
-    
+
     # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
         return
@@ -26,12 +28,7 @@ def dist_do_building(BSP_ROOT, dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../Libraries') != -1 and found:
-                position = line.find('../Libraries')
-                line = line[0:position] + 'Libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../Libraries', 'Libraries')
             f.write(line)

+ 9 - 10
bsp/wch/arm/tools/sdk_dist.py

@@ -1,9 +1,11 @@
 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, dist_dir):
     from mkdist import bsp_copy_files
@@ -12,25 +14,22 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy ch32 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, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers'))
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
-# change RTT_ROOT in Kconfig
+    # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
         return
 
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../Libraries') != -1 and found:
-                position = line.find('../Libraries')
-                line = line[0:position] + 'Libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../Libraries', 'Libraries')
             f.write(line)

+ 6 - 10
bsp/wch/risc-v/tools/sdk_dist.py

@@ -1,9 +1,11 @@
 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, dist_dir):
     from mkdist import bsp_copy_files
@@ -12,25 +14,19 @@ def dist_do_building(BSP_ROOT, dist_dir):
     print("=> copy ch32 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, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers'))
     shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
-# change RTT_ROOT in Kconfig
+    # change RTT_ROOT in Kconfig
     if not os.path.isfile(os.path.join(dist_dir, 'Kconfig')):
         return
 
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../Libraries') != -1 and found:
-                position = line.find('../Libraries')
-                line = line[0:position] + 'Libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../Libraries', 'Libraries')
             f.write(line)

+ 6 - 17
tools/mkdist.py

@@ -126,14 +126,9 @@ def bsp_update_kconfig(dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('default') != -1 and found:
-                position = line.find('default')
-                line = line[0:position] + 'default "rt-thread"\n'
-                found = 0
+            if line.find('RTT_DIR') != -1 and line.find(':=') != -1:
+                line = 'RTT_DIR := rt-thread\n'
             f.write(line)
 
 def bsp_update_kconfig_library(dist_dir):
@@ -144,14 +139,9 @@ def bsp_update_kconfig_library(dist_dir):
     with open(os.path.join(dist_dir, 'Kconfig'), 'r') as f:
         data = f.readlines()
     with open(os.path.join(dist_dir, 'Kconfig'), 'w') as f:
-        found = 0
         for line in data:
-            if line.find('RTT_ROOT') != -1:
-                found = 1
-            if line.find('../libraries') != -1 and found:
-                position = line.find('../libraries')
-                line = line[0:position] + 'libraries/Kconfig"\n'
-                found = 0
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)
 
     # change board/kconfig path
@@ -162,9 +152,8 @@ def bsp_update_kconfig_library(dist_dir):
         data = f.readlines()
     with open(os.path.join(dist_dir, 'board/Kconfig'), 'w') as f:
         for line in data:
-            if line.find('../libraries/HAL_Drivers/drivers/Kconfig') != -1:
-                position = line.find('../libraries/HAL_Drivers/drivers/Kconfig')
-                line = line[0:position] + 'libraries/HAL_Drivers/drivers/Kconfig"\n'
+            if line.find('source') != -1 and line.find('../libraries') != -1:
+                line = line.replace('../libraries', 'libraries')
             f.write(line)
 
 def zip_dist(dist_dir, dist_name):