Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kits: Project Status settings override .vscode/settings.json settings #3556

Open
towynlin opened this issue Jan 31, 2024 · 2 comments
Open
Assignees
Labels
bug a bug in the product Feature: configure
Milestone

Comments

@towynlin
Copy link

towynlin commented Jan 31, 2024

Brief Issue Summary

My .vscode/settings.json contains "cmake.configureArgs" including "-DCMAKE_BUILD_TYPE=Release". When I call "CMake: Delete Cache and Reconfigure" the build uses CMAKE_BUILD_TYPE=Debug as observed in both build/CMakeCache.txt and in the build products. Lately I've been working around it by manually editing build/CMakeCache.txt, after which it builds correctly using the Release type, and this warning is logged:

[cpptools] The build configurations generated do not contain the active build configuration. Using "Release" for CMAKE_BUILD_TYPE instead of "Debug" to ensure that IntelliSense configurations can be found

This issue only appeared very recently, maybe (guessing) v.1.16. This setup has been working for me for months prior.

This looks like closed issue #2353 which was fixed by PR #3267 and included in v1.15. However, I'm using CMake Tools v1.16.32 with VS Code 1.85.2 on macOS 14.3 on arm64.

It also resembles currently open #3507, but my problem isn't with keyboard shortcuts and menus.

The CMake: Log Diagnostics output includes the following where "buildTypesSeen" starts as "Debug" when I Delete Cache and Reconfigure, then changes to "Release" after I edit CMakeCache.txt and build again:

  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Release"
    ],

There's no cpptools warning on the first build. It only appears after I edit the cache.

Particularly notable from the debug log is:

[cmakefileapi-driver] Invoking CMake with arguments [
...
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_BUILD_TYPE:STRING=Debug",
...
]
[proc] Executing command: cmake ... -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE:STRING=Debug ...

I don't know where the CMAKE_BUILD_TYPE:STRING=Debug comes from.

Thoughts?

CMake Tools Diagnostics

{
  "os": "darwin",
  "vscodeVersion": "1.85.2",
  "cmtVersion": "1.16.32",
  "configurations": [
    {
      "folder": "/redacted",
      "cmakeVersion": "3.20.6",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/redacted/bin/arm-none-eabi-gcc",
        "CXX": "/redacted/bin/arm-none-eabi-g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Release"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 14,
    "executablesCount": 1,
    "librariesCount": 1,
    "targets": [
      {
        "name": "cppcheck",
        "type": "UTILITY"
      },
      {
        "name": "debug",
        "type": "UTILITY"
      },
      {
        "name": "debug_rtos",
        "type": "UTILITY"
      },
      {
        "name": "debug_tui",
        "type": "UTILITY"
      },
      {
        "name": "dfu_flash",
        "type": "UTILITY"
      },
      {
        "name": "eng-release",
        "type": "UTILITY"
      },
      {
        "name": "flash",
        "type": "UTILITY"
      },
      {
        "name": "flash_sd",
        "type": "UTILITY"
      },
      {
        "name": "flash_secondary",
        "type": "UTILITY"
      },
      {
        "name": "linkerscript",
        "type": "UTILITY"
      },
      {
        "name": "memfault_upload",
        "type": "UTILITY"
      },
      {
        "name": "redacted.elf",
        "type": "EXECUTABLE"
      },
      {
        "name": "test",
        "type": "UTILITY"
      },
      {
        "name": "redacted",
        "type": "STATIC_LIBRARY"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Configuring project: redacted 
[main] Saving open files before configure/build
[driver] Removing /redacted/build/CMakeCache.txt
[driver] Removing /redacted/build/CMakeFiles
[driver] Start configure 
[driver] Running pre-configure checks and steps
[driver] Using compilers in GCC 10.3.1 arm-none-eabi for configure
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake /redacted/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi-gcc.cmake","-DCMAKE_BUILD_TYPE=Release","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_C_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-gcc","-DCMAKE_CXX_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-g++","-S/redacted","-B/redacted/build","-G","Ninja"]
[proc] Executing command: /redacted/bin/cmake --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi-gcc.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/redacted/bin/arm-none-eabi-g++ -S/redacted -B/redacted/build -G Ninja
[proc]   with environment: {"COMMAND_MODE":"unix2003","CONDA_DEFAULT_ENV":"redacted","CONDA_EXE":"/redacted/bin/conda","CONDA_PREFIX":"/redacted","CONDA_PREFIX_1":"/redacted","CONDA_PROMPT_MODIFIER":"(redacted) ","CONDA_PYTHON_EXE":"/redacted/bin/python","CONDA_SHLVL":"2","ELECTRON_NO_ATTACH_CONSOLE":"1","GPG_TTY":"$(tty)","GTEST_COLOR":"1","HOME":"/redacted","HOMEBREW_CELLAR":"/opt/homebrew/Cellar","HOMEBREW_PREFIX":"/opt/homebrew","HOMEBREW_REPOSITORY":"/opt/homebrew","INFOPATH":"/opt/homebrew/share/info:","LANG":"en_US.UTF-8","LOGNAME":"redacted","MANPATH":"/opt/homebrew/share/man::","MallocNanoZone":"0","OPENSSL_ROOT_DIR":"/opt/homebrew/opt/openssl@3","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PATH":"/opt/homebrew/opt/postgresql@15/bin:/redacted/bin:/redacted/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin","PWD":"/redacted","SHELL":"/bin/zsh","SHLVL":"2","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.voHJSG0YGj/Listeners","STM32CubeMX_PATH":"/Applications/STMicroelectronics/STM32CubeMX.app/Contents/Resources","TERM":"xterm-256color","TERM_PROGRAM":"Apple_Terminal","TERM_PROGRAM_VERSION":"453","TERM_SESSION_ID":"30C5028E-27EA-4DBA-B00F-BC2F1250F463","TMPDIR":"/var/folders/fh/2fwm8cqd4ld1zrlj5djsympr0000gn/T/","USER":"redacted","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CLI":"1","VSCODE_CODE_CACHE_PATH":"/Users/redacted/Library/Application Support/Code/CachedData/8b3775030ed1a69b13e4f4c628c612102e30a681","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/redacted","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/redacted/Library/Application Support/Code/1.85-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"53193","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.16363725.16363731.B1674C2E-2C58-4F5D-91C0-75EB8423D67A","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","VSCODE_L10N_BUNDLE_LOCATION":""}
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 10.3.1
[cmake] -- The CXX compiler identification is GNU 10.3.1
[cmake] -- The ASM compiler identification is GNU
[cmake] -- Found assembler: /redacted/bin/arm-none-eabi-gcc
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /redacted/bin/arm-none-eabi-gcc - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /redacted/bin/arm-none-eabi-g++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Cross Compiling - Building Firmware
[cmake] -- Using BOOTLOADER configuration
[cmake] -- Performing Test _Map1
[cmake] -- Performing Test _Map1 - Success
[cmake] -- Using unsigned MCUBoot images.
[cmake] -- Using unencrypted MCUBoot images.
[cmake] -- Saving to /redacted/build/src/version.c
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /redacted/build
[cmakefileapi-parser] Read reply folder: /redacted/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-5677fb66618395b36f79.json","cmakeFiles-v1-ebd02cb9496abc1d6315.json","codemodel-v2-8a532ff8c9e9fa97e379.json","index-2024-01-31T18-47-43-0202.json","target-redacted-Debug-7dc5e361a1e7fdd3be09.json","target-cppcheck-Debug-0905a2efaa8f218a3f36.json","target-debug-Debug-7663404d47e95df4a81d.json","target-debug_rtos-Debug-19bc255a0e57fb26773d.json","target-debug_tui-Debug-f1e90ccd576b6ff9962a.json","target-dfu_flash-Debug-4dba3b89c2c36be363e0.json","target-eng-release-Debug-531276c8ae821654621d.json","target-flash-Debug-0ead6b1d71a1d6310d13.json","target-flash_sd-Debug-780339de46484680e4c0.json","target-flash_secondary-Debug-dc6aa8519f779e2d2b71.json","target-linkerscript-Debug-32b733ac427d6714ff4e.json","target-memfault_upload-Debug-91407e6e389bd9c7ce16.json","target-redacted-dbg.elf-Debug-a577e3babbe62209654b.json","target-test-Debug-4a067fcb87334d7d1d62.json","toolchains-v1-176adda914df9887b2c1.json"]
[cache] Reading CMake cache file /redacted/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [8081] cmake.cleanConfigure finished (returned 0)

Additional Information

No response

@towynlin
Copy link
Author

Aaaand I just found where that seems to come from — if I click on the CMake left toolbar icon (which I almost never do) to open the CMake drawer, in the top pane, under Project Status > Configure it says Debug, and I can click the pencil to edit and choose Release instead.

So what I'll do is remove the CMAKE_BUILD_TYPE from my .vscode/settings.json and manage build type from the CMake drawer. That's a bit awkward though, because I have to specify and constantly edit a whole bunch of other cache entries in the workspace settings.

Now I understand this extension a bit better and have a resolution to my personal case. However, an open question is what the behavior should be in order to be the most intuitive and ergonomic for most users when workspace settings and those parameters in the CMake drawer conflict. For me, because I'm editing the settings constantly along with other build flags, I expected them to dominate. I wonder what others think about that hierarchy? It's possible mine is not a common workflow, and I'd be curious to learn whether that's true.

@gcampbell-msft
Copy link
Collaborator

@towynlin Thank you for the investigation and workaround that you've already found.

Thank you for the issue as well, I'll rename this issue to reflect what we settled on.

Going forward, we will think through whether this is simply a bug, or whether we need to think through this experience. Thanks!

@gcampbell-msft gcampbell-msft added bug a bug in the product Feature: configure and removed triage labels Feb 6, 2024
@gcampbell-msft gcampbell-msft changed the title First build type is Debug disregarding Release in settings Kits: Project Status settings override .vscode/settings.json settings Feb 6, 2024
@gcampbell-msft gcampbell-msft added this to the Backlog milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: configure
Projects
Status: Pending Prioritization
Development

No branches or pull requests

3 participants