amezin/vscode-linux-kernel

Doesn't work for out-of-tree builds

marmistrz opened this issue · 0 comments

For instance, during Android Linux kernel development, the builds are usually done by a make bootimage is the global repo-workspace. (repo is an Android-specific tool for managing multiple git repositories) This builds the kernel with proper flags and configuration. This affects the paths. For instance:

repo workspace: /path/to/lineage-src
kernel repository and the VS Code workspace: /path/to/lineage-src/kernel/fxtec/msm8998
build artifacts: /path/to/lineage-src/out/target/product/pro1/obj/KERNEL_OBJ/usr/.initramfs_data.cpio.gz.cmd

However, the python script expects the cmd files to be present in the current working directory tree. One can change directory to point to some build artifact directory, but then the relative paths are incorrect. Trying to correct them manually causes some include path errors.

Out of tree builds are nothing new for the Linux kernel and are not Android-specific: https://lwn.net/Articles/90818/


Note: I tried playing around with includePath but it after arriving at:

            "includePath": [
                "${workspaceFolder}/include",
                "${workspaceFolder}/arch/arm64/include",
                "/path/to/lineage/out/target/product/pro1/obj/KERNEL_OBJ/arch/arm64/include/",
                "/path/to/lineage/out/target/product/pro1/obj/KERNEL_OBJ/arch/arm64/include/generated",
                "/path/to/lineage/out/target/product/pro1/obj/KERNEL_OBJ/include/",
                "/path/to/lineage/out/soong/ndk/sysroot/usr/include"
            ]

I ended up having errors like function type is not allowed for bool inside a definition of a struct, so something is completely wrong here


To reproduce, follow https://wiki.lineageos.org/devices/pro1/build, instead of the Start the build step, execute make bootimage in the root of the LineageOS tree. You can probably use some different device, the outcome should be the same.

Here's my compile commands, both vanilla and with paths adjusted.

compile_commands.json.zip
compile_commands_patched.json.zip


EDIT: the following contents of c_cpp_properties.json worked for me:

{
    "configurations": [
        {
            "name": "Linux",
            "cStandard": "c11",
            "intelliSenseMode": "gcc-x64",
            "compileCommands": "${workspaceFolder}/compile_commands.json",
            "defines": ["__KERNEL__"],
            "includePath": [
                "${workspaceFolder}/include",
                "${workspaceFolder}/arch/arm64/include",
                "/marcin/proj/lineage/out/target/product/pro1/obj/KERNEL_OBJ/arch/arm64/include/",
                "/marcin/proj/lineage/out/target/product/pro1/obj/KERNEL_OBJ/arch/arm64/include/generated",
                "/marcin/proj/lineage/out/target/product/pro1/obj/KERNEL_OBJ/include/",
                "/marcin/proj/lineage/out/soong/ndk/sysroot/usr/include"
            ]
        }
    ],
    "version": 4
}