analogdevicesinc / no-OS

Software drivers in C for systems without an operating system
http://analogdevicesinc.github.io/no-OS/
Other
874 stars 1.63k forks source link

Don't overwrite .vscode config if it already exists #2182

Closed trupples closed 1 month ago

trupples commented 1 month ago

Pull Request Description

(Referencing issue #2181, the following content is copied from there)

Behaviour

The $(PROJECT_TARGET)_configure targets in tools/scripts/stm32.mk and tools/scripts/maxim.mk use the GNU Make file function to set up a default VS Code configuration for projects, with no regard to the contents of those files.

https://github.com/analogdevicesinc/no-OS/blob/3cb5f58f6815c4fa63b732bb5072d42483ad6f81/tools/scripts/maxim.mk#L139-L143

For context, the content of the files is generated in vsc_intellisense.mk, vsc_openocd_debug.mk, and vsc_tasks.mk.

Impact

With the current makefiles, one may not change their VS Code config without it being reset to the no-OS defaults during the next build, which greatly hinders development. For instance, my WSL dev setup requires changing the gdb options in launch.json, but doing so is futile because the makefile resets my changes when building.

Options

I suggest (this PR) adding a condition to only write to these files if they are empty or don't exist (i.e., during project setup), but keep their current content otherwise, to allow for customization of the config.

Despite some effort, I didn't manage to do it using just GNU Make syntax, but rather by changing the file call from filename.json to filename.json.default, and having some shell commands conditionally copy filename.json.default to filename.json if the latter doesn't exist. Finally, shell commands remove the .default files to keep the directory tidy.

PR Type

PR Checklist

rbolboac commented 1 month ago

/AzurePipeline run

azure-pipelines[bot] commented 1 month ago
Azure Pipelines successfully started running 2 pipeline(s).
rbolboac commented 1 month ago

@EoghanMonahan can you please take a look at this since you might be familiar with the topic?