Skip to content

Commit d39848b

Browse files
committed
重命名core组件
1 parent 2eb6fd2 commit d39848b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+281
-410
lines changed

machines/qemu-virt-riscv64/rust/Cargo.lock

Lines changed: 0 additions & 181 deletions
This file was deleted.

machines/qemu-virt-riscv64/rust/Cargo.toml

Lines changed: 0 additions & 33 deletions
This file was deleted.

machines/qemu-virt-riscv64/rust/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ menuconfig RT_USING_RUST
66
This allows you to write RT-Thread components using Rust.
77

88
if RT_USING_RUST
9-
9+
config RT_RUST_CORE
10+
bool "Enable Rust Core Library"
11+
default y
1012
config RUST_DEBUG_BUILD
1113
bool "Build Rust code in debug mode"
1214
default n
1315
help
1416
Build Rust code with debug symbols and without optimizations.
1517
This increases binary size but helps with debugging.
16-
1718
config RUST_INIT_COMPONENT
1819
bool "Auto-initialize Rust component"
1920
default y
Lines changed: 8 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,14 @@
1+
# for module compiling
12
import os
2-
import sys
33
from building import *
44

55
cwd = GetCurrentDir()
6+
objs = []
7+
list = os.listdir(cwd)
68

7-
# Import helper utilities
8-
sys.path.append(os.path.join(cwd, 'tools'))
9-
from build_support import (
10-
detect_rust_target,
11-
make_rustflags,
12-
collect_features,
13-
verify_rust_toolchain,
14-
ensure_rust_target_installed,
15-
cargo_build_staticlib,
16-
clean_rust_build,
17-
)
9+
for d in list:
10+
path = os.path.join(cwd, d)
11+
if os.path.isfile(os.path.join(path, 'SConscript')):
12+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
1813

19-
20-
def _has(sym: str) -> bool:
21-
try:
22-
return bool(GetDepend([sym]))
23-
except Exception:
24-
return bool(GetDepend(sym))
25-
26-
27-
# Not enabled? Return empty group early
28-
if not _has('RT_USING_RUST'):
29-
group = []
30-
Return('group')
31-
32-
33-
# Source files – MSH command glue
34-
src = ['rust_cmd.c']
35-
LIBS = []
36-
LIBPATH = []
37-
38-
if GetOption('clean'):
39-
# Register Rust artifacts for cleaning
40-
rust_build_dir = clean_rust_build(Dir('#').abspath)
41-
if os.path.exists(rust_build_dir):
42-
print(f'Registering {rust_build_dir} for cleanup')
43-
Clean('.', rust_build_dir)
44-
else:
45-
print('No rust build artifacts to clean')
46-
else:
47-
if verify_rust_toolchain():
48-
import rtconfig
49-
50-
target = detect_rust_target(_has, rtconfig)
51-
if not target:
52-
print('Error: Unable to detect Rust target; please check configuration')
53-
else:
54-
print(f'Detected Rust target: {target}')
55-
56-
# Optional hint if target missing
57-
ensure_rust_target_installed(target)
58-
59-
# Build mode and features
60-
debug = bool(_has('RUST_DEBUG_BUILD'))
61-
features = collect_features(_has)
62-
63-
rustflags = make_rustflags(rtconfig, target)
64-
rust_lib = cargo_build_staticlib(
65-
rust_dir=cwd, target=target, features=features, debug=debug, rustflags=rustflags
66-
)
67-
68-
if rust_lib:
69-
LIBS = ['rt_rust']
70-
LIBPATH = [os.path.dirname(rust_lib)]
71-
print('Rust library linked successfully')
72-
else:
73-
print('Warning: Failed to build Rust library')
74-
else:
75-
print('Warning: Rust toolchain not found')
76-
print('Please install Rust from https://rustup.rs')
77-
78-
# Collect examples build artifacts
79-
examples_group = []
80-
examples_path = os.path.join(cwd, 'examples')
81-
if os.path.exists(examples_path):
82-
examples_sconscript = os.path.join(examples_path, 'SConscript')
83-
if os.path.exists(examples_sconscript):
84-
print('Building Rust examples...')
85-
# Use variant_dir=None to avoid directory switching issues
86-
examples_group = SConscript(examples_sconscript, variant_dir=None, duplicate=0)
87-
if not examples_group:
88-
examples_group = []
89-
90-
# Define component group for SCons
91-
group = DefineGroup('rust', src, depend=['RT_USING_RUST'], LIBS=LIBS, LIBPATH=LIBPATH)
92-
93-
# Combine main rust group with examples
94-
if examples_group:
95-
if isinstance(examples_group, list):
96-
group = [group] + examples_group
97-
else:
98-
group = [group, examples_group]
99-
100-
Return('group')
14+
Return('objs')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "rt-rust"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
name = "rt_rust"
8+
crate-type = ["rlib", "staticlib"]
9+
10+
[features]
11+
default = []
12+
smp = []
13+
14+
[profile.dev]
15+
panic = "abort"
16+
17+
[profile.release]
18+
panic = "abort"

0 commit comments

Comments
 (0)