Skip to content

Commit

Permalink
build: Remove DragonOS_GCC And make CI use docker image (#954)
Browse files Browse the repository at this point in the history
* build: 不再需要x86_64-elf-gcc的支持
* ci: 添加ci用的docker镜像
* 切换workflow到构建用的容器上

---------

Signed-off-by: longjin <[email protected]>
  • Loading branch information
fslongjin authored Oct 9, 2024
1 parent 1bd12bc commit 415e46e
Show file tree
Hide file tree
Showing 37 changed files with 258 additions and 919 deletions.
36 changes: 0 additions & 36 deletions .github/actions/import-toolchain/action.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/actions/install-apt-packages/action.yml

This file was deleted.

94 changes: 0 additions & 94 deletions .github/workflows/cache-toolchain.yml

This file was deleted.

38 changes: 18 additions & 20 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,65 @@ on:
branches: [ "master", "feat-*", "fix-*"]

jobs:
# ensure the toolchain is cached
ensure-toolchain:
uses: ./.github/workflows/cache-toolchain.yml

format-check:
name: Format check ${{ matrix.arch }}
runs-on: ubuntu-latest
needs: [ensure-toolchain]
continue-on-error: true
container: dragonos/dragonos-dev:v1.3

strategy:
matrix:
arch: [x86_64, riscv64]

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.3"
- uses: actions/checkout@v3

- uses: ./.github/actions/import-toolchain

- name: Format check
env:
ARCH: ${{ matrix.arch }}
HOME: /root
shell: bash -ileo pipefail {0}
run: |
printf "\n" >> kernel/src/include/bindings/bindings.rs
FMT_CHECK=1 make fmt
kernel-static-test:
name: Kernel static test ${{ matrix.arch }}
runs-on: ubuntu-latest
needs: [ensure-toolchain]
continue-on-error: true
container: dragonos/dragonos-dev:v1.3

strategy:
matrix:
arch: [x86_64, riscv64]

steps:
- uses: actions/checkout@v3
- run: echo "Running in dragonos/dragonos-dev:v1.3"

- uses: ./.github/actions/import-toolchain
- uses: actions/checkout@v3

- name: Run kernel static test
shell: bash -ileo pipefail {0}
env:
ARCH: ${{ matrix.arch }}
run: bash -c "source ~/.cargo/env && cd kernel && make test"

HOME: /root
run: bash -c "source /root/.cargo/env && cd kernel && make test"

build-x86_64:

runs-on: ubuntu-latest
needs: [ensure-toolchain]
container: dragonos/dragonos-dev:v1.3

steps:
- uses: actions/checkout@v3
- run: echo "Running in dragonos/dragonos-dev:v1.3"

- uses: ./.github/actions/import-toolchain


- uses: actions/checkout@v3
- name: build the DragonOS
env:
ARCH: x86_64
HOME: /root
shell: bash -ileo pipefail {0}

run: |
Expand All @@ -77,23 +75,23 @@ jobs:
make -j $(nproc)
build-riscv64:

runs-on: ubuntu-latest
needs: [ensure-toolchain]
container: dragonos/dragonos-dev:v1.3

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.3"

- uses: actions/checkout@v3
with:
submodules: 'recursive'

- uses: ./.github/actions/import-toolchain

- name: build the DragonOS
shell: bash -ileo pipefail {0}
env:
ARCH: riscv64
HOME: /root

run: source ~/.bashrc && source ~/.cargo/env && make kernel -j $(nproc)

37 changes: 37 additions & 0 deletions .github/workflows/publish-dragonos-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish Docker images

on:
workflow_dispatch:
push:
paths:
- tools/BUILD_CONTAINER_VERSION

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions/checkout@v4

- name: Fetch versions in the repo
id: fetch-versions
run: |
BUILD_CONTAINER_VERSION=$(cat tools/BUILD_CONTAINER_VERSION)
echo "build_container_version=$BUILD_CONTAINER_VERSION" >> "$GITHUB_OUTPUT"
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./tools/Dockerfile
platforms: linux/amd64
push: true
tags: dragonos/dragonos-dev:${{ steps.fetch-versions.outputs.build_container_version }}
4 changes: 0 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"glib.h": "c",
"asm.h": "c",
"memory.h": "c",
"multiboot2.h": "c",
"kprint.h": "c",
"ptrace.h": "c",
"mouse.h": "c",
Expand Down Expand Up @@ -77,7 +76,6 @@
"cstdbool": "c",
"typeinfo": "c",
"unistd.h": "c",
"syscall_num.h": "c",
"stdint.h": "c",
"syscall.h": "c",
"fcntl.h": "c",
Expand Down Expand Up @@ -121,9 +119,7 @@
"dirent.h": "c",
"cmd_help.h": "c",
"wait.h": "c",
"__libc__.h": "c",
"ctype.h": "c",
"mmio.h": "c",
"stdint-gcc.h": "c",
"acpi.h": "c",
"assert.h": "c",
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/kernel_build/src/cfiles/arch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::{collections::HashSet, path::PathBuf};

use cc::Build;

Expand All @@ -13,9 +13,9 @@ pub(super) trait CFilesArch {
/// 设置架构相关的宏定义
fn setup_defines(&self, c: &mut Build);
/// 设置架构相关的全局包含目录
fn setup_global_include_dir(&self, c: &mut Build);
fn setup_global_include_dir(&self, c: &mut HashSet<PathBuf>);
/// 设置需要编译的架构相关的文件
fn setup_files(&self, c: &mut Build, files: &mut Vec<PathBuf>);
fn setup_files(&self, c: &mut Build, files: &mut HashSet<PathBuf>);

/// 设置架构相关的全局编译标志
fn setup_global_flags(&self, c: &mut Build);
Expand Down
21 changes: 11 additions & 10 deletions build-scripts/kernel_build/src/cfiles/arch/riscv64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::{collections::HashSet, path::PathBuf};

use crate::{constant::ARCH_DIR_RISCV64, utils::FileUtils};

Expand All @@ -12,17 +12,18 @@ impl CFilesArch for RiscV64CFilesArch {
c.define("__riscv", None);
}

fn setup_global_include_dir(&self, c: &mut cc::Build) {
c.include("src/arch/riscv64/include");
fn setup_global_include_dir(&self, include_dirs: &mut HashSet<PathBuf>) {
include_dirs.insert("src/arch/riscv64/include".into());
}

fn setup_files(&self, _c: &mut cc::Build, files: &mut Vec<std::path::PathBuf>) {
files.push(PathBuf::from("src/arch/riscv64/asm/head.S"));
files.append(&mut FileUtils::list_all_files(
&arch_path("asm"),
Some("c"),
true,
));
fn setup_files(&self, _c: &mut cc::Build, files: &mut HashSet<PathBuf>) {
files.insert(PathBuf::from("src/arch/riscv64/asm/head.S"));

FileUtils::list_all_files(&arch_path("asm"), Some("c"), true)
.into_iter()
.for_each(|f| {
files.insert(f);
});
}

fn setup_global_flags(&self, c: &mut cc::Build) {
Expand Down
Loading

0 comments on commit 415e46e

Please sign in to comment.