diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2024-09-16 14:07:41 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2024-09-17 08:58:55 +0200 |
| commit | 8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a (patch) | |
| tree | 5e215dd93c34b3d58c287b036ad2d190e0a9a772 | |
| parent | c16a3739649fa15178df667d610553e93db83e4c (diff) | |
| download | teachos-8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a.tar.xz teachos-8f9b9cd8aac30572b7e275bbeb1b32d2cbb8950a.zip | |
build: migrate away from conan
| -rw-r--r-- | .clang-format (renamed from source/.clang-format) | 0 | ||||
| -rw-r--r-- | .devcontainer/x86-64/devcontainer.json | 11 | ||||
| -rw-r--r-- | .vscode/settings.json | 2 | ||||
| -rw-r--r-- | CMakeLists.txt (renamed from source/CMakeLists.txt) | 6 | ||||
| -rw-r--r-- | CMakePresets.json | 26 | ||||
| -rw-r--r-- | README.rst | 50 | ||||
| -rw-r--r-- | arch/x86_64/CMakeLists.txt (renamed from source/arch/x86_64/CMakeLists.txt) | 0 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/boot/pointers.hpp (renamed from source/arch/x86_64/include/arch/boot/pointers.hpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/io/port_io.hpp (renamed from source/arch/x86_64/include/arch/io/port_io.hpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/kernel/main.hpp (renamed from source/arch/x86_64/include/arch/kernel/main.hpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/video/vga/io.hpp (renamed from source/arch/x86_64/include/arch/video/vga/io.hpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/video/vga/text.hpp (renamed from source/arch/x86_64/include/arch/video/vga/text.hpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld (renamed from source/arch/x86_64/scripts/kernel.ld) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/boot/boot.s (renamed from source/arch/x86_64/src/boot/boot.s) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/boot/crti.s (renamed from source/arch/x86_64/src/boot/crti.s) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/boot/crtn.s (renamed from source/arch/x86_64/src/boot/crtn.s) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/boot/multiboot.s (renamed from source/arch/x86_64/src/boot/multiboot.s) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp (renamed from source/arch/x86_64/src/kernel/main.cpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/src/video/vga/text.cpp (renamed from source/arch/x86_64/src/video/vga/text.cpp) | 0 | ||||
| -rw-r--r-- | arch/x86_64/support/grub.cfg.in (renamed from source/arch/x86_64/support/grub.cfg.in) | 0 | ||||
| -rw-r--r-- | cmake/Modules/FindSphinx.cmake (renamed from source/cmake/Modules/FindSphinx.cmake) | 0 | ||||
| -rw-r--r-- | cmake/Modules/Findgrub-mkrescue.cmake (renamed from source/cmake/Modules/Findgrub-mkrescue.cmake) | 0 | ||||
| -rw-r--r-- | cmake/Platforms/x86_64.cmake (renamed from source/cmake/Platforms/x86_64.cmake) | 10 | ||||
| -rw-r--r-- | conanfile.py | 62 | ||||
| -rw-r--r-- | include/memory/asm_pointer.hpp (renamed from source/include/memory/asm_pointer.hpp) | 0 | ||||
| -rw-r--r-- | requirements.txt | 6 | ||||
| -rw-r--r-- | src/kernel/main.cpp (renamed from source/src/kernel/main.cpp) | 0 |
27 files changed, 57 insertions, 116 deletions
diff --git a/source/.clang-format b/.clang-format index d4da962..d4da962 100644 --- a/source/.clang-format +++ b/.clang-format diff --git a/.devcontainer/x86-64/devcontainer.json b/.devcontainer/x86-64/devcontainer.json new file mode 100644 index 0000000..3c88eae --- /dev/null +++ b/.devcontainer/x86-64/devcontainer.json @@ -0,0 +1,11 @@ +{ + "image": "registry.gitlab.ost.ch:45023/teachos/devcontainers/x86-64:14.2.0", + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools" + ] + } + } +} diff --git a/.vscode/settings.json b/.vscode/settings.json index f7a4d59..21d4f5f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { - "cmake.sourceDirectory": "/home/sophia/Projects/os/teachos/kernel/source", "cmake.useCMakePresets": "always", + "cmake.options.statusBarVisibility": "visible", "C_Cpp.autoAddFileAssociations": false, "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", diff --git a/source/CMakeLists.txt b/CMakeLists.txt index beb0c07..c51ffb9 100644 --- a/source/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION YES) +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules") + +set(CMAKE_CXX_STANDARD "20") +set(CMAKE_CXX_STANDARD_REQUIRED YES) +set(CMAKE_CXX_EXTENSIONS NO) + #[============================================================================[ # Documentation #]============================================================================] diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..ecac6fb --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,26 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "binaryDir": "${sourceDir}/build", + "generator": "Ninja Multi-Config", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Debug;MinSizeRel", + "CMAKE_TOOLCHAIN_FILE": "cmake/Platforms/x86_64.cmake" + } + } + ], + "buildPresets": [ + { + "name": "debug", + "configurePreset": "default", + "configuration": "Debug" + }, + { + "name": "release", + "configurePreset": "default", + "configuration": "MinSizeRel" + } + ] +} @@ -11,59 +11,17 @@ Development Development happens primarily on Linux. Other platforms (e.g. Windows, macOS) may allow building of the kernel as well, however at the time of this writing they are not officially supported. -To manage the toolchain and dependencies of the kernel, conan is used as a package manager. Required Tools ~~~~~~~~~~~~~~ -In orer to build the kernel, the following tools are required: +In order to build the kernel, the following tools are required: -- Python 3 to run conan -- A C and C++ toolchain to build the kernel toolchain -- GRUB2 to build the bootable ISO image +- Docker to run the development container +- Visual Studio Code for development Setup ~~~~~ -Create an activate a Python virtual environment, for example by using the ``venv`` module: +Open this directory in Visual Studio Code and then reopen the project in the development container -.. code-block:: bash - - $ python -m venv .venv - $ source .venv/bin/activate - -With the virtual environment activated, install the required Python package from the ``requirements.txt`` file: - -.. code-block:: bash - - $ pip install -r requirements.txt - -Next, prepare the default conan profile and install the required packages (note: the example below assumes x86_64 is being targeted as the kernel's platform): - -.. code-block:: bash - - $ conan profile new --detect default - $ conan install -if .conan/install -pr:b default -pr:h .conan/profiles/x86_64-gcc -b missing - -The second command may need to be rerun in case the conan dependencies change. - -Building -~~~~~~~~ - -With the setup performed, the kernel can now be built: - -.. code-block:: bash - - $ conan build -if .conan/install . - -Developing in an IDE -~~~~~~~~~~~~~~~~~~~~ - -This repository includes a configuration for Visual Studio Code. -In order to work on the kernel from within Visual Studio Code, activation of the conan build environment is required: - -.. code-block:: bash - - $ source build/generators/conanbuild.sh - -Afterward the IDE can be started from the same shell and will automatically pick up the required environment variables. diff --git a/source/arch/x86_64/CMakeLists.txt b/arch/x86_64/CMakeLists.txt index 6ff1332..6ff1332 100644 --- a/source/arch/x86_64/CMakeLists.txt +++ b/arch/x86_64/CMakeLists.txt diff --git a/source/arch/x86_64/include/arch/boot/pointers.hpp b/arch/x86_64/include/arch/boot/pointers.hpp index dcd14fe..dcd14fe 100644 --- a/source/arch/x86_64/include/arch/boot/pointers.hpp +++ b/arch/x86_64/include/arch/boot/pointers.hpp diff --git a/source/arch/x86_64/include/arch/io/port_io.hpp b/arch/x86_64/include/arch/io/port_io.hpp index 5b61f90..5b61f90 100644 --- a/source/arch/x86_64/include/arch/io/port_io.hpp +++ b/arch/x86_64/include/arch/io/port_io.hpp diff --git a/source/arch/x86_64/include/arch/kernel/main.hpp b/arch/x86_64/include/arch/kernel/main.hpp index 6961594..6961594 100644 --- a/source/arch/x86_64/include/arch/kernel/main.hpp +++ b/arch/x86_64/include/arch/kernel/main.hpp diff --git a/source/arch/x86_64/include/arch/video/vga/io.hpp b/arch/x86_64/include/arch/video/vga/io.hpp index 9226c5c..9226c5c 100644 --- a/source/arch/x86_64/include/arch/video/vga/io.hpp +++ b/arch/x86_64/include/arch/video/vga/io.hpp diff --git a/source/arch/x86_64/include/arch/video/vga/text.hpp b/arch/x86_64/include/arch/video/vga/text.hpp index 1e584d6..1e584d6 100644 --- a/source/arch/x86_64/include/arch/video/vga/text.hpp +++ b/arch/x86_64/include/arch/video/vga/text.hpp diff --git a/source/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 765a432..765a432 100644 --- a/source/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld diff --git a/source/arch/x86_64/src/boot/boot.s b/arch/x86_64/src/boot/boot.s index 7b4e193..7b4e193 100644 --- a/source/arch/x86_64/src/boot/boot.s +++ b/arch/x86_64/src/boot/boot.s diff --git a/source/arch/x86_64/src/boot/crti.s b/arch/x86_64/src/boot/crti.s index 26878fe..26878fe 100644 --- a/source/arch/x86_64/src/boot/crti.s +++ b/arch/x86_64/src/boot/crti.s diff --git a/source/arch/x86_64/src/boot/crtn.s b/arch/x86_64/src/boot/crtn.s index 06fb7ce..06fb7ce 100644 --- a/source/arch/x86_64/src/boot/crtn.s +++ b/arch/x86_64/src/boot/crtn.s diff --git a/source/arch/x86_64/src/boot/multiboot.s b/arch/x86_64/src/boot/multiboot.s index 7ccca56..7ccca56 100644 --- a/source/arch/x86_64/src/boot/multiboot.s +++ b/arch/x86_64/src/boot/multiboot.s diff --git a/source/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index 0e90264..0e90264 100644 --- a/source/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp diff --git a/source/arch/x86_64/src/video/vga/text.cpp b/arch/x86_64/src/video/vga/text.cpp index f1e7412..f1e7412 100644 --- a/source/arch/x86_64/src/video/vga/text.cpp +++ b/arch/x86_64/src/video/vga/text.cpp diff --git a/source/arch/x86_64/support/grub.cfg.in b/arch/x86_64/support/grub.cfg.in index 86674dd..86674dd 100644 --- a/source/arch/x86_64/support/grub.cfg.in +++ b/arch/x86_64/support/grub.cfg.in diff --git a/source/cmake/Modules/FindSphinx.cmake b/cmake/Modules/FindSphinx.cmake index a0a1c31..a0a1c31 100644 --- a/source/cmake/Modules/FindSphinx.cmake +++ b/cmake/Modules/FindSphinx.cmake diff --git a/source/cmake/Modules/Findgrub-mkrescue.cmake b/cmake/Modules/Findgrub-mkrescue.cmake index 036b4fa..036b4fa 100644 --- a/source/cmake/Modules/Findgrub-mkrescue.cmake +++ b/cmake/Modules/Findgrub-mkrescue.cmake diff --git a/source/cmake/Platforms/x86_64.cmake b/cmake/Platforms/x86_64.cmake index 2d419a4..291cbaa 100644 --- a/source/cmake/Platforms/x86_64.cmake +++ b/cmake/Platforms/x86_64.cmake @@ -1,4 +1,4 @@ -execute_process(COMMAND "x86_64-none-elf-g++" "-print-file-name=crtbegin.o" +execute_process(COMMAND "x86_64-elf-g++" "-print-file-name=crtbegin.o" OUTPUT_VARIABLE CRT_BEGIN ERROR_QUIET ) @@ -8,6 +8,13 @@ mark_as_advanced(CRT_BEGIN) string(REGEX REPLACE "/crtbegin.o" "" CMAKE_SYSROOT "${CRT_BEGIN}") mark_as_advanced(CMAKE_SYSROOT) +set(SYSTEM_NAME "Generic") + +set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + +set(CMAKE_C_COMPILER "x86_64-elf-gcc") +set(CMAKE_CXX_COMPILER "x86_64-elf-g++") + set(CMAKE_CXX_FLAGS_INIT "-m64 -mno-red-zone -mcmodel=large -fno-exceptions -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3") set(CMAKE_ASM_FLAGS_DEBUG "-ggdb3") @@ -23,5 +30,6 @@ set(CMAKE_CXX_LINK_EXECUTABLE <OBJECTS> \ -o <TARGET> \ <LINK_LIBRARIES> \ + -lgcc \ ${CMAKE_SYSROOT}/crtend.o" )
\ No newline at end of file diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 9b1d4d3..0000000 --- a/conanfile.py +++ /dev/null @@ -1,62 +0,0 @@ -from conan import ConanFile -from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.env import VirtualBuildEnv - - -class KernelConan(ConanFile): - name = "kernel" - description = "The kernel of TeachOS" - version = "0.0.1" - package_type = "application" - homepage = "https://gitlab.ost.ch/teachos/kernel" - - settings = [ - "arch", - "build_type", - "compiler", - ] - - tool_requires = [ - "cmake/[~3.27]", - "doxygen/[~1.9]", - "gcc/13.2.0@teachos/stable", - "ninja/[~1.11]", - ] - - def build(self): - cmake = CMake(self) - cmake.configure() - if self.settings.arch == "x86_64": - cmake.build(target="bootable-iso") - else: - cmake.build() - - def generate(self): - build_environment = VirtualBuildEnv(self) - build_environment.generate() - - dependencies = CMakeDeps(self) - dependencies.generate() - - toolchain = CMakeToolchain(self, generator="Ninja Multi-Config") - toolchain.cache_variables["CMAKE_TRY_COMPILE_TARGET_TYPE"] = "STATIC_LIBRARY" - toolchain.variables["TEACHOS_DESCRIPTION"] = self.description - toolchain.variables["TEACHOS_HOMEPAGE_URL"] = self.homepage - toolchain.variables["TEACHOS_VERSION"] = self.version - toolchain.blocks["teachos_cmake_modules"] = CMakeModulesPathBlock - toolchain.blocks["teachos_cmake_modules"].values["root"] = self.source_folder - toolchain.blocks["teachos_platform"] = PlatformIncludeBlock - toolchain.blocks["teachos_platform"].values["platform"] = self.settings.arch - toolchain.blocks.remove("cmake_flags_init") - toolchain.blocks.remove("arch_flags") - toolchain.generate() - - def layout(self): - cmake_layout(self, src_folder="source", generator="Ninja Multi-Config") - - -class PlatformIncludeBlock: - template = 'include("{{platform}}")' - -class CMakeModulesPathBlock: - template = 'list(APPEND CMAKE_MODULE_PATH "{{root}}/cmake/Modules" "{{root}}/cmake/Platforms")' diff --git a/source/include/memory/asm_pointer.hpp b/include/memory/asm_pointer.hpp index 9ec2218..9ec2218 100644 --- a/source/include/memory/asm_pointer.hpp +++ b/include/memory/asm_pointer.hpp diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5468185..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -black>=23 -conan~=1.61 -mypy~=1.5 -sphinx>=6,<7 -breathe~=4.35 -sphinx-book-theme~=1.0
\ No newline at end of file diff --git a/source/src/kernel/main.cpp b/src/kernel/main.cpp index 07a9955..07a9955 100644 --- a/source/src/kernel/main.cpp +++ b/src/kernel/main.cpp |
