243 lines
7.1 KiB
Makefile
243 lines
7.1 KiB
Makefile
SRC_DIR := "std/src"
|
|
PATCH_DIR := "std/patches"
|
|
RUST_SRC := `rustc --print sysroot` / "lib/rustlib/src/rust/library"
|
|
|
|
patch-std:
|
|
@echo "Start patching the std..."
|
|
@find {{ PATCH_DIR }} -type f | while read -r patch_file; do \
|
|
relative_path="${patch_file#{{ PATCH_DIR }}/}"; \
|
|
target_file="${relative_path%.sed}.rs"; \
|
|
if [ -f "{{ SRC_DIR }}/$target_file" ]; then \
|
|
echo " [SED] $target_file"; \
|
|
sed -i -f "$patch_file" "{{ SRC_DIR }}/$target_file"; \
|
|
else \
|
|
echo "⚠ [WARN] target doesn't exist: $target_file"; \
|
|
fi; \
|
|
done
|
|
@echo "✅ Patching done."
|
|
|
|
update-std:
|
|
@just setup-std
|
|
@just patch-std
|
|
|
|
cp_std path:
|
|
@echo "Copying {{ path }}"
|
|
@mkdir {{ "std/src" / parent_directory(path) }} -p
|
|
@cp {{ RUST_SRC / "std/src" / path }} {{ "std/src" / path }}
|
|
|
|
setup-std:
|
|
ln -fs {{ RUST_SRC / "std_detect" }} "."
|
|
ln -fs {{ RUST_SRC / "panic_abort" }} "."
|
|
ln -fs {{ RUST_SRC / "panic_unwind" }} "."
|
|
ln -fs {{ RUST_SRC / "windows_link" }} "."
|
|
ln -fs {{ RUST_SRC / "unwind" }} "."
|
|
ln -fs {{ RUST_SRC / "alloc" }} "."
|
|
ln -fs {{ RUST_SRC / "rustc-std-workspace-alloc" }} "."
|
|
ln -fs {{ RUST_SRC / "rustc-std-workspace-core" }} "."
|
|
ln -fs {{ RUST_SRC / "rustc-std-workspace-std" }} "."
|
|
ln -fs {{ RUST_SRC / "compiler-builtins" }} "."
|
|
ln -fs {{ RUST_SRC / "core" }} "."
|
|
ln -fs {{ RUST_SRC / "stdarch" }} "."
|
|
ln -fs {{ RUST_SRC / "portable-simd" }} "."
|
|
ln -fs {{ RUST_SRC / "proc_macro" }} "."
|
|
ln -fs {{ RUST_SRC / "profiler_builtins" }} "."
|
|
ln -fs {{ RUST_SRC / "test" }} "."
|
|
|
|
@# Complete
|
|
@just cp_std "alloc.rs"
|
|
@just cp_std "ascii.rs"
|
|
@just cp_std "backtrace.rs"
|
|
@just cp_std "bstr.rs"
|
|
@just cp_std "env.rs"
|
|
@just cp_std "error.rs"
|
|
@just cp_std "fs.rs"
|
|
@just cp_std "keyword_docs.rs"
|
|
@just cp_std "lib.rs"
|
|
@just cp_std "macros.rs"
|
|
@just cp_std "panic.rs"
|
|
@just cp_std "panicking.rs"
|
|
@just cp_std "pat.rs"
|
|
@just cp_std "path.rs"
|
|
@just cp_std "process.rs"
|
|
@just cp_std "random.rs"
|
|
@just cp_std "rt.rs"
|
|
# @just cp_std "tests_helpers.rs"
|
|
@just cp_std "time.rs"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/backtrace" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/collections" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/ffi" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/fs" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/hash" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/io" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/net" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/num" }} "std/src/"
|
|
|
|
@# Complete
|
|
@just cp_std "os/raw/mod.rs"
|
|
@just cp_std "os/raw/tests.rs"
|
|
@just cp_std "os/mod.rs"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/prelude" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/process" }} "std/src/"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/sync" }} "std/src/"
|
|
|
|
@# Complete
|
|
@just cp_std "sys/alloc/mod.rs"
|
|
|
|
@just cp_std "sys/args/mod.rs"
|
|
@just cp_std "sys/args/unsupported.rs"
|
|
|
|
@just cp_std "sys/env/mod.rs"
|
|
@just cp_std "sys/env/common.rs"
|
|
@just cp_std "sys/env/unsupported.rs"
|
|
|
|
@just cp_std "sys/fd/mod.rs"
|
|
|
|
@just cp_std "sys/fs/mod.rs"
|
|
@just cp_std "sys/fs/common.rs"
|
|
@just cp_std "sys/fs/unsupported.rs"
|
|
|
|
@just cp_std "sys/helpers/mod.rs"
|
|
@just cp_std "sys/helpers/small_c_string.rs"
|
|
@just cp_std "sys/helpers/tests.rs"
|
|
@just cp_std "sys/helpers/wstr.rs"
|
|
|
|
@just cp_std "sys/io/error/generic.rs"
|
|
@just cp_std "sys/io/error/mod.rs"
|
|
@just cp_std "sys/io/io_slice/unsupported.rs"
|
|
@just cp_std "sys/io/is_terminal/unsupported.rs"
|
|
@just cp_std "sys/io/kernel_copy/mod.rs"
|
|
@just cp_std "sys/io/mod.rs"
|
|
|
|
@just cp_std "sys/net/connection/mod.rs"
|
|
@just cp_std "sys/net/connection/unsupported.rs"
|
|
@just cp_std "sys/net/hostname/mod.rs"
|
|
@just cp_std "sys/net/hostname/unsupported.rs"
|
|
@just cp_std "sys/net/mod.rs"
|
|
|
|
@just cp_std "sys/os_str/bytes/tests.rs"
|
|
@just cp_std "sys/os_str/bytes.rs"
|
|
@just cp_std "sys/os_str/mod.rs"
|
|
|
|
@just cp_std "sys/pal/mod.rs"
|
|
@just cp_std "sys/pal/unsupported/mod.rs"
|
|
@just cp_std "sys/pal/unsupported/common.rs"
|
|
@just cp_std "sys/pal/unsupported/os.rs"
|
|
|
|
@just cp_std "sys/path/mod.rs"
|
|
@just cp_std "sys/path/unix.rs"
|
|
|
|
@just cp_std "sys/personality/dwarf/eh.rs"
|
|
@just cp_std "sys/personality/dwarf/mod.rs"
|
|
@just cp_std "sys/personality/dwarf/tests.rs"
|
|
@just cp_std "sys/personality/mod.rs"
|
|
|
|
@just cp_std "sys/pipe/mod.rs"
|
|
@just cp_std "sys/pipe/unsupported.rs"
|
|
|
|
@just cp_std "sys/platform_version/mod.rs"
|
|
|
|
@just cp_std "sys/process/mod.rs"
|
|
@just cp_std "sys/process/env.rs"
|
|
@just cp_std "sys/process/unsupported.rs"
|
|
|
|
@just cp_std "sys/random/mod.rs"
|
|
@just cp_std "sys/random/unsupported.rs"
|
|
|
|
@just cp_std "sys/stdio/mod.rs"
|
|
@just cp_std "sys/stdio/unsupported.rs"
|
|
|
|
@just cp_std "sys/sync/condvar/mod.rs"
|
|
@just cp_std "sys/sync/condvar/no_threads.rs"
|
|
@just cp_std "sys/sync/mutex/mod.rs"
|
|
@just cp_std "sys/sync/mutex/no_threads.rs"
|
|
@just cp_std "sys/sync/once/mod.rs"
|
|
@just cp_std "sys/sync/once/no_threads.rs"
|
|
@just cp_std "sys/sync/rwlock/mod.rs"
|
|
@just cp_std "sys/sync/rwlock/no_threads.rs"
|
|
@just cp_std "sys/sync/thread_parking/mod.rs"
|
|
@just cp_std "sys/sync/thread_parking/unsupported.rs"
|
|
@just cp_std "sys/sync/mod.rs"
|
|
@just cp_std "sys/sync/once_box.rs"
|
|
|
|
@just cp_std "sys/thread/mod.rs"
|
|
@just cp_std "sys/thread/unsupported.rs"
|
|
|
|
@just cp_std "sys/thread_local/mod.rs"
|
|
@just cp_std "sys/thread_local/no_threads.rs"
|
|
@just cp_std "sys/thread_local/os.rs"
|
|
|
|
@just cp_std "sys/time/mod.rs"
|
|
@just cp_std "sys/time/unsupported.rs"
|
|
|
|
@just cp_std "sys/backtrace.rs"
|
|
@just cp_std "sys/cmath.rs"
|
|
@just cp_std "sys/configure_builtins.rs"
|
|
@just cp_std "sys/env_consts.rs"
|
|
@just cp_std "sys/exit.rs"
|
|
@just cp_std "sys/mod.rs"
|
|
|
|
@# Complete
|
|
ln -fs {{ RUST_SRC / "std/src/thread" }} "std/src/"
|
|
|
|
build-sysroot: update-std
|
|
RUSTFLAGS="-Zforce-unstable-if-unmarked -C relocation-model=pic -C link-arg=-pie" cargo build --target ../riscv64.json
|
|
mkdir ../sysroot/lib/rustlib/riscv64/lib -p
|
|
rm ../sysroot/lib/rustlib/riscv64/lib/* -rf
|
|
cp target/riscv64/debug/deps/*.rlib ../sysroot/lib/rustlib/riscv64/lib
|
|
|
|
clean:
|
|
cargo clean
|
|
rm ../sysroot/lib/rustlib/riscv64/lib/* -rf
|
|
|
|
rm -f alloc
|
|
rm -f compiler-builtins
|
|
rm -f panic_abort
|
|
rm -f panic_unwind
|
|
rm -f windows_link
|
|
rm -f portable-simd
|
|
rm -f unwind
|
|
rm -f std_detect
|
|
rm -f stdarch
|
|
rm -f rustc-std-workspace-alloc
|
|
rm -f rustc-std-workspace-core
|
|
rm -f proc_macro
|
|
rm -f profiler_builtins
|
|
rm -f test
|
|
|
|
rm -rf std/src/backtrace
|
|
rm -rf std/src/thread
|
|
rm -rf std/src/sync
|
|
rm -rf std/src/collections
|
|
rm -rf std/src/ffi
|
|
rm -rf std/src/fs
|
|
rm -rf std/src/num
|
|
rm -rf std/src/net
|
|
rm -rf std/src/io
|
|
rm -rf std/src/hash
|
|
rm -rf std/src/prelude
|
|
rm -rf std/src/process
|
|
|
|
# rm -f Cargo.toml
|