xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
228 stars 55 forks source link

compile_commands.json not created #184

Closed lewisl closed 1 year ago

lewisl commented 1 year ago

Xmake Version

v2.7.8+20230406

Operating System Version and Architecture

MacOS Venture 13.3

Describe Bug

compile_commands.json is not created in the project .vscode directory.

I had previously manually edited c_cpp_properties.json during my miserable attempt to use CMake (not going back there...).

It looks like this:

    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "cppStandard": "c++14",
            "IntelliSenseMode": "gcc-arm",
            "compilerPath": "/usr/bin/clang",
            "defines": [],
            "macFrameworkPath": [
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
            ],
            "cStandard": "c17",
            "configurationProvider": "ms-vscode.makefile-tools"
        }
    ],
    "version": 4
}```

Does this eliminate the need for the other json file?

### Expected Behavior

The compile_commands.json file should be created in the project .vscode directory per the documentation.

### Project Configuration

target("hex") set_kind("binary") add_files("src/hex.cpp") set_languages("cxx14") set_optimize("faster")


### Additional Information and Error Logs

Note that I also get the dreaded 

Error: there is no registered task type 'cppbuild'. Did you miss installing an extension that provides a corresponding task provider?



But, I can run xmake via the add-in to build and run my code.  So, maybe this message is just wrong?  I have the Microsoft (meh) c++ plugins as well as clangd installed.  I still don't get autocompletion for c++.  I never have--but this is not your issue unless you have some hints.

Thanks!
waruqi commented 1 year ago

Only edit and save xmake.lua to trigger the compile_commands generation, or execute the updateIntelligense command manually

see https://xmake.io/#/plugin/more_plugins?id=configure-intellsence

lewisl commented 1 year ago

First of all, thank you. Didn’t see it in docs, but that is easy. The file is generated.

Now, more problems:

Visual Studio Code refuses to launch the language server, sourcekit-lsp. It tries and the server crashes repeatedly and then VS Code refuses to launch it.

I decided to make a new project in a completely different directory and I used xmake new project command in VS code. It makes a directory structure with a main.cpp, which is hello, world!

Guess what? On Macos Ventura 13.3 this won’t compile!. There is some directory mapping problem I cannot sort out. The compiler can’t find the right wchar.h.

Here is the error message: Executing task: xmake -w

[ 25%]: cache compiling.debug src/main.cpp error: /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/wchar.h:123:15: fatal error: 'wchar.h' file not found

include_next

          ^~~~~~~~~

1 error generated.

in src/main.cpp

But, an INSTANCE of wchar.h is found in the includes directory. But it is looking for a different wchar.h header file.

In the wonderful app codeRunner, which is perfect for single file code, of course it compiles and runs. Only when we do a “mature serious developer” build does it fail. And that is using the trivial default xmake.lua file that is used in the template:

add_rules("mode.debug", "mode.release")

target("one") set_kind("binary") add_files("src/*.cpp")

So, this is all very troubling. Got any suggestions for either problem?

From: ruki @.> Reply-To: xmake-io/xmake-vscode @.> Date: Thursday, April 6, 2023 at 7:59 PM To: xmake-io/xmake-vscode @.> Cc: Lewis Levin @.>, Author @.***> Subject: Re: [xmake-io/xmake-vscode] compile_commands.json not created (Issue #184)

Only edit and save xmake.lua to trigger the compile_commands generation, or execute the updateIntelligense command manually

see https://xmake.io/#/plugin/more_plugins?id=configure-intellsence

— Reply to this email directly, view it on GitHubhttps://github.com/xmake-io/xmake-vscode/issues/184#issuecomment-1499879415, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAIYWLMI63TFTLWY3J24RMLW757JHANCNFSM6AAAAAAWWBIJYQ. You are receiving this because you authored the thread.Message ID: @.***>

lewisl commented 1 year ago

Regarding the compilation problem. With only the command line tools installed and not xcode, clang doesn’t have any path the right includes. Not sure how to fix this.

Will trying installing the massive, unused blob that is Xcode.

From: ruki @.> Reply-To: xmake-io/xmake-vscode @.> Date: Thursday, April 6, 2023 at 7:59 PM To: xmake-io/xmake-vscode @.> Cc: Lewis Levin @.>, Author @.***> Subject: Re: [xmake-io/xmake-vscode] compile_commands.json not created (Issue #184)

Only edit and save xmake.lua to trigger the compile_commands generation, or execute the updateIntelligense command manually

see https://xmake.io/#/plugin/more_plugins?id=configure-intellsence

— Reply to this email directly, view it on GitHubhttps://github.com/xmake-io/xmake-vscode/issues/184#issuecomment-1499879415, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAIYWLMI63TFTLWY3J24RMLW757JHANCNFSM6AAAAAAWWBIJYQ. You are receiving this because you authored the thread.Message ID: @.***>

waruqi commented 1 year ago

If compile_commands is already working, I will close this issue. For different issue, please open a separate issue. also this seems to be a toolchain issue, please install the full toolchain or xcode.