mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 07:06:47 +00:00
parent
f09a98329c
commit
9a367aa7eb
55
.github/workflows/cache-toolchain.yml
vendored
Normal file
55
.github/workflows/cache-toolchain.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
name: Reusable workflow example
|
||||||
|
|
||||||
|
on: workflow_call
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache DragonOS GCC
|
||||||
|
id: cache-dragonos-gcc
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-dragonos-gcc
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/opt
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
|
||||||
|
|
||||||
|
- if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
|
||||||
|
name: build dragonos-gcc
|
||||||
|
continue-on-error: true
|
||||||
|
run: bash tools/build_gcc_toolchain.sh -f
|
||||||
|
|
||||||
|
- name: Cache build tools
|
||||||
|
id: cache-build-tools
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-build-tools
|
||||||
|
dadk_version: 0.1.2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo
|
||||||
|
~/.rustup
|
||||||
|
~/.bashrc
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
|
||||||
|
|
||||||
|
- if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
|
||||||
|
name: Install toolchain
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev pkg-config"
|
||||||
|
cargo install cargo-binutils
|
||||||
|
rustup toolchain install nightly
|
||||||
|
rustup default nightly
|
||||||
|
rustup component add rust-src
|
||||||
|
rustup component add llvm-tools-preview
|
||||||
|
rustup target add x86_64-unknown-none
|
||||||
|
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
|
||||||
|
rustup component add rustfmt
|
||||||
|
cargo install dadk --version 0.1.2
|
||||||
|
|
18
.github/workflows/makefile.yml
vendored
18
.github/workflows/makefile.yml
vendored
@ -7,9 +7,14 @@ on:
|
|||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# ensure the toolchain is cached
|
||||||
|
ensure-toolchain:
|
||||||
|
uses: ./.github/workflows/cache-toolchain.yml
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ensure-toolchain]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -24,28 +29,19 @@ jobs:
|
|||||||
~/opt
|
~/opt
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('tools/build_gcc_toolchain.sh') }}
|
||||||
|
|
||||||
- if: ${{ steps.cache-dragonos-gcc.outputs.cache-hit != 'true' }}
|
|
||||||
name: build dragonos-gcc
|
|
||||||
continue-on-error: true
|
|
||||||
run: bash tools/build_gcc_toolchain.sh -f
|
|
||||||
|
|
||||||
- name: Cache build tools
|
- name: Cache build tools
|
||||||
id: cache-build-tools
|
id: cache-build-tools
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
env:
|
env:
|
||||||
cache-name: cache-build-tools
|
cache-name: cache-build-tools
|
||||||
dadk_version: 0.1.1
|
dadk_version: 0.1.2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo
|
~/.cargo
|
||||||
~/.rustup
|
~/.rustup
|
||||||
~/.bashrc
|
~/.bashrc
|
||||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/makefile.yml') }}
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
|
||||||
|
|
||||||
- if: ${{ steps.cache-build-tools.outputs.cache-hit != 'true' }}
|
|
||||||
name: Install toolchain
|
|
||||||
continue-on-error: true
|
|
||||||
run: sudo sh -c "apt update && apt install -y llvm-dev libclang-dev clang gcc-multilib libssl-dev" && cargo install cargo-binutils && rustup toolchain install nightly && rustup default nightly && rustup component add rust-src && rustup component add llvm-tools-preview && rustup target add x86_64-unknown-none && rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu && cargo install dadk --version 0.1.1
|
|
||||||
|
|
||||||
- name: build the DragonOS
|
- name: build the DragonOS
|
||||||
run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) "
|
run: bash -c "source ~/.cargo/env && export DragonOS_GCC=$HOME/opt/dragonos-gcc/gcc-x86_64-unknown-none/bin && make -j $(nproc) "
|
||||||
|
40
.github/workflows/rustfmt.yml
vendored
Normal file
40
.github/workflows/rustfmt.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: Rust format check
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# ensure the toolchain is cached
|
||||||
|
ensure-toolchain:
|
||||||
|
uses: ./.github/workflows/cache-toolchain.yml
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
name: check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ensure-toolchain]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Cache build tools
|
||||||
|
id: cache-build-tools
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-build-tools
|
||||||
|
dadk_version: 0.1.2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo
|
||||||
|
~/.rustup
|
||||||
|
~/.bashrc
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.dadk_version }}-${{ hashFiles('.github/workflows/cache-toolchain.yml') }}
|
||||||
|
|
||||||
|
# 准备 bindings.rs
|
||||||
|
# 由于 bindings.rs 是在 build.rs 中生成的,而这里为了方便,直接 touch 一个空文件
|
||||||
|
- name: prepare bindings
|
||||||
|
run: |
|
||||||
|
printf "\n" >> kernel/src/include/bindings/bindings.rs
|
||||||
|
printf "\n" >> user/libs/libc/src/include/internal/bindings/bindings.rs
|
||||||
|
|
||||||
|
- name: Check format
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,3 +15,5 @@ user/sys_api_lib
|
|||||||
docs/_build
|
docs/_build
|
||||||
draft
|
draft
|
||||||
cppcheck.xml
|
cppcheck.xml
|
||||||
|
/target/
|
||||||
|
Cargo.lock
|
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
members = [
|
||||||
|
"kernel",
|
||||||
|
"user/libs/libc/",
|
||||||
|
]
|
@ -38,7 +38,7 @@ kernel_rust:
|
|||||||
all: kernel
|
all: kernel
|
||||||
|
|
||||||
@echo "Linking kernel..."
|
@echo "Linking kernel..."
|
||||||
$(LD) -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") ../target/x86_64-unknown-none/release/libdragonos_kernel.a -T link.lds
|
$(LD) -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") $(ROOT_PATH)/target/x86_64-unknown-none/release/libdragonos_kernel.a -T link.lds
|
||||||
# 生成kallsyms
|
# 生成kallsyms
|
||||||
current_dir=$(pwd)
|
current_dir=$(pwd)
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ all: kernel
|
|||||||
# 重新链接
|
# 重新链接
|
||||||
@echo "Re-Linking kernel..."
|
@echo "Re-Linking kernel..."
|
||||||
@echo $(shell find . -name "*.o")
|
@echo $(shell find . -name "*.o")
|
||||||
$(LD) -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") ../target/x86_64-unknown-none/release/libdragonos_kernel.a ./debug/kallsyms.o -T link.lds
|
$(LD) -b elf64-x86-64 -z muldefs -o kernel head.o main.o $(shell find . -name "*.o") $(ROOT_PATH)/target/x86_64-unknown-none/release/libdragonos_kernel.a ./debug/kallsyms.o -T link.lds
|
||||||
@echo "Generating kernel ELF file..."
|
@echo "Generating kernel ELF file..."
|
||||||
# 生成内核文件
|
# 生成内核文件
|
||||||
$(OBJCOPY) -I elf64-x86-64 -O elf64-x86-64 kernel ../../bin/kernel/kernel.elf
|
$(OBJCOPY) -I elf64-x86-64 -O elf64-x86-64 kernel ../../bin/kernel/kernel.elf
|
||||||
|
@ -664,7 +664,6 @@ impl Syscall {
|
|||||||
Ok(pipefd) => Self::pipe(pipefd),
|
Ok(pipefd) => Self::pipe(pipefd),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYS_UNLINK_AT => {
|
SYS_UNLINK_AT => {
|
||||||
|
@ -95,7 +95,7 @@ sys_api_lib: sys_api_lib_stage_1
|
|||||||
mkdir -p $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
mkdir -p $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
||||||
mkdir -p $(OLD_LIBC_INSTALL_PATH)/include
|
mkdir -p $(OLD_LIBC_INSTALL_PATH)/include
|
||||||
mkdir -p $(OLD_LIBC_INSTALL_PATH)/lib
|
mkdir -p $(OLD_LIBC_INSTALL_PATH)/lib
|
||||||
$(AR) x $(ROOT_PATH)/user/libs/libc/target/x86_64-unknown-none/release/liblibc.a --output=$(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
$(AR) x $(ROOT_PATH)/target/x86_64-unknown-none/release/liblibc.a --output=$(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
||||||
$(AR) crvs $(OLD_LIBC_INSTALL_PATH)/lib/libc.a $(shell find ./libs/* -name "*.o") $(shell find $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp/* -name "*.o")
|
$(AR) crvs $(OLD_LIBC_INSTALL_PATH)/lib/libc.a $(shell find ./libs/* -name "*.o") $(shell find $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp/* -name "*.o")
|
||||||
rm -rf $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
rm -rf $(ROOT_PATH)/bin/tmp/user/sys_api_lib_build_tmp
|
||||||
# $(shell find ./libs/* -name "*.o" | xargs -I {} cp {} $(ROOT_PATH)/bin/sysroot/usr/lib/)
|
# $(shell find ./libs/* -name "*.o" | xargs -I {} cp {} $(ROOT_PATH)/bin/sysroot/usr/lib/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user