microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 453 forks source link

Build fails when using the Green Hills MULTI generator #4179

Open fdk17 opened 3 days ago

fdk17 commented 3 days ago

Brief Issue Summary

The default target for gbuild and Green Hills MULTI should be ALL_BUILD, not all. ALL_BUILD is the same Utility target used by Visual Studio generators.

[build] Starting build
[proc] Executing command: /opt/cmake/bin/cmake --build /home/XXX/Projects/bin_dir --config Debug --target all -j 6 --
[build] Building all.tgt.gpj
[build] Could not find: all.tgt.gpj within: amcs_oe_sdk.top.gpj
[build] Not all requested files were built. Skipped: all.tgt.gpj
[build] Done

CMake Tools Diagnostics

Debug Log

Additional Information

No response

Amy-Li03 commented 2 days ago

Hi @fdk17, thanks for reporting issue here! After reading the above information, there are a few questions need to confirm with you:

  1. Does this issue only occur when using the Green Hills MULTI generator? Is it possible to build successfully with other generators (e.g. Ninja)?
  2. Can this issue be reproduced on a simple project? If not, please provide us with a sample project.
  3. This issue occurs after using the cmake:build command in VS code.
fdk17 commented 14 hours ago

1) It only happens with the Green Hills MULTI generator. Ninja and others work fine to the best of my knowledge. 2) Yes, any simple project will show the issue. 3) Correct, the issue occurs when using cmake:build or F7 when the build target is all or the Utility target ALL_BUILD is chosen.

Refer to https://github.com/microsoft/vscode-cmake-tools/issues/3 and https://github.com/microsoft/vscode-cmake-tools/commit/d76e047d5e0c0eb8ab9a48ede4e1f461fd498b70 on how the problem was fixed for Visual Studio generators, then again for XCode in https://github.com/microsoft/vscode-cmake-tools/commit/047c918d2a68cafaf2ff2a5952763cae2bdff375. This function should also return 'ALL_BUILD' when the generator is 'Green Hills MULTI'.

https://github.com/microsoft/vscode-cmake-tools/blob/0b8ebcfdb1077e59b1037be913f37be7e719254b/src/drivers/cmakeDriver.ts#L903C1-L910C6

    get allTargetName(): string {
        const gen = this.generatorName;
        if (gen && (gen.includes('Visual Studio') || gen.toLowerCase().includes('xcode'))) {
            return 'ALL_BUILD';
        } else {
            return 'all';
        }
    }
fdk17 commented 14 hours ago

Essentially, the build command should be

/opt/cmake/bin/cmake --build /home/XXX/Projects/bin_dir --config Debug --target ALL_BUILD -j 6 --
Amy-Li03 commented 13 hours ago

@fdk17 thanks for your detailed investigation. That would be great if you can create a PR, we are always happy to receive contributions from the community.

@gcampbell-msft FYI.

fdk17 commented 12 hours ago

@Amy-Li03 Is there a getting started guide detailed enough for an absolute beginner? I've not sure what a .ts file is or how I would get VS Code to use my changes.