xmake-io / xmake-vscode

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

*.lua in subproject didn't be traced #146

Closed Cyrisub closed 1 year ago

Cyrisub commented 1 year ago

Xmake Version

2.7.3

Operating System Version and Architecture

Windows 11 22H2

Describe Bug

I'm not sure it is a bug or just my misbehaviour.

The includes() function in project xmake.lua supports regex to trace any xmake.lua discribing a sub project, which means I can also use a *.lua file to trace makefiles in other names theoretically, like Project.lua. It works normally in xmake cli just like a normal xmake.lua.

However, when including lua file not named as xmake.lua, the vscode plugin can see targets defined in the file but would not generate compile_commands.json for it. And it still show a fake xmake.lua file below the target in the xmake sidepanel, clicking the fake file would not open the real Project.lua.

Expected Behavior

I think the behavior of vscode plugin should be the same the cli dose in the terminal. But if you consider the *.lua should not be used, please add some descriptions in the document.

Project Configuration

No response

Additional Information and Error Logs

No response

waruqi commented 1 year ago

The vscode plugin generates compile_commands.json by running the xmake project -k compile_commands command, so it should behave the same as the cli.

Cyrisub commented 1 year ago

The vscode plugin generates compile_commands.json by running the xmake project -k compile_commands command, so it should behave the same as the cli.

You're right, I was confused by the autogenerate compile_commands.json. Let me explain it further:

I create a project with file structure like this: image target Mod1 and Mod2 both contains a simple binary target only different in the file name.

And the plugin captures the project in the sidebar like this: image Mod2's lua file is shown as xmake.lua, and cannot jump to the Mod2.lua when I click it. Besides that, all works fin as I use the cli.

I'm confused because in some cases the plugin would generate an empty compile_commands.json file, like in the initial building? or sth else. I was thought the plugin hadn't found my targets but it just doesn't generate any info at all in that empty file.

After issuing that display bug and rasing the question above, I tried to generate it by triggling the UpdateIntellisense vscode cmd manually, that works fine and feeds my need. But I'm wondering how the plugin decide to execute the generation, or it just wouldn't generate automatically?

waruqi commented 1 year ago

But I'm wondering how the plugin decide to execute the generation, or it just wouldn't generate automatically?

When the xmake.lua file is changed, it is automatically regenerated.

Mod2's lua file is shown as xmake.lua, and cannot jump to the Mod2.lua when I click it. Besides that, all works fin as I use the cli.

This should be a problem with the plugin, which hardcodes the xmake.lua filename.

https://github.com/xmake-io/xmake-vscode/blob/05eb80bb235950581b78cb844450c682212f3044/src/explorer.ts#L217