clion 阅读 linux kernel wsl
发布于
Top
linux

https://github.com/microsoft/WSL2-Linux-Kernel

下面 Build Instructions,加上个编译时缺少的 bc

apt install build-essential flex bison dwarves libssl-dev libelf-dev bc 
make KCONFIG_CONFIG=Microsoft/config-wsl

bear make zImage

在内核源码目录下生成compile_commands.json. 记录完整的编译过程

生成CMakeLists.txt

apt install ruby

git clone https://github.com/habemus-papadum/kernel-grok.git

cd WSL2-Linux-Kernel-linux-xx

../kernel-grok/generate_cmake

打开CMakeLists.txt,添加:

SET(CMAKE_C_COMPILER "gcc")
include_directories(".")
include_directories("./include")

所有不支持cmake的传统c/c++项目都可以通过这种方式来导入,至少代码编写,阅读可以流畅许多