Skip to content

Commit

Permalink
Merge pull request Simple-XX#108 from MRNIU/master
Browse files Browse the repository at this point in the history
update mastar
  • Loading branch information
MRNIU authored Jan 17, 2022
2 parents cb7a5dd + bbf6b11 commit 3cc3a83
Show file tree
Hide file tree
Showing 72 changed files with 1,799 additions and 1,395 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
Expand Down Expand Up @@ -89,7 +89,7 @@ KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
Expand Down
127 changes: 81 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,78 +17,113 @@ jobs:
build_osx:
runs-on: macos-latest

steps:
- name: get code
uses: actions/checkout@v2

- name: setup toolchain
shell: bash
run: |
brew install x86_64-elf-gcc
brew tap riscv/riscv
brew install riscv-tools
- name: make build dir
shell: bash
run: |
mkdir ${{github.workspace}}/build
- name: osx-i386
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=x86_64-elf- -DCMAKE_C_COMPILER=x86_64-elf-gcc -DCMAKE_CXX_COMPILER=x86_64-elf-g++ -DARCH=i386 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
make
rm -rf ./*
- name: osx-x86_64
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=x86_64-elf- -DCMAKE_C_COMPILER=x86_64-elf-gcc -DCMAKE_CXX_COMPILER=x86_64-elf-g++ -DARCH=x86_64 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
make
rm -rf ./*
- name: osx-riscv64
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=riscv64-unknown-elf- -DCMAKE_C_COMPILER=riscv64-unknown-elf-gcc -DCMAKE_CXX_COMPILER=riscv64-unknown-elf-g++ -DARCH=riscv64 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
make
rm -rf ./*
build_ubuntu:
runs-on: ubuntu-latest
needs: [build_osx]
steps:
- name: get code
uses: actions/checkout@v2

- name: setup brew
- name: setup toolchain
shell: bash
run: |
brew install x86_64-elf-binutils
brew install x86_64-elf-gcc
brew tap riscv/riscv
brew install riscv-tools
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu
- name: make build dir
shell: bash
run: |
mkdir ${{github.workspace}}/build
- name: osx-i386
- name: ubuntu-i386
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=x86_64-elf- -DCMAKE_C_COMPILER=x86_64-elf-gcc -DCMAKE_CXX_COMPILER=x86_64-elf-g++ -DCMAKE_OBJCOPY=x86_64-elf-objcpy -DPLATFORM=bochs -DARCH=i386 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
cmake -DTOOLCHAIN_PREFIX= -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DARCH=i386 -DCMAKE_BUILD_TYPE=RELEASE ..
make
rm -rf ./*
- name: osx-x86_64
- name: ubuntu-x86_64
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=x86_64-elf- -DCMAKE_C_COMPILER=x86_64-elf-gcc -DCMAKE_CXX_COMPILER=x86_64-elf-g++ -DCMAKE_OBJCOPY=x86_64-elf-objcpy -DPLATFORM=bochs -DARCH=x86_64 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
cmake -DTOOLCHAIN_PREFIX= -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DARCH=x86_64 -DCMAKE_BUILD_TYPE=RELEASE ..
make
rm -rf ./*
- name: osx-riscv64
- name: ubuntu-riscv64
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake -DTOOLCHAIN_PREFIX=riscv64-unknown-elf- -DCMAKE_C_COMPILER=riscv64-unknown-elf-gcc -DCMAKE_CXX_COMPILER=riscv64-unknown-elf-g++ -DCMAKE_OBJCOPY=riscv64-unknown-elf-objcpy -DPLATFORM=qemu -DARCH=riscv64 -DCMAKE_BUILD_TYPE=RELEASE -DHAVE_FLAG_SEARCH_PATHS_FIRST=0 ..
cmake -DTOOLCHAIN_PREFIX=riscv64-linux-gnu- -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ -DARCH=riscv64 -DCMAKE_BUILD_TYPE=RELEASE ..
make
rm -rf ./*
# build_ubuntu:
# runs-on: ubuntu-latest

# steps:
# - name: Get code
# uses: actions/checkout@v2

# - name: Setup brew
# shell: bash
# run: |
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# brew install make
# brew install cmake
# brew install x86_64-elf-binutils
# brew install x86_64-elf-gcc

# - name: Make build dir
# shell: bash
# run: |
# mkdir ${{github.workspace}}/build

# - name: cmake
# shell: bash
# working-directory: ${{github.workspace}}/build
# run: cmake -DTOOLCHAIN_PREFIX=x86_64-elf- -DCMAKE_C_COMPILER=x86_64-elf-gcc -DCMAKE_OBJCOPY=x86_64-elf-objcpy -DPLATFORM=bochs -DARCH=x86_64 ..

# - name: make
# shell: bash
# working-directory: ${{github.workspace}}/build
# run: make


# build_win:
# runs-on: windows-latest
# build_win:
# runs-on: windows-latest

# auto_pr:
# runs-on: ubuntu-latest
# needs: [build_osx]

# steps:
# - name: get code
# uses: actions/checkout@v2

# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.PAT }}
# commit-message: "[Auto PR]"
# committer: GitHub <[email protected]>
# author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
# signoff: true
# branch: test-patches
# delete-branch: true
# title: '[BOT] Auto PR'
# body: |
# Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
# labels: |
# Auto PR
# assignees: MRNIU
# reviewers: MRNIU
# draft: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ iso
*.iso
*.bin
null.d
tools/opensbi/
tools/aarch64-unknown-linux-gnu*
4 changes: 2 additions & 2 deletions cmake/arch_detector.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ if (ARCH STREQUAL i386)
elseif (ARCH STREQUAL x86_64)
set(SimpleKernelArch ia32/x86_64)
# 其它情况不变
elseif (ARCH STREQUAL arm)
set(SimpleKernelArch arm)
elseif (ARCH STREQUAL aarch64)
set(SimpleKernelArch aarch64)
elseif (ARCH STREQUAL riscv64)
set(SimpleKernelArch riscv64)
else ()
Expand Down
6 changes: 2 additions & 4 deletions cmake/header_files.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

# This file is a part of Simple-XX/SimpleKernel
# (https://github.com/Simple-XX/SimpleKernel).
# This file is a part of Simple-XX/SimpleKernel (https://github.com/Simple-XX/SimpleKernel).
# Based on https://github.com/SynestiaOS/SynestiaOS
# CMakeLists.txt for Simple-XX/SimpleKernel.
# 将头文件路径添加到 Target 的搜索路径中
# header_files.cmake for Simple-XX/SimpleKernel.

function(target_include_libc_header_files Target)
target_include_directories(${Target} PRIVATE ${SimpleKernel_SOURCE_CODE_DIR}/libc/include)
Expand Down
37 changes: 37 additions & 0 deletions cmake/toolchain_linux_aarch64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# This file is a part of Simple-XX/SimpleKernel (https://github.com/Simple-XX/SimpleKernel).
#
# toolchain_linux_aarch64.cmake for Simple-XX/SimpleKernel.

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR AARCH64)

# TODO
# GCC
find_program(GCC aarch64-none-eabi-gcc)
if (NOT GCC)
message(FATAL_ERROR "aarch64-none-eabi-gcc not found.\n"
"Run `brew install aarch64-none-eabi-gcc` to install the toolchain")
else ()
message(STATUS "Found aarch64-none-eabi-gcc ${GCC}")
endif ()

set(TOOLCHAIN_PREFIX aarch64-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_READELF ${TOOLCHAIN_PREFIX}readelf)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib)

# qemu
find_program(QEMU qemu-system-aarch64)
if (NOT QEMU)
message(FATAL_ERROR "qemu not found.\n"
"Please install qemu first.")
else ()
message(STATUS "Found qemu ${QEMU}")
endif ()
40 changes: 0 additions & 40 deletions cmake/toolchain_linux_arm.cmake

This file was deleted.

36 changes: 36 additions & 0 deletions cmake/toolchain_linux_riscv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# This file is a part of Simple-XX/SimpleKernel (https://github.com/Simple-XX/SimpleKernel).
#
# toolchain_linux_riscv.cmake for Simple-XX/SimpleKernel.

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR RISCV)

# GCC
find_program(RISCV riscv64-linux-gnu-g++)
if (NOT RISCV)
message(FATAL_ERROR "riscv64-linux-gnu-gcc not found.\n"
"Run `sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu` to install the toolchain. Then add the bin path to you PATH.")
else ()
message(STATUS "Found riscv64-linux-gnu-gcc ${RISCV}.")
endif ()

set(TOOLCHAIN_PREFIX riscv64-linux-gnu-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_READELF ${TOOLCHAIN_PREFIX}readelf)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar)
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib)

# qemu
find_program(QEMU qemu-system-riscv64)
if (NOT QEMU)
message(FATAL_ERROR "qemu not found.\n"
"Please install qemu-system-riscv64 first.")
else ()
message(STATUS "Found qemu ${QEMU}")
endif ()
34 changes: 15 additions & 19 deletions cmake/toolchain_linux_x86_64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,20 @@ set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# linuxbrew
find_program(BREW brew)
if (NOT BREW)
message(FATAL_ERROR "brew not found.\n"
"Run `/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"` to install linuxbrew")
else ()
message(STATUS "Found brew ${BREW}")
endif ()

# GCC
find_program(GCC x86_64-elf-gcc)
if (NOT GCC)
message(FATAL_ERROR "x86_64-elf-gcc not found.\n"
"Run `brew install x86_64-elf-gcc` to install the toolchain")
find_program(G++ g++)
if (NOT G++)
message(FATAL_ERROR "g++ not found.\n"
"Run `sudo apt-get install -y gcc g++` to install the toolchain")
else ()
message(STATUS "Found x86_64-elf-gcc ${GCC}")
message(STATUS "Found g++ ${G++}")
endif ()

set(TOOLCHAIN_PREFIX x86_64-elf-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)

# xorriso
find_program(XORRISO xorriso)
if (NOT XORRISO)
message(FATAL_ERROR "xorriso not found.\n"
"Run `brew install xorriso` to install the toolchain")
"Run `sudo apt-get install -y xorriso` to install the toolchain")
else ()
message(STATUS "Found xorriso ${XORRISO}")
endif ()
Expand All @@ -55,3 +42,12 @@ if (NOT BOCHS)
else ()
message(STATUS "Found bochs ${BOCHS}")
endif ()

# qemu
find_program(QEMU qemu-system-x86_64)
if (NOT QEMU)
message(FATAL_ERROR "qemu not found.\n"
"Please install qemu first.")
else ()
message(STATUS "Found qemu ${QEMU}")
endif ()
Loading

0 comments on commit 3cc3a83

Please sign in to comment.