1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
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")'
|