Skip to content

Commit 47b7c1f

Browse files
committed
Fix non-mm32 BSP dist CI paths
1 parent 2449aa9 commit 47b7c1f

8 files changed

Lines changed: 97 additions & 15 deletions

File tree

bsp/allwinner/tools/sdk_dist.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
77

88

9+
def update_kconfig_library_path(dist_dir):
10+
library_dir = os.path.join(dist_dir, 'libraries')
11+
if not os.path.isdir(library_dir):
12+
return
13+
14+
for root, dirs, files in os.walk(library_dir):
15+
if 'Kconfig' not in files:
16+
continue
17+
18+
kconfig_path = os.path.join(root, 'Kconfig')
19+
with open(kconfig_path, 'r') as f:
20+
data = f.read()
21+
22+
data = data.replace('$(BSP_DIR)/../libraries', 'libraries')
23+
data = data.replace('$BSP_DIR/../libraries', 'libraries')
24+
data = data.replace('../libraries', 'libraries')
25+
26+
with open(kconfig_path, 'w') as f:
27+
f.write(data)
28+
29+
930
# BSP dist function
1031
def dist_do_building(BSP_ROOT, dist_dir):
1132
from mkdist import bsp_copy_files
@@ -24,3 +45,4 @@ def dist_do_building(BSP_ROOT, dist_dir):
2445
bsp_copy_files(os.path.join(library_path, 'libos'), os.path.join(library_dir, 'libos'))
2546

2647
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
48+
update_kconfig_library_path(dist_dir)

bsp/ft32/tools/sdk_dist.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@
66
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
77

88

9+
def update_dist_project_paths(dist_dir):
10+
sconstruct_path = os.path.join(dist_dir, 'SConstruct')
11+
if not os.path.isfile(sconstruct_path):
12+
return
13+
14+
with open(sconstruct_path, 'r') as f:
15+
data = f.read()
16+
17+
data = data.replace("os.path.join(libraries_path_prefix, 'STD_Drivers', 'SConscript')",
18+
"os.path.join(libraries_path_prefix, 'Drivers', 'SConscript')")
19+
data = data.replace("variant_dir='../libraries/Drivers'",
20+
"variant_dir='build/libraries/Drivers'")
21+
data = data.replace('variant_dir="../libraries/Drivers"',
22+
'variant_dir="build/libraries/Drivers"')
23+
24+
with open(sconstruct_path, 'w') as f:
25+
f.write(data)
26+
27+
928
# BSP dist function
1029
def dist_do_building(BSP_ROOT, dist_dir):
1130
from mkdist import bsp_copy_files
@@ -21,3 +40,4 @@ def dist_do_building(BSP_ROOT, dist_dir):
2140
print("=> copy bsp drivers")
2241
bsp_copy_files(os.path.join(library_path, 'Drivers'), os.path.join(library_dir, 'Drivers'))
2342
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
43+
update_dist_project_paths(dist_dir)

bsp/hc32/tools/sdk_dist.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44

55
cwd_path = os.getcwd()
66
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
7-
7+
8+
9+
def update_dist_project_paths(dist_dir):
10+
tests_sconscript = os.path.join(os.path.dirname(dist_dir), 'tests', 'SConscript')
11+
if os.path.isfile(tests_sconscript):
12+
with open(tests_sconscript, 'r') as f:
13+
data = f.read()
14+
15+
data = data.replace('../../../components', '../project/rt-thread/components')
16+
17+
with open(tests_sconscript, 'w') as f:
18+
f.write(data)
19+
20+
821
# BSP dist function
922
def dist_do_building(BSP_ROOT, dist_dir):
1023
from mkdist import bsp_copy_files
@@ -26,3 +39,4 @@ def dist_do_building(BSP_ROOT, dist_dir):
2639

2740
print("=> copy hc32 tests")
2841
bsp_copy_files(os.path.join(os.path.dirname(BSP_ROOT), 'tests'), os.path.join(os.path.dirname(dist_dir), 'tests'))
42+
update_dist_project_paths(dist_dir)

bsp/hpmicro/tools/sdk_dist.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@
44
cwd_path = os.getcwd()
55
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
66

7-
def update_dist_project_paths(dist_dir):
8-
sconstruct_path = os.path.join(dist_dir, 'SConstruct')
9-
if os.path.isfile(sconstruct_path):
10-
with open(sconstruct_path, 'r') as f:
11-
data = f.read()
7+
def update_rtt_root_path(path):
8+
if not os.path.isfile(path):
9+
return
1210

13-
data = data.replace("RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')",
14-
"RTT_ROOT = os.path.join(os.getcwd(), 'rt-thread')")
11+
with open(path, 'r') as f:
12+
data = f.read()
1513

16-
with open(sconstruct_path, 'w') as f:
17-
f.write(data)
14+
data = data.replace("RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')",
15+
"RTT_ROOT = os.path.join(os.getcwd(), 'rt-thread')")
16+
data = data.replace('RTT_ROOT = os.path.normpath(os.getcwd() + "/../../..")',
17+
"RTT_ROOT = os.path.join(os.getcwd(), 'rt-thread')")
18+
19+
with open(path, 'w') as f:
20+
f.write(data)
21+
22+
23+
def update_dist_project_paths(dist_dir):
24+
update_rtt_root_path(os.path.join(dist_dir, 'SConstruct'))
25+
update_rtt_root_path(os.path.join(dist_dir, 'rtconfig.py'))
1826

1927
kconfig_path = os.path.join(dist_dir, 'Kconfig')
2028
if os.path.isfile(kconfig_path):

bsp/nxp/imx/imxrt/tools/sdk_dist.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ def update_kconfig_library_path(dist_dir):
1818
with open(kconfig_path, 'w') as f:
1919
f.write(data)
2020

21+
22+
def update_sconstruct_library_path(dist_dir):
23+
sconstruct_path = os.path.join(dist_dir, 'SConstruct')
24+
if not os.path.isfile(sconstruct_path):
25+
return
26+
27+
with open(sconstruct_path, 'r') as f:
28+
data = f.read()
29+
30+
data = data.replace("SDK_ROOT = os.path.abspath('./..')",
31+
"SDK_ROOT = os.path.abspath('./')")
32+
33+
with open(sconstruct_path, 'w') as f:
34+
f.write(data)
35+
36+
2137
# BSP dist function
2238
def dist_do_building(BSP_ROOT, dist_dir=None):
2339
from mkdist import bsp_copy_files
@@ -39,3 +55,4 @@ def dist_do_building(BSP_ROOT, dist_dir=None):
3955
print("=> copy bsp peripherals")
4056
bsp_copy_files(os.path.join(library_path, 'peripherals'), os.path.join(library_dir, 'peripherals'))
4157
update_kconfig_library_path(dist_dir)
58+
update_sconstruct_library_path(dist_dir)

bsp/wch/arm/ch32f103c8-core/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ PKGS_DIR := packages
88

99
source "$(RTT_DIR)/Kconfig"
1010
osource "$PKGS_DIR/Kconfig"
11-
rsource "../libraries/Kconfig"
11+
rsource "../Libraries/Kconfig"
1212
rsource "board/Kconfig"

bsp/wch/arm/ch32f203r-evt/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ PKGS_DIR := packages
88

99
source "$(RTT_DIR)/Kconfig"
1010
osource "$PKGS_DIR/Kconfig"
11-
rsource "../libraries/Kconfig"
11+
rsource "../Libraries/Kconfig"
1212
rsource "board/Kconfig"

bsp/wch/risc-v/tools/sdk_dist.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ def dist_do_building(BSP_ROOT, dist_dir):
1414
print("=> copy ch32 bsp library")
1515
library_dir = os.path.join(dist_dir, 'Libraries')
1616
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'Libraries')
17-
if rtconfig.BSP_LIBRARY_TYPE is not None:
18-
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
19-
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
17+
library_type = getattr(rtconfig, 'BSP_LIBRARY_TYPE', None)
18+
if library_type is not None:
19+
bsp_copy_files(os.path.join(library_path, library_type),
20+
os.path.join(library_dir, library_type))
2021
print("=> copy bsp drivers")
2122
bsp_copy_files(os.path.join(library_path, 'ch32_drivers'), os.path.join(library_dir, 'ch32_drivers'))
2223
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))

0 commit comments

Comments
 (0)